/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
import{a as l,b as c}from"./IC36TD4R.js";import{B as o,P as u,U as v,j as p,k as s}from"./3VKC6PRK.js";var N=p`:host{display:none;background:#bdf2c4}:host([selected]){display:flex}calcite-block{margin-block:0}calcite-pagination{justify-content:center}`,h=class extends u{constructor(){super(...arguments),this._filterInputElement=l(),this._flowItemElement=l(),this.currentPage=1,this.selected=!1,this.showBackButton=!1,this.geosceneFlowItemBack=o(),this.geosceneFlowItemClose=o(),this.geosceneGetVersions=o(),this.geosceneManageVersion=o(),this.geosceneNewVersion=o()}static{this.properties={_filteredVersionInfos:16,currentPage:11,selected:7,showBackButton:7,versionListElementProps:0}}static{this.styles=N}load(){this._filteredVersionInfos=this.versionListElementProps.versionInfos}willUpdate(e){if(e.has("versionListElementProps")){let i=e.get("versionListElementProps"),t=this.versionListElementProps;i?.versionInfos!==t.versionInfos&&(this._filteredVersionInfos=t.versionInfos,this._filterInputElement.value&&this._handleFilterChange())}}updated(){this._filterInputElement.value?.setFocus()}async setFocus(){this._flowItemElement.value?.setFocus()}goBack(){}_handleFilterChange(){let{versionListElementProps:{versionInfos:e}}=this,i=this._filterInputElement.value.value.toUpperCase();this._filteredVersionInfos=i===""?e:e.filter(t=>t.versionIdentifier.name.toUpperCase().includes(i)||t.versionIdentifier.guid.toUpperCase().includes(i)),this._filteredVersionInfos.length&&(this.currentPage=1)}_handleNoticeClosed(){this.versionListElementProps={...this.versionListElementProps,executionError:void 0}}_handlePaginationChange(e){this.currentPage=e.target.startItem}_getExecutionError(e){let{versionListElementProps:{strings:{executionErrors:i}}}=this;switch(e){case"no-feature-service-found":return i.noFeatureServiceFound;case"no-valid-enterprise-version":return i.notValidEnterpriseVersion;case"no-valid-version-name":return i.invalidVersionName;default:return e}}_paginate(e,i,t){return e.slice((t-1)*i,t*i)}render(){let{currentPage:e,selected:i,showBackButton:t,versionListElementProps:{closable:I,currentUser:V,currentVersionIdentifier:d,executionError:g,heading:$,isVersionAdministrator:_,isVersioningApiAvailable:f,pageSize:r,serviceName:E,serviceUrl:a,state:w,strings:{headers:m},strings:n,versionInfos:b}}=this,P=s`<calcite-block .heading=${m.currentVersion} .description=${d.name} overlay-positioning=fixed></calcite-block>`,k=s`<calcite-action id=actionRefreshVersions icon=refresh text @click=${()=>this.geosceneGetVersions.emit({serviceUrl:a})} slot=header-actions-end><calcite-tooltip overlay-positioning=fixed reference-element=actionRefreshVersions><span>${n.actions.refreshVersions}</span></calcite-tooltip></calcite-action>`;this._paginatedVersionInfos=this._filteredVersionInfos.length>r?this._paginate(this._filteredVersionInfos,r,e):this._filteredVersionInfos;let x=this._filteredVersionInfos.length>r?s`<calcite-pagination @calcitePaginationChange=${this._handlePaginationChange} page-size=1 .startItem=${e} .totalItems=${Math.ceil(this._filteredVersionInfos.length/r)}></calcite-pagination>`:void 0,C=this._paginate(this._paginatedVersionInfos,r,1).map(y=>s`<geoscene-version-management-version-item .versionItemElementProps=${{currentUser:V,currentVersionIdentifier:d,isCurrentVersionCard:!1,isVersionAdministrator:_,isVersioningApiAvailable:f,serviceUrl:a,strings:n,versionInfo:y}}></geoscene-version-management-version-item>`),F=b.length>r?s`<calcite-block heading .label=${m.filterVersions} open><calcite-input-text clearable icon=search @calciteInputTextInput=${this._handleFilterChange} .placeholder=${n.actions.searchVersions} ${c(this._filterInputElement)}></calcite-input-text></calcite-block>`:void 0,L=s`<calcite-list .label=${n.labels.versionList}>${C}</calcite-list>`,B=f?s`<calcite-fab appearance=outline-fill slot=fab text-enabled .text=${n.actions.newVersion} @click=${()=>this.geosceneNewVersion.emit({serviceUrl:a})}></calcite-fab>`:void 0,U=g?s`<calcite-notice @calciteNoticeClose=${this._handleNoticeClosed} class="notice" closable kind=warning open scale=s slot=footer width=full><div slot=message>${this._getExecutionError(g)}</div></calcite-notice>`:void 0;return s`<calcite-flow-item .closable=${I} .description=${E} .heading=${$} .selected=${i} .showBackButton=${t} @calciteFlowItemBack=${()=>this.geosceneFlowItemBack.emit()} @calciteFlowItemClose=${()=>this.geosceneFlowItemClose.emit()} ${c(this._flowItemElement)}><calcite-panel .loading=${w==="executing"}>${P}<calcite-panel .heading=${this._filteredVersionInfos.length?`${n.headers.manageVersions} (${this._filteredVersionInfos.length})`:n.headers.manageVersions}>${k}${F}${L}${B}</calcite-panel>${x}${U}</calcite-panel></calcite-flow-item>`}};v("geoscene-version-management-version-list",h);export{h as GeosceneVersionManagementVersionList};