import{g as o,o as s,C as P,x as q,a as i,n as g,c as r,F as k,y as m,f as L,t as b,j as h,K as z}from"./index-1784378651390.js";import{_ as R}from"./index-8193533d-1784378651390.js";import{b as j}from"./townshipBoundaries-a3a8b9c1-1784378651390.js";const D={key:0,class:"layer-panel-list"},E=["onClick"],I=["onClick"],$={key:0,class:"layer-panel-empty"},G={key:1,class:"layer-panel-legend"},J=["disabled","title","onClick"],Q={class:"legend-name"},U={key:0,class:"legend-check"},W={key:1,class:"layer-panel-empty is-legend"},ee={__name:"LayerPanel",props:{topicKey:{type:String,required:!0},modelValue:{type:[String,Array],default:""},legends:{type:Array,default:()=>[]},selectedLegendKey:{type:String,default:""},height:{type:Number,default:0},width:{type:Number,default:248},layers:{type:Array,default:null},overlayLayers:{type:Array,default:()=>[]},overlayKeys:{type:Array,default:()=>[]},legendOnly:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},showLegend:{type:Boolean,default:!0}},emits:["update:modelValue","update:selectedLegendKey","update:overlayKeys"],setup(d,{emit:K}){const t=d,p=K,v=o(()=>Array.isArray(t.layers)?t.layers:j(t.topicKey)),f=o(()=>Array.isArray(t.overlayLayers)?t.overlayLayers:[]),y=o(()=>Array.isArray(t.legends)?t.legends:[]),w=o(()=>Array.isArray(t.modelValue)?t.modelValue.map(String).filter(Boolean):t.modelValue?[String(t.modelValue)]:[]),A=o(()=>Array.isArray(t.overlayKeys)?t.overlayKeys.map(String).filter(Boolean):[]),V=o(()=>y.value.filter(B).length>1),x=o(()=>y.value.length===1),_=o(()=>t.legendOnly?"图例":t.compact?"图层":"图层控制"),M=o(()=>{const l=t.legendOnly?0:v.value.length+f.value.length,e=t.showLegend?Math.ceil(y.value.length/2):0,a=l?l*34+Math.max(0,l-1)*5:30,u=t.showLegend?y.value.length?30+Math.max(28,e*28):28:0,H=t.showLegend?172:108;return Math.max(H,Math.min(430,72+a+u))}),O=o(()=>t.compact?t.height||M.value:t.height?t.height:430);function T(n,l){var e,a;if((a=(e=n.currentTarget)==null?void 0:e.blur)==null||a.call(e),t.multiple){const u=new Set(w.value);u.has(l)?u.delete(l):u.add(l),p("update:modelValue",Array.from(u));return}p("update:modelValue",t.modelValue===l?"":l)}function C(n){return w.value.includes(String(n))}function N(n,l){var a,u;(u=(a=n.currentTarget)==null?void 0:a.blur)==null||u.call(a);const e=new Set(A.value);e.has(l)?e.delete(l):e.add(l),p("update:overlayKeys",Array.from(e))}function S(n){return A.value.includes(String(n))}function F(n,l){var e,a;(a=(e=n.currentTarget)==null?void 0:e.blur)==null||a.call(e),c(l)&&p("update:selectedLegendKey",t.selectedLegendKey===l.key?"":l.key)}function B(n){return(n==null?void 0:n.selectable)===!1?!1:!!(n!=null&&n.key&&(n.cqlFilter||n.rankingValueKey))}function c(n){return V.value&&B(n)}return(n,l)=>(s(),P(R,{title:_.value,width:d.width,height:O.value},{default:q(()=>[i("div",{class:g(["layer-panel",{"is-legend-only":d.legendOnly,"is-compact":d.compact,"is-without-legend":!d.showLegend}])},[d.legendOnly?h("",!0):(s(),r("div",D,[(s(!0),r(k,null,m(v.value,e=>(s(),r("button",{key:e.key,class:g(["layer-panel-item",{"is-active":C(e.key),"is-checked":C(e.key)}]),type:"button",onMousedown:l[0]||(l[0]=L(()=>{},["prevent"])),onClick:a=>T(a,e.key)},[i("span",null,b(e.name),1),l[3]||(l[3]=i("i",null,null,-1))],42,E))),128)),(s(!0),r(k,null,m(f.value,e=>(s(),r("button",{key:e.key,class:g(["layer-panel-item is-overlay",{"is-active":S(e.key),"is-checked":S(e.key)}]),type:"button",onMousedown:l[1]||(l[1]=L(()=>{},["prevent"])),onClick:a=>N(a,e.key)},[i("span",null,b(e.name),1),l[4]||(l[4]=i("i",null,null,-1))],42,I))),128)),!v.value.length&&!f.value.length?(s(),r("div",$,"暂无图层配置")):h("",!0)])),d.showLegend?(s(),r("div",G,[l[5]||(l[5]=i("div",{class:"layer-panel-section-title"},"图例",-1)),y.value.length?(s(),r("div",{key:0,class:g(["layer-panel-legend-grid",{"is-single":x.value}])},[(s(!0),r(k,null,m(y.value,e=>(s(),r("button",{key:e.key||e.name,class:g(["layer-panel-legend-row",{"is-selected":c(e)&&e.key===d.selectedLegendKey,"is-checkable":c(e),"is-disabled":!c(e)}]),type:"button",disabled:!c(e),title:e.name,onMousedown:l[2]||(l[2]=L(()=>{},["prevent"])),onClick:a=>F(a,e)},[i("span",{class:"legend-swatch",style:z({backgroundColor:e.fillColor,borderColor:e.strokeColor||e.fillColor})},null,4),i("span",Q,b(e.name),1),c(e)?(s(),r("i",U)):h("",!0)],42,J))),128))],2)):(s(),r("div",W,"暂无图例"))])):h("",!0)],2)]),_:1},8,["title","width","height"]))}};export{ee as _};
