// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("require ../chunks/tslib.es6 ../core/reactiveUtils ../core/accessorSupport/decorators/property ../core/has ../core/Logger ../core/RandomLCG ../core/accessorSupport/decorators/subclass ../layers/support/layerUtils ./Widget ./FeatureForm/featureFormUtils ./FeatureTemplates/FeatureTemplatesViewModel ./FeatureTemplates/ItemList ./FeatureTemplates/TemplateItem ./FeatureTemplates/VisibleElements ../chunks/componentsUtils ./support/globalCss ./support/widgetUtils ./support/decorators/messageBundle ./support/decorators/vmEvent ./support/jsxFactory".split(" "), function(l,d,r,e,b,J,K,y,z,A,t,u,B,C,v,D,E,L,w,F,m){function G(a){return a.id}b=class extends A{constructor(a,c){super(a,c);this.enableListScroll=!0;this.filterText="";this.headingLevel=4;this.messagesCommon=this.messages=null;this.selectionMode="none";this.viewModel=new u;this.visibleElements=new v;this.renderCustomItem=f=>null;this.renderCustomGroupContent=f=>null;this.renderItemLabel=()=>null;this.renderItemDescription=()=>null;this.renderItemContent=f=>null;this.renderItemContentEnd=f=>null;this._iconIntersectionObserver= new IntersectionObserver((f,p)=>{f.forEach(async g=>{if(g.isIntersecting){const h=g.target;if(h?.["data-has-icon"])p.unobserve(h);else{var {layer:n,template:q}=h?.["data-item"];h&&(h["data-has-icon"]=!0);g=await C.fetchThumbnail(n,q).catch(()=>{h&&(h["data-has-icon"]=!1);return null});null!=g&&h.appendChild(g)}}})});this._renderItemIcon=f=>z.isTable(f.layer)?m.tsx("span",{"data-has-icon":!0,"data-item":f,key:"icon"},m.tsx("calcite-icon",{icon:"table"})):m.tsx("span",{afterCreate:this._afterItemCreateOrUpdate, afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":f,key:"icon"});this._afterItemCreateOrUpdate=f=>{this._iconIntersectionObserver?.observe(f)};this._afterItemRemoved=f=>{this._iconIntersectionObserver?.unobserve(f)}}initialize(){const a=({label:c})=>!this.filterText||!!c?.toLowerCase().includes(this.filterText.toLowerCase());this.addHandles(r.watch(()=>this.viewModel,(c,f)=>{c&&!c.filterFunction&&(this.filterFunction=a);f&&f!==c&&f.filterFunction=== a&&(f.filterFunction=null)},r.initial))}destroy(){this._iconIntersectionObserver?.disconnect();this._iconIntersectionObserver=null}loadDependencies(){return D.loadCalciteComponents({icon:()=>new Promise((a,c)=>l(["../chunks/calcite-icon"],a,c)),loader:()=>new Promise((a,c)=>l(["../chunks/calcite-loader"],a,c)),input:()=>new Promise((a,c)=>l(["../chunks/calcite-input"],a,c)),list:()=>new Promise((a,c)=>l(["../chunks/calcite-list"],a,c)),"list-item":()=>new Promise((a,c)=>l(["../chunks/calcite-list-item"], a,c)),notice:()=>new Promise((a,c)=>l(["../chunks/calcite-notice"],a,c))})}get disabled(){return this.viewModel.disabled}set disabled(a){this.viewModel.disabled=a}get filterFunction(){return this.viewModel.filterFunction}set filterFunction(a){this.viewModel.filterFunction=a}get groupBy(){return this.viewModel.groupBy}set groupBy(a){this.viewModel.groupBy=a}get icon(){return"list-rectangle"}set icon(a){this._overrideIfSome("icon",a)}get label(){return this.messages?.widgetLabel??""}set label(a){this._overrideIfSome("label", a)}get layers(){return this.viewModel.layers}set layers(a){this.viewModel.layers=a}get selectedItem(){return this.viewModel.selectedItem}select(a,c){return this.viewModel.select(a,c)}render(){const {disabled:a,enableListScroll:c,filterText:f,headingLevel:p,messages:g,viewModel:{items:n,numberOfFeatureTemplates:q,selectedItem:h,state:x}}=this,H=this.visibleElements.filter&&1I.label===u.nullGroupBy.label);k&&(k.label=g.other)}return m.tsx("div", {"aria-label":g.widgetLabel,class:this.classes("esri-feature-templates",E.globalCss.widget)},"loading"===x?m.tsx("calcite-loader",{key:"loader",label:this.messagesCommon.loading,type:"indeterminate"}):"ready"===x?m.tsx(B.ItemList,{disabled:a,enableListScroll:c,filterEnabled:H,filterText:f,headingLevel:p,id:this.id,identify:G,items:n,messages:{filterPlaceholder:g.filterPlaceholder,noItems:g.noItems,noMatches:g.noMatches},renderCustomGroupContent:this.renderCustomGroupContent,renderCustomItem:this.renderCustomItem, renderIcon:this._renderItemIcon,renderItemContent:this.renderItemContent,renderItemContentEnd:this.renderItemContentEnd,renderItemDescription:this.renderItemDescription,renderItemLabel:this.renderItemLabel,selectedItem:h??void 0,selectionMode:this.selectionMode??void 0,onFilterChange:k=>{this.filterText=k;this.viewModel.refresh()},onItemSelect:k=>!t.isTemplateItemGroup(k)&&this.viewModel.select(k)}):null)}};d.__decorate([e.property()],b.prototype,"disabled",null);d.__decorate([e.property()],b.prototype, "enableListScroll",void 0);d.__decorate([e.property()],b.prototype,"filterFunction",null);d.__decorate([e.property()],b.prototype,"filterText",void 0);d.__decorate([e.property()],b.prototype,"groupBy",null);d.__decorate([e.property()],b.prototype,"headingLevel",void 0);d.__decorate([e.property()],b.prototype,"icon",null);d.__decorate([e.property()],b.prototype,"label",null);d.__decorate([e.property()],b.prototype,"layers",null);d.__decorate([e.property(),w.messageBundle("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")], b.prototype,"messages",void 0);d.__decorate([e.property(),w.messageBundle("esri/t9n/common")],b.prototype,"messagesCommon",void 0);d.__decorate([e.property({readOnly:!0})],b.prototype,"selectedItem",null);d.__decorate([e.property()],b.prototype,"selectionMode",void 0);d.__decorate([e.property(),F.vmEvent("select")],b.prototype,"viewModel",void 0);d.__decorate([e.property({type:v,nonNullable:!0})],b.prototype,"visibleElements",void 0);d.__decorate([e.property()],b.prototype,"renderCustomItem",void 0); d.__decorate([e.property()],b.prototype,"renderCustomGroupContent",void 0);d.__decorate([e.property()],b.prototype,"renderItemLabel",void 0);d.__decorate([e.property()],b.prototype,"renderItemDescription",void 0);d.__decorate([e.property()],b.prototype,"renderItemContent",void 0);d.__decorate([e.property()],b.prototype,"renderItemContentEnd",void 0);return b=d.__decorate([y.subclass("esri.widgets.FeatureTemplates")],b)});