/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import j from"./SBOSBG32.js";import i from"./SK6MHFPK.js";import"./F5YQAUW4.js";import e from"./EZAL5KYF.js";import c from"./HBC3TKGZ.js";import{b as y}from"./W4YXXJAS.js";import{b as D}from"./S7VQX4XX.js";import{Yb as b}from"./4Q4PZB7R.js";import{a as I}from"./XN2LWKJE.js";import"./4BPRM7CL.js";import"./NIL6NWG5.js";import"./ED6SUP22.js";import"./E6P6PYNW.js";import"./IKKBLHLZ.js";import"./CUA2IUXX.js";import"./4UZDZNJD.js";import"./KOTG6W5Z.js";import"./6SC7YR5Y.js";import"./Z6NOHRUL.js";import"./GVM4XYEI.js";import"./NGDVSE4Z.js";import"./BTNJZZQQ.js";import"./ZYQ4P2ON.js";import"./5MKH4QDV.js";import"./3GWWHA4S.js";import"./3YYHZQJB.js";import"./JEJ23R3P.js";import"./TONS7KZJ.js";import"./Q62UEPOL.js";import"./44A5XEM4.js";import{b as g}from"./ODCCVHGI.js";import{F as f,G as d,H as _,J as r,h as m,i as a,l as p,r as h}from"./42WFQ3AX.js";import"./3QPJ2JCA.js";export default $arcgis.t(([{n:w},,{a:C,b:$},{a:S}])=>{var T=m`/** @license
 * Copyright 2025 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

.panel-bg-color {
  --calcite-panel-header-background-color: var(--calcite-color-foreground-1);
  --calcite-panel-background-color: var(--calcite-color-foreground-1);
}

.display-none {
  display: none;
}`,u=class extends _{constructor(){super(),this.open=!1,this.source="Card Dropdown",this._deletePercentage=0,this._fetchingTemplates=!1,this._isDeleteInProgress=!1,this._nonSolutionDependencyItems=[],this._showDeleteError=!1,this._showUndeletableItems=!1,this._templateInfos=[],this._translations=I({name:"solution-delete-dialog",blocking:!0}),this._accordion=f(),this._configContextConsumer=D({context:y,subscribe:!0}),this.solutionDeleteDialogOpen=h(),this.solutionDeleted=h(),this.solutionDeleteDialogBeforeClose=h(),this.listenOn(window,"beforeunload",e=>{this._isDeleteInProgress&&(e.preventDefault(),e.returnValue=!0)})}static{this.properties={card:[0,{},{attribute:!1}],open:[5,{},{type:Boolean}],source:1,_deletePercentage:[16,{},{state:!0}],_fetchingTemplates:[16,{},{state:!0}],_isDeleteInProgress:[16,{},{state:!0}],_nonSolutionDependencyItems:[16,{},{state:!0}],_showDeleteError:[16,{},{state:!0}],_showUndeletableItems:[16,{},{state:!0}],_templateInfos:[16,{},{state:!0}],_translations:[16,{},{state:!0}]}}static{this.styles=T}get _telemetry(){return this._configContextConsumer.value?.telemetrySession}close(){this._showUndeletableItems&&this.solutionDeleted.emit({showAlert:!1,refreshSolutionsTimeout:!0,solutionTitle:this.card?.title}),this._showDeleteError=!1,this._showUndeletableItems=!1,this._isDeleteInProgress=!1,this.open=!1,this.solutionDeleteDialogOpen.emit(!1)}delete(){if(this._telemetry?.logEvent({category:w.DEPLOYMENTS,action:"Delete Solution",dimensions:[this.card?.title||"",this.card?.deployCommonId||"",this.card?.deployVersion||"",this.source]}),this._isDeleteInProgress=!0,this.card){let e=[{itemName:this.card.title,itemType:"Solution",owner:this.card.owner,modified:this.card.modified}],s={progressCallback:t=>{this._deletePercentage=Math.round(t)}};b(this.card.id,this._configContextConsumer.value.userSession,s).then(t=>{let c=t[1],i;if(c?i=c.items.map(o=>({itemName:o.title,itemType:o.type,owner:o.owner,modified:o.modified})):i=e,i.length===0)this.solutionDeleted.emit({showAlert:!0,refreshSolutionsTimeout:!0,solutionTitle:this.card?.title}),this._isDeleteInProgress=!1,this.open=!1;else if(i.some(l=>l.itemType==="Solution"))this.card?$(this.card,this._configContextConsumer.value.userSession).then(l=>{this._templateInfos=l,this._showDeleteError=!0,this._showUndeletableItems=!0,this._isDeleteInProgress=!1}):(this._showDeleteError=!0,this._isDeleteInProgress=!1);else if(this.card){let l=[];l=c.items.map(n=>({id:n.id,title:n.title,type:n.type,owner:n.owner,modified:n.modified,typeKeywords:[],snippet:"",dependencies:[],url:S(n.id,this._configContextConsumer.value.authentication)})),this._templateInfos=l,this._showDeleteError=!1,this._showUndeletableItems=!0,this._isDeleteInProgress=!1}else this.solutionDeleted.emit({showAlert:!0,refreshSolutionsTimeout:!0}),this._isDeleteInProgress=!1,this.open=!1})}}willUpdate(e){if(e.has("open")){let s=e.get("open");this.open&&!s&&(this._fetchingTemplates=!0,C(this._configContextConsumer.value.userSession,this.card).then(t=>{this._templateInfos=t.templateInfos,this._nonSolutionDependencyItems=t._nonSolutionDependencyItems,setTimeout(()=>{this._accordion.value.expandFirstItem(),t.uniqueIitemIds.length>0&&this._accordion.value.expandItems(t.uniqueIitemIds)},500),this._fetchingTemplates=!1}))}}updated(e){e.has("_showUndeletableItems")&&this._showUndeletableItems!==e.get("_showUndeletableItems")&&this._accordion.value.expandItems(this._templateInfos.map(s=>s.id))}render(){let e=this._fetchingTemplates?"":"display-none",s=this._fetchingTemplates?"display-none":"",t=[...new Set(this._nonSolutionDependencyItems.map(o=>o.controlItemId))],c=this._templateInfos.length-this._getDependencyCount(),i=this._translations.deletionCount.replace("{{deleteableCount}}",c.toString()).replace("{{totalCount}}",this._templateInfos.length.toString());return a`<calcite-dialog class="panel-bg-color" .closeDisabled=${this._isDeleteInProgress} .heading=${this._translations.title.replace("{{solution}}",this.card?.title??"")} id=${this._translations.title.replace("{{solution}}",this.card?.title??"")??p} modal kind=danger .open=${this.open} width=l outside-close-disabled @calciteDialogBeforeClose=${()=>{this.solutionDeleteDialogBeforeClose.emit()}} @calciteDialogClose=${()=>{this.open=!1,this.solutionDeleteDialogOpen.emit(!1)}}>${this._isDeleteInProgress?a`<calcite-loader .label=${this._translations.deleteInProgress} scale=l .text=${this._translations.deleteInProgress} type=determinate-value .value=${this._deletePercentage}></calcite-loader>`:this._showUndeletableItems?a`<calcite-label class=${r(s)} layout=inline>${this._translations.failedToDeleteItems}</calcite-label><solution-item-accordion class=${r(s)} .itemRelationshipDependencies=${[]} link-type=item list-selection-mode=multiple .reuseWarning=${this._translations.itemDependencyReusewarning} .templateInfos=${this._templateInfos} .typeKeywords=${this.card?.typeKeywords} ${d(this._accordion)}></solution-item-accordion><calcite-button appearance=outline @click=${this.close} slot=footer-end>${this._translations.buttonClose}</calcite-button>`:a`<calcite-label class=${r(s)} layout=inline scale=l>${this._translations.deletionNote}<calcite-chip .label=${i} scale=m icon=information>${i}</calcite-chip></calcite-label><calcite-loader class=${r(e)} label></calcite-loader><solution-item-accordion class=${r(s)} .itemRelationshipDependencies=${t} link-type=item list-selection-mode=multiple .reuseWarning=${this._translations.itemDependencyReusewarning} .templateInfos=${this._templateInfos} .typeKeywords=${this.card?.typeKeywords} ${d(this._accordion)}></solution-item-accordion><calcite-button appearance=outline @click=${this.close} slot=footer-end>${this._translations.buttonCancel}</calcite-button><calcite-button @click=${()=>{this.delete()}} slot=footer-end kind=danger>${this._translations.buttonDelete}</calcite-button>${this._showDeleteError&&a`<calcite-alert icon=exclamation-mark-triangle kind=danger .label=${this._translations.failedToDelete} @calciteAlertClose=${()=>{this._showDeleteError=!1}} open><div slot=message>${this._translations.failedToDelete}</div></calcite-alert>`||""}`}</calcite-dialog>`}_getDependencyCount(){let e=this._nonSolutionDependencyItems.map(t=>t.controlItemId);return[...new Set(e)].length}};g("solution-delete-dialog",u);return u},c,e,i,j)