import{r as t}from"./p-23450e8b.js";class e{constructor(t,e={}){this.feature=t;if(e.keyPrefix==undefined)e.keyPrefix="webmapgl.like";if(e.clientId==undefined){e.clientId=localStorage.getItem(e.keyPrefix+".clientId");if(e.clientId==null){e.clientId=this.makeId(64);localStorage.setItem(e.keyPrefix+".clientId",e.clientId)}}this.options=e}getLayerId(){var t;return"layer"in this.feature&&Boolean((t=this.feature.layer)===null||t===void 0?void 0:t.id)?this.feature.layer.id:undefined}getClientId(){return this.options.clientId}isLiked(){let t=this.getArray(this.getLayerId());return t.indexOf(Number(this.feature.id))!==-1}like(){let t=this.getArray(this.getLayerId());if(t.indexOf(Number(this.feature.id))===-1)t.push(Number(this.feature.id));this.setArray(this.getLayerId(),t)}unlike(){let t=this.getArray(this.getLayerId());let e=t.indexOf(Number(this.feature.id));if(e!==-1)t.splice(e,1);this.setArray(this.getLayerId(),t)}makeId(t){var e="";var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+"0123456789";for(let r=0;r<t;r++)e+=i.charAt(Math.floor(Math.random()*i.length));return e}getLayerKey(t){return this.options.keyPrefix+"|"+document.location.pathname+"|"+(t||"default")}getArray(t){let e=localStorage.getItem(this.getLayerKey(t));if(e==null)return[];return e.split(",").map((t=>parseInt(t))).filter((t=>!isNaN(t)))}setArray(t,e){let i=e.filter((t=>!isNaN(t))).map((t=>t.toString())).join(",");localStorage.setItem(this.getLayerKey(t),i)}}const i=class{constructor(e){t(this,e)}async create(t,i={}){return new e(t,i)}};export{i as gl_like_controller};
//# sourceMappingURL=p-3742094d.entry.js.map