/*! 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{E as x,P as f,Q as c,S as d,U as g,i as u,j as h,k as n}from"./3VKC6PRK.js";export default $geoscene.t(([{watch:$,whenOnce:b}])=>{var L=h`@layer{.geoscene-print__exported-file{display:flex;align-items:center;justify-content:space-between}.geoscene-print__exported-file-link-title,.geoscene-print__exported-file-link-description{word-wrap:break-word;word-break:break-all;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}}`,p="geoscene-print",m={exportedFile:`${p}__exported-file`,exportedFileLinkTitle:`${p}__exported-file-link-title`,exportedFileLinkDescription:`${p}__exported-file-link-description`};function w(l){let{state:e,extension:t}=l;switch(e){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return t?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}function v(l,e){return!l||l==="all"||!!(e&&l.includes(e))}var k=class extends f{constructor(){super(...arguments),this._handleLinkClick=e=>{if(!e||e.state!=="ready"||!e.url)return;let t=e.url,i=document.createElement("a");i.target="_blank",i.href=t,i.rel="noreferrer",i.download=e.formattedName??"";{i.click();return}}}static{this.properties={saveAsButtonCallback:0,allowedFormatsForSaving:1,exportedLink:0,viewModel:0,messages:0}}static{this.styles=L}static{this.shadowRootOptions=x}loaded(){this.manager.onLifecycle(()=>[$(()=>this.exportedLink.state,()=>this.requestUpdate())])}render(){let{messages:e,exportedLink:t}=this,{error:i,state:o}=t,r;switch(o){case"pending":r=e.pending;break;case"ready":r=e.ready;break;case"error":r=e.errorMessage;break}let a=o==="error"?i?.name==="print-task:cim-symbol-unsupported"?e.exportWebMapCIMError:e.exportWebMapError:"";return n`<calcite-list-item .ariaLabel=${r} title=${a??d}>${this._renderExportedLinkItemContent(t,a)}${this._renderExportedLinkItemIcon(t)}${this._renderExportedLinkItemAction(t,a)}</calcite-list-item>${this._renderExportedLinkItemPopover(t)}`}_renderExportedLinkItemPopover(e){let t=this.messages,i=e.formattedName??"",{state:o}=e,r=this.saveAsButtonCallback&&o!=="error"&&v(this.allowedFormatsForSaving,e.extension);return o!=="pending"&&r?n`<calcite-popover auto-close label=Popover offset-distance=1 overlay-positioning=fixed pointer-disabled .referenceElement=${`${i}-popover-button`} scale=s><calcite-list label>${e.portalItem?n`<calcite-list-item .label=${t.openItem} @calciteListItemSelect=${()=>{let a=e.portalItem;if(!a?.itemPageUrl)return;let s=document.createElement("a");s.target="_blank",s.href=a.itemPageUrl,s.rel="noreferrer",s.click()}}><calcite-icon icon=launch2 scale=s slot=content-start></calcite-icon></calcite-list-item>`:n`<calcite-list-item .label=${t.saveAs} @calciteListItemSelect=${async()=>{this.saveAsButtonCallback&&(b(()=>e.portalItem).then(a=>{a.itemPageUrl&&this.requestUpdate()}),await this.saveAsButtonCallback(e))}}><calcite-icon icon=save scale=s slot=content-start></calcite-icon></calcite-list-item>`}<calcite-list-item label=Delete @calciteListItemSelect=${()=>this.viewModel.exportedLinks.remove(e)}><calcite-icon icon=trash scale=s slot=content-start></calcite-icon></calcite-list-item></calcite-list></calcite-popover>`:null}_renderExportedLinkItemContent(e,t){let i=this.messages,{url:o,state:r}=e,a=e.formattedName??"",s=u(o||null,document.location.href);return n`<div class=${c(m.exportedFile)} slot=content @click=${()=>this._handleLinkClick(e)}><div><div class=${c(m.exportedFileLinkTitle)}>${a}</div><div class=${c(m.exportedFileLinkDescription)}>${r==="pending"?i.generatingExport:t||(s?i.ready:i.linkReady)}</div></div>${r==="ready"?n`<calcite-icon .ariaLabel=${`${a}. ${i.linkReady}`} .icon=${s?"download-to":"launch"} scale=s slot=content-end></calcite-icon>`:null}</div>`}_renderExportedLinkItemIcon(e){return e.state==="pending"?n`<calcite-loader inline .label=${this.messages.generatingExport} scale=m slot=content-start></calcite-loader>`:n`<calcite-icon .icon=${w(e)} scale=s slot=content-start></calcite-icon>`}_renderExportedLinkItemAction(e,t){let{state:i}=e,o=e.formattedName??"",r=this.saveAsButtonCallback&&i!=="error"&&v(this.allowedFormatsForSaving,e.extension);return i!=="pending"?n`<calcite-action .ariaLabel=${t} .icon=${r?"ellipsis":"x"} id=${(r?`${o}-popover-button`:void 0)??d} @click=${r?void 0:()=>{this.viewModel.exportedLinks.remove(e)}} slot=actions-end .text=${t}></calcite-action>`:null}};g("geoscene-print-exported-link",k);return k},"core/reactiveUtils")