-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-074c281c.entry.js
5 lines (5 loc) · 32.3 KB
/
p-074c281c.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,c as e,h as i,H as s,g as r}from"./p-00e3df8e.js";import{m as o,c as h}from"./p-22ab23bc.js";import{t as a}from"./p-dc076e70.js";import{a as n}from"./p-6875fc29.js";import{s as c}from"./p-89a330bf.js";import{d,a as l,n as p,g as b,t as f,p as u,i as w,b as v}from"./p-922077e5.js";import{h as g}from"./p-3e9fe89f.js";class m{constructor(){this._history=[],this._index=-1,this._locked=!1}get canBack(){return this._index>0}get canForward(){return this._index<this._history.length-1}get locked(){return this._locked}get previous(){return 0===this._index?"":this._history[this._index-1]}get current(){return this._history[this._index]}get next(){return this._index===this._history.length-1?"":this._history[this._index+1]}add(t){if(this._locked)return;const e=this._history[this._history.length-1];Array.isArray(t)?t.forEach((t=>{t!==e&&this._history.push(t)})):this._history.push(t),this._index=this._history.length-1}back(){let t=this._index-1;return t<0&&(t=0),this._index=t,this.current}forward(){let t=this._index+1;return t>this._history.length&&(t=this._history.length),this._index=t,this.current}clear(){this._history=[],this._index=-1}lock(){this._locked=!0}unlock(){this._locked=!1}getHistory(){return[...this._history]}}const x=class{constructor(i){t(this,i),this.navigateEvent=e(this,"dwc-navigate",7),this.selectedEvent=e(this,"dwc-selected",7),this.deselectedEvent=e(this,"dwc-deselected",7),this.selectionChangedEvent=e(this,"dwc-selection-changed",7),this.filterChangedEvent=e(this,"dwc-filter-changed",7),this.approvedEvent=e(this,"dwc-approved",7),this.canceledEvent=e(this,"dwc-canceled",7),this.history=new m,this.typeToSelectString="",this.lastSearchIndex=-1,this._i18n=d,this._entries=[],this._filters=[],this._sort=[],this._disableValueSync=!1,this._disableSelectionSync=!1,this.computeValue=t=>0===t.length?"":1===t.length?t[0]:t.map((t=>`"${t}"`)).join(","),this.handleColumnsMenuPopupItemClick=t=>{const e=t.target,i=e.getAttribute("value"),s=this.columns.split(",").map((t=>t.trim().toLowerCase())),r=s.indexOf(i);e.checked?-1===r&&s.push(i):-1!==r&&s.splice(r,1),this.columns=s.join(",")},this.allFilesFilterEnabled=!0,this.allowSelectionsAcrossDirectories=!1,this.activeFilter="",this.approveAccesskey=void 0,this.buttonsVisible=!0,this.cancelAccesskey=void 0,this.columns="length, modified",this.cacheCustomFilters=!0,this.customFilters=!0,this.disabled=!1,this.dateLocale="en-US",this.dateFormatOptions=l,this.directory=void 0,this.entries=[],this.filters=void 0,this.gridColumns=3,this.i18n=d,this.loading=!1,this.multiSelection=!1,this.restrictedDirectory=void 0,this.roots=[],this.selectionMode="files",this.selected=[],this.sort="",this.theme="primary",this.type="open",this.typeToSelect=!0,this.typeToSelectTimeout=1e3,this.typeToSelectCaseSensitive=!1,this.value="",this.view="detail"}onActiveFilterChange(){"save"===this.type&&"files"===this.selectionMode&&(this._disableValueSync=!0,this.value=this.computeValueExtension(this.value),this._disableValueSync=!1)}onDateFormatOptionsChanged(t){this._dateFormatOptions=this.resolveDateFormatOptions(t)}onDirectoryChanged(t,e){e&&!this.history.locked&&this.history.add(p(e)),this.history.unlock()}onI18nChanged(t){this._i18n=this.resolveI18n(t)}onSelectionModeChanged(){this.selected=this.selected.filter((t=>"directories"===this.selectionMode?t.directory:"files"!==this.selectionMode||!t.directory))}onSelectedChanged(t){this._disableValueSync||(this.value=this.computeValue(t.map((t=>Object.hasOwn(t,"name")?t.name:t.path))))}onValueChanged(t){if(this._disableSelectionSync)return;const e=this.computeValues(t),i=e.map((t=>t.toLocaleLowerCase()));let s=[];s=this._entries.filter((t=>{const s=t.name,r=i.includes(s.toLocaleLowerCase());return r&&e.splice(e.indexOf(s),1),r})),"save"===this.type&&e.forEach((t=>{const e={name:t,path:this.directory.endsWith("/")?`${this.directory}${t}`:`${this.directory}/${t}`,length:0,modified:(new Date).getTime(),directory:!1};s.push(e)})),!this.multiSelection&&s.length>0&&(s=[s[0]]),JSON.stringify(s)!==JSON.stringify(this.selected)&&(this.selected=s)}onPropertiesChanged(t,e,i){if(this._sort=this.resolveSort(),"directories"!==this.selectionMode&&(this._filters=this.resolveFilters(),!(this.activeFilter||"").length&&"allFilesFilterEnabled"===i)){const t=this._filters[0];t&&(this.activeFilter=String(t.id))}this._entries=this.resolveEntries(this.entries,this.directory),this.$tableWrapper&&(this.$tableWrapper.scrollTop=0)}connectedCallback(){this.handleUp=this.handleUp.bind(this),this.handleBack=this.handleBack.bind(this),this.handleForward=this.handleForward.bind(this),this.handlePathListChanged=this.handlePathListChanged.bind(this),this.handlePathListClosed=this.handlePathListClosed.bind(this),this.handlePathListCanceled=this.handlePathListCanceled.bind(this),this.handleRefreshKeydown=this.handleRefreshKeydown.bind(this),this.handleRefreshClick=this.handleRefreshClick.bind(this),this.handleViewChange=this.handleViewChange.bind(this),this.handleColumnsMenuClick=this.handleColumnsMenuClick.bind(this),this.handleColumnsMenuPopupItemClick=this.handleColumnsMenuPopupItemClick.bind(this),this.handleTableKeyDown=this.handleTableKeyDown.bind(this),this.handleTableHeaderClick=this.handleTableHeaderClick.bind(this),this.handleTableRowAndCellClick=this.handleTableRowAndCellClick.bind(this),this.handleTableRowAndCellDBClick=this.handleTableRowAndCellDBClick.bind(this),this.handleValueInputChanged=this.handleValueInputChanged.bind(this),this.handleValueInputBlurred=this.handleValueInputBlurred.bind(this),this.handleValueInputKeyDown=this.handleValueInputKeyDown.bind(this),this.handleFiltersListChanged=this.handleFiltersListChanged.bind(this),this.renderFilterListItem=this.renderFilterListItem.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleApprove=this.handleApprove.bind(this)}disconnectedCallback(){this.$columnsMenuPopup&&this.$columnsMenuPopup.remove()}componentWillLoad(){null!=window.applyFocusVisiblePolyfill&&window.applyFocusVisiblePolyfill(this.el.shadowRoot),this.onI18nChanged(this.i18n),this.onDateFormatOptionsChanged(this.dateFormatOptions),this.onPropertiesChanged(null,null,"allFilesFilterEnabled"),this.onSelectedChanged(this.selected)}componentWillRender(){this.$lastActiveElement=a(this.el.shadowRoot.activeElement)}componentDidRender(){const t=this.$lastActiveElement;if(t)if(t.isConnected)requestAnimationFrame((()=>{try{this.$lastActiveElement.hasAttribute("disabled")&&this.$lastActiveElement.removeAttribute("disabled"),this.$lastActiveElement.focus(),this.$lastActiveElement.setFocus()}catch(t){}}));else{const e=t.nodeName.toLowerCase();if(["tr","td"].indexOf(e)>-1){const t=this.$tbody.querySelector(`${e}:first-child`);this.focusTableNode(t)}}}componentDidLoad(){n(this.$tbody)}handleKeyDown(t){if(this.loading||this.disabled)return;const e=t.composedPath().map((t=>t.nodeName?t.nodeName.toLowerCase():"")).indexOf("dwc-combobox")>-1;"Escape"!==t.key||e||this.handleCancel(),"ArrowLeft"===t.key&&t.altKey&&!e&&(t.preventDefault(),this.handleBack()),"ArrowRight"===t.key&&t.altKey&&!e&&(t.preventDefault(),this.handleForward()),"ArrowUp"===t.key&&t.altKey&&!e&&(t.preventDefault(),this.handleUp())}async approve(){this.handleApprove()}async cancel(){this.handleCancel()}async refresh(){this.history.lock(),this.navigate(this.directory,!0)}async up(){this.handleUp()}async canUp(){return this.isUpPermitted()}async back(){this.handleBack()}async canBack(){return this.isBackPermitted()}async forward(){this.handleForward()}async canForward(){return this.isForwardPermitted()}formatDate(t){return new Intl.DateTimeFormat(this.dateLocale,this._dateFormatOptions).format(t)}formatSize(t){let e=0;for(;t>=1024||-t>=1024;)t/=1024,e++;return(e?t.toFixed(2)+" ":t)+" KMGTPEZY"[e]+"B"}resolveEntries(t,e){var i;let s=t.map((t=>{const{name:i,length:s,modified:r,directory:o}=t;return{name:i,length:s,modified:r,directory:o,path:`${(null==e?void 0:e.endsWith("/"))?e:e+"/"}${i}`}}));if("directories"!==this.selectionMode){const t=this._filters.find((t=>t.id===this.activeFilter));t&&(s=s.filter((e=>{var i;if(e.directory||t.id===this._i18n.filterAll)return!0;const s=t.globs;return null===(i=null==s?void 0:s.split(","))||void 0===i?void 0:i.some((t=>b(t).test(e.name)))})))}else s=s.filter((t=>t.directory));const r="desc"===(null===(i=(this._sort||[]).find((t=>"name"===t.prop)))||void 0===i?void 0:i.direction);return s=o(s,this._sort).sort(((t,e)=>{if(r){if(t.directory&&!e.directory)return 1;if(!t.directory&&e.directory)return-1}return t.directory&&!e.directory?-1:!t.directory&&e.directory?1:0})),s}resolveI18n(t){return Object.assign(d,"string"==typeof t?JSON.parse(t):t)}resolveDateFormatOptions(t){return"string"==typeof t?JSON.parse(t):t}resolveFilters(){const t=[...this.filters||[]].map((t=>({id:t.id||t.name,name:t.name,globs:t.globs}))),e=t.find((t=>"*"===t.globs||""===t.globs));return this.allFilesFilterEnabled&&!e&&t.unshift({id:this._i18n.filterAll,name:this._i18n.filterAll,globs:"*"}),t}resolveSort(){return(this.sort||"").split(",").map((t=>t.trim())).filter((t=>t.length>0)).map((t=>{const e=t.charAt(0),i="-"===e?"desc":"+"===e?"asc":"none";return{prop:"none"===i?t:t.substring(1),direction:i}}))}computePathsList(){const t=this.directory||"",e=this.roots,i=[];let s=-1;for(const r of e){const e=r;if(i.push({value:e,label:e,prefix:'<dwc-icon pool="dwc" name="hard-drive" style="font-size: 1.3rem;"></dwc-icon>',disabled:!this.canNavigate(e),formattedLabel:e}),!t.startsWith(e)||t.length<e.length)continue;const o=t.split("/");let h=`${o[0]}/`;for(let t=1;t<o.length;++t){h+=o[t];let e=" ";for(let i=2*t;i>0;--i)e+=" ";e+=o[t],e.trim().length&&i.push({value:h,label:h,disabled:!this.canNavigate(h),formattedLabel:e}),h=`${h}/`}s=i.length-1}return{paths:i,selectedPath:s}}computeFilterList(){const t=this._filters.map((t=>({label:t.name,value:t.id})));if(this.cacheCustomFilters&&this.el.hasAttribute("id")){const e=this.el.getAttribute("id"),i=JSON.parse(localStorage.getItem(`${e}-filters`)||"[]");Object.values(i).forEach((e=>{t.find((t=>t.value===e.id))||t.push({label:e.name,value:e.name})}))}const e=this._filters.findIndex((t=>t.id===this.activeFilter));return{filters:t,selectedFilter:e}}computeValues(t){return t.split(/[,]+/).map((t=>t.replace(/"/g,""))).filter(Boolean)}computeValueExtension(t){var e;const i=this._filters.find((t=>t.id===this.activeFilter||t.name===this.activeFilter));if(!(null===(e=null==i?void 0:i.globs)||void 0===e?void 0:e.length))return;const s=i.globs.split(",").map((t=>t.split(".").pop().replace("*","").toLowerCase())).filter(Boolean);if(0===s.length)return t;const r=this.computeValues(t),o=[];return r.forEach((t=>{let e=t;const i=e.lastIndexOf(".");let r="";if(i>0&&(r=e.substring(i+1).toLowerCase(),e=e.substring(0,i)),s.indexOf(r)<0){let t=s[0];t=t.replace(/[^a-z0-9]/gi,""),t.length>0&&(e=`${e}.${t}`)}else e=`${e}.${r}`;o.push(e)})),this.computeValue(o)}isEntrySelectable(t){return"both"===this.selectionMode||"files"===this.selectionMode&&!t.directory||"directories"===this.selectionMode&&t.directory}isEntrySelected(t){return this.selected.map((t=>f(t.path))).indexOf(f(t.path))>-1}canNavigate(t){return!this.restrictedDirectory||f(p(t)).startsWith(f(p(this.restrictedDirectory)))}isUpPermitted(){const t=p(this.directory||"");return t!==p(this.restrictedDirectory)&&this.canNavigate(t)&&!this.roots.includes(t)&&!this.loading&&!this.disabled}isBackPermitted(){return!!this.history.canBack&&this.canNavigate(this.history.current)&&!this.loading&&!this.disabled}isForwardPermitted(){return!!this.history.canForward&&this.canNavigate(this.history.next)&&!this.loading&&!this.disabled}navigate(t,e=!1){const i=p(t),s=p(this.directory||""),r=p(this.restrictedDirectory||"");if(i!==s||e)if(f(i)===f(r)||this.canNavigate(t))this.allowSelectionsAcrossDirectories||(this.selected=[]),this.navigateEvent.emit({path:t.replace(/\/?(\?|#|$)/,"/$1"),history:this.history});else if(this.navigate(s),this.$pathList){const{selectedPath:t}=this.computePathsList();this.$pathList.selected=t,this.$pathList.value=this.$pathList.itemValue}}resetTableTableIndex(){const t="detail"===this.view?"tr":"td";this.$tbody.querySelectorAll(t).forEach((t=>{t.tabIndex=-1}));const e=this.$tbody.querySelector(`${t}:first-child`);e&&(e.tabIndex=0)}focusTableNode(t){this.resetTableTableIndex(),t&&t.focus()}clickTableNode(t,e=!1){const i=t.getAttribute("data-index"),s=this._entries[i],r=this.isEntrySelectable(s),o=this.isEntrySelected(s);if(r&&(o?(this.selected=this.selected.filter((t=>t!==s)),this.deselectedEvent.emit(s),this.selectionChangedEvent.emit(this.selected)):(this.selected=this.multiSelection?[...this.selected,s]:[s],this.selectedEvent.emit(s),this.selectionChangedEvent.emit(this.selected))),s.directory&&e){const t=this.history,e=p(this.directory),i=p(s.path);t.add([e,i]),this.history.lock(),this.navigate(i)}}async triggerTypeToSelect(t){(this.lastKeypressTime+this.typeToSelectTimeout<(new Date).getTime()||this.typeToSelectString==t)&&(this.typeToSelectString=""),this.typeToSelectString+=t.toLowerCase(),this.lastKeypressTime=(new Date).getTime(),await this.search(this.typeToSelectString,this.typeToSelectCaseSensitive,!0)}async search(t,e=!1,i=!1,s=!0,r=!1){let o=!1,h=-1;const a=e?t:t.toLowerCase(),n=this._entries.filter((t=>"object"==typeof t));for(let t=0;t<n.length;t++){h=t;let i=n[h].name;if(i=e?i:i.toLowerCase(),i.substring(0,a.length)==a){if(this.lastSearchIndex>=h)continue;o=!0,this.lastSearchIndex=h;break}}if(!o)return this.lastSearchIndex=-1,r?null:await this.search(t,e,i,s,!0);this.isEntrySelectable(n[h])&&(this.selected=i?[...this.selected,n[h]]:[n[h]]);const d=this.$tbody.querySelector(`[data-index="${h}"]`);return this.focusTableNode(d),s&&c(d,this.$table),h}mayApprove(t){const e=t.getAttribute("data-index"),i=this._entries[e],s=this.isEntrySelectable(i);["files","both"].indexOf(this.selectionMode)>-1&&!1===this.multiSelection&&!1===i.directory&&s&&this.isEntrySelected(i)&&this.handleApprove()}handleUp(){if(!this.isUpPermitted())return;const t=p(this.directory),e=u(t);e!==t&&(this.history.add([p(this.directory),p(e)]),this.history.lock(),this.navigate(e))}handleBack(){const t=this.history.previous;if(t){if(!this.canNavigate(t))return;this.history.back(),this.history.lock(),this.navigate(t)}}handleForward(){const t=this.history.next;if(t){if(!this.canNavigate(t))return;this.history.forward(),this.history.lock(),this.navigate(t)}}handlePathListClosed(){this.lastSelectedPath&&(this.history.lock(),this.history.add(p(this.directory)),this.history.add(this.lastSelectedPath),this.navigate(this.lastSelectedPath)),this.lastSelectedPath=null}handlePathListChanged(t){const e=p(t.target.value);this.$pathList.opened?this.lastSelectedPath=e:(this.history.lock(),this.history.add(p(this.directory)),this.history.add(e),this.navigate(e))}handleRefreshKeydown(t){"Enter"===t.key&&(t.stopImmediatePropagation(),t.preventDefault(),this.refresh())}handleRefreshClick(t){t.stopImmediatePropagation(),t.preventDefault(),this.refresh()}handleFiltersListChanged(t){const e=t.target,i=this.activeFilter;let s=e.value;const r=this._filters.findIndex((t=>t.id===s));if(this.customFilters&&-1===r)if(w(s)){const t={id:s,name:s,globs:s.trim()};if(this.filters=[...this.filters,t],this.cacheCustomFilters||this.el.hasAttribute("id")){const e=`${this.el.id}-filters`,i=JSON.parse(localStorage.getItem(e))||{};i[s]=t,localStorage.setItem(e,JSON.stringify(i))}}else s=i,e.value=s;this.activeFilter=s,i!==s&&this.filterChangedEvent.emit(this.activeFilter)}handleViewChange(){this.view="grid"===this.view?"detail":"grid"}handleColumnsMenuClick(t){let e=this.$columnsMenuPopup;if(!e){this.$columnsMenuPopup=document.createElement("dwc-popupmenu");const t=document.createElement("dwc-menu"),i=this._i18n;[{label:i.length,value:"length"},{label:i.modified,value:"modified"}].forEach((e=>{const i=document.createElement("dwc-menuitem");i.setAttribute("label",e.label),i.setAttribute("value",e.value),i.setAttribute("checkable","true"),i.setAttribute("checked","true"),i.addEventListener("dwc-clicked",this.handleColumnsMenuPopupItemClick),t.appendChild(i)})),this.$columnsMenuPopup.appendChild(t),document.body.appendChild(this.$columnsMenuPopup),e=this.$columnsMenuPopup}e.contextElement=t.target,e.x=t.clientX,e.y=t.clientY,e.opened=!e.opened}handleTableHeaderClick(t){const e=t.target.closest("th"),i=e.getAttribute("data-name"),s=e.getAttribute("data-sort");if(i){let t=this.sort||"";switch("none"===s?"desc":"desc"===s?"asc":"none"){case"asc":t+=`,+${i}`,t=t.replace(`-${i}`,"");break;case"desc":t+=`,-${i}`,t=t.replace(`+${i}`,"");break;case"none":t=t.replace(`+${i}`,"").replace(`-${i}`,"")}this.sort=[...new Set(t.split(",").map((t=>t.trim())).filter((t=>t)))].join(",")}}handleTableRowAndCellClick(t){const e=t.target.closest("grid"===this.view?"td":"tr");e&&this.clickTableNode(e,!1)}handleTableRowAndCellDBClick(t){const e=t.target.closest("grid"===this.view?"td":"tr");e&&this.clickTableNode(e,!0),this.mayApprove(e)}async handleTableKeyDown(t){if(this.loading||this.disabled)return;const{key:e}=t,i=this.$tbody.querySelectorAll("detail"===this.view?"tr":"td"),s=this.$tbody.querySelector("detail"===this.view?"tr:focus":"td:focus");if(!s)return;const r=Array.from(i).indexOf(s),o=i[r];switch(e){case"Enter":t.preventDefault(),this.clickTableNode(o,!0),this.mayApprove(o);break;case" ":t.preventDefault(),this.clickTableNode(o,!1);break;case"Backspace":t.preventDefault(),this.up();break;case"ArrowUp":"detail"!==this.view||t.altKey?r>=this.gridColumns&&!t.altKey&&(t.preventDefault(),this.focusTableNode(i[r-this.gridColumns])):r>0&&(t.preventDefault(),this.focusTableNode(i[r-1]));break;case"ArrowDown":"detail"===this.view?r<i.length-1&&(t.preventDefault(),this.focusTableNode(i[r+1])):r<i.length-this.gridColumns&&(t.preventDefault(),this.focusTableNode(i[r+this.gridColumns]));break;case"ArrowLeft":"grid"===this.view&&r>0&&!t.altKey&&(t.preventDefault(),this.focusTableNode(i[r-1]));break;case"ArrowRight":"grid"===this.view&&r<i.length-1&&!t.altKey&&(t.preventDefault(),this.focusTableNode(i[r+1]));break;case"Home":t.preventDefault(),this.focusTableNode(i[0]);break;case"End":t.preventDefault(),this.focusTableNode(i[i.length-1])}this.typeToSelect&&1===t.key.length&&await this.triggerTypeToSelect(t.key)}handleValueInputChanged(t){this._disableSelectionSync=!0,this.value=t.detail}handleValueInputBlurred(){this._disableSelectionSync=!1,this._disableValueSync=!0,this.onValueChanged(this.value),"files"===this.selectionMode&&(this.value=this.computeValueExtension(this.value)),this._disableSelectionSync=!1,this._disableValueSync=!1}handleValueInputKeyDown(t){"Enter"===t.key&&(this.handleValueInputBlurred(),this.handleApprove())}handleApprove(){"open"===this.type&&0===this.selected.length&&["directories","both"].indexOf(this.selectionMode)>-1&&(this.value=this.computeValue([this.directory]),this.selected.push({directory:!0,path:this.directory,name:v(this.directory)})),this.approvedEvent.emit()}handleCancel(){this.canceledEvent.emit()}handlePathListCanceled(t){t.stopPropagation(),t.stopImmediatePropagation()}renderPathListItem(t){return t.item.formattedLabel}renderFilterListItem(t){var e;const i=(null===(e=this._filters.find((e=>e.id===t.item.value)))||void 0===e?void 0:e.globs)||"";return 0===i.length?t.item.label:`${t.item.label} (${i.split(", ")})`}renderTableHeader(){return"detail"===this.view&&i("tr",{part:"table-row table-row-header",onClick:this.handleTableHeaderClick},["name","modified","length"].map((t=>{var e;if(-1===this.columns.indexOf(t)&&"name"!==t)return null;const s=(null===(e=this._sort.find((e=>e.prop===t)))||void 0===e?void 0:e.direction)||"none";return i("th",{key:`${t}-${s}`,part:"table-cell table-cell-header","data-name":t,"data-sort":s},i("div",{part:"table-cell-wrapper"},i("div",{part:"table-cell-label"},this._i18n[t]),i("div",{part:"table-cell-sort "+("none"!==s?"table-cell-sort-active":"")},i("dwc-icon",{pool:"dwc",name:"chevron-up",hidden:"asc"!==s&&"none"!==s}),i("dwc-icon",{pool:"dwc",name:"chevron-down",hidden:"desc"!==s&&"none"!==s}))))})))}renderTableRows(){return"detail"===this.view?this.renderListView():this.renderGridView()}renderListView(){const t=-1!==this.columns.indexOf("modified"),e=-1!==this.columns.indexOf("length");return this._entries.map(((s,r)=>{const o=r%2==0,h=!o,a=s.modified?this.formatDate(s.modified):"",n=!s.directory&&s.length?this.formatSize(s.length):"",c=[`${this._i18n.name}: ${s.name}`,s.directory?"":this._i18n.length+": "+n,`${this._i18n.modified}: ${a}`].filter(Boolean).join("\n"),d=this.isEntrySelected(s);return i("tr",{part:`table-row ${o?"table-row-even":""} ${h?"table-row-odd":""} ${d?"table-row-selected":""}`,key:s.path,"data-index":r,tabindex:0!==r||this.disabled?-1:0,title:c},i("td",{part:"table-cell"},i("dwc-icon",{name:s.directory?"folder":"file",pool:"dwc"}),s.name),t&&i("td",{part:"table-cell"},a),e&&i("td",{part:"table-cell"},n))}))}renderGridView(){return[...h(this._entries,this.gridColumns)].map(((t,e)=>{const s=e%2==0,r=t.map((t=>t.path)).join("-");return i("tr",{key:r,part:"table-row "+(s?"table-row-even":"table-row-odd")},t.map(((t,s)=>{const r=s%2==0,o=t.modified?this.formatDate(t.modified):"",h=!t.directory&&t.length?this.formatSize(t.length):"",a=[`${this._i18n.name}: ${t.name}`,t.directory?"":this._i18n.length+": "+h,`${this._i18n.modified}: ${o}`].filter(Boolean).join("\n");return i("td",{part:`table-cell ${r?"table-cell-even":"table-cell-odd"} ${this.isEntrySelected(t)?"table-cell-selected":""}`,key:t.path,"data-index":e*this.gridColumns+s,tabindex:0!==e||0!==s||this.disabled?-1:0,title:a},i("dwc-icon",{name:t.directory?"folder":"file",pool:"dwc"}),t.name)})))}))}render(){const{paths:t,selectedPath:e}=this.computePathsList(),{filters:r,selectedFilter:o}=this.computeFilterList(),h=this.isUpPermitted(),a=this.isBackPermitted(),n=this.isForwardPermitted(),c=v(this.history.previous),d=v(this.history.next),l=v(u(this.directory)),p=this._i18n.back.replace("%s",c?`(${c})`:""),b=this._i18n.forward.replace("%s",d?`(${d})`:""),f=this._i18n.up.replace("%s",l?`(${l})`:"");return i(s,{class:g({BBjFileChooser:!0,"bbj-server":!0,"bbj-server-open":"open"===this.type,"bbj-server-save":"save"===this.type,"bbj-server-loading":this.loading,"bbj-disabled":this.disabled})},i("div",{part:"control "+("detail"===this.view?"control-detail":"control-grid")},i("div",{part:"header"},i("div",{part:"header-prefix"},i("dwc-icon-button",{part:"header-prefix-button header-prefix-button-back",name:"chevron-left",pool:"dwc",disabled:!a,title:p,onClick:this.handleBack}),i("dwc-icon-button",{part:"header-prefix-button header-prefix-button-forward",name:"chevron-right",pool:"dwc",disabled:!n,title:b,onClick:this.handleForward}),i("dwc-icon-button",{part:"header-prefix-button header-prefix-button-up",name:"arrow-up",pool:"dwc",disabled:!h,title:f,onClick:this.handleUp})),i("div",{part:"header-inputs"},i("dwc-combobox",{ref:t=>this.$pathList=t,part:"header-pathlist",items:t,selected:e,toggleOnEnter:!1,disabled:this.disabled||this.loading,renderer:this.renderPathListItem,"onDwc-changed":this.handlePathListChanged,"onDwc-closed":this.handlePathListClosed,"onDwc-canceled":this.handlePathListCanceled},i("dwc-icon",{part:"header-pathlist-icon header-pathlist-icon-hard-drive",pool:"dwc",name:"hard-drive",slot:"prefix"}),i("dwc-icon-button",{part:"header-pathlist-button header-pathlist-button-refresh",pool:"dwc",name:"refresh",slot:"suffix",focusVisible:!1,disabled:this.loading||this.disabled,onKeyDown:this.handleRefreshKeydown,onClick:this.handleRefreshClick,title:this._i18n.refresh}))),i("div",{part:"header-layouts"},i("dwc-icon-button",{part:"header-suffix-button "+("detail"===this.view?"header-suffix-button-detail":"header-suffix-button-grid"),name:"detail"===this.view?"grid":"list",pool:"dwc",disabled:this.disabled,title:this._i18n["detail"===this.view?"gridView":"detailView"],onClick:this.handleViewChange}),i("dwc-icon-button",{part:"header-suffix-button header-suffix-button--columns",name:"columns",pool:"dwc",disabled:this.disabled||"grid"===this.view,title:this._i18n.columns,onClick:this.handleColumnsMenuClick}))),i("div",{part:"content",onKeyDown:this.handleTableKeyDown},i("dwc-loading",{part:"content-busy",opened:this.loading&&!this.disabled,suppressMessage:!0,"no-backdrop":!0}),i("div",{ref:t=>this.$tableWrapper=t,part:"table-wrapper"},i("table",{ref:t=>this.$table=t,part:"table",hidden:0===this._entries.length},i("thead",null,this.renderTableHeader()),i("tbody",{ref:t=>this.$tbody=t,onClick:this.handleTableRowAndCellClick,onDblClick:this.handleTableRowAndCellDBClick},this.renderTableRows())),i("div",{part:"content-nodata",hidden:this._entries.length>0},this._i18n.folderEmpty))),i("div",{part:"footer "+("save"===this.type?"footer-save":"footer-open")},i("div",{part:"footer-inputs"},"save"===this.type&&i("dwc-field",{part:"footer-save-input",placeholder:this._i18n.fileName,value:this.value,title:this._i18n.fileName,maxlength:255,"onDwc-modified":this.handleValueInputChanged,"onDwc-blurred":this.handleValueInputBlurred,onKeyDown:this.handleValueInputKeyDown}),"directories"!==this.selectionMode&&i("dwc-combobox",{part:"footer-filter-input",items:r,selected:o,toggleOnEnter:!1,disabled:this.disabled,title:this._i18n.filters,customValue:this.customFilters,renderer:this.renderFilterListItem,"onDwc-changed":this.handleFiltersListChanged,"onDwc-canceled":this.handlePathListCanceled})),this.buttonsVisible&&i("div",{part:"footer-buttons"},i("dwc-button",{part:"footer-buttons-button footer-buttons-button-approve",label:this._i18n.approve,theme:this.theme,accessKey:this.approveAccesskey,disabled:(()=>!(!this.disabled&&!this.loading&&("open"===this.type?["directories","both"].indexOf(this.selectionMode)>-1||this.selected.length:this.value.length)))(),onClick:this.handleApprove}),i("dwc-button",{part:"footer-buttons-button footer-buttons-button-cancel",label:this._i18n.cancel,accessKey:this.cancelAccesskey,disabled:this.disabled,onClick:this.handleCancel})))))}get el(){return r(this)}static get watchers(){return{activeFilter:["onActiveFilterChange","onPropertiesChanged"],dateFormatOptions:["onDateFormatOptionsChanged"],directory:["onDirectoryChanged","onPropertiesChanged"],i18n:["onI18nChanged"],selectionMode:["onSelectionModeChanged","onPropertiesChanged"],selected:["onSelectedChanged"],value:["onValueChanged"],allFilesFilterEnabled:["onPropertiesChanged"],filters:["onPropertiesChanged"],customFilters:["onPropertiesChanged"],cacheCustomFilters:["onPropertiesChanged"],sort:["onPropertiesChanged"],entries:["onPropertiesChanged"]}}};x.style="@media (prefers-reduced-motion: reduce){*,::before,::after{animation-delay:-1ms !important;animation-duration:1ms !important;animation-iteration-count:1 !important;background-attachment:initial !important;scroll-behavior:auto !important;transition-delay:0s !important;transition-duration:0s !important}}:host{box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:relative;-webkit-tap-highlight-color:transparent;text-size-adjust:100%}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{--_dwc-fc-padding:var(--dwc-file-chooser-padding, var(--dwc-space-s));--_dwc-fc-border-color:var(--dwc-file-chooser-border-color, var(--dwc-color-default));--_dwc-fc-border:var(--dwc-file-chooser-border, var(--dwc-border-width) solid var(--_dwc-fc-border-color));--_dwc-fc-hover-background:var(--dwc-file-chooser-hover-background, var(--dwc-color-primary-alt));--_dwc-fc-hover-color:var(--dwc-file-chooser-hover-color, var(--dwc-color-on-primary-alt));--_dwc-fc-hover-border-color:var(--dwc-file-chooser-hover-border-color, var(--dwc-color-primary));--_dwc-fc-selected-bg:var(--dwc-file-chooser-selected-background-color, var(--dwc-color-primary-85));--_dwc-fc-selected-c:var(--dwc-file-chooser-selected-color, var(--dwc-color-primary-text-85));--_dwc-fc-icon-fill:var(--dwc-file-chooser-icon-fill, var(--dwc-color-gray-text));--_bt-fc-icon-color:var(--dwc-file-chooser-icon-color, var(--_dwc-fc-icon-fill));border:var(--_dwc-fc-border);border-radius:var(--dwc-border-radius);display:block}[part~=control]{border-radius:inherit;display:flex;flex-direction:column;height:100%;overflow:hidden;position:relative;width:100%}[part=header]{align-items:center;background-color:var(--dwc-surface-3);border-bottom:var(--_dwc-fc-border);display:flex;gap:var(--_dwc-fc-padding);padding:var(--_dwc-fc-padding);width:100%}[part=header-prefix],[part=header-layouts]{display:flex;flex:0 0 auto}[part=header-inputs]{display:flex;flex:1}[part=header-inputs] dwc-combobox{min-width:100%;width:0}[part=content]{display:flex;flex:1;flex-direction:column;overflow:hidden;position:relative}[part=content] dwc-loading{position:absolute}:host([loading]) [part=content]{cursor:var(--dwc-cursor-progress)}:host([disabled]) [part=content]{cursor:var(--dwc-disabled-cursor);opacity:var(--dwc-disabled-opacity);user-select:none;pointer-events:none}:host([disabled]) [part=content] *{cursor:var(--dwc-disabled-cursor);user-select:none;pointer-events:none}[part=table-wrapper]{background:var(--dwc-surface-2);height:100%;overflow-x:auto}[part=content-nodata]{align-items:center;display:flex;flex:1;justify-content:center;margin-top:var(--dwc-space-m)}[part=table]{border-collapse:collapse;border-spacing:0;width:100%}[part=table-cell-wrapper]{align-items:center;display:flex;justify-content:space-between}[part~=table-cell-sort]{--dwc-icon-size:1rem;align-items:stretch;box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;margin-left:var(--dwc-space-s)}[part~=table-cell-sort-active]{color:var(--dwc-color-primary-text)}[part~=table-cell]{box-shadow:inset 0 -1px 0 var(--_dwc-fc-border-color);cursor:var(--dwc-cursor-click);padding:var(--_dwc-fc-padding) calc(var(--_dwc-fc-padding) * 2);text-align:left;user-select:none;white-space:nowrap}[part~=table-cell].focus-visible{box-shadow:inset 0 0 0 1px var(--_dwc-fc-hover-border-color);outline:none}[part~=table-cell]:not([part~=table-cell-header]) dwc-icon{height:var(--dwc-size-s);margin-right:var(--dwc-space-s);width:var(--dwc-size-s)}[part~=table-cell]:not([part~=table-cell-header]) dwc-icon::part(control),[part~=table-cell]:not([part~=table-cell-header]) dwc-icon::part(icon){height:var(--dwc-size-s);width:var(--dwc-size-s)}[part~=table-cell]:not([part~=table-cell-header]) dwc-icon[name=folder][pool=dwc]::part(icon){color:var(--_bt-fc-icon-color);fill:var(--_dwc-fc-icon-fill)}[part~=table-cell]:not([part~=table-cell-header]) dwc-icon[name=file][pool=dwc] ::part(icon){color:var(--_bt-fc-icon-color)}[part~=table-cell-header]{padding-bottom:0;padding-top:0}[part~=control-grid] [part~=table-cell]:not([part~=table-cell-selected]):hover{background-color:var(--_dwc-fc-hover-background);color:var(--_dwc-fc-hover-color)}[part~=control-grid] [part~=table-cell]:hover{box-shadow:inset 0 0 0 1px var(--_dwc-fc-hover-border-color)}[part~=table-cell-selected]{background-color:var(--_dwc-fc-selected-bg);color:var(--_dwc-fc-selected-c)}[part~=table-cell-header]{background-color:var(--dwc-surface-3);box-shadow:inset 0 calc(-1 * var(--dwc-border-width)) 0 var(--dwc-color-default);height:var(--dwc-size-l);position:sticky;top:-1px;z-index:1;}[part~=table-row-even]{background:var(--dwc-surface-2)}[part~=table-row-odd]{background:var(--dwc-surface-1)}[part~=table-row]{outline:none}[part~=table-row].focus-visible [part~=table-cell]{box-shadow:inset 0 1px 0 0 var(--_dwc-fc-hover-border-color), inset 0 -1px 0 0 var(--_dwc-fc-hover-border-color)}[part~=table-row].focus-visible [part~=table-cell]:first-child{box-shadow:inset 1px 0 0 0 var(--_dwc-fc-hover-border-color), inset 0 1px 0 0 var(--_dwc-fc-hover-border-color), inset 0 -1px 0 0 var(--_dwc-fc-hover-border-color)}[part~=table-row].focus-visible [part~=table-cell]:last-child{box-shadow:inset -1px 0 0 0 var(--_dwc-fc-hover-border-color), inset 0 1px 0 0 var(--_dwc-fc-hover-border-color), inset 0 -1px 0 0 var(--_dwc-fc-hover-border-color)}[part~=table-row-selected]{background-color:var(--_dwc-fc-selected-bg);color:var(--_dwc-fc-selected-c)}[part~=control-detail] [part~=table-row]:not([part~=table-row-selected]):hover{background-color:var(--_dwc-fc-hover-background);color:var(--_dwc-fc-hover-color)}[part~=footer]{background-color:var(--dwc-surface-3);border-top:var(--_dwc-fc-border);box-shadow:0 7px 9px -7px rgba(0, 0, 0, 0.4);display:flex;flex:0 0 auto;flex-wrap:wrap;gap:var(--_dwc-fc-padding);justify-content:flex-end;padding:var(--_dwc-fc-padding);width:100%}[part=footer-inputs]{display:flex;flex:1;gap:var(--_dwc-fc-padding);width:100%}[part=footer-save-input]{flex:1}[part=footer-buttons]{display:flex;flex:0 0 auto;gap:var(--_dwc-fc-padding);justify-content:flex-end}[part~=footer-save]{flex-direction:column}[part~=footer-save] [part=footer-inputs]{flex-direction:column}[hidden]{display:none !important}:host([dwc-fs-server]){border:0;border-radius:0;height:inherit}:host([dwc-fs-server]) [part~=footer]{background-color:var(--dwc-surface-1)}";export{x as dwc_file_chooser}