/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
import{property as g,customElement as h}from"lit/decorators.js";import{LitElement as b,html as i,nothing as c}from"lit";import r from"@typo3/workspaces/utility/icon-helper.js";import{classMap as w}from"lit/directives/class-map.js";import{ifDefined as d}from"lit/directives/if-defined.js";import{repeat as k}from"lit/directives/repeat.js";import"@typo3/backend/element/icon-element.js";var u=function(p,e,n,s){var l=arguments.length,t=l<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(p,e,n,s);else for(var a=p.length-1;a>=0;a--)(o=p[a])&&(t=(l<3?o(t):l>3?o(e,n,t):o(e,n))||t);return l>3&&t&&Object.defineProperty(e,n,t),t};let m=class extends b{constructor(){super(...arguments),this.results=[],this.latestPath=null}createRenderRoot(){return this}render(){return i`<div class="table-fit mb-0"><table class="table table-striped"><thead><tr><th><div class="btn-group dropdown"><button type=button class="dropdown-toggle dropdown-toggle-link t3js-multi-record-selection-check-actions-toggle" data-bs-toggle=dropdown data-bs-boundary=window aria-expanded=false aria-label=${TYPO3.lang["labels.openSelectionOptions"]}><typo3-backend-icon identifier=actions-selection size=small></typo3-backend-icon></button><ul class="dropdown-menu t3js-multi-record-selection-check-actions"><li><button type=button class=dropdown-item disabled data-multi-record-selection-check-action=check-all title=${TYPO3.lang["labels.checkAll"]}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=actions-selection-elements-all size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${TYPO3.lang["labels.checkAll"]} </span> </span></button></li><li><button type=button class=dropdown-item disabled data-multi-record-selection-check-action=check-none title=${TYPO3.lang["labels.uncheckAll"]}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=actions-selection-elements-none size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${TYPO3.lang["labels.uncheckAll"]} </span> </span></button></li><li><button type=button class=dropdown-item data-multi-record-selection-check-action=toggle title=${TYPO3.lang["labels.toggleSelection"]}><span class=dropdown-item-columns> <span class="dropdown-item-column dropdown-item-column-icon" aria-hidden=true><typo3-backend-icon identifier=actions-selection-elements-invert size=small></typo3-backend-icon> </span> <span class="dropdown-item-column dropdown-item-column-title">${TYPO3.lang["labels.toggleSelection"]} </span> </span></button></li></ul></div></th><th class=col-min>${TYPO3.lang["column.wsTitle"]}</th><th class=col-language>${TYPO3.lang["labels._LOCALIZATION_"]}</th><th class=col-datetime>${TYPO3.lang["column.lastChangeOn"]}</th><th class=col-state>${TYPO3.lang["column.wsStateAction"]}</th><th class=col-state>${TYPO3.lang["column.integrity"]}</th><th>${TYPO3.lang["column.stage"]}</th><th class="col-control nowrap"><span class=visually-hidden>${TYPO3.lang["labels._CONTROL_"]}</span></th></tr></thead><tbody data-multi-record-selection-row-selection=true>${k(this.results,e=>e.uid,e=>this.renderTableRow(e))}</tbody></table></div>`}renderTableRow(e){let n=null,s=!1;this.latestPath!==e.path_Workspace&&(this.latestPath=e.path_Workspace,s=!0),e.Workspaces_CollectionParent!==""&&(n=this.results.find(a=>a.Workspaces_CollectionCurrent===e.Workspaces_CollectionParent));const l=e.state_Workspace;let t,o;switch(l){case"deleted":t="danger",o=TYPO3.lang["column.wsStateAction.deleted"];break;case"hidden":t="secondary",o=TYPO3.lang["column.wsStateAction.hidden"];break;case"modified":t="warning",o=TYPO3.lang["column.wsStateAction.modified"];break;case"moved":t="primary",o=TYPO3.lang["column.wsStateAction.moved"];break;case"new":t="success",o=TYPO3.lang["column.wsStateAction.new"];break;default:t="secondary",o=TYPO3.lang["column.wsStateAction.unchanged"]}return i`${s?i`<tr><th colspan=8 class=col-white-space-normal><a href=${e.urlToPage}>${e.path_Workspace}</a></th></tr>`:c}<tr class=${w({collapse:e.Workspaces_CollectionParent!=="",show:n?.expanded})} data-uid=${e.uid} data-pid=${e.livepid} data-t3ver_oid=${e.t3ver_oid} data-t3ver_wsid=${e.t3ver_wsid} data-table=${e.table} data-next-stage=${e.value_nextStage} data-prev-stage=${e.value_prevStage} data-stage=${e.stage} data-multi-record-selection-element=true data-collection=${e.Workspaces_CollectionParent?e.Workspaces_CollectionParent:c} data-collection-current=${d(e.Workspaces_CollectionCurrent)}><td class=col-checkbox><span class="form-check form-check-type-toggle"> <input type=checkbox class="form-check-input t3js-multi-record-selection-check"> </span></td><td class="col-min t3js-title-workspace">${e.Workspaces_CollectionLevel>0?this.renderIndent(e.Workspaces_CollectionLevel):c} <span class="icon icon-size-small"><typo3-backend-icon identifier=${r.getIconIdentifier(e.icon_Workspace)} overlay=${r.getIconIdentifier(e.icon_Workspace_Overlay)} size=small></typo3-backend-icon> </span> <a href=# data-action=changes>${e.label_Workspace} </a></td><td class=col-language><span title=${e.language.title} class="icon icon-size-small"> <typo3-backend-icon identifier=${r.getIconIdentifier(e.language.icon)} size=small></typo3-backend-icon> </span>${e.language.title_crop}</td><td class=col-datetime>${e.lastChangedFormatted}</td><td class=col-state><span class="badge badge-${t}">${o}</span></td><td class=col-state>${e.integrity.messages!==""?i`<span title=${e.integrity.messages} class="icon icon-size-small"> <typo3-backend-icon identifier=${r.getIconIdentifier(e.integrity.status)} size=small></typo3-backend-icon> </span>`:c}</td><td>${e.label_Stage}</td><td class="col-control nowrap"><div class=btn-group>${this.renderElementActions(e)}</div><div class=btn-group>${this.renderVersioningActions(e)}</div></td></tr>`}renderIndent(e){return i`<span class="indent indent-inline-block" style=--indent-level:${e}></span>`}renderElementActions(e){return[this.getAction(e.allowedAction_view,"preview","actions-version-workspace-preview",{title:TYPO3.lang["tooltip.viewElementAction"]}),this.getAction(e.allowedAction_edit&&e.state_Workspace!=="deleted","open","actions-open",{title:TYPO3.lang["tooltip.editElementAction"]}),this.getAction(e.allowedAction_versionPageOpen,"version","actions-version-page-open",{title:TYPO3.lang["tooltip.openPage"]})]}renderVersioningActions(e){const n=e.Workspaces_CollectionChildren>0&&e.Workspaces_CollectionCurrent!=="";return[this.getAction(n,"expand",e.expanded?"actions-caret-down":"actions-caret-right",{title:TYPO3.lang["tooltip.expand"],"data-bs-target":'[data-collection="'+e.Workspaces_CollectionCurrent+'"]',"aria-expanded":!n||e.expanded?"true":"false","data-bs-toggle":"collapse"}),this.getAction(e.hasChanges,"changes","actions-document-info",{title:TYPO3.lang["tooltip.showChanges"]}),this.getAction(e.allowedAction_publish&&e.Workspaces_CollectionParent==="","publish","actions-version-swap-version",{title:TYPO3.lang["tooltip.publish"]}),this.getAction(e.allowedAction_delete,"remove","actions-delete",{title:TYPO3.lang["tooltip.discardVersion"]})]}getAction(e,n,s,l){return i`<button type=button class="btn btn-default" ?disabled=${e?c:""} data-action=${e?n:c} title=${d(l.title)} data-bs-target=${d(l["data-bs-target"])} data-bs-toggle=${d(l["data-bs-toggle"])} aria-expanded=${d(l["aria-expanded"])}><typo3-backend-icon identifier=${r.getIconIdentifier(e?s:"empty-empty")} size=small></typo3-backend-icon></button>`}};u([g({type:Array})],m.prototype,"results",void 0),m=u([h("typo3-workspaces-record-table")],m);export{m as RecordTableElement};
