/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{a as u}from"./P5EZZH6S.js";import"./EH5576ZY.js";import"./7QZVR2UR.js";import"./ZNBKMZP7.js";import{O as g,U as h,a as m,b as c,p as s,s as p}from"./GRFF5Y4R.js";import"./ALDX5YZO.js";export default $arcgis.t(([v,{substitute:y}])=>{var x=m`:host{margin-block-start:0;padding:0 var(--calcite-spacing-sm) var(--calcite-spacing-sm) var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}calcite-list{border:solid 1px var(--calcite-color-border-3);border-radius:var(--calcite-corner-radius-sm);overflow:hidden}calcite-list-item [slot=content-bottom]{background-color:transparent;display:none}calcite-list-item[expanded] [slot=content-bottom]{display:unset}.warning{color:var(--calcite-color-status-danger)}.terminals{padding-block:var(--calcite-spacing-sm);padding-inline-start:var(--calcite-spacing-xl);padding-inline-end:var(--calcite-spacing-sm);display:flex;flex-direction:column}.filter-barrier-container{display:flex;width:100%;calcite-label{width:100%}}.filter-barrier{display:flex;justify-content:space-between;align-items:center;width:100%}`,d=class extends g{constructor(){super(...arguments),this._messages=u({blocking:!0}),this.traceLocations=new v,this.traceLocationType="starting-point"}static{this.properties={traceLocations:0,traceLocationType:1}}static{this.styles=x}_handleTraceLocationItemRemoved(e){let i=e.spatialProperties.flagGraphic?.layer,{traceLocations:t}=this;e.spatialProperties.flagGraphic&&i&&i.remove(e.spatialProperties.flagGraphic),t?.remove(e)}_renderTerminal(e,i){let{flagProperties:t}=e,{selectedTerminals:r}=t;if(!e)return s("warn",this,"One or more elements in `traceLocations` are missing the required property `flag`."),null;let{name:n,id:a}=i,o=r?.has(a)??!1;return c`<calcite-label layout=inline><calcite-checkbox .value=${a} .checked=${o} @calciteCheckboxChange=${l=>{l.target.checked?r?.add(a):r?.delete(a),this.requestUpdate()}}></calcite-checkbox>${n}</calcite-label>`}_renderTerminalError(){let{_messages:e}=this;return c`<calcite-notice kind=danger open scale=s width=auto><div slot=message>${e.errors.noTerminalSelected}</div></calcite-notice>`}_renderFilterBarrier(e){let{_messages:i}=this,{traceLocation:t}=e;return c`<div class="filter-barrier-container"><calcite-label layout=inline><div class="filter-barrier">${i.labels.filterBarrier}<calcite-switch .checked=${t.isFilterBarrier} @calciteSwitchChange=${r=>{t.isFilterBarrier=r.target.checked}}></calcite-switch></div></calcite-label></div>`}_renderContents(e){let{flagProperties:i}=e,{terminalConfiguration:t,selectedTerminals:r}=i,n=e.traceLocation.type==="barrier",a=t&&t.terminals.length>0&&r?.size===0;return c`<calcite-action .icon=${i.expanded?"chevron-up":"chevron-down"} slot=actions-end scale=s text @click=${()=>{i.expanded=!i.expanded,this.requestUpdate()}}></calcite-action>${a&&c`<calcite-icon class="warning" icon=exclamation-mark-triangle scale=s slot=content-start></calcite-icon>`||""}${i.expanded&&c`<div class="terminals" slot=content-bottom>${n&&this._renderFilterBarrier(e)||""}${t&&this._renderTerminals(e)||""}${a&&this._renderTerminalError()||""}</div>`||""}`}_renderTerminals(e){let{flagProperties:i}=e,{terminalConfiguration:t}=i;if(!t)return s("warn",this,"One or more locations are missing the required flag property `terminalConfiguration`."),[];let r=t.terminals;return!r||r.length===0?(s("warn",this,"`terminalConfiguration.terminals` is required but either missing or empty.`"),[]):r.map(n=>this._renderTerminal(e,n))}_renderListItem(e){let{flagProperties:i}=e,{terminalConfiguration:t,expanded:r,title:n}=i,a=n,o=t&&t.id!==0,l=e.traceLocation.type==="barrier",f=o||l,b=t?.name??void 0;return c`<calcite-list-item .label=${a} .description=${b} .value=${a} .expanded=${r}>${f?this._renderContents(e):c`<div slot=content-bottom></div>`}<calcite-action icon=x slot=actions-end scale=s text @click=${()=>this._handleTraceLocationItemRemoved(e)}></calcite-action></calcite-list-item>`}render(){let{_messages:e,traceLocationType:i}=this,t=y(e.labels.list,{traceLocationType:i}),r=this.traceLocations?.map(n=>this._renderListItem(n)).toArray()??[];return r.length===0?(s("warn",this,p("traceLocations")),null):c`<div><calcite-list interaction-mode=static selection-mode=none .label=${t}>${r}</calcite-list></div>`}};h("arcgis-utility-network-trace-location-list",d);return d},"core/Collection","intl")