/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import f from"./C4F2OOUL.js";import e from"./SIODWUWX.js";import c from"./7JC52SFZ.js";import a from"./4AFANEZZ.js";import"./CJ3EZE7U.js";import{b as I,e as $}from"./C5KDPY7R.js";import"./YM4U4HSN.js";import{a as x}from"./IADXB53D.js";import{a as u}from"./ONARC6AZ.js";import{a as y}from"./BM4VSEDV.js";import{b as _}from"./HVT2WBVC.js";import"./UBPOT5V3.js";import"./ISFTCFSJ.js";import{G as b,I as d,h as v,i as r}from"./FFF5HUPM.js";import"./EXBEKVP5.js";export default $arcgis.t(([F,,{a:n,b:p,c:C},{c:m,e:T},{d:f,e:L,f:w}])=>{var z=v`:host{display:flex;align-items:center}.instant-apps-interactive-legend__total-feature-count{font-weight:var(--calcite-font-weight-medium);font-size:var(--calcite-font-size-0)}.instant-apps-interactive-legend__info-count-text{font-size:var(--instant-apps-interactive-legend-info-font-size);color:var(--instant-apps-interactive-legend-secondary-color);white-space:nowrap}.calcite-mode-dark.instant-apps-interactive-legend__info-count-text.instant-apps-interactive-legend__info-count-text--selected{color:var(--calcite-color-text-inverse)}.instant-apps-interactive-legend-count--compact .instant-apps-interactive-legend__total-feature-count{font-size:.75rem}:host:dir(rtl){margin-left:0;margin-right:auto}`,c={countText:" instant-apps-interactive-legend__info-count-text",countTextSelected:" instant-apps-interactive-legend__info-count-text--selected",totalFeatureCount:"instant-apps-interactive-legend__total-feature-count",compact:"instant-apps-interactive-legend-count--compact"},g=class extends b{constructor(){super(...arguments),this._messages=y({name:"instant-apps-interactive-legend"}),this.showTotal=!1,this.categoryId=""}static{this.properties={showTotal:5,legendvm:0,activeLayerInfo:0,categoryId:1,infoIndex:9,selected:5,legendElement:0}}static{this.styles=z}load(){if(this.attributeObserver=new MutationObserver(()=>{this.requestUpdate()}),this.attributeObserver.observe(this.el,{attributes:!0}),!this.dataChangeHandle){let t=p.onChange("data",()=>this.requestUpdate());this.isRemovableHandle(t)&&(this.dataChangeHandle={remove:t.remove.bind(t)})}}disconnectedCallback(){super.disconnectedCallback(),this.attributeObserver?.disconnect(),this.attributeObserver=void 0,this.dataChangeHandle?.remove(),this.dataChangeHandle=void 0}isRemovableHandle(t){return!!t&&typeof t.remove=="function"}formatResolvedNumber(t){return f(t)?F.formatNumber(t):""}getCount(){let{categoryId:t}=this,a=this.activeLayerInfo.layer.id,o=n.data[a]?.categories?.size;if((!n.data||!a||!t)&&!o)return"";let s=n.data[a];if(!s)return;let{categories:l}=s,e=l.get(t),i;return e?.nestedInfos?i=T(e,this.infoIndex):i=e,this.formatResolvedNumber(i.count)}getTotalFeatureCount(){let t=this.activeLayerInfo.layer.id;if(!n.data||!t)return"";let a=n.data[t];if(!a)return;let{categories:o}=a,s=m(o),l=I(o),e;if(l)e=w(s);else if($(this.activeLayerInfo)){let i=C(this.activeLayerInfo.layer),h=m(i.categories)[1];e=f(h.count)?h.count:null}else e=L(s);return this.formatResolvedNumber(e)}render(){let t=p.get("compact")?c.compact:"";return u("int-legend-count",r`<div class=${d(t)}>${this.showTotal?r`<span class=${d(c.totalFeatureCount)}>${this._messages?.totalFeatureCount}: ${this.getTotalFeatureCount()}</span>`:u("element-info-count",r`<span class=${`${c.countText} ${x(this.el)}${this.selected?c.countTextSelected:""}`}>${this.getCount()}</span>`)}</div>`)}};_("instant-apps-interactive-legend-count",g);return g},"intl",a,c,e,f)