import{r as t,h as i,H as e}from"./p-23450e8b.js";import{_ as s}from"./p-9554b2b5.js";import{g as n}from"./p-d8674de4.js";import"./p-7183ba4d.js";const h=class{constructor(i){t(this,i);this.data=undefined;this.limit=undefined;this.batchSize=20;this.component=undefined;this.componentOptions=undefined;this.display="visible";this.features=[];this.item=true;this.loadingSpinner="bubbles";this.loadingText=s("webmapgl.feature-list.loading");this.mapId=undefined;this.orderBy=undefined;this.order="asc";this.styleId=undefined;this.sourceId=undefined}async componentWillLoad(){await this.handleSourceId()}componentDidLoad(){const t=n(this.mapId).map;if(t!=undefined)t.on("moveend",(async()=>await this.filter()))}handleInfiniteScroll(t){this.limit+=this.batchSize;t.target.complete()}handleStyleUpdated(t){if(t.detail.id===this.styleId)this.handleSourceId()}async handleSourceId(){const t=document.querySelector(`#${this.styleId}`);if(t==undefined||t.json.sources==undefined)return;const i=t.json.sources[this.sourceId].data;if(typeof i==="string"){let t=await fetch(i);this.data=await t.json()}else{this.data=i}this.filter()}async filter(){var t;if(((t=this.data)===null||t===void 0?void 0:t.features)==undefined||this.data.features.length===0)return;let i;if(this.display==="all"){i=this.data.features}else{let t=n(this.mapId).map.getBounds();i=this.data.features.filter((i=>{let[e,s]=i.geometry.coordinates;return e>=t.getWest()&&e<=t.getEast()&&s>=t.getSouth()&&s<=t.getNorth()}))}this.limit=this.batchSize;this.features=this.sort(i)}sort(t){if(this.order==="none"||this.orderBy==undefined)return t;t.sort(((t,i)=>{const e=t.properties[this.orderBy];const s=i.properties[this.orderBy];if(e<s)return this.order==="asc"?-1:1;if(e>s)return this.order==="asc"?1:-1;return 0}));return t}render(){let t=this.component;let s=this.limit!==0?this.features.slice(0,this.limit):this.features;let n=s.length<this.features.length;let h=s.map((e=>{let s=i(t,Object.assign({feature:e},this.componentOptions));return this.item?i("ion-item",null,s):s}));return i(e,null,i("ion-list",null,i("slot",{name:"start"}),h,i("slot",{name:"end"})),i("ion-infinite-scroll",{disabled:!n},i("ion-infinite-scroll-content",{"loading-spinner":this.loadingSpinner,"loading-text":this.loadingText})))}static get watchers(){return{styleId:["handleSourceId"],sourceId:["handleSourceId"]}}};export{h as gl_feature_list};
//# sourceMappingURL=p-9a52a393.entry.js.map