@bitalltech-maplibre/core 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +19 -7
- package/dist/index.umd.js +1 -1
- package/dist/types/effects/low-altitude.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,6 +156,9 @@ map.on("load", () => {
|
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
`radarPower.sourceId` 是共享 GeoJSON source,`radarPower.layerIds` 是按绘制顺序排列的固定图层 id。插件只保证威力图组内部顺序;雷达组与目标、轨迹、测距等其他业务组之间的顺序,建议由业务侧统一图层管理器安排。
|
|
159
|
+
|
|
160
|
+
渐变扇形扫描在不显示轮廓线时,动画只更新 Canvas 并主动请求地图重绘,不会逐帧更新 GeoJSON source;`frameRate` 可用于限制动画刷新频率。若需要轮廓线跟随扇面旋转,插件会保留低频 GeoJSON 更新以保持轮廓线位置正确。
|
|
161
|
+
|
|
159
162
|
扇形扫描支持从圆心到外缘的径向渐变:
|
|
160
163
|
|
|
161
164
|
```ts
|
|
@@ -166,6 +169,7 @@ addSectorScan(map, {
|
|
|
166
169
|
startAngle: 215,
|
|
167
170
|
endAngle: 282,
|
|
168
171
|
outlineColor: "#22c55e",
|
|
172
|
+
frameRate: 30,
|
|
169
173
|
gradient: {
|
|
170
174
|
colors: ["#f97316", "#facc15", "#22c55e"],
|
|
171
175
|
steps: 64,
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("maplibre-gl"),e={},o=()=>({...e}),i="https://tiles.openfreemap.org/styles",n=(t,e,o)=>({type:t,label:e,style:`${i}/${o}`}),r={"openfreemap-liberty":n("openfreemap-liberty","OpenFreeMap Liberty","liberty"),"openfreemap-bright":n("openfreemap-bright","OpenFreeMap Bright","bright"),"openfreemap-positron":n("openfreemap-positron","OpenFreeMap Positron","positron"),"openfreemap-dark":n("openfreemap-dark","OpenFreeMap Dark","dark"),"openfreemap-fiord":n("openfreemap-fiord","OpenFreeMap Fiord","fiord")},a=Object.keys(r),l=(t="openfreemap-liberty")=>r[t].style,c=["0","1","2","3","4","5","6","7"],s="© 天地图",d=(t,e)=>{const i=(t=>{const e=t||o().tdtToken;if(!e)throw new Error("Tianditu token is required. Pass token or call setMaplibreToolsConfig({ tdtToken }).");return e})(e);return c.map(e=>`https://t${e}.tianditu.gov.cn/DataServer?T=${t}&x={x}&y={y}&l={z}&tk=${i}`)},f=(t,e={})=>({type:"raster",tiles:d(t,e.token),tileSize:256,minzoom:0,maxzoom:18,attribution:s}),h=(t={})=>({type:"raster",tiles:d("vec_w",t.token),tileSize:256,minzoom:0,maxzoom:18,attribution:s}),p=(t={})=>{const e=!1!==t.label,o={"tdt-image":f("img_w",t)},i=[{id:"tdt-image",type:"raster",source:"tdt-image"}];return e&&(o["tdt-image-label"]=f("cia_w",t),i.push({id:"tdt-image-label",type:"raster",source:"tdt-image-label"})),{version:8,sources:o,layers:i}},u=(t={})=>{const e=!1!==t.label,o={"tdt-mvt":h(t)},i=[{id:"tdt-mvt",type:"raster",source:"tdt-mvt"}];return e&&(o["tdt-mvt-label"]=f("cva_w",t),i.push({id:"tdt-mvt-label",type:"raster",source:"tdt-mvt-label"})),{version:8,sources:o,layers:i}},g=[...Object.keys(r),"tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],y=t=>g.includes(t),m=(t="openfreemap-liberty",e={})=>"tdt-image"===t?p({...e,label:!1}):"tdt-image-label"===t?p({...e,label:!0}):"tdt-mvt"===t?u({...e,label:!1}):"tdt-mvt-label"===t?u({...e,label:!0}):l(t),_=6378137,w=t=>t*Math.PI/180,v=t=>180*t/Math.PI,b=t=>(t%360+360)%360,M=(t,e,o)=>{const i=e/_,n=w(o),r=w(t[1]),a=w(t[0]),l=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(n)),c=a+Math.atan2(Math.sin(n)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(l));return[(s=v(c),s>180?s-360:s<-180?s+360:s),v(l)];var s},$=(t,e)=>{const o=w(e[1]-t[1]),i=w(e[0]-t[0]),n=w(t[1]),r=w(e[1]),a=Math.sin(o/2)*Math.sin(o/2)+Math.cos(n)*Math.cos(r)*Math.sin(i/2)*Math.sin(i/2);return 12756274*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))},x=(t,e)=>{const o=w(t[1]),i=w(e[1]),n=w(e[0]-t[0]),r=Math.sin(n)*Math.cos(i),a=Math.cos(o)*Math.sin(i)-Math.sin(o)*Math.cos(i)*Math.cos(n);return b(v(Math.atan2(r,a)))},k=(t,e,o=64)=>{const i=((t,e)=>{const o=b(e)-b(t);return o<=0?o+360:o})(t,e),n=Math.max(12,Math.ceil(o*i/360));return Array.from({length:n+1},(e,o)=>b(t+i*o/n))},A=(t,e,o=64)=>(t=>{if(0===t.length)return t;const[e,o]=t[0],i=t[t.length-1];return i[0]===e&&i[1]===o?t:[...t,[e,o]]})(Array.from({length:o},(i,n)=>M(t,e,360*n/o))),F=(t,e,o=64)=>({type:"Polygon",coordinates:[A(t,e,o)]}),C=(t,e,o=64)=>({type:"LineString",coordinates:A(t,e,o)}),P=(t,e,o,i,n=64)=>{const r=k(o,i,n).map(o=>M(t,e,o));return{type:"Polygon",coordinates:[[t,...r,t]]}},S=(t,e,o,i,n=64)=>({type:"LineString",coordinates:k(o,i,n).map(o=>M(t,e,o))}),O=(t,e,o)=>({type:"LineString",coordinates:[t,M(t,e,o)]}),L={type:"FeatureCollection",features:[]},I=(t,e)=>({type:"Feature",geometry:t,properties:e}),W=(t,e)=>Math.max(0,Math.min(1,t??e)),N=t=>{var e;if(!1===t.visible)return[];const o=t.color??"#38ff4a",i=t.ringColor??o,n=Math.max(0,Math.floor(t.ringCount??4)),r=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),a=[];t.fillOpacity&&t.fillOpacity>0&&a.push(I(F(t.center,t.radius),{radarId:t.id,kind:"fill",color:t.fillColor??o,opacity:W(t.fillOpacity,0)}));for(let l=n;l>=1;l-=1){const o=t.radius*l/n;if(a.push(I(C(t.center,o),{radarId:t.id,kind:"ring",color:i,opacity:W(t.ringOpacity,.95),width:Math.max(0,t.ringWidth??2)})),!1!==t.showDistanceLabels){const n=(null==(e=t.distanceLabelFormatter)?void 0:e.call(t,o,l))??`${Math.round(o)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(e=>{a.push(I({type:"Point",coordinates:M(t.center,o,e.bearing)},{radarId:t.id,kind:"distance-label",text:n,textAnchor:e.textAnchor,color:t.distanceLabelColor??i,opacity:W(t.distanceLabelOpacity,.92),haloColor:t.distanceLabelHaloColor??"rgba(15, 23, 42, 0.42)",size:t.distanceLabelSize??12}))})}}return!1!==t.showCrosshair&&a.push(I({type:"LineString",coordinates:[M(t.center,t.radius,180),M(t.center,t.radius,0)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:W(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)}),I({type:"LineString",coordinates:[M(t.center,t.radius,270),M(t.center,t.radius,90)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:W(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)})),a.push(I(F(t.center,r),{radarId:t.id,kind:"core",color:t.coreColor??o,opacity:W(t.fillOpacity,0)})),a},R=t=>({type:"FeatureCollection",features:t.flatMap(N)}),q=(t,e)=>({type:"Feature",geometry:t,properties:e}),G=t=>({type:"FeatureCollection",features:t}),E=(t,e)=>{t.getLayer(e)&&t.removeLayer(e)},D=(t,e)=>{t.getSource(e)&&t.removeSource(e)},j=(t,e,o)=>{const i=o?"visible":"none";e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",i)})},V=t=>t instanceof Error&&"Style is not done loading."===t.message,T=(t,e,o)=>{const i=e.id,n=`${i}-source`;let r,a={...e},l=[],c=[n],s=!1,d=!1;const f=()=>{null==r||r(),r=void 0,[...l].reverse().forEach(e=>{E(t,e)}),[...c].reverse().forEach(e=>{D(t,e)}),l=[],c=[n]},h=e=>{const o=t.getSource(n);o&&o.setData(e)},p=()=>{try{(()=>{var e,i,d;if(s)return;f();const p=o(a);t.addSource(n,{type:"geojson",data:p.data}),null==(e=p.canvasSources)||e.forEach(e=>{t.addSource(e.id,e.source)}),c=[n,...(null==(i=p.canvasSources)?void 0:i.map(t=>t.id))||[]],l=p.layers.map(t=>t.id),p.layers.forEach(e=>{var o;const i="raster"===e.type&&(null==(o=p.canvasSources)?void 0:o[0])?p.canvasSources[0].id:n;t.addLayer({...e,source:i},a.beforeId)}),j(t,l,!1!==a.visible),null==(d=p.canvasSources)||d.forEach(e=>{var o;const i=t.style,n=null==(o=null==i?void 0:i.tileManagers)?void 0:o[e.id];if(!n||!n.t)return;const r=n.used;n.used=!0;const a=t;n.update(a.transform,a.terrain),n.used=r}),p.startAnimation&&(r=p.startAnimation({getOptions:()=>a,setData:h})||void 0)})(),d&&(d=!1,t.off("styledata",u))}catch(e){if(!V(e))throw e;d||(d=!0,t.on("styledata",u))}},u=()=>{d&&!s&&p()},g=()=>{s||p()};return g(),{id:i,update(t){s||(a={...a,...t,id:i},g())},show(){s||(a={...a,visible:!0},j(t,l,!0))},hide(){s||(a={...a,visible:!1},j(t,l,!1))},remove(){s||(s=!0,d&&(d=!1,t.off("styledata",u)),f())}}},z=(t,e=0)=>{const o=Math.max(10,t.radius??70),i=Math.max(o,t.maxRadius??2.3*o),n=Math.max(1,t.pulseCount??2),r=Math.max(1,t.lineWidth??2),a=t.pulseOpacity??.9,l=[q(F(t.center,o),{kind:"core"})];for(let c=0;c<n;c+=1){const s=(e+c/n)%1,d=o+(i-o)*s;l.push(q(C(t.center,d),{kind:"pulse",opacity:a*(1-s),width:r*(1-.35*s)}))}return G(l)},Y=t=>{const e=t.color||"#ff3b30",o=t.fillColor||e;return{data:z(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":t.fillOpacity??.28}},{id:`${t.id}-pulse`,type:"line",filter:["==",["get","kind"],"pulse"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.pulseOpacity??.9],"line-width":["coalesce",["get","width"],t.lineWidth??2]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800);let i=0;const n=performance.now(),r=a=>{const l=t();e(z(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},U=(t,e=0)=>{const o=Math.max(16,t.radius??110),i=Math.max(0,t.pulseScale??.16),n=(1-Math.cos(e*Math.PI*2))/2,r=o*(1+i*n),a=Math.max(1,t.ringCount??3),l=Math.max(2.2*r,t.maxRadius??o*(2.5*a)),c=l/a,s=t.fillOpacity??.28,d=[q(F(t.center,r),{kind:"core",opacity:s*(.88+.2*n)}),q(C(t.center,1.06*r),{kind:"core-ring",opacity:(t.lineOpacity??.95)*(.8+.2*n),width:Math.max(1,(t.lineWidth??3)*(.92+.12*n))})];for(let f=0;f<a;f+=1){const o=(f+e+1)*c%l||l,i=o/l;d.push(q(C(t.center,o),{kind:"ring",opacity:Math.max(.18,(t.lineOpacity??.95)*(1-.42*i)),width:Math.max(1,(t.lineWidth??3)*(1-.18*i))}))}return G(d)},B=t=>{const e=t.color||"#ef4444",o=t.fillColor||e;return{data:U(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-rings`,type:"line",filter:["any",["==",["get","kind"],"ring"]],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.lineOpacity??.95],"line-width":["coalesce",["get","width"],t.lineWidth??3]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(600,t().duration??2e3);let i=0;const n=performance.now(),r=a=>{const l=t();e(U(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},H=(t,e=0)=>{const o=Math.max(1,t.radius??90),i=Math.max(1,t.minRadius??.78*o),n=Math.max(i,t.maxRadius??1.22*o),r=(1-Math.cos(e*Math.PI*2))/2,a=i+(n-i)*r,l=t.fillOpacity??.28,c=t.minFillOpacity??.46*l,s=t.strokeOpacity??.82,d=t.minStrokeOpacity??.38*s,f=1-r,h=[q(F(t.center,a),{kind:"breathing-fill",opacity:c+(l-c)*f})];return(t.strokeWidth??2)>0&&h.push(q(C(t.center,a),{kind:"breathing-stroke",opacity:d+(s-d)*f})),G(h)},J=t=>{const e=t.color||"#1677ff",o=t.fillColor||e,i=t.strokeColor||e,n=Math.max(0,t.strokeWidth??2);return{data:H(t),layers:[{id:`${t.id}-breathing-fill`,type:"fill",filter:["==",["get","kind"],"breathing-fill"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-breathing-stroke`,type:"line",filter:["==",["get","kind"],"breathing-stroke"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":i,"line-opacity":["coalesce",["get","opacity"],t.strokeOpacity??.82],"line-width":n}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800),i=performance.now();let n=0;const r=a=>{const l=t();e(H(l,(a-i)%o/o)),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>{cancelAnimationFrame(n)}}}},X=(t,e,o)=>Math.min(o,Math.max(e,t)),K=t=>{const e=t.trim(),o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const t=o[1],e=3===t.length?t.split("").map(t=>t+t).join(""):t;return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const i=e.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(i)return[X(Number(i[1]),0,255),X(Number(i[2]),0,255),X(Number(i[3]),0,255)]},Q=t=>(t%360+360)%360,Z=t=>(t-90)*Math.PI/180,tt=(t,e)=>{const o=K(t);return o?`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${X(e,0,1)})`:t},et=t=>t*(2-t),ot=(t,e)=>{const o=t.length-1;if(e<=0)return t[0];if(e>=o)return t[o];const i=Math.floor(e),n=e-i,[r,a]=[K(t[i]),K(t[i+1])];if(!r||!a)return t[Math.round(e)];const[l,c,s]=((t,e,o)=>[Math.round(t[0]+(e[0]-t[0])*o),Math.round(t[1]+(e[1]-t[1])*o),Math.round(t[2]+(e[2]-t[2])*o)])(r,a,n);return`rgb(${l},${c},${s})`},it=(t,e)=>{const o=M(t,e,0)[1],i=M(t,e,90)[0],n=M(t,e,180)[1],r=M(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},nt=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2?o:void 0},rt=(t,e,o=0)=>{const i=t.getContext("2d"),n=nt(e);if(!i||!e.gradient||!n)return;const r=t.width,a=r/2,l=a-2,c=e.startAngle+o,s=((t,e)=>{const o=Q(e)-Q(t);return o<=0?o+360:o})(c,e.endAngle+o),d=Z(c),f=d+s*Math.PI/180,h=e.gradient.opacity??e.opacity??.28,p=e.gradient.centerOpacity??.25*h,u=e.gradient.edgeOpacity??h,g=i.createRadialGradient(a,a,0,a,a,l);n.forEach((t,e)=>{const o=e/Math.max(1,n.length-1),i=p+(u-p)*o;g.addColorStop(o,tt(t,i))}),i.clearRect(0,0,r,r),i.save(),i.beginPath(),i.moveTo(a,a),i.arc(a,a,l,d,f,!1),i.closePath(),i.clip(),i.fillStyle=g,i.fillRect(0,0,r,r),i.restore()},at=t=>{if(!nt(t))return;const e=(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})();return rt(e,t),e},lt=(t,e,o)=>nt(t)?[]:[q(P(t.center,t.radius,e,o),{kind:"sector",color:t.color||"#ff453a",opacity:t.opacity??.28})],ct=(t,e=0)=>{const o=t.startAngle+e,i=t.endAngle+e,n=[...lt(t,o,i),q(O(t.center,t.radius,o),{kind:"frame"}),q(O(t.center,t.radius,i),{kind:"frame"})];return G(n)},st=t=>{const e=at(t),o=e?{id:`${t.id}-sector-fill`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-sector-fill`,type:"fill",filter:["==",["get","kind"],"sector"],paint:{"fill-color":["coalesce",["get","color"],t.color||"#ff453a"],"fill-opacity":["coalesce",["get","opacity"],t.opacity??.28],"fill-antialias":!1}};return{data:ct(t),canvasSources:e?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:it(t.center,t.radius),animate:Boolean(t.rotationSpeed&&0!==t.rotationSpeed)}}]:void 0,layers:[o,{id:`${t.id}-sector-frame`,type:"line",filter:["==",["get","kind"],"frame"],paint:{"line-color":t.outlineColor||t.color||"#ff453a","line-opacity":t.outlineOpacity??.95,"line-width":t.outlineWidth??2}}],startAnimation:t.rotationSpeed&&0!==t.rotationSpeed?({getOptions:t,setData:o})=>{const i=performance.now();let n=0;const r=a=>{const l=t(),c=(a-i)/1e3*(l.rotationSpeed||0);e&&rt(e,l,c),o(ct(l,c)),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>{cancelAnimationFrame(n)}}:void 0}},dt=(t,e)=>{const o=Math.max(40,t.radius),i=t.direction??270,n=Math.min(180,Math.max(8,t.spread??72)),r=Math.max(1,t.lineCount??7),a=Math.max(20,t.lineSpacing??Math.max(80,o/9)),l=e??0,c=Math.max(0,Math.min(.35*o,t.innerRadius??Math.min(.4*a,120))),s=i-n/2,d=i+n/2,f=[];for(let h=0;h<r;h+=1){const e=c+l+h*a;if(e>o)continue;const i=e/o,n=1-h/Math.max(1,r);f.push(q(S(t.center,e,s,d),{kind:"directional-pulse-line",opacity:Math.max(.08,(t.opacity??.92)*(.42+.58*n)*(1-.28*i)),width:Math.max(1,(t.lineWidth??2.8)*(.86+.24*n)*(1-.08*i))}))}return G(f)},ft=t=>({data:dt(t),layers:[{id:`${t.id}-directional-pulse`,type:"line",filter:["==",["get","kind"],"directional-pulse-line"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.color||"#ef4444","line-opacity":["coalesce",["get","opacity"],t.opacity??.92],"line-width":["coalesce",["get","width"],t.lineWidth??2.8]}}],startAnimation:t.speed&&t.speed>0?({getOptions:t,setData:e})=>{const o=performance.now();let i=0;const n=r=>{const a=t(),l=Math.max(40,a.radius),c=Math.max(20,a.lineSpacing??Math.max(80,l/9)),s=(r-o)/1e3*(a.speed??0)%c;e(dt(a,s)),i=requestAnimationFrame(n)};return i=requestAnimationFrame(n),()=>{cancelAnimationFrame(i)}}:void 0}),ht=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2},pt=(t,e)=>{const o=M(t,e,0)[1],i=M(t,e,90)[0],n=M(t,e,180)[1],r=M(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},ut=(t,e,o=0)=>{const i=t.getContext("2d"),n=e.gradient,r=null==n?void 0:n.colors;if(!i||!n||!r||r.length<2)return;const a=t.width,l=a/2,c=l-2,s=Math.max(12,e.sweepAngle??42),d=e.tailOpacity??.04,f=Math.max(.24,e.opacity??.3),h=(e.sweepStartAngle??0)+o,p=h,u=h+s,g=s;i.clearRect(0,0,a,a);const y=i.createConicGradient(Z(p),l,l),m=g/360,_=Math.min(1,f+.08);for(let w=0;w<=128;w++){const t=w/128,e=d+(_-d)*et(t),o=t*(r.length-1),i=ot(r,o);y.addColorStop(t*m,tt(i,Math.max(0,e)))}i.save(),i.beginPath(),i.moveTo(l,l),i.arc(l,l,c,Z(p),Z(u),!1),i.closePath(),i.fillStyle=y,i.fill(),i.restore()},gt=(t,e=0)=>{var o;const i=Math.max(0,t.ringCount??4),n=Math.max(12,t.sweepAngle??42),r=t.headOpacity??Math.max(.24,t.opacity??.3),a=(t.sweepStartAngle??0)+e,l=!1!==t.showCrosshair,c=!1!==t.showDistanceLabels,s=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),d=ht(t),f=[];for(let h=i;h>=1;h-=1){const e=t.radius*h/i;if(f.push(q(C(t.center,e),{kind:"ring"})),c){const i=(null==(o=t.distanceLabelFormatter)?void 0:o.call(t,e,h))??`${Math.round(e)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(o=>{f.push(q({type:"Point",coordinates:M(t.center,e,o.bearing)},{kind:"distance-label",text:i,textAnchor:o.textAnchor}))})}}return l&&f.push(q({type:"LineString",coordinates:[M(t.center,t.radius,180),M(t.center,t.radius,0)]},{kind:"crosshair"}),q({type:"LineString",coordinates:[M(t.center,t.radius,270),M(t.center,t.radius,90)]},{kind:"crosshair"})),f.push(q(F(t.center,s),{kind:"core"})),d||f.push(q(P(t.center,t.radius,a,a+n),{kind:"sweep",opacity:r})),G(f)},yt=t=>{const e=ht(t),o=e?(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})():void 0,i=0!==(t.rotationSpeed??36);o&&ut(o,t);const n=o?{id:`${t.id}-radar-trail`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-radar-trail`,type:"fill",filter:["==",["get","kind"],"sweep"],paint:{"fill-color":t.color||"#22c55e","fill-opacity":["coalesce",["get","opacity"],t.opacity??.32]}};return{data:gt(t),canvasSources:o?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:o,coordinates:pt(t.center,t.radius),animate:i}}]:void 0,layers:[n,{id:`${t.id}-radar-rings`,type:"line",filter:["==",["get","kind"],"ring"],paint:{"line-color":t.ringColor||t.color||"#22c55e","line-opacity":t.ringOpacity??.95,"line-width":t.ringWidth??2}},{id:`${t.id}-radar-crosshair`,type:"line",filter:["==",["get","kind"],"crosshair"],paint:{"line-color":t.crosshairColor||t.ringColor||t.color||"#22c55e","line-opacity":t.crosshairOpacity??.5,"line-width":t.crosshairWidth??1.4}},{id:`${t.id}-radar-distance-labels`,type:"symbol",filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":t.distanceLabelSize??12,"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":t.distanceLabelColor||t.ringColor||t.color||"#22c55e","text-opacity":t.distanceLabelOpacity??.92,"text-halo-color":t.distanceLabelHaloColor||"rgba(15, 23, 42, 0.42)","text-halo-width":1}}],startAnimation:i?({getOptions:t,setData:i})=>{const n=performance.now();let r=0;const a=l=>{const c=t(),s=(l-n)/1e3*(c.rotationSpeed??36);o&&ut(o,c,s),e||i(gt(c,s)),r=requestAnimationFrame(a)};return r=requestAnimationFrame(a),()=>{cancelAnimationFrame(r)}}:void 0}},mt=(t,e)=>{const o=M(t,e,0)[1],i=M(t,e,90)[0],n=M(t,e,180)[1],r=M(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},_t=t=>{const e=(()=>{const t=document.createElement("canvas");return t.width=512,t.height=512,t})();((t,e)=>{const o=t.getContext("2d");if(!o)return;const i=t.width,n=i/2,r=n-1,a=e.color||"#06c536",l=e.fillColor||a,c=e.borderColor||a,s=e.fillOpacity??.06,d=e.borderOpacity??.92;o.clearRect(0,0,i,i),o.save(),o.beginPath(),o.arc(n,n,r,0,2*Math.PI),o.clip();const f=o.createRadialGradient(n,n,0,n,n,r),h=Math.min(.8,s+.85*(d-s));f.addColorStop(0,tt(l,s)),f.addColorStop(.85,tt(l,s)),f.addColorStop(.92,tt(c,s+.3*(h-s))),f.addColorStop(.96,tt(c,s+.7*(h-s))),f.addColorStop(1,tt(c,h)),o.fillStyle=f,o.fillRect(0,0,i,i),o.restore()})(e,t);const o=t.borderColor||t.color||"#06c536";return{data:G([q(C(t.center,t.radius),{kind:"defence-border"})]),canvasSources:[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:mt(t.center,t.radius),animate:!0}}],layers:[{id:`${t.id}-defence-circle`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}},{id:`${t.id}-defence-border`,type:"line",filter:["==",["get","kind"],"defence-border"],paint:{"line-color":o,"line-opacity":t.borderOpacity??.92,"line-width":t.borderWidth??2}}]}},wt=(t,e=0)=>{const o=Math.max(1,t.sourceWidth??220),i=Math.max(1,t.targetWidth??45),n=(t=>{const e=t.target||M(t.center,t.distance||0,t.bearing||0),o=void 0!==t.target?x(t.center,t.target):b(t.bearing||0),i=M(t.center,t.startWidth/2,o-90),n=M(t.center,t.startWidth/2,o+90);return{polygon:{type:"Polygon",coordinates:[[i,M(e,t.endWidth/2,o-90),M(e,t.endWidth/2,o+90),n,i]]},centerLine:{type:"LineString",coordinates:[t.center,e]}}})({center:t.center,target:t.target,startWidth:o,endWidth:i}),r=[q(n.polygon,{kind:"countermeasure-channel"}),q(n.centerLine,{kind:"countermeasure-line"})],a=$(t.center,t.target),l=x(t.center,t.target),c=Math.max(0,Math.floor(t.particleCount??18)),s=Math.max(300,t.particleDuration??1200),d=e%s/s,f=Math.max(1,t.particleRadius??2.8);if(a>0)for(let h=0;h<c;h+=1){const e=(d+h/c)%1;r.push(q({type:"Point",coordinates:M(t.center,a*e,l)},{kind:"countermeasure-particle",opacity:.25+.75*e,radius:f*(.7+.3*e)}))}if(!1!==t.targetRipple){const o=Math.max(1,Math.floor(t.targetRippleCount??2)),i=Math.max(10,t.targetRippleRadius??120),n=Math.max(300,t.targetRippleDuration??900),a=e%n/n;for(let e=0;e<o;e+=1){const n=(a+e/o)%1,l="forcedLanding"===t.mode?1-n:n;r.push(q(C(t.target,Math.max(2,i*l)),{kind:"countermeasure-target-ripple",opacity:.9*Math.sin(Math.PI*n)}))}}return G(r)},vt=t=>{const e=t.color??"#a855f7",o=t.lineColor??"#f0abfc",i=Math.max(1,t.lineWidth??2.5);return{data:wt(t),layers:[{id:`${t.id}-countermeasure-channel`,type:"fill",filter:["==",["get","kind"],"countermeasure-channel"],paint:{"fill-color":t.channelColor??e,"fill-opacity":t.channelOpacity??.16}},{id:`${t.id}-countermeasure-glow`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":.28*(t.lineOpacity??.92),"line-width":4*i,"line-blur":1.4*i}},{id:`${t.id}-countermeasure-line`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":t.lineOpacity??.92,"line-width":i}},{id:`${t.id}-countermeasure-target-ripple`,type:"line",filter:["==",["get","kind"],"countermeasure-target-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.9],"line-width":Math.max(1,t.targetRippleWidth??2.5)}},{id:`${t.id}-countermeasure-particle`,type:"circle",filter:["==",["get","kind"],"countermeasure-particle"],paint:{"circle-color":t.particleColor??o,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.8],"circle-blur":.18,"circle-stroke-color":"#ffffff","circle-stroke-opacity":.45,"circle-stroke-width":.5}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(wt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},bt=(t,e=0)=>{const o=[],i=new Set,n=Math.max(0,Math.floor(t.particleCount??5)),r=Math.max(300,t.particleDuration??1600),a=e%r/r,l=Math.max(1,t.particleRadius??2.5);if(t.links.forEach((e,r)=>{const c=e.color??("detection"===(s=e.type)?"#38bdf8":"command"===s?"#22d3ee":"#f97316");var s;const d=$(e.from,e.to),f=x(e.from,e.to);if(o.push(q({type:"LineString",coordinates:[e.from,e.to]},{kind:"coordination-link",linkType:e.type,color:c})),!1!==t.showNodes&&[e.from,e.to].forEach(t=>{const e=`${t[0]},${t[1]}`;i.has(e)||(i.add(e),o.push(q({type:"Point",coordinates:t},{kind:"coordination-node",color:c})))}),!(d<=0))for(let i=0;i<n;i+=1){const s=(a+i/n+r/t.links.length)%1;o.push(q({type:"Point",coordinates:M(e.from,d*s,f)},{kind:"coordination-particle",color:c,opacity:.35+.65*s,radius:l}))}}),!1!==t.targetRipple){const i=Math.max(300,t.targetRippleDuration??1200),n=e%i/i,r=Math.max(10,t.targetRippleRadius??100)*n;o.push(q(C(t.center,Math.max(2,r)),{kind:"coordination-target-ripple",opacity:.9*(1-n)}))}return G(o)},Mt=t=>{const e=Math.max(1,t.lineWidth??2.2),o=t.lineOpacity??.9;return{data:bt(t),layers:[{id:`${t.id}-coordination-detection`,type:"line",filter:["==",["get","linkType"],"detection"],paint:{"line-color":["coalesce",["get","color"],"#38bdf8"],"line-opacity":o,"line-width":e,"line-dasharray":[2,2]}},{id:`${t.id}-coordination-command`,type:"line",filter:["==",["get","linkType"],"command"],paint:{"line-color":["coalesce",["get","color"],"#22d3ee"],"line-opacity":o,"line-width":e,"line-dasharray":[.5,1.8]}},{id:`${t.id}-coordination-countermeasure`,type:"line",filter:["==",["get","linkType"],"countermeasure"],paint:{"line-color":["coalesce",["get","color"],"#f97316"],"line-opacity":o,"line-width":e+.8}},{id:`${t.id}-coordination-target-ripple`,type:"line",filter:["==",["get","kind"],"coordination-target-ripple"],paint:{"line-color":"#ff3b30","line-opacity":["coalesce",["get","opacity"],.9],"line-width":2.5}},{id:`${t.id}-coordination-node`,type:"circle",filter:["==",["get","kind"],"coordination-node"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-radius":Math.max(2,t.nodeRadius??5),"circle-stroke-color":"#ffffff","circle-stroke-width":1.5}},{id:`${t.id}-coordination-particle`,type:"circle",filter:["==",["get","kind"],"coordination-particle"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.5],"circle-blur":.1}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(bt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},$t=(t,e=0)=>{const o=[q({type:"LineString",coordinates:[t.center,t.spoofedPosition]},{kind:"spoofing-offset"})],i=$(t.center,t.spoofedPosition),n=x(t.center,t.spoofedPosition),r=Math.max(0,Math.floor(t.particleCount??10)),a=Math.max(300,t.particleDuration??1800),l=e%a/a;if(!1!==t.showTruePosition&&o.push(q({type:"Point",coordinates:t.center},{kind:"spoofing-true-position"})),!1!==t.showSpoofedPosition&&o.push(q({type:"Point",coordinates:t.spoofedPosition},{kind:"spoofing-ghost"})),i>0)for(let c=0;c<r;c+=1){const e=(l+c/r)%1;o.push(q({type:"Point",coordinates:M(t.center,i*e,n)},{kind:"spoofing-particle",opacity:.25+.75*e}))}if(!1!==t.ripple){const i=Math.max(1,Math.floor(t.rippleCount??2)),n=Math.max(300,t.rippleDuration??1200),r=Math.max(10,t.rippleRadius??120),a=e%n/n;for(let e=0;e<i;e+=1){const n=(a+e/i)%1;o.push(q(C(t.spoofedPosition,Math.max(2,r*n)),{kind:"spoofing-ripple",opacity:.75*(1-n)}))}}return G(o)},xt=t=>{const e=t.color??"#8b5cf6";return{data:$t(t),layers:[{id:`${t.id}-spoofing-offset`,type:"line",filter:["==",["get","kind"],"spoofing-offset"],layout:{"line-cap":"round"},paint:{"line-color":t.lineColor??e,"line-opacity":t.lineOpacity??.82,"line-width":Math.max(1,t.lineWidth??2),"line-dasharray":[1.2,2]}},{id:`${t.id}-spoofing-ripple`,type:"line",filter:["==",["get","kind"],"spoofing-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.75],"line-width":2}},{id:`${t.id}-spoofing-true-position`,type:"circle",filter:["==",["get","kind"],"spoofing-true-position"],paint:{"circle-color":"#ffffff","circle-radius":5,"circle-stroke-color":e,"circle-stroke-width":2}},{id:`${t.id}-spoofing-ghost`,type:"circle",filter:["==",["get","kind"],"spoofing-ghost"],paint:{"circle-color":e,"circle-opacity":t.ghostOpacity??.42,"circle-radius":Math.max(2,t.ghostRadius??8),"circle-stroke-color":"#ffffff","circle-stroke-opacity":.8,"circle-stroke-width":1.5}},{id:`${t.id}-spoofing-particle`,type:"circle",filter:["==",["get","kind"],"spoofing-particle"],paint:{"circle-color":e,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":Math.max(1,t.particleRadius??2.5),"circle-blur":.12}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e($t(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},kt="__electronic_fence_id",At=t=>JSON.parse(JSON.stringify(t)),Ft=t=>{const e=t.map(t=>{const e=Number(t[0]),o=Number(t[1]);if(!Number.isFinite(e)||!Number.isFinite(o))throw new Error("电子围栏坐标必须是有限数字。");return[e,o]});if(e.length<3)throw new Error("电子围栏的每个环至少需要 3 个不同坐标。");var o,i;if(o=e[0],i=e[e.length-1],(o[0]!==i[0]||o[1]!==i[1])&&e.push([...e[0]]),e.length<4)throw new Error("电子围栏 Polygon 环无效。");return e},Ct=t=>{if("string"!=typeof t.id||!t.id.trim())throw new Error("电子围栏必须提供非空字符串 id。");if(!t.geometry||"Polygon"!==t.geometry.type)throw new Error(`电子围栏 ${t.id} 仅支持 Polygon geometry。`);const e=At(t.properties||{});return{type:"Feature",id:t.id,geometry:{type:"Polygon",coordinates:t.geometry.coordinates.map(Ft)},properties:e}};class Pt{constructor(){this.features=new Map,this.states=new Map,this.activeIds=new Set,this.hiddenIds=new Set}setData(t){const e=new Map;t.features.forEach(t=>{const o=Ct(t);if(e.has(o.id))throw new Error(`电子围栏 id 重复:${o.id}`);e.set(o.id,o)}),this.features=e,this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}add(t){const e=Ct(t);if(this.features.has(e.id))throw new Error(`电子围栏 id 已存在:${e.id}`);return this.features.set(e.id,e),e.id}update(t,e){const o=this.requireFeature(t);this.features.set(t,((t,e)=>{const o=t.properties||{},i=e.properties||{},n=i.style?{...o.style||{},...i.style}:o.style;return Ct({...At(t),geometry:e.geometry?At(e.geometry):At(t.geometry),properties:{...At(o),...At(i),...n?{style:n}:{}}})})(o,e))}remove(t){this.requireFeature(t),this.features.delete(t),this.states.delete(t),this.activeIds.delete(t),this.hiddenIds.delete(t)}clear(){this.features.clear(),this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}setActive(t,e){this.requireFeature(t),e?this.activeIds.add(t):this.activeIds.delete(t)}setState(t,e){if(this.requireFeature(t),"normal"!==e&&"warning"!==e&&"alarm"!==e&&"disabled"!==e)throw new Error(`电子围栏 ${t} 的渲染状态无效。`);"normal"===e?this.states.delete(t):this.states.set(t,e)}setVisible(t,e){this.requireFeature(t),e?this.hiddenIds.delete(t):this.hiddenIds.add(t)}isActive(t){return this.activeIds.has(t)}getState(t){return this.requireFeature(t),this.states.get(t)||"normal"}get(t){const e=this.features.get(t);return e?At(e):void 0}values(){return Array.from(this.features.values())}visibleValues(){return this.values().filter(t=>!this.hiddenIds.has(t.id))}requireFeature(t){const e=this.features.get(t);if(!e)throw new Error(`电子围栏不存在:${t}`);return e}}const St=(t,e,o,i=!1)=>{const n=void 0===t?e:Number(t);if(!Number.isFinite(n)||i&&n<=0)throw new Error(`${o} 必须是${i?"大于 0 的":"有限"}数字。`);return n},Ot=(t,e)=>{if(!t.trim())throw new Error("电子围栏插件 id 不能为空。");St(e.baseHeight,0,"defaults.baseHeight"),St(e.height,0,"defaults.height",!0),St(e.thickness,1,"defaults.thickness",!0)},Lt=t=>({baseHeight:St(t.baseHeight,0,"defaults.baseHeight"),height:St(t.height,0,"defaults.height",!0),thickness:St(t.thickness,1,"defaults.thickness",!0)}),It=(t,e)=>"normal"!==t?t:e?"active":"normal",Wt=t=>{var e,o;return{...{...t.defaults.normal,...(null==(e=t.overrides)?void 0:e.normal)||{}},..."normal"===t.state?{}:{...t.defaults[t.state],...(null==(o=t.overrides)?void 0:o[t.state])||{}}}},Nt=(t,e)=>{const o=e/2,i=[];return t.coordinates.forEach(t=>{const e=[];for(let o=0;o<t.length-1;o+=1){const i=[t[o][0],t[o][1]],n=[t[o+1][0],t[o+1][1]],r=$(i,n);r<.01||e.push({start:i,end:n,length:r,bearing:x(i,n)})}const n=e.reduce((t,e)=>t+e.length,0);let r=0;e.forEach(t=>{const e=M(t.start,o,t.bearing+180),a=M(t.end,o,t.bearing);i.push({startLeft:M(e,o,t.bearing-90),startRight:M(e,o,t.bearing+90),endLeft:M(a,o,t.bearing-90),endRight:M(a,o,t.bearing+90),startProgress:n?r/n:0,endProgress:n?(r+t.length)/n:1}),r+=t.length})}),i},Rt=t=>({type:"MultiPolygon",coordinates:t.map(t=>[[t.startLeft,t.endLeft,t.endRight,t.startRight,t.startLeft]])}),qt=(t,e,o)=>Math.min(o,Math.max(e,t)),Gt=t=>{const e=t.trim().toLowerCase();if(e.startsWith("#")){const t=e.slice(1),o=3===t.length||4===t.length?t.split("").map(t=>t+t).join(""):t;if(6===o.length||8===o.length){const t=Number.parseInt(o,16);if(Number.isFinite(t))return[(t>>(8===o.length?24:16)&255)/255,(t>>(8===o.length?16:8)&255)/255,(t>>(8===o.length?8:0)&255)/255,8===o.length?(255&t)/255:1]}}const o=e.match(/^rgba?\(([^)]+)\)$/);if(o){const t=o[1].split(",").map(t=>Number(t.trim()));if(t.length>=3&&t.every(t=>Number.isFinite(t)))return[qt(t[0]/255,0,1),qt(t[1]/255,0,1),qt(t[2]/255,0,1),qt(t[3]??1,0,1)]}throw new Error(`暂不支持的围栏颜色格式:${t}`)},Et=(t,e=1)=>{const[o,i,n,r]=Gt(t);return`rgba(${Math.round(255*o)}, ${Math.round(255*i)}, ${Math.round(255*n)}, ${qt(r*e,0,1)})`},Dt=qt,jt=t=>({type:"FeatureCollection",features:t.visibleValues().map(t=>({type:"Feature",id:`${t.id}:interaction`,geometry:At(t.geometry),properties:{[kt]:t.id}}))}),Vt=t=>{let e;const o=e=>{var o;if(!t.map.getLayer(t.layerId))return;const i=t.map.queryRenderedFeatures(e.point,{layers:[t.layerId]})[0],n=null==(o=null==i?void 0:i.properties)?void 0:o[kt];return"string"==typeof n?n:void 0},i=(e,o,i)=>{const n=t.store.get(o);n&&t.map.fire(`fence.${e}`,{instanceId:t.instanceId,renderer:t.renderer,id:o,feature:n,originalEvent:i})},n=t=>{const e=o(t);e&&i("click",e,t)},r=t=>{const n=o(t);n!==e&&(e&&i("mouseleave",e,t),e=n,e&&i("mouseenter",e,t))},a=t=>{e&&(i("mouseleave",e,t),e=void 0)};return t.map.on("click",n),t.map.on("mousemove",r),t.map.on("mouseout",a),()=>{t.map.off("click",n),t.map.off("mousemove",r),t.map.off("mouseout",a)}},Tt=t=>t instanceof Error&&"Style is not done loading."===t.message,zt=(t,e,o)=>{e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",o?"visible":"none")})},Yt=t=>{let e=!1;const o=()=>{if(e)throw new Error(`电子围栏插件 ${t.id} 已销毁。`)};return{id:t.id,renderer:t.renderer,setData(e){o(),t.store.setData(e),t.refresh()},add(e){o();const i=t.store.add(e);return t.refresh(),i},update(e,i){o(),t.store.update(e,i),t.refresh()},removeFeature(e){o(),t.store.remove(e),t.refresh()},clear(){o(),t.store.clear(),t.refresh()},setFeatureState(e,i){o(),t.store.setState(e,i),t.refresh()},setFeatureActive(e,i){o(),t.store.setActive(e,i),t.refresh()},setFeatureVisible(e,i){o(),t.store.setVisible(e,i),t.refresh()},show(){o(),t.setPluginVisible(!0)},hide(){o(),t.setPluginVisible(!1)},destroy(){e||(e=!0,t.destroy())}}},Ut="__electronic_fence_kind",Bt="__electronic_fence_color",Ht="__electronic_fence_outline_color",Jt="__electronic_fence_outline_width",Xt="__electronic_fence_base",Kt="__electronic_fence_top",Qt={normal:{color:"#d8b4fe",opacity:.28,outlineColor:"#f5e9ff",outlineWidth:1.5},active:{color:"#c084fc",opacity:.42,outlineColor:"#ffffff",outlineWidth:2.5},warning:{color:"#f59e0b",opacity:.38,outlineColor:"#fde68a",outlineWidth:2},alarm:{color:"#ef4444",opacity:.48,outlineColor:"#ffffff",outlineWidth:2.5},disabled:{color:"#94a3b8",opacity:.16,outlineColor:"#cbd5e1",outlineWidth:1}},Zt=(t,e)=>{const o=[],i=Lt(e.defaults);return t.visibleValues().forEach(n=>{const r=It(t.getState(n.id),t.isActive(n.id)),a=Wt({defaults:Qt,overrides:e.styles,state:r}),l=Nt(n.geometry,i.thickness),c={[kt]:n.id,[Bt]:Et(a.color,Dt(a.opacity,0,1)),[Ht]:Et(a.outlineColor),[Jt]:Math.max(0,a.outlineWidth),[Xt]:i.baseHeight,[Kt]:i.baseHeight+i.height};l.length&&o.push({type:"Feature",id:`${n.id}:wall`,geometry:Rt(l),properties:{...c,[Ut]:"wall"}}),o.push({type:"Feature",id:`${n.id}:boundary`,geometry:n.geometry,properties:{...c,[Ut]:"boundary"}})}),{type:"FeatureCollection",features:o}},te=[{thicknessScale:.08,opacity:1},{thicknessScale:.22,opacity:.56},{thicknessScale:.45,opacity:.28},{thicknessScale:.8,opacity:.12},{thicknessScale:1.3,opacity:.045}],ee={normal:{color:"#d8b4fe",opacity:.2,outlineColor:"#f5e9ff",outlineWidth:1.5,glowStrength:1,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.18},active:{color:"#e9d5ff",opacity:.28,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.25,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.2},warning:{color:"#f59e0b",opacity:.25,outlineColor:"#fde68a",outlineWidth:2,glowStrength:1.1,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.18},alarm:{color:"#ef4444",opacity:.3,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.35,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.2},disabled:{color:"#94a3b8",opacity:.12,outlineColor:"#cbd5e1",outlineWidth:1,glowStrength:0,flowColor:"#ffffff",flowCount:0,flowLineStyle:"dashed",flowWidth:0}},oe=(e,o)=>{const i=t.MercatorCoordinate.fromLngLat(e,o);return[i.x,i.y,i.z]},ie=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],ne=(t,e,o)=>{const i=ie(e,t),n=ie(o,t);return(t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]})([i[1]*n[2]-i[2]*n[1],i[2]*n[0]-i[0]*n[2],i[0]*n[1]-i[1]*n[0]])},re=(t,e,o,i,n)=>{const r=ne(e[0],e[1],e[2]);[0,1,2,0,2,3].forEach(a=>{((t,e,o,i,n,r)=>{t.push(...e,...o,i,n,...r.color,r.flowColor[0],r.flowColor[1],r.flowColor[2],r.glowStrength,r.flowWidth,r.flowCount,r.flowLineStyle)})(t,e[a],r,o[a],i[a],n)})},ae=(t,e,o,i,n)=>{const r=o+i,a=oe(e.startLeft,o),l=oe(e.startRight,o),c=oe(e.endLeft,o),s=oe(e.endRight,o),d=oe(e.startLeft,r),f=oe(e.startRight,r),h=oe(e.endLeft,r),p=oe(e.endRight,r);re(t,[d,h,p,f],[1,1,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),re(t,[a,c,h,d],[0,0,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),re(t,[s,l,f,p],[0,0,1,1],[e.endProgress,e.startProgress,e.startProgress,e.endProgress],n)},le=(t,e,o)=>{const i=te.map(()=>[]),n=[],r=Lt(e.defaults);let a=!1;t.visibleValues().forEach(l=>{const c=t.isActive(l.id),s=It(t.getState(l.id),c),d=Wt({defaults:ee,overrides:e.styles,state:s}),f=o.enabled&&("all"===o.scope||(t=>"active"===t||"warning"===t||"alarm"===t)(s)),h=((t,e)=>{const o=Gt(t.color),i=Gt(t.flowColor),n=e&&t.flowCount>0?Math.round(Dt(t.flowCount,1,8)):0;return{color:[o[0],o[1],o[2],Dt(o[3]*t.opacity,0,1)],flowColor:i,glowStrength:Dt(t.glowStrength,0,4),flowCount:n,flowLineStyle:"solid"===t.flowLineStyle?0:1,flowWidth:n>0?Dt(t.flowWidth,.01,.49):0}})(d,f);Nt(l.geometry,r.thickness).forEach(t=>{ae(n,t,r.baseHeight,r.height,h)}),h.glowStrength>0&&te.forEach((t,e)=>{const o=r.thickness*(1+Math.min(h.glowStrength,2)*t.thicknessScale);Nt(l.geometry,o).forEach(t=>{ae(i[e],t,r.baseHeight,r.height,h)})}),a||(a=h.flowCount>0&&h.flowWidth>0)});const l=i.reduce((t,e)=>t+e.length,0),c=new Float32Array(l+n.length),s=[];let d=0;i.forEach((t,e)=>{const o=t.length/19;o>0&&s.push({first:d/19,count:o,opacity:te[e].opacity}),c.set(t,d),d+=t.length});const f=d/19;return c.set(n,d),{vertices:c,glowPasses:s,bodyFirst:f,bodyVertexCount:n.length/19,animated:a}},ce=(t,e,o)=>{const i=t.createShader(e);if(!i)throw new Error("无法创建电子围栏 WebGL shader。");if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(i)||"未知 shader 编译错误";throw t.deleteShader(i),new Error(`电子围栏 WebGL shader 编译失败:${e}`)}return i},se=(t,e,o)=>{const i=t.getUniformLocation(e,o);if(!i)throw new Error(`电子围栏 WebGL uniform 不存在:${o}`);return i};class de{constructor(t,e){this.type="custom",this.renderingMode="3d",this.geometry={vertices:new Float32Array,glowPasses:[],bodyFirst:0,bodyVertexCount:0,animated:!1},this.visible=!0,this.id=t,this.animation=e}setGeometry(t){var e;this.geometry=t,this.uploadGeometry(),null==(e=this.map)||e.triggerRepaint()}setVisible(t){var e;this.visible=t,null==(e=this.map)||e.triggerRepaint()}onAdd(t,e){if(this.map=t,this.gl=e,this.program=(t=>{const e="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext,o=e?"#version 300 es\n precision highp float;\n in vec3 a_position;\n in vec3 a_normal;\n in float a_height_ratio;\n in float a_path_progress;\n in vec4 a_color;\n in vec3 a_flow_color;\n in float a_glow_strength;\n in float a_flow_width;\n in float a_flow_count;\n in float a_flow_line_style;\n uniform mat4 u_matrix;\n out vec3 v_normal;\n out float v_height_ratio;\n out float v_path_progress;\n out vec4 v_color;\n out vec3 v_flow_color;\n out float v_glow_strength;\n out float v_flow_width;\n out float v_flow_count;\n out float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ":"\n precision highp float;\n attribute vec3 a_position;\n attribute vec3 a_normal;\n attribute float a_height_ratio;\n attribute float a_path_progress;\n attribute vec4 a_color;\n attribute vec3 a_flow_color;\n attribute float a_glow_strength;\n attribute float a_flow_width;\n attribute float a_flow_count;\n attribute float a_flow_line_style;\n uniform mat4 u_matrix;\n varying vec3 v_normal;\n varying float v_height_ratio;\n varying float v_path_progress;\n varying vec4 v_color;\n varying vec3 v_flow_color;\n varying float v_glow_strength;\n varying float v_flow_width;\n varying float v_flow_count;\n varying float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ",i="\n precision highp float;\n uniform float u_time;\n uniform float u_speed;\n uniform float u_animation_enabled;\n uniform float u_glow_pass;\n uniform float u_glow_opacity;\n VARYING vec3 v_normal;\n VARYING float v_height_ratio;\n VARYING float v_path_progress;\n VARYING vec4 v_color;\n VARYING vec3 v_flow_color;\n VARYING float v_glow_strength;\n VARYING float v_flow_width;\n VARYING float v_flow_count;\n VARYING float v_flow_line_style;\n void main() {\n float bandCore = 0.0;\n float bandGlow = 0.0;\n float verticalFace = 1.0 - smoothstep(\n 0.82,\n 0.98,\n abs(normalize(v_normal).z)\n );\n\n if (\n u_animation_enabled > 0.5 &&\n v_flow_count > 0.5 &&\n v_flow_width > 0.0001\n ) {\n float count = max(v_flow_count, 1.0);\n float phase = fract(\n v_height_ratio * count + u_time * u_speed * count\n );\n float bandDistance = abs(phase - 0.5);\n float dashPhase = fract(\n v_path_progress * 36.0 - u_time * u_speed * 2.4\n );\n float dash = smoothstep(0.02, 0.1, dashPhase) *\n (1.0 - smoothstep(0.62, 0.74, dashPhase));\n float linePattern = v_flow_line_style > 0.5 ? dash : 1.0;\n\n bandCore = 1.0 - smoothstep(\n max(v_flow_width * 0.08, 0.001),\n max(v_flow_width * 0.42, 0.003),\n bandDistance\n );\n float glowDistance = bandDistance / max(v_flow_width, 0.001);\n bandGlow = exp(\n -glowDistance * glowDistance * 2.6\n );\n bandCore *= linePattern * verticalFace;\n bandGlow *= verticalFace;\n }\n\n if (u_glow_pass > 0.5) {\n float glowAlpha = clamp(\n (v_color.a * 0.003 + bandGlow * 0.085) *\n v_glow_strength * u_glow_opacity,\n 0.0,\n 0.14\n );\n OUTPUT_COLOR = vec4(v_color.rgb, glowAlpha);\n return;\n }\n\n float faceLight = 0.88 + 0.12 * abs(normalize(v_normal).z);\n vec3 bodyColor = v_color.rgb * faceLight;\n vec3 color = mix(bodyColor, v_flow_color, bandCore);\n float alpha = clamp(\n v_color.a + bandCore * 0.68,\n 0.0,\n 1.0\n );\n OUTPUT_COLOR = vec4(color, alpha);\n }\n ",n=(t,e,o)=>t.split(e).join(o),r=e?`#version 300 es\n ${n(n(i,"VARYING","in"),"OUTPUT_COLOR","fragmentColor").replace("precision highp float;","precision highp float;\n out vec4 fragmentColor;")}\n `:n(n(i,"VARYING","varying"),"OUTPUT_COLOR","gl_FragColor"),a=ce(t,t.VERTEX_SHADER,o),l=ce(t,t.FRAGMENT_SHADER,r),c=t.createProgram();if(!c)throw t.deleteShader(a),t.deleteShader(l),new Error("无法创建电子围栏 WebGL program。");if(t.attachShader(c,a),t.attachShader(c,l),t.linkProgram(c),t.deleteShader(a),t.deleteShader(l),!t.getProgramParameter(c,t.LINK_STATUS)){const e=t.getProgramInfoLog(c)||"未知 program 链接错误";throw t.deleteProgram(c),new Error(`电子围栏 WebGL program 链接失败:${e}`)}return c})(e),this.locations=((t,e)=>({position:t.getAttribLocation(e,"a_position"),normal:t.getAttribLocation(e,"a_normal"),heightRatio:t.getAttribLocation(e,"a_height_ratio"),pathProgress:t.getAttribLocation(e,"a_path_progress"),color:t.getAttribLocation(e,"a_color"),flowColor:t.getAttribLocation(e,"a_flow_color"),glowStrength:t.getAttribLocation(e,"a_glow_strength"),flowWidth:t.getAttribLocation(e,"a_flow_width"),flowCount:t.getAttribLocation(e,"a_flow_count"),flowLineStyle:t.getAttribLocation(e,"a_flow_line_style"),matrix:se(t,e,"u_matrix"),time:se(t,e,"u_time"),speed:se(t,e,"u_speed"),animationEnabled:se(t,e,"u_animation_enabled"),glowPass:se(t,e,"u_glow_pass"),glowOpacity:se(t,e,"u_glow_opacity")}))(e,this.program),this.buffer=e.createBuffer()||void 0,!this.buffer)throw new Error("无法创建电子围栏 WebGL 顶点缓冲。");this.uploadGeometry(e)}render(t,e){if(!(this.visible&&this.program&&this.buffer&&this.locations&&(this.geometry.glowPasses.length||this.geometry.bodyVertexCount)))return;const o=19*Float32Array.BYTES_PER_ELEMENT,i=(e,i,n)=>{t.enableVertexAttribArray(e),t.vertexAttribPointer(e,i,t.FLOAT,!1,o,n*Float32Array.BYTES_PER_ELEMENT)};t.useProgram(this.program),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),i(this.locations.position,3,0),i(this.locations.normal,3,3),i(this.locations.heightRatio,1,6),i(this.locations.pathProgress,1,7),i(this.locations.color,4,8),i(this.locations.flowColor,3,12),i(this.locations.glowStrength,1,15),i(this.locations.flowWidth,1,16),i(this.locations.flowCount,1,17),i(this.locations.flowLineStyle,1,18),t.uniformMatrix4fv(this.locations.matrix,!1,e.defaultProjectionData.mainMatrix),t.uniform1f(this.locations.time,performance.now()/1e3),t.uniform1f(this.locations.speed,this.animation.speed),t.uniform1f(this.locations.animationEnabled,this.animation.enabled?1:0),t.enable(t.BLEND),t.enable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.depthMask(!1),this.geometry.glowPasses.length&&(t.blendFunc(t.SRC_ALPHA,t.ONE),t.uniform1f(this.locations.glowPass,1),this.geometry.glowPasses.forEach(e=>{t.uniform1f(this.locations.glowOpacity,e.opacity),t.drawArrays(t.TRIANGLES,e.first,e.count)})),this.geometry.bodyVertexCount&&(t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.uniform1f(this.locations.glowPass,0),t.uniform1f(this.locations.glowOpacity,0),t.drawArrays(t.TRIANGLES,this.geometry.bodyFirst,this.geometry.bodyVertexCount)),t.depthMask(!0),t.bindBuffer(t.ARRAY_BUFFER,null)}onRemove(t,e){this.buffer&&e.deleteBuffer(this.buffer),this.program&&e.deleteProgram(this.program),this.map=void 0,this.gl=void 0,this.buffer=void 0,this.program=void 0,this.locations=void 0}uploadGeometry(t){const e=t||this.gl;e&&this.buffer&&(e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bufferData(e.ARRAY_BUFFER,this.geometry.vertices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null))}}const fe=(t,e)=>t?"string"==typeof t&&y(t)?m(t,{token:e}):t:m("openfreemap-liberty");exports.maplibregl=t,exports.BASE_MAP_TYPES=g,exports.OPENFREEMAP_STYLES=r,exports.OPENFREEMAP_STYLE_BASE_URL=i,exports.OPENFREEMAP_STYLE_TYPES=a,exports.TDT_STYLE_TYPES=["tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],exports.addBreachAlert=(t,e)=>{const o=e.id,i=`${o}-fence-source`,n=`${o}-fence-fill`,r=`${o}-fence-line`,a=`${o}-ripple-source`,l=`${o}-ripple-line`;let c,s,d,f={...e},h=!1,p=!1,u=!1,g=!1,y=0;const m=()=>f.fenceColor??"#1677ff",_=()=>f.fenceFillColor??m(),w=()=>f.fenceFillOpacity??.1,v=()=>f.fenceBorderWidth??2,b=()=>f.fenceBorderOpacity??.9,M=()=>f.fenceAlertColor??"#ff3b30",$=()=>f.rippleColor??M(),x=e=>{const o=t.getSource(a);o&&o.setData(e)},k=t=>{const e=Math.max(20,f.rippleRadius??800),o=Math.max(1,f.rippleCount??3),i=Math.max(400,f.rippleDuration??1500),n=Math.max(1,f.rippleLineWidth??3),r=performance.now(),a=l=>{x(((t,e,o,i,n,r)=>{const a=[];for(let l=0;l<o;l+=1){const c=(r/i+l/o)%1,s=c*e;s<1||a.push(q(C(t,s),{kind:"ring",opacity:.95*(1-c),width:n*(1-.3*c)}))}return G(a)})(t,e,o,i,n,l-r)),y=requestAnimationFrame(a)};y=requestAnimationFrame(a)},A=()=>{if(!u)return;const e=m(),o=_();t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",o),t.setPaintProperty(n,"fill-opacity",w())),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-width",v()),t.setPaintProperty(r,"line-opacity",b()))},F=()=>{const e=f.tacticalColor??M(),o=Math.max(1,f.tacticalBorderWidth??4),i="viewport"===f.tacticalScope?12:0,n=Math.max(60,f.fenceFlashInterval??200),r=t.getContainer(),a=document.createElement("div");a.style.position="absolute",a.style.inset=`${i}px`,a.style.border=`${o}px solid ${e}`,a.style.boxShadow=`inset 0 0 ${6*o}px ${e}`,a.style.pointerEvents="none",a.style.zIndex="5",a.style.opacity="1",r.appendChild(a),d=a;let l=!0;s=setInterval(()=>{l=!l,a.style.opacity=l?"1":"0.15"},n)},P=()=>{const e=(t=>{if(!t)return[];if(Array.isArray(t))return[{type:"Polygon",coordinates:t}];switch(t.type){case"Polygon":return[t];case"MultiPolygon":return t.coordinates.map(t=>({type:"Polygon",coordinates:t}));case"Feature":{const e=t.geometry;return"Polygon"===(null==e?void 0:e.type)?[e]:"MultiPolygon"===(null==e?void 0:e.type)?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):[]}case"FeatureCollection":{const e=[];for(const o of t.features){const t=o.geometry;"Polygon"===(null==t?void 0:t.type)?e.push(t):"MultiPolygon"===(null==t?void 0:t.type)&&e.push(...t.coordinates.map(t=>({type:"Polygon",coordinates:t})))}return e}default:return[]}})(f.fence);if(0===e.length)return;const o=G(e.map(t=>q(t,{kind:"fence"})));if(u){const e=t.getSource(i);e&&e.setData(o),A()}else t.getSource(i)?t.getSource(i).setData(o):t.addSource(i,{type:"geojson",data:o}),t.getLayer(n)||t.addLayer({id:n,type:"fill",source:i,filter:["==",["get","kind"],"fence"],paint:{"fill-color":_(),"fill-opacity":w()}},f.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get","kind"],"fence"],paint:{"line-color":m(),"line-width":v(),"line-opacity":b()}},f.beforeId),u=!0,j(t,[n,r],!1!==f.visible)},S=()=>{p&&!h&&O()},O=()=>{if(!h)try{P(),t.getSource(a)||t.addSource(a,{type:"geojson",data:G([])}),t.getLayer(l)?t.getLayer(l)&&t.setPaintProperty(l,"line-color",$()):(t.addLayer({id:l,type:"line",source:a,filter:["==",["get","kind"],"ring"],paint:{"line-color":$(),"line-opacity":["coalesce",["get","opacity"],.9],"line-width":["coalesce",["get","width"],3]}},f.beforeId),j(t,[l],!1!==f.visible)),p=!1,t.off("styledata",S)}catch(e){if(!V(e))throw e;p||(p=!0,t.on("styledata",S))}},L=()=>{c&&(clearInterval(c),c=void 0),y&&(cancelAnimationFrame(y),y=0),x(G([])),s&&(clearInterval(s),s=void 0),d&&(d.remove(),d=void 0),A()};return O(),{id:o,update(t){h||(f={...f,...t,id:o},O())},show(){h||(f={...f,visible:!0},j(t,[n,r,l],!0))},hide(){h||(f={...f,visible:!1},j(t,[n,r,l],!1))},remove(){h||(h=!0,p&&(p=!1,t.off("styledata",S)),L(),E(t,l),E(t,r),E(t,n),D(t,a),D(t,i),u=!1)},trigger(e){if(h)return;g&&L();const o=e??f.center;g=!0,!1!==f.fenceFlash&&(()=>{if(!u)return;const e=M(),o=Math.max(60,f.fenceFlashInterval??200);let i=!0;t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",e),t.setPaintProperty(n,"fill-opacity",.42)),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-opacity",1)),c=setInterval(()=>{i=!i;const e=i?.42:.08,o=i?1:.4;t.getLayer(n)&&t.setPaintProperty(n,"fill-opacity",e),t.getLayer(r)&&t.setPaintProperty(r,"line-opacity",o)},o)})(),!1!==f.ripple&&k(o),f.tacticalFlash&&F()},reset(){h||(L(),g=!1)},isActive:()=>g}},exports.addBreathingCircle=(t,e)=>T(t,e,J),exports.addCoordinatedCountermeasure=(t,e)=>T(t,e,Mt),exports.addCountermeasureBeam=(t,e)=>T(t,e,vt),exports.addDefenceCircle=(t,e)=>T(t,e,_t),exports.addDirectionalPulse=(t,e)=>T(t,e,ft),exports.addNavigationSpoofing=(t,e)=>T(t,e,xt),exports.addPulseMarker=(t,e)=>T(t,e,Y),exports.addRadarPowerGroup=(t,e)=>{const{source:o,layers:i}=(t=>{const e=`${t}-source`;return{source:e,layers:[{id:`${t}-fill`,type:"fill",source:e,filter:["==",["get","kind"],"fill"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-core`,type:"fill",source:e,filter:["==",["get","kind"],"core"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-ring`,type:"line",source:e,filter:["==",["get","kind"],"ring"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.95],"line-width":["coalesce",["get","width"],2]}},{id:`${t}-crosshair`,type:"line",source:e,filter:["==",["get","kind"],"crosshair"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.5],"line-width":["coalesce",["get","width"],1.4]}},{id:`${t}-labels`,type:"symbol",source:e,filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":["coalesce",["get","size"],12],"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":["coalesce",["get","color"],"#38ff4a"],"text-opacity":["coalesce",["get","opacity"],.92],"text-halo-color":["coalesce",["get","haloColor"],"rgba(15, 23, 42, 0.42)"],"text-halo-width":1}}]}})(e.id);let n=[...e.radars??[]],r=!1;t.addSource(o,{type:"geojson",data:L}),i.forEach(o=>{t.addLayer(o,e.beforeId)});const a=t.getSource(o),l=i.map(t=>t.id),c=e=>{l.forEach(o=>{t.getLayer(o)&&t.setLayoutProperty(o,"visibility",e?"visible":"none")})},s=t=>{r||(n=t.map(t=>({...t})),a.setData(R(n)))};return n.length>0&&s(n),!1===e.visible&&c(!1),{id:e.id,sourceId:o,layerIds:l,setData:s,updateRadar(t,e){const o=n.findIndex(e=>e.id===t);o<0||r||(n[o]={...n[o],...e,id:t},a.setData(R(n)))},setRadarVisible(t,e){const o=n.find(e=>e.id===t);o&&!r&&(o.visible=e,a.setData(R(n)))},removeRadar(t){r||(n=n.filter(e=>e.id!==t),a.setData(R(n)))},show(){r||c(!0)},hide(){r||c(!1)},remove(){r||(r=!0,[...l].reverse().forEach(e=>((t,e)=>{t.getLayer(e)&&t.removeLayer(e)})(t,e)),((t,e)=>{t.getSource(e)&&t.removeSource(e)})(t,o))}}},exports.addRadarSweep=(t,e)=>T(t,e,yt),exports.addRingPulseMarker=(t,e)=>T(t,e,B),exports.addSectorScan=(t,e)=>T(t,e,st),exports.addStandardElectronicFenceLayer=(t,e)=>{Ot(e.id,e.defaults);const o=new Pt,i=`${e.id}-standard-source`,n=`${e.id}-standard-extrusion`,r=`${e.id}-standard-outline`,a=`${e.id}-standard-interaction`,l=[n,r,...!1===e.interactive?[]:[a]];let c=Zt(o,e),s=!1!==e.visible,d=!1;const f=()=>{if(!d)try{t.getSource(i)||t.addSource(i,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer({id:n,type:"fill-extrusion",source:i,filter:["==",["get",Ut],"wall"],paint:{"fill-extrusion-color":["get",Bt],"fill-extrusion-opacity":1,"fill-extrusion-base":["get",Xt],"fill-extrusion-height":["get",Kt],"fill-extrusion-vertical-gradient":!0}},e.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get",Ut],"boundary"],paint:{"line-color":["get",Ht],"line-width":["get",Jt],"line-opacity":1}},e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:i,filter:["==",["get",Ut],"boundary"],paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),zt(t,l,s)}catch(o){if(!Tt(o))throw o}},h=()=>{f()};t.on("styledata",h),f();const p=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"standard",layerId:a,store:o});return Yt({id:e.id,renderer:"standard",store:o,refresh:()=>{c=Zt(o,e);const n=t.getSource(i);n?n.setData(c):f()},setPluginVisible(e){s=e,f(),zt(t,l,s)},destroy(){d=!0,t.off("styledata",h),p(),[...l].reverse().forEach(e=>{t.getLayer(e)&&t.removeLayer(e)}),t.getSource(i)&&t.removeSource(i)}})},exports.addTargetLock=(e,o)=>{const i=o.id;let n,r={...o},a=!1;const l=document.createElement("div"),c=document.createElement("div"),s=Array.from({length:4},()=>document.createElement("div")),d=Array.from({length:4},()=>document.createElement("div"));l.dataset.effectId=i,l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.pointerEvents="none",c.style.position="absolute",c.style.inset="0",l.appendChild(c),s.forEach(t=>{t.style.position="absolute",t.style.boxSizing="border-box",c.appendChild(t)}),d.forEach(t=>{t.style.position="absolute",l.appendChild(t)});const f=new t.Marker({element:l,anchor:"center"}).setLngLat(r.center).addTo(e),h=()=>{const t=r.color??"#ff3b30",e=Math.max(24,r.size??72),o=Math.max(1,r.lineWidth??2),i=Math.min(e/2,Math.max(2*o,r.cornerLength??18)),a=Math.max(2,r.crosshairLength??10),h=Math.max(0,r.crosshairGap??5);f.setLngLat(r.center),l.style.width=`${e}px`,l.style.height=`${e}px`,l.style.display=!1===r.visible?"none":"block",l.style.opacity=`${Math.min(1,Math.max(0,r.opacity??1))}`,s.forEach(t=>{t.style.width=`${i}px`,t.style.height=`${i}px`,t.style.border="0"}),Object.assign(s[0].style,{left:"0",top:"0",borderLeft:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[1].style,{right:"0",top:"0",borderRight:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[2].style,{right:"0",bottom:"0",borderRight:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),Object.assign(s[3].style,{left:"0",bottom:"0",borderLeft:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),d.forEach(e=>{e.style.display=!1===r.showCrosshair?"none":"block",e.style.background=t}),Object.assign(d[0].style,{width:`${o}px`,height:`${a}px`,left:"50%",bottom:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[1].style,{width:`${o}px`,height:`${a}px`,left:"50%",top:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[2].style,{width:`${a}px`,height:`${o}px`,right:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),Object.assign(d[3].style,{width:`${a}px`,height:`${o}px`,left:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),null==n||n.cancel(),n=void 0,c.style.transform="rotate(0deg)",!1!==r.rotate&&(n=c.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:Math.max(300,r.rotationDuration??2400),iterations:1/0}))};return h(),{id:i,update(t){a||(r={...r,...t,id:i},h())},show(){a||(r={...r,visible:!0},l.style.display="block")},hide(){a||(r={...r,visible:!1},l.style.display="none")},remove(){a||(a=!0,null==n||n.cancel(),n=void 0,f.remove())}}},exports.addWebGLElectronicFenceLayer=(t,e)=>{Ot(e.id,e.defaults);const o=(t=>({enabled:(null==t?void 0:t.enabled)??!0,fps:Math.round(Dt((null==t?void 0:t.fps)??30,1,60)),speed:Math.max(0,(null==t?void 0:t.speed)??.35),scope:(null==t?void 0:t.scope)??"all"}))(e.animation),i=new Pt,n=`${e.id}-webgl`,r=`${e.id}-webgl-interaction-source`,a=`${e.id}-webgl-interaction`,l=new de(n,o);let c=jt(i),s=le(i,e,o),d=!1!==e.visible,f=!1,h=0,p=0;const u=()=>{h&&(cancelAnimationFrame(h),h=0)},g=e=>{!f&&d&&s.animated?(("undefined"==typeof document||!document.hidden)&&e-p>=1e3/o.fps&&(p=e,t.triggerRepaint()),h=requestAnimationFrame(g)):h=0},y=()=>{const e=o.enabled&&d&&s.animated&&!!t.getLayer(n);e&&!h?(p=0,h=requestAnimationFrame(g)):e||u()},m=()=>{if(!f)try{!1===e.interactive||t.getSource(r)||t.addSource(r,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer(l,e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:r,paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),l.setVisible(d),zt(t,!1===e.interactive?[]:[a],d),y()}catch(o){if(!Tt(o))throw o}},_=()=>{m()};l.setGeometry(s),t.on("styledata",_),m();const w=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"webgl",layerId:a,store:i});return Yt({id:e.id,renderer:"webgl",store:i,refresh:()=>{s=le(i,e,o),c=jt(i),l.setGeometry(s);const n=t.getSource(r);n&&n.setData(c),m(),y()},setPluginVisible(o){d=o,l.setVisible(d),m(),zt(t,!1===e.interactive?[]:[a],d),y()},destroy(){f=!0,u(),t.off("styledata",_),w(),t.getLayer(a)&&t.removeLayer(a),t.getLayer(n)&&t.removeLayer(n),t.getSource(r)&&t.removeSource(r)}})},exports.createFenceCircle=(t,e,o)=>F(t,e,o),exports.createMap=e=>{const{style:o,tdtToken:i,...n}=e;return new t.Map({...n,style:fe(o,i)})},exports.createTiandituImageStyle=p,exports.createTiandituRasterSource=f,exports.getBaseMapStyle=m,exports.getMaplibreToolsConfig=o,exports.getOpenFreeMapStyle=l,exports.isBaseMapType=y,exports.setBaseMap=(t,e,o={})=>{const{diff:i=!1,...n}=o;t.setStyle(m(e,n),{diff:i})},exports.setMaplibreToolsConfig=t=>{Object.assign(e,t)};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("maplibre-gl"),e={},o=()=>({...e}),i="https://tiles.openfreemap.org/styles",n=(t,e,o)=>({type:t,label:e,style:`${i}/${o}`}),r={"openfreemap-liberty":n("openfreemap-liberty","OpenFreeMap Liberty","liberty"),"openfreemap-bright":n("openfreemap-bright","OpenFreeMap Bright","bright"),"openfreemap-positron":n("openfreemap-positron","OpenFreeMap Positron","positron"),"openfreemap-dark":n("openfreemap-dark","OpenFreeMap Dark","dark"),"openfreemap-fiord":n("openfreemap-fiord","OpenFreeMap Fiord","fiord")},a=Object.keys(r),l=(t="openfreemap-liberty")=>r[t].style,c=["0","1","2","3","4","5","6","7"],s="© 天地图",d=(t,e)=>{const i=(t=>{const e=t||o().tdtToken;if(!e)throw new Error("Tianditu token is required. Pass token or call setMaplibreToolsConfig({ tdtToken }).");return e})(e);return c.map(e=>`https://t${e}.tianditu.gov.cn/DataServer?T=${t}&x={x}&y={y}&l={z}&tk=${i}`)},f=(t,e={})=>({type:"raster",tiles:d(t,e.token),tileSize:256,minzoom:0,maxzoom:18,attribution:s}),h=(t={})=>({type:"raster",tiles:d("vec_w",t.token),tileSize:256,minzoom:0,maxzoom:18,attribution:s}),p=(t={})=>{const e=!1!==t.label,o={"tdt-image":f("img_w",t)},i=[{id:"tdt-image",type:"raster",source:"tdt-image"}];return e&&(o["tdt-image-label"]=f("cia_w",t),i.push({id:"tdt-image-label",type:"raster",source:"tdt-image-label"})),{version:8,sources:o,layers:i}},u=(t={})=>{const e=!1!==t.label,o={"tdt-mvt":h(t)},i=[{id:"tdt-mvt",type:"raster",source:"tdt-mvt"}];return e&&(o["tdt-mvt-label"]=f("cva_w",t),i.push({id:"tdt-mvt-label",type:"raster",source:"tdt-mvt-label"})),{version:8,sources:o,layers:i}},g=[...Object.keys(r),"tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],y=t=>g.includes(t),m=(t="openfreemap-liberty",e={})=>"tdt-image"===t?p({...e,label:!1}):"tdt-image-label"===t?p({...e,label:!0}):"tdt-mvt"===t?u({...e,label:!1}):"tdt-mvt-label"===t?u({...e,label:!0}):l(t),_=6378137,w=t=>t*Math.PI/180,v=t=>180*t/Math.PI,b=t=>(t%360+360)%360,M=(t,e,o)=>{const i=e/_,n=w(o),r=w(t[1]),a=w(t[0]),l=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(n)),c=a+Math.atan2(Math.sin(n)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(l));return[(s=v(c),s>180?s-360:s<-180?s+360:s),v(l)];var s},$=(t,e)=>{const o=w(e[1]-t[1]),i=w(e[0]-t[0]),n=w(t[1]),r=w(e[1]),a=Math.sin(o/2)*Math.sin(o/2)+Math.cos(n)*Math.cos(r)*Math.sin(i/2)*Math.sin(i/2);return 12756274*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))},x=(t,e)=>{const o=w(t[1]),i=w(e[1]),n=w(e[0]-t[0]),r=Math.sin(n)*Math.cos(i),a=Math.cos(o)*Math.sin(i)-Math.sin(o)*Math.cos(i)*Math.cos(n);return b(v(Math.atan2(r,a)))},k=(t,e,o=64)=>{const i=((t,e)=>{const o=b(e)-b(t);return o<=0?o+360:o})(t,e),n=Math.max(12,Math.ceil(o*i/360));return Array.from({length:n+1},(e,o)=>b(t+i*o/n))},A=(t,e,o=64)=>(t=>{if(0===t.length)return t;const[e,o]=t[0],i=t[t.length-1];return i[0]===e&&i[1]===o?t:[...t,[e,o]]})(Array.from({length:o},(i,n)=>M(t,e,360*n/o))),F=(t,e,o=64)=>({type:"Polygon",coordinates:[A(t,e,o)]}),C=(t,e,o=64)=>({type:"LineString",coordinates:A(t,e,o)}),P=(t,e,o,i,n=64)=>{const r=k(o,i,n).map(o=>M(t,e,o));return{type:"Polygon",coordinates:[[t,...r,t]]}},S=(t,e,o,i,n=64)=>({type:"LineString",coordinates:k(o,i,n).map(o=>M(t,e,o))}),O=(t,e,o)=>({type:"LineString",coordinates:[t,M(t,e,o)]}),L={type:"FeatureCollection",features:[]},I=(t,e)=>({type:"Feature",geometry:t,properties:e}),R=(t,e)=>Math.max(0,Math.min(1,t??e)),q=t=>{var e;if(!1===t.visible)return[];const o=t.color??"#38ff4a",i=t.ringColor??o,n=Math.max(0,Math.floor(t.ringCount??4)),r=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),a=[];t.fillOpacity&&t.fillOpacity>0&&a.push(I(F(t.center,t.radius),{radarId:t.id,kind:"fill",color:t.fillColor??o,opacity:R(t.fillOpacity,0)}));for(let l=n;l>=1;l-=1){const o=t.radius*l/n;if(a.push(I(C(t.center,o),{radarId:t.id,kind:"ring",color:i,opacity:R(t.ringOpacity,.95),width:Math.max(0,t.ringWidth??2)})),!1!==t.showDistanceLabels){const n=(null==(e=t.distanceLabelFormatter)?void 0:e.call(t,o,l))??`${Math.round(o)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(e=>{a.push(I({type:"Point",coordinates:M(t.center,o,e.bearing)},{radarId:t.id,kind:"distance-label",text:n,textAnchor:e.textAnchor,color:t.distanceLabelColor??i,opacity:R(t.distanceLabelOpacity,.92),haloColor:t.distanceLabelHaloColor??"rgba(15, 23, 42, 0.42)",size:t.distanceLabelSize??12}))})}}return!1!==t.showCrosshair&&a.push(I({type:"LineString",coordinates:[M(t.center,t.radius,180),M(t.center,t.radius,0)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:R(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)}),I({type:"LineString",coordinates:[M(t.center,t.radius,270),M(t.center,t.radius,90)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:R(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)})),a.push(I(F(t.center,r),{radarId:t.id,kind:"core",color:t.coreColor??o,opacity:R(t.fillOpacity,0)})),a},W=t=>({type:"FeatureCollection",features:t.flatMap(q)}),N=(t,e)=>({type:"Feature",geometry:t,properties:e}),G=t=>({type:"FeatureCollection",features:t}),E=(t,e)=>{t.getLayer(e)&&t.removeLayer(e)},D=(t,e)=>{t.getSource(e)&&t.removeSource(e)},j=(t,e,o)=>{const i=o?"visible":"none";e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",i)})},V=t=>t instanceof Error&&"Style is not done loading."===t.message,T=(t,e,o)=>{const i=e.id,n=`${i}-source`;let r,a={...e},l=[],c=[n],s=!1,d=!1;const f=()=>{null==r||r(),r=void 0,[...l].reverse().forEach(e=>{E(t,e)}),[...c].reverse().forEach(e=>{D(t,e)}),l=[],c=[n]},h=e=>{const o=t.getSource(n);o&&o.setData(e)},p=()=>{try{(()=>{var e,i,d;if(s)return;f();const p=o(a);t.addSource(n,{type:"geojson",data:p.data}),null==(e=p.canvasSources)||e.forEach(e=>{t.addSource(e.id,e.source)}),c=[n,...(null==(i=p.canvasSources)?void 0:i.map(t=>t.id))||[]],l=p.layers.map(t=>t.id),p.layers.forEach(e=>{var o;const i="raster"===e.type&&(null==(o=p.canvasSources)?void 0:o[0])?p.canvasSources[0].id:n;t.addLayer({...e,source:i},a.beforeId)}),j(t,l,!1!==a.visible),null==(d=p.canvasSources)||d.forEach(e=>{var o;const i=t.style,n=null==(o=null==i?void 0:i.tileManagers)?void 0:o[e.id];if(!n||!n.t)return;const r=n.used;n.used=!0;const a=t;n.update(a.transform,a.terrain),n.used=r}),p.startAnimation&&(r=p.startAnimation({getOptions:()=>a,setData:h,requestRender:()=>t.triggerRepaint()})||void 0)})(),d&&(d=!1,t.off("styledata",u))}catch(e){if(!V(e))throw e;d||(d=!0,t.on("styledata",u))}},u=()=>{d&&!s&&p()},g=()=>{s||p()};return g(),{id:i,update(t){s||(a={...a,...t,id:i},g())},show(){s||(a={...a,visible:!0},j(t,l,!0))},hide(){s||(a={...a,visible:!1},j(t,l,!1))},remove(){s||(s=!0,d&&(d=!1,t.off("styledata",u)),f())}}},z=(t,e=0)=>{const o=Math.max(10,t.radius??70),i=Math.max(o,t.maxRadius??2.3*o),n=Math.max(1,t.pulseCount??2),r=Math.max(1,t.lineWidth??2),a=t.pulseOpacity??.9,l=[N(F(t.center,o),{kind:"core"})];for(let c=0;c<n;c+=1){const s=(e+c/n)%1,d=o+(i-o)*s;l.push(N(C(t.center,d),{kind:"pulse",opacity:a*(1-s),width:r*(1-.35*s)}))}return G(l)},Y=t=>{const e=t.color||"#ff3b30",o=t.fillColor||e;return{data:z(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":t.fillOpacity??.28}},{id:`${t.id}-pulse`,type:"line",filter:["==",["get","kind"],"pulse"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.pulseOpacity??.9],"line-width":["coalesce",["get","width"],t.lineWidth??2]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800);let i=0;const n=performance.now(),r=a=>{const l=t();e(z(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},U=(t,e=0)=>{const o=Math.max(16,t.radius??110),i=Math.max(0,t.pulseScale??.16),n=(1-Math.cos(e*Math.PI*2))/2,r=o*(1+i*n),a=Math.max(1,t.ringCount??3),l=Math.max(2.2*r,t.maxRadius??o*(2.5*a)),c=l/a,s=t.fillOpacity??.28,d=[N(F(t.center,r),{kind:"core",opacity:s*(.88+.2*n)}),N(C(t.center,1.06*r),{kind:"core-ring",opacity:(t.lineOpacity??.95)*(.8+.2*n),width:Math.max(1,(t.lineWidth??3)*(.92+.12*n))})];for(let f=0;f<a;f+=1){const o=(f+e+1)*c%l||l,i=o/l;d.push(N(C(t.center,o),{kind:"ring",opacity:Math.max(.18,(t.lineOpacity??.95)*(1-.42*i)),width:Math.max(1,(t.lineWidth??3)*(1-.18*i))}))}return G(d)},B=t=>{const e=t.color||"#ef4444",o=t.fillColor||e;return{data:U(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-rings`,type:"line",filter:["any",["==",["get","kind"],"ring"]],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.lineOpacity??.95],"line-width":["coalesce",["get","width"],t.lineWidth??3]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(600,t().duration??2e3);let i=0;const n=performance.now(),r=a=>{const l=t();e(U(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},H=(t,e=0)=>{const o=Math.max(1,t.radius??90),i=Math.max(1,t.minRadius??.78*o),n=Math.max(i,t.maxRadius??1.22*o),r=(1-Math.cos(e*Math.PI*2))/2,a=i+(n-i)*r,l=t.fillOpacity??.28,c=t.minFillOpacity??.46*l,s=t.strokeOpacity??.82,d=t.minStrokeOpacity??.38*s,f=1-r,h=[N(F(t.center,a),{kind:"breathing-fill",opacity:c+(l-c)*f})];return(t.strokeWidth??2)>0&&h.push(N(C(t.center,a),{kind:"breathing-stroke",opacity:d+(s-d)*f})),G(h)},J=t=>{const e=t.color||"#1677ff",o=t.fillColor||e,i=t.strokeColor||e,n=Math.max(0,t.strokeWidth??2);return{data:H(t),layers:[{id:`${t.id}-breathing-fill`,type:"fill",filter:["==",["get","kind"],"breathing-fill"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-breathing-stroke`,type:"line",filter:["==",["get","kind"],"breathing-stroke"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":i,"line-opacity":["coalesce",["get","opacity"],t.strokeOpacity??.82],"line-width":n}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800),i=performance.now();let n=0;const r=a=>{const l=t();e(H(l,(a-i)%o/o)),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>{cancelAnimationFrame(n)}}}},X=(t,e,o)=>Math.min(o,Math.max(e,t)),K=t=>{const e=t.trim(),o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const t=o[1],e=3===t.length?t.split("").map(t=>t+t).join(""):t;return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const i=e.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(i)return[X(Number(i[1]),0,255),X(Number(i[2]),0,255),X(Number(i[3]),0,255)]},Q=t=>(t%360+360)%360,Z=t=>(t-90)*Math.PI/180,tt=(t,e)=>{const o=K(t);return o?`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${X(e,0,1)})`:t},et=t=>t*(2-t),ot=(t,e)=>{const o=t.length-1;if(e<=0)return t[0];if(e>=o)return t[o];const i=Math.floor(e),n=e-i,[r,a]=[K(t[i]),K(t[i+1])];if(!r||!a)return t[Math.round(e)];const[l,c,s]=((t,e,o)=>[Math.round(t[0]+(e[0]-t[0])*o),Math.round(t[1]+(e[1]-t[1])*o),Math.round(t[2]+(e[2]-t[2])*o)])(r,a,n);return`rgb(${l},${c},${s})`},it=(t,e)=>{const o=M(t,e,0)[1],i=M(t,e,90)[0],n=M(t,e,180)[1],r=M(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},nt=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2?o:void 0},rt=(t,e,o=0)=>{const i=t.getContext("2d"),n=nt(e);if(!i||!e.gradient||!n)return;const r=t.width,a=r/2,l=a-2,c=e.startAngle+o,s=((t,e)=>{const o=Q(e)-Q(t);return o<=0?o+360:o})(c,e.endAngle+o),d=Z(c),f=d+s*Math.PI/180,h=e.gradient.opacity??e.opacity??.28,p=e.gradient.centerOpacity??.25*h,u=e.gradient.edgeOpacity??h,g=i.createRadialGradient(a,a,0,a,a,l);n.forEach((t,e)=>{const o=e/Math.max(1,n.length-1),i=p+(u-p)*o;g.addColorStop(o,tt(t,i))}),i.clearRect(0,0,r,r),i.save(),i.beginPath(),i.moveTo(a,a),i.arc(a,a,l,d,f,!1),i.closePath(),i.clip(),i.fillStyle=g,i.fillRect(0,0,r,r),i.restore()},at=t=>{if(!nt(t))return;const e=(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})();return rt(e,t),e},lt=(t,e,o)=>nt(t)?[]:[N(P(t.center,t.radius,e,o),{kind:"sector",color:t.color||"#ff453a",opacity:t.opacity??.28})],ct=(t,e=0)=>{const o=t.startAngle+e,i=t.endAngle+e,n=[...lt(t,o,i),N(O(t.center,t.radius,o),{kind:"frame"}),N(O(t.center,t.radius,i),{kind:"frame"})];return G(n)},st=t=>{const e=at(t),o=e?{id:`${t.id}-sector-fill`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-sector-fill`,type:"fill",filter:["==",["get","kind"],"sector"],paint:{"fill-color":["coalesce",["get","color"],t.color||"#ff453a"],"fill-opacity":["coalesce",["get","opacity"],t.opacity??.28],"fill-antialias":!1}};return{data:ct(t),canvasSources:e?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:it(t.center,t.radius),animate:!1}}]:void 0,layers:[o,{id:`${t.id}-sector-frame`,type:"line",filter:["==",["get","kind"],"frame"],paint:{"line-color":t.outlineColor||t.color||"#ff453a","line-opacity":t.outlineOpacity??.95,"line-width":t.outlineWidth??2}}],startAnimation:t.rotationSpeed&&0!==t.rotationSpeed?({getOptions:t,setData:o,requestRender:i})=>{const n=performance.now();let r=0,a=-1/0;const l=c=>{const s=t(),d=s.frameRate??30;if(c-a>=(d>0?1e3/d:0)){const t=(c-n)/1e3*(s.rotationSpeed||0),r=(s.outlineOpacity??.95)>0&&(s.outlineWidth??2)>0;e&&(rt(e,s,t),i()),e&&!r||o(ct(s,t)),a=c}r=requestAnimationFrame(l)};return r=requestAnimationFrame(l),()=>{cancelAnimationFrame(r)}}:void 0}},dt=(t,e)=>{const o=Math.max(40,t.radius),i=t.direction??270,n=Math.min(180,Math.max(8,t.spread??72)),r=Math.max(1,t.lineCount??7),a=Math.max(20,t.lineSpacing??Math.max(80,o/9)),l=e??0,c=Math.max(0,Math.min(.35*o,t.innerRadius??Math.min(.4*a,120))),s=i-n/2,d=i+n/2,f=[];for(let h=0;h<r;h+=1){const e=c+l+h*a;if(e>o)continue;const i=e/o,n=1-h/Math.max(1,r);f.push(N(S(t.center,e,s,d),{kind:"directional-pulse-line",opacity:Math.max(.08,(t.opacity??.92)*(.42+.58*n)*(1-.28*i)),width:Math.max(1,(t.lineWidth??2.8)*(.86+.24*n)*(1-.08*i))}))}return G(f)},ft=t=>({data:dt(t),layers:[{id:`${t.id}-directional-pulse`,type:"line",filter:["==",["get","kind"],"directional-pulse-line"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.color||"#ef4444","line-opacity":["coalesce",["get","opacity"],t.opacity??.92],"line-width":["coalesce",["get","width"],t.lineWidth??2.8]}}],startAnimation:t.speed&&t.speed>0?({getOptions:t,setData:e})=>{const o=performance.now();let i=0;const n=r=>{const a=t(),l=Math.max(40,a.radius),c=Math.max(20,a.lineSpacing??Math.max(80,l/9)),s=(r-o)/1e3*(a.speed??0)%c;e(dt(a,s)),i=requestAnimationFrame(n)};return i=requestAnimationFrame(n),()=>{cancelAnimationFrame(i)}}:void 0}),ht=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2},pt=(t,e)=>{const o=M(t,e,0)[1],i=M(t,e,90)[0],n=M(t,e,180)[1],r=M(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},ut=(t,e,o=0)=>{const i=t.getContext("2d"),n=e.gradient,r=null==n?void 0:n.colors;if(!i||!n||!r||r.length<2)return;const a=t.width,l=a/2,c=l-2,s=Math.max(12,e.sweepAngle??42),d=e.tailOpacity??.04,f=Math.max(.24,e.opacity??.3),h=(e.sweepStartAngle??0)+o,p=h,u=h+s,g=s;i.clearRect(0,0,a,a);const y=i.createConicGradient(Z(p),l,l),m=g/360,_=Math.min(1,f+.08);for(let w=0;w<=128;w++){const t=w/128,e=d+(_-d)*et(t),o=t*(r.length-1),i=ot(r,o);y.addColorStop(t*m,tt(i,Math.max(0,e)))}i.save(),i.beginPath(),i.moveTo(l,l),i.arc(l,l,c,Z(p),Z(u),!1),i.closePath(),i.fillStyle=y,i.fill(),i.restore()},gt=(t,e=0)=>{var o;const i=Math.max(0,t.ringCount??4),n=Math.max(12,t.sweepAngle??42),r=t.headOpacity??Math.max(.24,t.opacity??.3),a=(t.sweepStartAngle??0)+e,l=!1!==t.showCrosshair,c=!1!==t.showDistanceLabels,s=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),d=ht(t),f=[];for(let h=i;h>=1;h-=1){const e=t.radius*h/i;if(f.push(N(C(t.center,e),{kind:"ring"})),c){const i=(null==(o=t.distanceLabelFormatter)?void 0:o.call(t,e,h))??`${Math.round(e)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(o=>{f.push(N({type:"Point",coordinates:M(t.center,e,o.bearing)},{kind:"distance-label",text:i,textAnchor:o.textAnchor}))})}}return l&&f.push(N({type:"LineString",coordinates:[M(t.center,t.radius,180),M(t.center,t.radius,0)]},{kind:"crosshair"}),N({type:"LineString",coordinates:[M(t.center,t.radius,270),M(t.center,t.radius,90)]},{kind:"crosshair"})),f.push(N(F(t.center,s),{kind:"core"})),d||f.push(N(P(t.center,t.radius,a,a+n),{kind:"sweep",opacity:r})),G(f)},yt=t=>{const e=ht(t),o=e?(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})():void 0,i=0!==(t.rotationSpeed??36);o&&ut(o,t);const n=o?{id:`${t.id}-radar-trail`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-radar-trail`,type:"fill",filter:["==",["get","kind"],"sweep"],paint:{"fill-color":t.color||"#22c55e","fill-opacity":["coalesce",["get","opacity"],t.opacity??.32]}};return{data:gt(t),canvasSources:o?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:o,coordinates:pt(t.center,t.radius),animate:i}}]:void 0,layers:[n,{id:`${t.id}-radar-rings`,type:"line",filter:["==",["get","kind"],"ring"],paint:{"line-color":t.ringColor||t.color||"#22c55e","line-opacity":t.ringOpacity??.95,"line-width":t.ringWidth??2}},{id:`${t.id}-radar-crosshair`,type:"line",filter:["==",["get","kind"],"crosshair"],paint:{"line-color":t.crosshairColor||t.ringColor||t.color||"#22c55e","line-opacity":t.crosshairOpacity??.5,"line-width":t.crosshairWidth??1.4}},{id:`${t.id}-radar-distance-labels`,type:"symbol",filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":t.distanceLabelSize??12,"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":t.distanceLabelColor||t.ringColor||t.color||"#22c55e","text-opacity":t.distanceLabelOpacity??.92,"text-halo-color":t.distanceLabelHaloColor||"rgba(15, 23, 42, 0.42)","text-halo-width":1}}],startAnimation:i?({getOptions:t,setData:i})=>{const n=performance.now();let r=0;const a=l=>{const c=t(),s=(l-n)/1e3*(c.rotationSpeed??36);o&&ut(o,c,s),e||i(gt(c,s)),r=requestAnimationFrame(a)};return r=requestAnimationFrame(a),()=>{cancelAnimationFrame(r)}}:void 0}},mt=(t,e)=>{const o=M(t,e,0)[1],i=M(t,e,90)[0],n=M(t,e,180)[1],r=M(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},_t=t=>{const e=(()=>{const t=document.createElement("canvas");return t.width=512,t.height=512,t})();((t,e)=>{const o=t.getContext("2d");if(!o)return;const i=t.width,n=i/2,r=n-1,a=e.color||"#06c536",l=e.fillColor||a,c=e.borderColor||a,s=e.fillOpacity??.06,d=e.borderOpacity??.92;o.clearRect(0,0,i,i),o.save(),o.beginPath(),o.arc(n,n,r,0,2*Math.PI),o.clip();const f=o.createRadialGradient(n,n,0,n,n,r),h=Math.min(.8,s+.85*(d-s));f.addColorStop(0,tt(l,s)),f.addColorStop(.85,tt(l,s)),f.addColorStop(.92,tt(c,s+.3*(h-s))),f.addColorStop(.96,tt(c,s+.7*(h-s))),f.addColorStop(1,tt(c,h)),o.fillStyle=f,o.fillRect(0,0,i,i),o.restore()})(e,t);const o=t.borderColor||t.color||"#06c536";return{data:G([N(C(t.center,t.radius),{kind:"defence-border"})]),canvasSources:[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:mt(t.center,t.radius),animate:!0}}],layers:[{id:`${t.id}-defence-circle`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}},{id:`${t.id}-defence-border`,type:"line",filter:["==",["get","kind"],"defence-border"],paint:{"line-color":o,"line-opacity":t.borderOpacity??.92,"line-width":t.borderWidth??2}}]}},wt=(t,e=0)=>{const o=Math.max(1,t.sourceWidth??220),i=Math.max(1,t.targetWidth??45),n=(t=>{const e=t.target||M(t.center,t.distance||0,t.bearing||0),o=void 0!==t.target?x(t.center,t.target):b(t.bearing||0),i=M(t.center,t.startWidth/2,o-90),n=M(t.center,t.startWidth/2,o+90);return{polygon:{type:"Polygon",coordinates:[[i,M(e,t.endWidth/2,o-90),M(e,t.endWidth/2,o+90),n,i]]},centerLine:{type:"LineString",coordinates:[t.center,e]}}})({center:t.center,target:t.target,startWidth:o,endWidth:i}),r=[N(n.polygon,{kind:"countermeasure-channel"}),N(n.centerLine,{kind:"countermeasure-line"})],a=$(t.center,t.target),l=x(t.center,t.target),c=Math.max(0,Math.floor(t.particleCount??18)),s=Math.max(300,t.particleDuration??1200),d=e%s/s,f=Math.max(1,t.particleRadius??2.8);if(a>0)for(let h=0;h<c;h+=1){const e=(d+h/c)%1;r.push(N({type:"Point",coordinates:M(t.center,a*e,l)},{kind:"countermeasure-particle",opacity:.25+.75*e,radius:f*(.7+.3*e)}))}if(!1!==t.targetRipple){const o=Math.max(1,Math.floor(t.targetRippleCount??2)),i=Math.max(10,t.targetRippleRadius??120),n=Math.max(300,t.targetRippleDuration??900),a=e%n/n;for(let e=0;e<o;e+=1){const n=(a+e/o)%1,l="forcedLanding"===t.mode?1-n:n;r.push(N(C(t.target,Math.max(2,i*l)),{kind:"countermeasure-target-ripple",opacity:.9*Math.sin(Math.PI*n)}))}}return G(r)},vt=t=>{const e=t.color??"#a855f7",o=t.lineColor??"#f0abfc",i=Math.max(1,t.lineWidth??2.5);return{data:wt(t),layers:[{id:`${t.id}-countermeasure-channel`,type:"fill",filter:["==",["get","kind"],"countermeasure-channel"],paint:{"fill-color":t.channelColor??e,"fill-opacity":t.channelOpacity??.16}},{id:`${t.id}-countermeasure-glow`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":.28*(t.lineOpacity??.92),"line-width":4*i,"line-blur":1.4*i}},{id:`${t.id}-countermeasure-line`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":t.lineOpacity??.92,"line-width":i}},{id:`${t.id}-countermeasure-target-ripple`,type:"line",filter:["==",["get","kind"],"countermeasure-target-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.9],"line-width":Math.max(1,t.targetRippleWidth??2.5)}},{id:`${t.id}-countermeasure-particle`,type:"circle",filter:["==",["get","kind"],"countermeasure-particle"],paint:{"circle-color":t.particleColor??o,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.8],"circle-blur":.18,"circle-stroke-color":"#ffffff","circle-stroke-opacity":.45,"circle-stroke-width":.5}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(wt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},bt=(t,e=0)=>{const o=[],i=new Set,n=Math.max(0,Math.floor(t.particleCount??5)),r=Math.max(300,t.particleDuration??1600),a=e%r/r,l=Math.max(1,t.particleRadius??2.5);if(t.links.forEach((e,r)=>{const c=e.color??("detection"===(s=e.type)?"#38bdf8":"command"===s?"#22d3ee":"#f97316");var s;const d=$(e.from,e.to),f=x(e.from,e.to);if(o.push(N({type:"LineString",coordinates:[e.from,e.to]},{kind:"coordination-link",linkType:e.type,color:c})),!1!==t.showNodes&&[e.from,e.to].forEach(t=>{const e=`${t[0]},${t[1]}`;i.has(e)||(i.add(e),o.push(N({type:"Point",coordinates:t},{kind:"coordination-node",color:c})))}),!(d<=0))for(let i=0;i<n;i+=1){const s=(a+i/n+r/t.links.length)%1;o.push(N({type:"Point",coordinates:M(e.from,d*s,f)},{kind:"coordination-particle",color:c,opacity:.35+.65*s,radius:l}))}}),!1!==t.targetRipple){const i=Math.max(300,t.targetRippleDuration??1200),n=e%i/i,r=Math.max(10,t.targetRippleRadius??100)*n;o.push(N(C(t.center,Math.max(2,r)),{kind:"coordination-target-ripple",opacity:.9*(1-n)}))}return G(o)},Mt=t=>{const e=Math.max(1,t.lineWidth??2.2),o=t.lineOpacity??.9;return{data:bt(t),layers:[{id:`${t.id}-coordination-detection`,type:"line",filter:["==",["get","linkType"],"detection"],paint:{"line-color":["coalesce",["get","color"],"#38bdf8"],"line-opacity":o,"line-width":e,"line-dasharray":[2,2]}},{id:`${t.id}-coordination-command`,type:"line",filter:["==",["get","linkType"],"command"],paint:{"line-color":["coalesce",["get","color"],"#22d3ee"],"line-opacity":o,"line-width":e,"line-dasharray":[.5,1.8]}},{id:`${t.id}-coordination-countermeasure`,type:"line",filter:["==",["get","linkType"],"countermeasure"],paint:{"line-color":["coalesce",["get","color"],"#f97316"],"line-opacity":o,"line-width":e+.8}},{id:`${t.id}-coordination-target-ripple`,type:"line",filter:["==",["get","kind"],"coordination-target-ripple"],paint:{"line-color":"#ff3b30","line-opacity":["coalesce",["get","opacity"],.9],"line-width":2.5}},{id:`${t.id}-coordination-node`,type:"circle",filter:["==",["get","kind"],"coordination-node"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-radius":Math.max(2,t.nodeRadius??5),"circle-stroke-color":"#ffffff","circle-stroke-width":1.5}},{id:`${t.id}-coordination-particle`,type:"circle",filter:["==",["get","kind"],"coordination-particle"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.5],"circle-blur":.1}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(bt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},$t=(t,e=0)=>{const o=[N({type:"LineString",coordinates:[t.center,t.spoofedPosition]},{kind:"spoofing-offset"})],i=$(t.center,t.spoofedPosition),n=x(t.center,t.spoofedPosition),r=Math.max(0,Math.floor(t.particleCount??10)),a=Math.max(300,t.particleDuration??1800),l=e%a/a;if(!1!==t.showTruePosition&&o.push(N({type:"Point",coordinates:t.center},{kind:"spoofing-true-position"})),!1!==t.showSpoofedPosition&&o.push(N({type:"Point",coordinates:t.spoofedPosition},{kind:"spoofing-ghost"})),i>0)for(let c=0;c<r;c+=1){const e=(l+c/r)%1;o.push(N({type:"Point",coordinates:M(t.center,i*e,n)},{kind:"spoofing-particle",opacity:.25+.75*e}))}if(!1!==t.ripple){const i=Math.max(1,Math.floor(t.rippleCount??2)),n=Math.max(300,t.rippleDuration??1200),r=Math.max(10,t.rippleRadius??120),a=e%n/n;for(let e=0;e<i;e+=1){const n=(a+e/i)%1;o.push(N(C(t.spoofedPosition,Math.max(2,r*n)),{kind:"spoofing-ripple",opacity:.75*(1-n)}))}}return G(o)},xt=t=>{const e=t.color??"#8b5cf6";return{data:$t(t),layers:[{id:`${t.id}-spoofing-offset`,type:"line",filter:["==",["get","kind"],"spoofing-offset"],layout:{"line-cap":"round"},paint:{"line-color":t.lineColor??e,"line-opacity":t.lineOpacity??.82,"line-width":Math.max(1,t.lineWidth??2),"line-dasharray":[1.2,2]}},{id:`${t.id}-spoofing-ripple`,type:"line",filter:["==",["get","kind"],"spoofing-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.75],"line-width":2}},{id:`${t.id}-spoofing-true-position`,type:"circle",filter:["==",["get","kind"],"spoofing-true-position"],paint:{"circle-color":"#ffffff","circle-radius":5,"circle-stroke-color":e,"circle-stroke-width":2}},{id:`${t.id}-spoofing-ghost`,type:"circle",filter:["==",["get","kind"],"spoofing-ghost"],paint:{"circle-color":e,"circle-opacity":t.ghostOpacity??.42,"circle-radius":Math.max(2,t.ghostRadius??8),"circle-stroke-color":"#ffffff","circle-stroke-opacity":.8,"circle-stroke-width":1.5}},{id:`${t.id}-spoofing-particle`,type:"circle",filter:["==",["get","kind"],"spoofing-particle"],paint:{"circle-color":e,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":Math.max(1,t.particleRadius??2.5),"circle-blur":.12}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e($t(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},kt="__electronic_fence_id",At=t=>JSON.parse(JSON.stringify(t)),Ft=t=>{const e=t.map(t=>{const e=Number(t[0]),o=Number(t[1]);if(!Number.isFinite(e)||!Number.isFinite(o))throw new Error("电子围栏坐标必须是有限数字。");return[e,o]});if(e.length<3)throw new Error("电子围栏的每个环至少需要 3 个不同坐标。");var o,i;if(o=e[0],i=e[e.length-1],(o[0]!==i[0]||o[1]!==i[1])&&e.push([...e[0]]),e.length<4)throw new Error("电子围栏 Polygon 环无效。");return e},Ct=t=>{if("string"!=typeof t.id||!t.id.trim())throw new Error("电子围栏必须提供非空字符串 id。");if(!t.geometry||"Polygon"!==t.geometry.type)throw new Error(`电子围栏 ${t.id} 仅支持 Polygon geometry。`);const e=At(t.properties||{});return{type:"Feature",id:t.id,geometry:{type:"Polygon",coordinates:t.geometry.coordinates.map(Ft)},properties:e}};class Pt{constructor(){this.features=new Map,this.states=new Map,this.activeIds=new Set,this.hiddenIds=new Set}setData(t){const e=new Map;t.features.forEach(t=>{const o=Ct(t);if(e.has(o.id))throw new Error(`电子围栏 id 重复:${o.id}`);e.set(o.id,o)}),this.features=e,this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}add(t){const e=Ct(t);if(this.features.has(e.id))throw new Error(`电子围栏 id 已存在:${e.id}`);return this.features.set(e.id,e),e.id}update(t,e){const o=this.requireFeature(t);this.features.set(t,((t,e)=>{const o=t.properties||{},i=e.properties||{},n=i.style?{...o.style||{},...i.style}:o.style;return Ct({...At(t),geometry:e.geometry?At(e.geometry):At(t.geometry),properties:{...At(o),...At(i),...n?{style:n}:{}}})})(o,e))}remove(t){this.requireFeature(t),this.features.delete(t),this.states.delete(t),this.activeIds.delete(t),this.hiddenIds.delete(t)}clear(){this.features.clear(),this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}setActive(t,e){this.requireFeature(t),e?this.activeIds.add(t):this.activeIds.delete(t)}setState(t,e){if(this.requireFeature(t),"normal"!==e&&"warning"!==e&&"alarm"!==e&&"disabled"!==e)throw new Error(`电子围栏 ${t} 的渲染状态无效。`);"normal"===e?this.states.delete(t):this.states.set(t,e)}setVisible(t,e){this.requireFeature(t),e?this.hiddenIds.delete(t):this.hiddenIds.add(t)}isActive(t){return this.activeIds.has(t)}getState(t){return this.requireFeature(t),this.states.get(t)||"normal"}get(t){const e=this.features.get(t);return e?At(e):void 0}values(){return Array.from(this.features.values())}visibleValues(){return this.values().filter(t=>!this.hiddenIds.has(t.id))}requireFeature(t){const e=this.features.get(t);if(!e)throw new Error(`电子围栏不存在:${t}`);return e}}const St=(t,e,o,i=!1)=>{const n=void 0===t?e:Number(t);if(!Number.isFinite(n)||i&&n<=0)throw new Error(`${o} 必须是${i?"大于 0 的":"有限"}数字。`);return n},Ot=(t,e)=>{if(!t.trim())throw new Error("电子围栏插件 id 不能为空。");St(e.baseHeight,0,"defaults.baseHeight"),St(e.height,0,"defaults.height",!0),St(e.thickness,1,"defaults.thickness",!0)},Lt=t=>({baseHeight:St(t.baseHeight,0,"defaults.baseHeight"),height:St(t.height,0,"defaults.height",!0),thickness:St(t.thickness,1,"defaults.thickness",!0)}),It=(t,e)=>"normal"!==t?t:e?"active":"normal",Rt=t=>{var e,o;return{...{...t.defaults.normal,...(null==(e=t.overrides)?void 0:e.normal)||{}},..."normal"===t.state?{}:{...t.defaults[t.state],...(null==(o=t.overrides)?void 0:o[t.state])||{}}}},qt=(t,e)=>{const o=e/2,i=[];return t.coordinates.forEach(t=>{const e=[];for(let o=0;o<t.length-1;o+=1){const i=[t[o][0],t[o][1]],n=[t[o+1][0],t[o+1][1]],r=$(i,n);r<.01||e.push({start:i,end:n,length:r,bearing:x(i,n)})}const n=e.reduce((t,e)=>t+e.length,0);let r=0;e.forEach(t=>{const e=M(t.start,o,t.bearing+180),a=M(t.end,o,t.bearing);i.push({startLeft:M(e,o,t.bearing-90),startRight:M(e,o,t.bearing+90),endLeft:M(a,o,t.bearing-90),endRight:M(a,o,t.bearing+90),startProgress:n?r/n:0,endProgress:n?(r+t.length)/n:1}),r+=t.length})}),i},Wt=t=>({type:"MultiPolygon",coordinates:t.map(t=>[[t.startLeft,t.endLeft,t.endRight,t.startRight,t.startLeft]])}),Nt=(t,e,o)=>Math.min(o,Math.max(e,t)),Gt=t=>{const e=t.trim().toLowerCase();if(e.startsWith("#")){const t=e.slice(1),o=3===t.length||4===t.length?t.split("").map(t=>t+t).join(""):t;if(6===o.length||8===o.length){const t=Number.parseInt(o,16);if(Number.isFinite(t))return[(t>>(8===o.length?24:16)&255)/255,(t>>(8===o.length?16:8)&255)/255,(t>>(8===o.length?8:0)&255)/255,8===o.length?(255&t)/255:1]}}const o=e.match(/^rgba?\(([^)]+)\)$/);if(o){const t=o[1].split(",").map(t=>Number(t.trim()));if(t.length>=3&&t.every(t=>Number.isFinite(t)))return[Nt(t[0]/255,0,1),Nt(t[1]/255,0,1),Nt(t[2]/255,0,1),Nt(t[3]??1,0,1)]}throw new Error(`暂不支持的围栏颜色格式:${t}`)},Et=(t,e=1)=>{const[o,i,n,r]=Gt(t);return`rgba(${Math.round(255*o)}, ${Math.round(255*i)}, ${Math.round(255*n)}, ${Nt(r*e,0,1)})`},Dt=Nt,jt=t=>({type:"FeatureCollection",features:t.visibleValues().map(t=>({type:"Feature",id:`${t.id}:interaction`,geometry:At(t.geometry),properties:{[kt]:t.id}}))}),Vt=t=>{let e;const o=e=>{var o;if(!t.map.getLayer(t.layerId))return;const i=t.map.queryRenderedFeatures(e.point,{layers:[t.layerId]})[0],n=null==(o=null==i?void 0:i.properties)?void 0:o[kt];return"string"==typeof n?n:void 0},i=(e,o,i)=>{const n=t.store.get(o);n&&t.map.fire(`fence.${e}`,{instanceId:t.instanceId,renderer:t.renderer,id:o,feature:n,originalEvent:i})},n=t=>{const e=o(t);e&&i("click",e,t)},r=t=>{const n=o(t);n!==e&&(e&&i("mouseleave",e,t),e=n,e&&i("mouseenter",e,t))},a=t=>{e&&(i("mouseleave",e,t),e=void 0)};return t.map.on("click",n),t.map.on("mousemove",r),t.map.on("mouseout",a),()=>{t.map.off("click",n),t.map.off("mousemove",r),t.map.off("mouseout",a)}},Tt=t=>t instanceof Error&&"Style is not done loading."===t.message,zt=(t,e,o)=>{e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",o?"visible":"none")})},Yt=t=>{let e=!1;const o=()=>{if(e)throw new Error(`电子围栏插件 ${t.id} 已销毁。`)};return{id:t.id,renderer:t.renderer,setData(e){o(),t.store.setData(e),t.refresh()},add(e){o();const i=t.store.add(e);return t.refresh(),i},update(e,i){o(),t.store.update(e,i),t.refresh()},removeFeature(e){o(),t.store.remove(e),t.refresh()},clear(){o(),t.store.clear(),t.refresh()},setFeatureState(e,i){o(),t.store.setState(e,i),t.refresh()},setFeatureActive(e,i){o(),t.store.setActive(e,i),t.refresh()},setFeatureVisible(e,i){o(),t.store.setVisible(e,i),t.refresh()},show(){o(),t.setPluginVisible(!0)},hide(){o(),t.setPluginVisible(!1)},destroy(){e||(e=!0,t.destroy())}}},Ut="__electronic_fence_kind",Bt="__electronic_fence_color",Ht="__electronic_fence_outline_color",Jt="__electronic_fence_outline_width",Xt="__electronic_fence_base",Kt="__electronic_fence_top",Qt={normal:{color:"#d8b4fe",opacity:.28,outlineColor:"#f5e9ff",outlineWidth:1.5},active:{color:"#c084fc",opacity:.42,outlineColor:"#ffffff",outlineWidth:2.5},warning:{color:"#f59e0b",opacity:.38,outlineColor:"#fde68a",outlineWidth:2},alarm:{color:"#ef4444",opacity:.48,outlineColor:"#ffffff",outlineWidth:2.5},disabled:{color:"#94a3b8",opacity:.16,outlineColor:"#cbd5e1",outlineWidth:1}},Zt=(t,e)=>{const o=[],i=Lt(e.defaults);return t.visibleValues().forEach(n=>{const r=It(t.getState(n.id),t.isActive(n.id)),a=Rt({defaults:Qt,overrides:e.styles,state:r}),l=qt(n.geometry,i.thickness),c={[kt]:n.id,[Bt]:Et(a.color,Dt(a.opacity,0,1)),[Ht]:Et(a.outlineColor),[Jt]:Math.max(0,a.outlineWidth),[Xt]:i.baseHeight,[Kt]:i.baseHeight+i.height};l.length&&o.push({type:"Feature",id:`${n.id}:wall`,geometry:Wt(l),properties:{...c,[Ut]:"wall"}}),o.push({type:"Feature",id:`${n.id}:boundary`,geometry:n.geometry,properties:{...c,[Ut]:"boundary"}})}),{type:"FeatureCollection",features:o}},te=[{thicknessScale:.08,opacity:1},{thicknessScale:.22,opacity:.56},{thicknessScale:.45,opacity:.28},{thicknessScale:.8,opacity:.12},{thicknessScale:1.3,opacity:.045}],ee={normal:{color:"#d8b4fe",opacity:.2,outlineColor:"#f5e9ff",outlineWidth:1.5,glowStrength:1,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.18},active:{color:"#e9d5ff",opacity:.28,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.25,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.2},warning:{color:"#f59e0b",opacity:.25,outlineColor:"#fde68a",outlineWidth:2,glowStrength:1.1,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.18},alarm:{color:"#ef4444",opacity:.3,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.35,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.2},disabled:{color:"#94a3b8",opacity:.12,outlineColor:"#cbd5e1",outlineWidth:1,glowStrength:0,flowColor:"#ffffff",flowCount:0,flowLineStyle:"dashed",flowWidth:0}},oe=(e,o)=>{const i=t.MercatorCoordinate.fromLngLat(e,o);return[i.x,i.y,i.z]},ie=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],ne=(t,e,o)=>{const i=ie(e,t),n=ie(o,t);return(t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]})([i[1]*n[2]-i[2]*n[1],i[2]*n[0]-i[0]*n[2],i[0]*n[1]-i[1]*n[0]])},re=(t,e,o,i,n)=>{const r=ne(e[0],e[1],e[2]);[0,1,2,0,2,3].forEach(a=>{((t,e,o,i,n,r)=>{t.push(...e,...o,i,n,...r.color,r.flowColor[0],r.flowColor[1],r.flowColor[2],r.glowStrength,r.flowWidth,r.flowCount,r.flowLineStyle)})(t,e[a],r,o[a],i[a],n)})},ae=(t,e,o,i,n)=>{const r=o+i,a=oe(e.startLeft,o),l=oe(e.startRight,o),c=oe(e.endLeft,o),s=oe(e.endRight,o),d=oe(e.startLeft,r),f=oe(e.startRight,r),h=oe(e.endLeft,r),p=oe(e.endRight,r);re(t,[d,h,p,f],[1,1,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),re(t,[a,c,h,d],[0,0,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),re(t,[s,l,f,p],[0,0,1,1],[e.endProgress,e.startProgress,e.startProgress,e.endProgress],n)},le=(t,e,o)=>{const i=te.map(()=>[]),n=[],r=Lt(e.defaults);let a=!1;t.visibleValues().forEach(l=>{const c=t.isActive(l.id),s=It(t.getState(l.id),c),d=Rt({defaults:ee,overrides:e.styles,state:s}),f=o.enabled&&("all"===o.scope||(t=>"active"===t||"warning"===t||"alarm"===t)(s)),h=((t,e)=>{const o=Gt(t.color),i=Gt(t.flowColor),n=e&&t.flowCount>0?Math.round(Dt(t.flowCount,1,8)):0;return{color:[o[0],o[1],o[2],Dt(o[3]*t.opacity,0,1)],flowColor:i,glowStrength:Dt(t.glowStrength,0,4),flowCount:n,flowLineStyle:"solid"===t.flowLineStyle?0:1,flowWidth:n>0?Dt(t.flowWidth,.01,.49):0}})(d,f);qt(l.geometry,r.thickness).forEach(t=>{ae(n,t,r.baseHeight,r.height,h)}),h.glowStrength>0&&te.forEach((t,e)=>{const o=r.thickness*(1+Math.min(h.glowStrength,2)*t.thicknessScale);qt(l.geometry,o).forEach(t=>{ae(i[e],t,r.baseHeight,r.height,h)})}),a||(a=h.flowCount>0&&h.flowWidth>0)});const l=i.reduce((t,e)=>t+e.length,0),c=new Float32Array(l+n.length),s=[];let d=0;i.forEach((t,e)=>{const o=t.length/19;o>0&&s.push({first:d/19,count:o,opacity:te[e].opacity}),c.set(t,d),d+=t.length});const f=d/19;return c.set(n,d),{vertices:c,glowPasses:s,bodyFirst:f,bodyVertexCount:n.length/19,animated:a}},ce=(t,e,o)=>{const i=t.createShader(e);if(!i)throw new Error("无法创建电子围栏 WebGL shader。");if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(i)||"未知 shader 编译错误";throw t.deleteShader(i),new Error(`电子围栏 WebGL shader 编译失败:${e}`)}return i},se=(t,e,o)=>{const i=t.getUniformLocation(e,o);if(!i)throw new Error(`电子围栏 WebGL uniform 不存在:${o}`);return i};class de{constructor(t,e){this.type="custom",this.renderingMode="3d",this.geometry={vertices:new Float32Array,glowPasses:[],bodyFirst:0,bodyVertexCount:0,animated:!1},this.visible=!0,this.id=t,this.animation=e}setGeometry(t){var e;this.geometry=t,this.uploadGeometry(),null==(e=this.map)||e.triggerRepaint()}setVisible(t){var e;this.visible=t,null==(e=this.map)||e.triggerRepaint()}onAdd(t,e){if(this.map=t,this.gl=e,this.program=(t=>{const e="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext,o=e?"#version 300 es\n precision highp float;\n in vec3 a_position;\n in vec3 a_normal;\n in float a_height_ratio;\n in float a_path_progress;\n in vec4 a_color;\n in vec3 a_flow_color;\n in float a_glow_strength;\n in float a_flow_width;\n in float a_flow_count;\n in float a_flow_line_style;\n uniform mat4 u_matrix;\n out vec3 v_normal;\n out float v_height_ratio;\n out float v_path_progress;\n out vec4 v_color;\n out vec3 v_flow_color;\n out float v_glow_strength;\n out float v_flow_width;\n out float v_flow_count;\n out float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ":"\n precision highp float;\n attribute vec3 a_position;\n attribute vec3 a_normal;\n attribute float a_height_ratio;\n attribute float a_path_progress;\n attribute vec4 a_color;\n attribute vec3 a_flow_color;\n attribute float a_glow_strength;\n attribute float a_flow_width;\n attribute float a_flow_count;\n attribute float a_flow_line_style;\n uniform mat4 u_matrix;\n varying vec3 v_normal;\n varying float v_height_ratio;\n varying float v_path_progress;\n varying vec4 v_color;\n varying vec3 v_flow_color;\n varying float v_glow_strength;\n varying float v_flow_width;\n varying float v_flow_count;\n varying float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ",i="\n precision highp float;\n uniform float u_time;\n uniform float u_speed;\n uniform float u_animation_enabled;\n uniform float u_glow_pass;\n uniform float u_glow_opacity;\n VARYING vec3 v_normal;\n VARYING float v_height_ratio;\n VARYING float v_path_progress;\n VARYING vec4 v_color;\n VARYING vec3 v_flow_color;\n VARYING float v_glow_strength;\n VARYING float v_flow_width;\n VARYING float v_flow_count;\n VARYING float v_flow_line_style;\n void main() {\n float bandCore = 0.0;\n float bandGlow = 0.0;\n float verticalFace = 1.0 - smoothstep(\n 0.82,\n 0.98,\n abs(normalize(v_normal).z)\n );\n\n if (\n u_animation_enabled > 0.5 &&\n v_flow_count > 0.5 &&\n v_flow_width > 0.0001\n ) {\n float count = max(v_flow_count, 1.0);\n float phase = fract(\n v_height_ratio * count + u_time * u_speed * count\n );\n float bandDistance = abs(phase - 0.5);\n float dashPhase = fract(\n v_path_progress * 36.0 - u_time * u_speed * 2.4\n );\n float dash = smoothstep(0.02, 0.1, dashPhase) *\n (1.0 - smoothstep(0.62, 0.74, dashPhase));\n float linePattern = v_flow_line_style > 0.5 ? dash : 1.0;\n\n bandCore = 1.0 - smoothstep(\n max(v_flow_width * 0.08, 0.001),\n max(v_flow_width * 0.42, 0.003),\n bandDistance\n );\n float glowDistance = bandDistance / max(v_flow_width, 0.001);\n bandGlow = exp(\n -glowDistance * glowDistance * 2.6\n );\n bandCore *= linePattern * verticalFace;\n bandGlow *= verticalFace;\n }\n\n if (u_glow_pass > 0.5) {\n float glowAlpha = clamp(\n (v_color.a * 0.003 + bandGlow * 0.085) *\n v_glow_strength * u_glow_opacity,\n 0.0,\n 0.14\n );\n OUTPUT_COLOR = vec4(v_color.rgb, glowAlpha);\n return;\n }\n\n float faceLight = 0.88 + 0.12 * abs(normalize(v_normal).z);\n vec3 bodyColor = v_color.rgb * faceLight;\n vec3 color = mix(bodyColor, v_flow_color, bandCore);\n float alpha = clamp(\n v_color.a + bandCore * 0.68,\n 0.0,\n 1.0\n );\n OUTPUT_COLOR = vec4(color, alpha);\n }\n ",n=(t,e,o)=>t.split(e).join(o),r=e?`#version 300 es\n ${n(n(i,"VARYING","in"),"OUTPUT_COLOR","fragmentColor").replace("precision highp float;","precision highp float;\n out vec4 fragmentColor;")}\n `:n(n(i,"VARYING","varying"),"OUTPUT_COLOR","gl_FragColor"),a=ce(t,t.VERTEX_SHADER,o),l=ce(t,t.FRAGMENT_SHADER,r),c=t.createProgram();if(!c)throw t.deleteShader(a),t.deleteShader(l),new Error("无法创建电子围栏 WebGL program。");if(t.attachShader(c,a),t.attachShader(c,l),t.linkProgram(c),t.deleteShader(a),t.deleteShader(l),!t.getProgramParameter(c,t.LINK_STATUS)){const e=t.getProgramInfoLog(c)||"未知 program 链接错误";throw t.deleteProgram(c),new Error(`电子围栏 WebGL program 链接失败:${e}`)}return c})(e),this.locations=((t,e)=>({position:t.getAttribLocation(e,"a_position"),normal:t.getAttribLocation(e,"a_normal"),heightRatio:t.getAttribLocation(e,"a_height_ratio"),pathProgress:t.getAttribLocation(e,"a_path_progress"),color:t.getAttribLocation(e,"a_color"),flowColor:t.getAttribLocation(e,"a_flow_color"),glowStrength:t.getAttribLocation(e,"a_glow_strength"),flowWidth:t.getAttribLocation(e,"a_flow_width"),flowCount:t.getAttribLocation(e,"a_flow_count"),flowLineStyle:t.getAttribLocation(e,"a_flow_line_style"),matrix:se(t,e,"u_matrix"),time:se(t,e,"u_time"),speed:se(t,e,"u_speed"),animationEnabled:se(t,e,"u_animation_enabled"),glowPass:se(t,e,"u_glow_pass"),glowOpacity:se(t,e,"u_glow_opacity")}))(e,this.program),this.buffer=e.createBuffer()||void 0,!this.buffer)throw new Error("无法创建电子围栏 WebGL 顶点缓冲。");this.uploadGeometry(e)}render(t,e){if(!(this.visible&&this.program&&this.buffer&&this.locations&&(this.geometry.glowPasses.length||this.geometry.bodyVertexCount)))return;const o=19*Float32Array.BYTES_PER_ELEMENT,i=(e,i,n)=>{t.enableVertexAttribArray(e),t.vertexAttribPointer(e,i,t.FLOAT,!1,o,n*Float32Array.BYTES_PER_ELEMENT)};t.useProgram(this.program),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),i(this.locations.position,3,0),i(this.locations.normal,3,3),i(this.locations.heightRatio,1,6),i(this.locations.pathProgress,1,7),i(this.locations.color,4,8),i(this.locations.flowColor,3,12),i(this.locations.glowStrength,1,15),i(this.locations.flowWidth,1,16),i(this.locations.flowCount,1,17),i(this.locations.flowLineStyle,1,18),t.uniformMatrix4fv(this.locations.matrix,!1,e.defaultProjectionData.mainMatrix),t.uniform1f(this.locations.time,performance.now()/1e3),t.uniform1f(this.locations.speed,this.animation.speed),t.uniform1f(this.locations.animationEnabled,this.animation.enabled?1:0),t.enable(t.BLEND),t.enable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.depthMask(!1),this.geometry.glowPasses.length&&(t.blendFunc(t.SRC_ALPHA,t.ONE),t.uniform1f(this.locations.glowPass,1),this.geometry.glowPasses.forEach(e=>{t.uniform1f(this.locations.glowOpacity,e.opacity),t.drawArrays(t.TRIANGLES,e.first,e.count)})),this.geometry.bodyVertexCount&&(t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.uniform1f(this.locations.glowPass,0),t.uniform1f(this.locations.glowOpacity,0),t.drawArrays(t.TRIANGLES,this.geometry.bodyFirst,this.geometry.bodyVertexCount)),t.depthMask(!0),t.bindBuffer(t.ARRAY_BUFFER,null)}onRemove(t,e){this.buffer&&e.deleteBuffer(this.buffer),this.program&&e.deleteProgram(this.program),this.map=void 0,this.gl=void 0,this.buffer=void 0,this.program=void 0,this.locations=void 0}uploadGeometry(t){const e=t||this.gl;e&&this.buffer&&(e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bufferData(e.ARRAY_BUFFER,this.geometry.vertices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null))}}const fe=(t,e)=>t?"string"==typeof t&&y(t)?m(t,{token:e}):t:m("openfreemap-liberty");exports.maplibregl=t,exports.BASE_MAP_TYPES=g,exports.OPENFREEMAP_STYLES=r,exports.OPENFREEMAP_STYLE_BASE_URL=i,exports.OPENFREEMAP_STYLE_TYPES=a,exports.TDT_STYLE_TYPES=["tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],exports.addBreachAlert=(t,e)=>{const o=e.id,i=`${o}-fence-source`,n=`${o}-fence-fill`,r=`${o}-fence-line`,a=`${o}-ripple-source`,l=`${o}-ripple-line`;let c,s,d,f={...e},h=!1,p=!1,u=!1,g=!1,y=0;const m=()=>f.fenceColor??"#1677ff",_=()=>f.fenceFillColor??m(),w=()=>f.fenceFillOpacity??.1,v=()=>f.fenceBorderWidth??2,b=()=>f.fenceBorderOpacity??.9,M=()=>f.fenceAlertColor??"#ff3b30",$=()=>f.rippleColor??M(),x=e=>{const o=t.getSource(a);o&&o.setData(e)},k=t=>{const e=Math.max(20,f.rippleRadius??800),o=Math.max(1,f.rippleCount??3),i=Math.max(400,f.rippleDuration??1500),n=Math.max(1,f.rippleLineWidth??3),r=performance.now(),a=l=>{x(((t,e,o,i,n,r)=>{const a=[];for(let l=0;l<o;l+=1){const c=(r/i+l/o)%1,s=c*e;s<1||a.push(N(C(t,s),{kind:"ring",opacity:.95*(1-c),width:n*(1-.3*c)}))}return G(a)})(t,e,o,i,n,l-r)),y=requestAnimationFrame(a)};y=requestAnimationFrame(a)},A=()=>{if(!u)return;const e=m(),o=_();t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",o),t.setPaintProperty(n,"fill-opacity",w())),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-width",v()),t.setPaintProperty(r,"line-opacity",b()))},F=()=>{const e=f.tacticalColor??M(),o=Math.max(1,f.tacticalBorderWidth??4),i="viewport"===f.tacticalScope?12:0,n=Math.max(60,f.fenceFlashInterval??200),r=t.getContainer(),a=document.createElement("div");a.style.position="absolute",a.style.inset=`${i}px`,a.style.border=`${o}px solid ${e}`,a.style.boxShadow=`inset 0 0 ${6*o}px ${e}`,a.style.pointerEvents="none",a.style.zIndex="5",a.style.opacity="1",r.appendChild(a),d=a;let l=!0;s=setInterval(()=>{l=!l,a.style.opacity=l?"1":"0.15"},n)},P=()=>{const e=(t=>{if(!t)return[];if(Array.isArray(t))return[{type:"Polygon",coordinates:t}];switch(t.type){case"Polygon":return[t];case"MultiPolygon":return t.coordinates.map(t=>({type:"Polygon",coordinates:t}));case"Feature":{const e=t.geometry;return"Polygon"===(null==e?void 0:e.type)?[e]:"MultiPolygon"===(null==e?void 0:e.type)?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):[]}case"FeatureCollection":{const e=[];for(const o of t.features){const t=o.geometry;"Polygon"===(null==t?void 0:t.type)?e.push(t):"MultiPolygon"===(null==t?void 0:t.type)&&e.push(...t.coordinates.map(t=>({type:"Polygon",coordinates:t})))}return e}default:return[]}})(f.fence);if(0===e.length)return;const o=G(e.map(t=>N(t,{kind:"fence"})));if(u){const e=t.getSource(i);e&&e.setData(o),A()}else t.getSource(i)?t.getSource(i).setData(o):t.addSource(i,{type:"geojson",data:o}),t.getLayer(n)||t.addLayer({id:n,type:"fill",source:i,filter:["==",["get","kind"],"fence"],paint:{"fill-color":_(),"fill-opacity":w()}},f.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get","kind"],"fence"],paint:{"line-color":m(),"line-width":v(),"line-opacity":b()}},f.beforeId),u=!0,j(t,[n,r],!1!==f.visible)},S=()=>{p&&!h&&O()},O=()=>{if(!h)try{P(),t.getSource(a)||t.addSource(a,{type:"geojson",data:G([])}),t.getLayer(l)?t.getLayer(l)&&t.setPaintProperty(l,"line-color",$()):(t.addLayer({id:l,type:"line",source:a,filter:["==",["get","kind"],"ring"],paint:{"line-color":$(),"line-opacity":["coalesce",["get","opacity"],.9],"line-width":["coalesce",["get","width"],3]}},f.beforeId),j(t,[l],!1!==f.visible)),p=!1,t.off("styledata",S)}catch(e){if(!V(e))throw e;p||(p=!0,t.on("styledata",S))}},L=()=>{c&&(clearInterval(c),c=void 0),y&&(cancelAnimationFrame(y),y=0),x(G([])),s&&(clearInterval(s),s=void 0),d&&(d.remove(),d=void 0),A()};return O(),{id:o,update(t){h||(f={...f,...t,id:o},O())},show(){h||(f={...f,visible:!0},j(t,[n,r,l],!0))},hide(){h||(f={...f,visible:!1},j(t,[n,r,l],!1))},remove(){h||(h=!0,p&&(p=!1,t.off("styledata",S)),L(),E(t,l),E(t,r),E(t,n),D(t,a),D(t,i),u=!1)},trigger(e){if(h)return;g&&L();const o=e??f.center;g=!0,!1!==f.fenceFlash&&(()=>{if(!u)return;const e=M(),o=Math.max(60,f.fenceFlashInterval??200);let i=!0;t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",e),t.setPaintProperty(n,"fill-opacity",.42)),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-opacity",1)),c=setInterval(()=>{i=!i;const e=i?.42:.08,o=i?1:.4;t.getLayer(n)&&t.setPaintProperty(n,"fill-opacity",e),t.getLayer(r)&&t.setPaintProperty(r,"line-opacity",o)},o)})(),!1!==f.ripple&&k(o),f.tacticalFlash&&F()},reset(){h||(L(),g=!1)},isActive:()=>g}},exports.addBreathingCircle=(t,e)=>T(t,e,J),exports.addCoordinatedCountermeasure=(t,e)=>T(t,e,Mt),exports.addCountermeasureBeam=(t,e)=>T(t,e,vt),exports.addDefenceCircle=(t,e)=>T(t,e,_t),exports.addDirectionalPulse=(t,e)=>T(t,e,ft),exports.addNavigationSpoofing=(t,e)=>T(t,e,xt),exports.addPulseMarker=(t,e)=>T(t,e,Y),exports.addRadarPowerGroup=(t,e)=>{const{source:o,layers:i}=(t=>{const e=`${t}-source`;return{source:e,layers:[{id:`${t}-fill`,type:"fill",source:e,filter:["==",["get","kind"],"fill"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-core`,type:"fill",source:e,filter:["==",["get","kind"],"core"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-ring`,type:"line",source:e,filter:["==",["get","kind"],"ring"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.95],"line-width":["coalesce",["get","width"],2]}},{id:`${t}-crosshair`,type:"line",source:e,filter:["==",["get","kind"],"crosshair"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.5],"line-width":["coalesce",["get","width"],1.4]}},{id:`${t}-labels`,type:"symbol",source:e,filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":["coalesce",["get","size"],12],"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":["coalesce",["get","color"],"#38ff4a"],"text-opacity":["coalesce",["get","opacity"],.92],"text-halo-color":["coalesce",["get","haloColor"],"rgba(15, 23, 42, 0.42)"],"text-halo-width":1}}]}})(e.id);let n=[...e.radars??[]],r=!1;t.addSource(o,{type:"geojson",data:L}),i.forEach(o=>{t.addLayer(o,e.beforeId)});const a=t.getSource(o),l=i.map(t=>t.id),c=e=>{l.forEach(o=>{t.getLayer(o)&&t.setLayoutProperty(o,"visibility",e?"visible":"none")})},s=t=>{r||(n=t.map(t=>({...t})),a.setData(W(n)))};return n.length>0&&s(n),!1===e.visible&&c(!1),{id:e.id,sourceId:o,layerIds:l,setData:s,updateRadar(t,e){const o=n.findIndex(e=>e.id===t);o<0||r||(n[o]={...n[o],...e,id:t},a.setData(W(n)))},setRadarVisible(t,e){const o=n.find(e=>e.id===t);o&&!r&&(o.visible=e,a.setData(W(n)))},removeRadar(t){r||(n=n.filter(e=>e.id!==t),a.setData(W(n)))},show(){r||c(!0)},hide(){r||c(!1)},remove(){r||(r=!0,[...l].reverse().forEach(e=>((t,e)=>{t.getLayer(e)&&t.removeLayer(e)})(t,e)),((t,e)=>{t.getSource(e)&&t.removeSource(e)})(t,o))}}},exports.addRadarSweep=(t,e)=>T(t,e,yt),exports.addRingPulseMarker=(t,e)=>T(t,e,B),exports.addSectorScan=(t,e)=>T(t,e,st),exports.addStandardElectronicFenceLayer=(t,e)=>{Ot(e.id,e.defaults);const o=new Pt,i=`${e.id}-standard-source`,n=`${e.id}-standard-extrusion`,r=`${e.id}-standard-outline`,a=`${e.id}-standard-interaction`,l=[n,r,...!1===e.interactive?[]:[a]];let c=Zt(o,e),s=!1!==e.visible,d=!1;const f=()=>{if(!d)try{t.getSource(i)||t.addSource(i,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer({id:n,type:"fill-extrusion",source:i,filter:["==",["get",Ut],"wall"],paint:{"fill-extrusion-color":["get",Bt],"fill-extrusion-opacity":1,"fill-extrusion-base":["get",Xt],"fill-extrusion-height":["get",Kt],"fill-extrusion-vertical-gradient":!0}},e.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get",Ut],"boundary"],paint:{"line-color":["get",Ht],"line-width":["get",Jt],"line-opacity":1}},e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:i,filter:["==",["get",Ut],"boundary"],paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),zt(t,l,s)}catch(o){if(!Tt(o))throw o}},h=()=>{f()};t.on("styledata",h),f();const p=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"standard",layerId:a,store:o});return Yt({id:e.id,renderer:"standard",store:o,refresh:()=>{c=Zt(o,e);const n=t.getSource(i);n?n.setData(c):f()},setPluginVisible(e){s=e,f(),zt(t,l,s)},destroy(){d=!0,t.off("styledata",h),p(),[...l].reverse().forEach(e=>{t.getLayer(e)&&t.removeLayer(e)}),t.getSource(i)&&t.removeSource(i)}})},exports.addTargetLock=(e,o)=>{const i=o.id;let n,r={...o},a=!1;const l=document.createElement("div"),c=document.createElement("div"),s=Array.from({length:4},()=>document.createElement("div")),d=Array.from({length:4},()=>document.createElement("div"));l.dataset.effectId=i,l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.pointerEvents="none",c.style.position="absolute",c.style.inset="0",l.appendChild(c),s.forEach(t=>{t.style.position="absolute",t.style.boxSizing="border-box",c.appendChild(t)}),d.forEach(t=>{t.style.position="absolute",l.appendChild(t)});const f=new t.Marker({element:l,anchor:"center"}).setLngLat(r.center).addTo(e),h=()=>{const t=r.color??"#ff3b30",e=Math.max(24,r.size??72),o=Math.max(1,r.lineWidth??2),i=Math.min(e/2,Math.max(2*o,r.cornerLength??18)),a=Math.max(2,r.crosshairLength??10),h=Math.max(0,r.crosshairGap??5);f.setLngLat(r.center),l.style.width=`${e}px`,l.style.height=`${e}px`,l.style.display=!1===r.visible?"none":"block",l.style.opacity=`${Math.min(1,Math.max(0,r.opacity??1))}`,s.forEach(t=>{t.style.width=`${i}px`,t.style.height=`${i}px`,t.style.border="0"}),Object.assign(s[0].style,{left:"0",top:"0",borderLeft:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[1].style,{right:"0",top:"0",borderRight:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[2].style,{right:"0",bottom:"0",borderRight:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),Object.assign(s[3].style,{left:"0",bottom:"0",borderLeft:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),d.forEach(e=>{e.style.display=!1===r.showCrosshair?"none":"block",e.style.background=t}),Object.assign(d[0].style,{width:`${o}px`,height:`${a}px`,left:"50%",bottom:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[1].style,{width:`${o}px`,height:`${a}px`,left:"50%",top:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[2].style,{width:`${a}px`,height:`${o}px`,right:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),Object.assign(d[3].style,{width:`${a}px`,height:`${o}px`,left:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),null==n||n.cancel(),n=void 0,c.style.transform="rotate(0deg)",!1!==r.rotate&&(n=c.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:Math.max(300,r.rotationDuration??2400),iterations:1/0}))};return h(),{id:i,update(t){a||(r={...r,...t,id:i},h())},show(){a||(r={...r,visible:!0},l.style.display="block")},hide(){a||(r={...r,visible:!1},l.style.display="none")},remove(){a||(a=!0,null==n||n.cancel(),n=void 0,f.remove())}}},exports.addWebGLElectronicFenceLayer=(t,e)=>{Ot(e.id,e.defaults);const o=(t=>({enabled:(null==t?void 0:t.enabled)??!0,fps:Math.round(Dt((null==t?void 0:t.fps)??30,1,60)),speed:Math.max(0,(null==t?void 0:t.speed)??.35),scope:(null==t?void 0:t.scope)??"all"}))(e.animation),i=new Pt,n=`${e.id}-webgl`,r=`${e.id}-webgl-interaction-source`,a=`${e.id}-webgl-interaction`,l=new de(n,o);let c=jt(i),s=le(i,e,o),d=!1!==e.visible,f=!1,h=0,p=0;const u=()=>{h&&(cancelAnimationFrame(h),h=0)},g=e=>{!f&&d&&s.animated?(("undefined"==typeof document||!document.hidden)&&e-p>=1e3/o.fps&&(p=e,t.triggerRepaint()),h=requestAnimationFrame(g)):h=0},y=()=>{const e=o.enabled&&d&&s.animated&&!!t.getLayer(n);e&&!h?(p=0,h=requestAnimationFrame(g)):e||u()},m=()=>{if(!f)try{!1===e.interactive||t.getSource(r)||t.addSource(r,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer(l,e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:r,paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),l.setVisible(d),zt(t,!1===e.interactive?[]:[a],d),y()}catch(o){if(!Tt(o))throw o}},_=()=>{m()};l.setGeometry(s),t.on("styledata",_),m();const w=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"webgl",layerId:a,store:i});return Yt({id:e.id,renderer:"webgl",store:i,refresh:()=>{s=le(i,e,o),c=jt(i),l.setGeometry(s);const n=t.getSource(r);n&&n.setData(c),m(),y()},setPluginVisible(o){d=o,l.setVisible(d),m(),zt(t,!1===e.interactive?[]:[a],d),y()},destroy(){f=!0,u(),t.off("styledata",_),w(),t.getLayer(a)&&t.removeLayer(a),t.getLayer(n)&&t.removeLayer(n),t.getSource(r)&&t.removeSource(r)}})},exports.createFenceCircle=(t,e,o)=>F(t,e,o),exports.createMap=e=>{const{style:o,tdtToken:i,...n}=e;return new t.Map({...n,style:fe(o,i)})},exports.createTiandituImageStyle=p,exports.createTiandituRasterSource=f,exports.getBaseMapStyle=m,exports.getMaplibreToolsConfig=o,exports.getOpenFreeMapStyle=l,exports.isBaseMapType=y,exports.setBaseMap=(t,e,o={})=>{const{diff:i=!1,...n}=o;t.setStyle(m(e,n),{diff:i})},exports.setMaplibreToolsConfig=t=>{Object.assign(e,t)};
|
package/dist/index.esm.js
CHANGED
|
@@ -665,7 +665,8 @@ const createManagedEffect = (map, initialOptions, renderEffect) => {
|
|
|
665
665
|
if (nextRender.startAnimation) {
|
|
666
666
|
disposeAnimation = nextRender.startAnimation({
|
|
667
667
|
getOptions: () => options,
|
|
668
|
-
setData
|
|
668
|
+
setData,
|
|
669
|
+
requestRender: () => map.triggerRepaint()
|
|
669
670
|
}) || void 0;
|
|
670
671
|
}
|
|
671
672
|
};
|
|
@@ -1176,7 +1177,8 @@ const createSectorScanRender = (options) => {
|
|
|
1176
1177
|
options.center,
|
|
1177
1178
|
options.radius
|
|
1178
1179
|
),
|
|
1179
|
-
|
|
1180
|
+
// 动画由插件主动 triggerRepaint,避免 CanvasSource 自己持续刷新一整张地图。
|
|
1181
|
+
animate: false
|
|
1180
1182
|
}
|
|
1181
1183
|
}
|
|
1182
1184
|
] : void 0,
|
|
@@ -1193,16 +1195,26 @@ const createSectorScanRender = (options) => {
|
|
|
1193
1195
|
}
|
|
1194
1196
|
}
|
|
1195
1197
|
],
|
|
1196
|
-
startAnimation: options.rotationSpeed && options.rotationSpeed !== 0 ? ({ getOptions, setData }) => {
|
|
1198
|
+
startAnimation: options.rotationSpeed && options.rotationSpeed !== 0 ? ({ getOptions, setData, requestRender }) => {
|
|
1197
1199
|
const startTime = performance.now();
|
|
1198
1200
|
let frameId = 0;
|
|
1201
|
+
let lastFrameTime = -Infinity;
|
|
1199
1202
|
const tick = (timestamp) => {
|
|
1200
1203
|
const currentOptions = getOptions();
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
+
const frameRate = currentOptions.frameRate ?? 30;
|
|
1205
|
+
const minFrameInterval = frameRate > 0 ? 1e3 / frameRate : 0;
|
|
1206
|
+
if (timestamp - lastFrameTime >= minFrameInterval) {
|
|
1207
|
+
const angleOffset = (timestamp - startTime) / 1e3 * (currentOptions.rotationSpeed || 0);
|
|
1208
|
+
const outlineVisible = (currentOptions.outlineOpacity ?? 0.95) > 0 && (currentOptions.outlineWidth ?? 2) > 0;
|
|
1209
|
+
if (canvas) {
|
|
1210
|
+
drawSectorGradientCanvas(canvas, currentOptions, angleOffset);
|
|
1211
|
+
requestRender();
|
|
1212
|
+
}
|
|
1213
|
+
if (!canvas || outlineVisible) {
|
|
1214
|
+
setData(createSectorScanData(currentOptions, angleOffset));
|
|
1215
|
+
}
|
|
1216
|
+
lastFrameTime = timestamp;
|
|
1204
1217
|
}
|
|
1205
|
-
setData(createSectorScanData(currentOptions, angleOffset));
|
|
1206
1218
|
frameId = requestAnimationFrame(tick);
|
|
1207
1219
|
};
|
|
1208
1220
|
frameId = requestAnimationFrame(tick);
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maplibre-gl")):"function"==typeof define&&define.amd?define(["exports","maplibre-gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BitAllTechMaplibreCore={},t.maplibregl)}(this,function(t,e){"use strict";const o={},i=()=>({...o}),n="https://tiles.openfreemap.org/styles",r=(t,e,o)=>({type:t,label:e,style:`${n}/${o}`}),a={"openfreemap-liberty":r("openfreemap-liberty","OpenFreeMap Liberty","liberty"),"openfreemap-bright":r("openfreemap-bright","OpenFreeMap Bright","bright"),"openfreemap-positron":r("openfreemap-positron","OpenFreeMap Positron","positron"),"openfreemap-dark":r("openfreemap-dark","OpenFreeMap Dark","dark"),"openfreemap-fiord":r("openfreemap-fiord","OpenFreeMap Fiord","fiord")},l=Object.keys(a),c=(t="openfreemap-liberty")=>a[t].style,s=["0","1","2","3","4","5","6","7"],d="© 天地图",f=(t,e)=>{const o=(t=>{const e=t||i().tdtToken;if(!e)throw new Error("Tianditu token is required. Pass token or call setMaplibreToolsConfig({ tdtToken }).");return e})(e);return s.map(e=>`https://t${e}.tianditu.gov.cn/DataServer?T=${t}&x={x}&y={y}&l={z}&tk=${o}`)},h=(t,e={})=>({type:"raster",tiles:f(t,e.token),tileSize:256,minzoom:0,maxzoom:18,attribution:d}),p=(t={})=>({type:"raster",tiles:f("vec_w",t.token),tileSize:256,minzoom:0,maxzoom:18,attribution:d}),u=(t={})=>{const e=!1!==t.label,o={"tdt-image":h("img_w",t)},i=[{id:"tdt-image",type:"raster",source:"tdt-image"}];return e&&(o["tdt-image-label"]=h("cia_w",t),i.push({id:"tdt-image-label",type:"raster",source:"tdt-image-label"})),{version:8,sources:o,layers:i}},g=(t={})=>{const e=!1!==t.label,o={"tdt-mvt":p(t)},i=[{id:"tdt-mvt",type:"raster",source:"tdt-mvt"}];return e&&(o["tdt-mvt-label"]=h("cva_w",t),i.push({id:"tdt-mvt-label",type:"raster",source:"tdt-mvt-label"})),{version:8,sources:o,layers:i}},y=[...Object.keys(a),"tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],m=t=>y.includes(t),_=(t="openfreemap-liberty",e={})=>"tdt-image"===t?u({...e,label:!1}):"tdt-image-label"===t?u({...e,label:!0}):"tdt-mvt"===t?g({...e,label:!1}):"tdt-mvt-label"===t?g({...e,label:!0}):c(t),w=6378137,v=t=>t*Math.PI/180,b=t=>180*t/Math.PI,M=t=>(t%360+360)%360,$=(t,e,o)=>{const i=e/w,n=v(o),r=v(t[1]),a=v(t[0]),l=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(n)),c=a+Math.atan2(Math.sin(n)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(l));return[(s=b(c),s>180?s-360:s<-180?s+360:s),b(l)];var s},k=(t,e)=>{const o=v(e[1]-t[1]),i=v(e[0]-t[0]),n=v(t[1]),r=v(e[1]),a=Math.sin(o/2)*Math.sin(o/2)+Math.cos(n)*Math.cos(r)*Math.sin(i/2)*Math.sin(i/2);return 12756274*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))},x=(t,e)=>{const o=v(t[1]),i=v(e[1]),n=v(e[0]-t[0]),r=Math.sin(n)*Math.cos(i),a=Math.cos(o)*Math.sin(i)-Math.sin(o)*Math.cos(i)*Math.cos(n);return M(b(Math.atan2(r,a)))},A=(t,e,o=64)=>{const i=((t,e)=>{const o=M(e)-M(t);return o<=0?o+360:o})(t,e),n=Math.max(12,Math.ceil(o*i/360));return Array.from({length:n+1},(e,o)=>M(t+i*o/n))},F=(t,e,o=64)=>(t=>{if(0===t.length)return t;const[e,o]=t[0],i=t[t.length-1];return i[0]===e&&i[1]===o?t:[...t,[e,o]]})(Array.from({length:o},(i,n)=>$(t,e,360*n/o))),C=(t,e,o=64)=>({type:"Polygon",coordinates:[F(t,e,o)]}),P=(t,e,o=64)=>({type:"LineString",coordinates:F(t,e,o)}),S=(t,e,o,i,n=64)=>{const r=A(o,i,n).map(o=>$(t,e,o));return{type:"Polygon",coordinates:[[t,...r,t]]}},O=(t,e,o,i,n=64)=>({type:"LineString",coordinates:A(o,i,n).map(o=>$(t,e,o))}),L=(t,e,o)=>({type:"LineString",coordinates:[t,$(t,e,o)]}),I={type:"FeatureCollection",features:[]},W=(t,e)=>({type:"Feature",geometry:t,properties:e}),N=(t,e)=>Math.max(0,Math.min(1,t??e)),R=t=>{var e;if(!1===t.visible)return[];const o=t.color??"#38ff4a",i=t.ringColor??o,n=Math.max(0,Math.floor(t.ringCount??4)),r=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),a=[];t.fillOpacity&&t.fillOpacity>0&&a.push(W(C(t.center,t.radius),{radarId:t.id,kind:"fill",color:t.fillColor??o,opacity:N(t.fillOpacity,0)}));for(let l=n;l>=1;l-=1){const o=t.radius*l/n;if(a.push(W(P(t.center,o),{radarId:t.id,kind:"ring",color:i,opacity:N(t.ringOpacity,.95),width:Math.max(0,t.ringWidth??2)})),!1!==t.showDistanceLabels){const n=(null==(e=t.distanceLabelFormatter)?void 0:e.call(t,o,l))??`${Math.round(o)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(e=>{a.push(W({type:"Point",coordinates:$(t.center,o,e.bearing)},{radarId:t.id,kind:"distance-label",text:n,textAnchor:e.textAnchor,color:t.distanceLabelColor??i,opacity:N(t.distanceLabelOpacity,.92),haloColor:t.distanceLabelHaloColor??"rgba(15, 23, 42, 0.42)",size:t.distanceLabelSize??12}))})}}return!1!==t.showCrosshair&&a.push(W({type:"LineString",coordinates:[$(t.center,t.radius,180),$(t.center,t.radius,0)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:N(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)}),W({type:"LineString",coordinates:[$(t.center,t.radius,270),$(t.center,t.radius,90)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:N(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)})),a.push(W(C(t.center,r),{radarId:t.id,kind:"core",color:t.coreColor??o,opacity:N(t.fillOpacity,0)})),a},q=t=>({type:"FeatureCollection",features:t.flatMap(R)}),G=(t,e)=>({type:"Feature",geometry:t,properties:e}),E=t=>({type:"FeatureCollection",features:t}),j=(t,e)=>{t.getLayer(e)&&t.removeLayer(e)},D=(t,e)=>{t.getSource(e)&&t.removeSource(e)},T=(t,e,o)=>{const i=o?"visible":"none";e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",i)})},V=t=>t instanceof Error&&"Style is not done loading."===t.message,z=(t,e,o)=>{const i=e.id,n=`${i}-source`;let r,a={...e},l=[],c=[n],s=!1,d=!1;const f=()=>{null==r||r(),r=void 0,[...l].reverse().forEach(e=>{j(t,e)}),[...c].reverse().forEach(e=>{D(t,e)}),l=[],c=[n]},h=e=>{const o=t.getSource(n);o&&o.setData(e)},p=()=>{try{(()=>{var e,i,d;if(s)return;f();const p=o(a);t.addSource(n,{type:"geojson",data:p.data}),null==(e=p.canvasSources)||e.forEach(e=>{t.addSource(e.id,e.source)}),c=[n,...(null==(i=p.canvasSources)?void 0:i.map(t=>t.id))||[]],l=p.layers.map(t=>t.id),p.layers.forEach(e=>{var o;const i="raster"===e.type&&(null==(o=p.canvasSources)?void 0:o[0])?p.canvasSources[0].id:n;t.addLayer({...e,source:i},a.beforeId)}),T(t,l,!1!==a.visible),null==(d=p.canvasSources)||d.forEach(e=>{var o;const i=t.style,n=null==(o=null==i?void 0:i.tileManagers)?void 0:o[e.id];if(!n||!n.t)return;const r=n.used;n.used=!0;const a=t;n.update(a.transform,a.terrain),n.used=r}),p.startAnimation&&(r=p.startAnimation({getOptions:()=>a,setData:h})||void 0)})(),d&&(d=!1,t.off("styledata",u))}catch(e){if(!V(e))throw e;d||(d=!0,t.on("styledata",u))}},u=()=>{d&&!s&&p()},g=()=>{s||p()};return g(),{id:i,update(t){s||(a={...a,...t,id:i},g())},show(){s||(a={...a,visible:!0},T(t,l,!0))},hide(){s||(a={...a,visible:!1},T(t,l,!1))},remove(){s||(s=!0,d&&(d=!1,t.off("styledata",u)),f())}}},Y=(t,e=0)=>{const o=Math.max(10,t.radius??70),i=Math.max(o,t.maxRadius??2.3*o),n=Math.max(1,t.pulseCount??2),r=Math.max(1,t.lineWidth??2),a=t.pulseOpacity??.9,l=[G(C(t.center,o),{kind:"core"})];for(let c=0;c<n;c+=1){const s=(e+c/n)%1,d=o+(i-o)*s;l.push(G(P(t.center,d),{kind:"pulse",opacity:a*(1-s),width:r*(1-.35*s)}))}return E(l)},U=t=>{const e=t.color||"#ff3b30",o=t.fillColor||e;return{data:Y(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":t.fillOpacity??.28}},{id:`${t.id}-pulse`,type:"line",filter:["==",["get","kind"],"pulse"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.pulseOpacity??.9],"line-width":["coalesce",["get","width"],t.lineWidth??2]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800);let i=0;const n=performance.now(),r=a=>{const l=t();e(Y(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},B=(t,e=0)=>{const o=Math.max(16,t.radius??110),i=Math.max(0,t.pulseScale??.16),n=(1-Math.cos(e*Math.PI*2))/2,r=o*(1+i*n),a=Math.max(1,t.ringCount??3),l=Math.max(2.2*r,t.maxRadius??o*(2.5*a)),c=l/a,s=t.fillOpacity??.28,d=[G(C(t.center,r),{kind:"core",opacity:s*(.88+.2*n)}),G(P(t.center,1.06*r),{kind:"core-ring",opacity:(t.lineOpacity??.95)*(.8+.2*n),width:Math.max(1,(t.lineWidth??3)*(.92+.12*n))})];for(let f=0;f<a;f+=1){const o=(f+e+1)*c%l||l,i=o/l;d.push(G(P(t.center,o),{kind:"ring",opacity:Math.max(.18,(t.lineOpacity??.95)*(1-.42*i)),width:Math.max(1,(t.lineWidth??3)*(1-.18*i))}))}return E(d)},H=t=>{const e=t.color||"#ef4444",o=t.fillColor||e;return{data:B(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-rings`,type:"line",filter:["any",["==",["get","kind"],"ring"]],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.lineOpacity??.95],"line-width":["coalesce",["get","width"],t.lineWidth??3]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(600,t().duration??2e3);let i=0;const n=performance.now(),r=a=>{const l=t();e(B(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},J=(t,e=0)=>{const o=Math.max(1,t.radius??90),i=Math.max(1,t.minRadius??.78*o),n=Math.max(i,t.maxRadius??1.22*o),r=(1-Math.cos(e*Math.PI*2))/2,a=i+(n-i)*r,l=t.fillOpacity??.28,c=t.minFillOpacity??.46*l,s=t.strokeOpacity??.82,d=t.minStrokeOpacity??.38*s,f=1-r,h=[G(C(t.center,a),{kind:"breathing-fill",opacity:c+(l-c)*f})];return(t.strokeWidth??2)>0&&h.push(G(P(t.center,a),{kind:"breathing-stroke",opacity:d+(s-d)*f})),E(h)},X=t=>{const e=t.color||"#1677ff",o=t.fillColor||e,i=t.strokeColor||e,n=Math.max(0,t.strokeWidth??2);return{data:J(t),layers:[{id:`${t.id}-breathing-fill`,type:"fill",filter:["==",["get","kind"],"breathing-fill"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-breathing-stroke`,type:"line",filter:["==",["get","kind"],"breathing-stroke"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":i,"line-opacity":["coalesce",["get","opacity"],t.strokeOpacity??.82],"line-width":n}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800),i=performance.now();let n=0;const r=a=>{const l=t();e(J(l,(a-i)%o/o)),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>{cancelAnimationFrame(n)}}}},K=(t,e,o)=>Math.min(o,Math.max(e,t)),Q=t=>{const e=t.trim(),o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const t=o[1],e=3===t.length?t.split("").map(t=>t+t).join(""):t;return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const i=e.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(i)return[K(Number(i[1]),0,255),K(Number(i[2]),0,255),K(Number(i[3]),0,255)]},Z=t=>(t%360+360)%360,tt=t=>(t-90)*Math.PI/180,et=(t,e)=>{const o=Q(t);return o?`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${K(e,0,1)})`:t},ot=t=>t*(2-t),it=(t,e)=>{const o=t.length-1;if(e<=0)return t[0];if(e>=o)return t[o];const i=Math.floor(e),n=e-i,[r,a]=[Q(t[i]),Q(t[i+1])];if(!r||!a)return t[Math.round(e)];const[l,c,s]=((t,e,o)=>[Math.round(t[0]+(e[0]-t[0])*o),Math.round(t[1]+(e[1]-t[1])*o),Math.round(t[2]+(e[2]-t[2])*o)])(r,a,n);return`rgb(${l},${c},${s})`},nt=(t,e)=>{const o=$(t,e,0)[1],i=$(t,e,90)[0],n=$(t,e,180)[1],r=$(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},rt=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2?o:void 0},at=(t,e,o=0)=>{const i=t.getContext("2d"),n=rt(e);if(!i||!e.gradient||!n)return;const r=t.width,a=r/2,l=a-2,c=e.startAngle+o,s=((t,e)=>{const o=Z(e)-Z(t);return o<=0?o+360:o})(c,e.endAngle+o),d=tt(c),f=d+s*Math.PI/180,h=e.gradient.opacity??e.opacity??.28,p=e.gradient.centerOpacity??.25*h,u=e.gradient.edgeOpacity??h,g=i.createRadialGradient(a,a,0,a,a,l);n.forEach((t,e)=>{const o=e/Math.max(1,n.length-1),i=p+(u-p)*o;g.addColorStop(o,et(t,i))}),i.clearRect(0,0,r,r),i.save(),i.beginPath(),i.moveTo(a,a),i.arc(a,a,l,d,f,!1),i.closePath(),i.clip(),i.fillStyle=g,i.fillRect(0,0,r,r),i.restore()},lt=t=>{if(!rt(t))return;const e=(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})();return at(e,t),e},ct=(t,e,o)=>rt(t)?[]:[G(S(t.center,t.radius,e,o),{kind:"sector",color:t.color||"#ff453a",opacity:t.opacity??.28})],st=(t,e=0)=>{const o=t.startAngle+e,i=t.endAngle+e,n=[...ct(t,o,i),G(L(t.center,t.radius,o),{kind:"frame"}),G(L(t.center,t.radius,i),{kind:"frame"})];return E(n)},dt=t=>{const e=lt(t),o=e?{id:`${t.id}-sector-fill`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-sector-fill`,type:"fill",filter:["==",["get","kind"],"sector"],paint:{"fill-color":["coalesce",["get","color"],t.color||"#ff453a"],"fill-opacity":["coalesce",["get","opacity"],t.opacity??.28],"fill-antialias":!1}};return{data:st(t),canvasSources:e?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:nt(t.center,t.radius),animate:Boolean(t.rotationSpeed&&0!==t.rotationSpeed)}}]:void 0,layers:[o,{id:`${t.id}-sector-frame`,type:"line",filter:["==",["get","kind"],"frame"],paint:{"line-color":t.outlineColor||t.color||"#ff453a","line-opacity":t.outlineOpacity??.95,"line-width":t.outlineWidth??2}}],startAnimation:t.rotationSpeed&&0!==t.rotationSpeed?({getOptions:t,setData:o})=>{const i=performance.now();let n=0;const r=a=>{const l=t(),c=(a-i)/1e3*(l.rotationSpeed||0);e&&at(e,l,c),o(st(l,c)),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>{cancelAnimationFrame(n)}}:void 0}},ft=(t,e)=>{const o=Math.max(40,t.radius),i=t.direction??270,n=Math.min(180,Math.max(8,t.spread??72)),r=Math.max(1,t.lineCount??7),a=Math.max(20,t.lineSpacing??Math.max(80,o/9)),l=e??0,c=Math.max(0,Math.min(.35*o,t.innerRadius??Math.min(.4*a,120))),s=i-n/2,d=i+n/2,f=[];for(let h=0;h<r;h+=1){const e=c+l+h*a;if(e>o)continue;const i=e/o,n=1-h/Math.max(1,r);f.push(G(O(t.center,e,s,d),{kind:"directional-pulse-line",opacity:Math.max(.08,(t.opacity??.92)*(.42+.58*n)*(1-.28*i)),width:Math.max(1,(t.lineWidth??2.8)*(.86+.24*n)*(1-.08*i))}))}return E(f)},ht=t=>({data:ft(t),layers:[{id:`${t.id}-directional-pulse`,type:"line",filter:["==",["get","kind"],"directional-pulse-line"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.color||"#ef4444","line-opacity":["coalesce",["get","opacity"],t.opacity??.92],"line-width":["coalesce",["get","width"],t.lineWidth??2.8]}}],startAnimation:t.speed&&t.speed>0?({getOptions:t,setData:e})=>{const o=performance.now();let i=0;const n=r=>{const a=t(),l=Math.max(40,a.radius),c=Math.max(20,a.lineSpacing??Math.max(80,l/9)),s=(r-o)/1e3*(a.speed??0)%c;e(ft(a,s)),i=requestAnimationFrame(n)};return i=requestAnimationFrame(n),()=>{cancelAnimationFrame(i)}}:void 0}),pt=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2},ut=(t,e)=>{const o=$(t,e,0)[1],i=$(t,e,90)[0],n=$(t,e,180)[1],r=$(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},gt=(t,e,o=0)=>{const i=t.getContext("2d"),n=e.gradient,r=null==n?void 0:n.colors;if(!i||!n||!r||r.length<2)return;const a=t.width,l=a/2,c=l-2,s=Math.max(12,e.sweepAngle??42),d=e.tailOpacity??.04,f=Math.max(.24,e.opacity??.3),h=(e.sweepStartAngle??0)+o,p=h,u=h+s,g=s;i.clearRect(0,0,a,a);const y=i.createConicGradient(tt(p),l,l),m=g/360,_=Math.min(1,f+.08);for(let w=0;w<=128;w++){const t=w/128,e=d+(_-d)*ot(t),o=t*(r.length-1),i=it(r,o);y.addColorStop(t*m,et(i,Math.max(0,e)))}i.save(),i.beginPath(),i.moveTo(l,l),i.arc(l,l,c,tt(p),tt(u),!1),i.closePath(),i.fillStyle=y,i.fill(),i.restore()},yt=(t,e=0)=>{var o;const i=Math.max(0,t.ringCount??4),n=Math.max(12,t.sweepAngle??42),r=t.headOpacity??Math.max(.24,t.opacity??.3),a=(t.sweepStartAngle??0)+e,l=!1!==t.showCrosshair,c=!1!==t.showDistanceLabels,s=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),d=pt(t),f=[];for(let h=i;h>=1;h-=1){const e=t.radius*h/i;if(f.push(G(P(t.center,e),{kind:"ring"})),c){const i=(null==(o=t.distanceLabelFormatter)?void 0:o.call(t,e,h))??`${Math.round(e)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(o=>{f.push(G({type:"Point",coordinates:$(t.center,e,o.bearing)},{kind:"distance-label",text:i,textAnchor:o.textAnchor}))})}}return l&&f.push(G({type:"LineString",coordinates:[$(t.center,t.radius,180),$(t.center,t.radius,0)]},{kind:"crosshair"}),G({type:"LineString",coordinates:[$(t.center,t.radius,270),$(t.center,t.radius,90)]},{kind:"crosshair"})),f.push(G(C(t.center,s),{kind:"core"})),d||f.push(G(S(t.center,t.radius,a,a+n),{kind:"sweep",opacity:r})),E(f)},mt=t=>{const e=pt(t),o=e?(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})():void 0,i=0!==(t.rotationSpeed??36);o&>(o,t);const n=o?{id:`${t.id}-radar-trail`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-radar-trail`,type:"fill",filter:["==",["get","kind"],"sweep"],paint:{"fill-color":t.color||"#22c55e","fill-opacity":["coalesce",["get","opacity"],t.opacity??.32]}};return{data:yt(t),canvasSources:o?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:o,coordinates:ut(t.center,t.radius),animate:i}}]:void 0,layers:[n,{id:`${t.id}-radar-rings`,type:"line",filter:["==",["get","kind"],"ring"],paint:{"line-color":t.ringColor||t.color||"#22c55e","line-opacity":t.ringOpacity??.95,"line-width":t.ringWidth??2}},{id:`${t.id}-radar-crosshair`,type:"line",filter:["==",["get","kind"],"crosshair"],paint:{"line-color":t.crosshairColor||t.ringColor||t.color||"#22c55e","line-opacity":t.crosshairOpacity??.5,"line-width":t.crosshairWidth??1.4}},{id:`${t.id}-radar-distance-labels`,type:"symbol",filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":t.distanceLabelSize??12,"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":t.distanceLabelColor||t.ringColor||t.color||"#22c55e","text-opacity":t.distanceLabelOpacity??.92,"text-halo-color":t.distanceLabelHaloColor||"rgba(15, 23, 42, 0.42)","text-halo-width":1}}],startAnimation:i?({getOptions:t,setData:i})=>{const n=performance.now();let r=0;const a=l=>{const c=t(),s=(l-n)/1e3*(c.rotationSpeed??36);o&>(o,c,s),e||i(yt(c,s)),r=requestAnimationFrame(a)};return r=requestAnimationFrame(a),()=>{cancelAnimationFrame(r)}}:void 0}},_t=(t,e)=>{const o=$(t,e,0)[1],i=$(t,e,90)[0],n=$(t,e,180)[1],r=$(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},wt=t=>{const e=(()=>{const t=document.createElement("canvas");return t.width=512,t.height=512,t})();((t,e)=>{const o=t.getContext("2d");if(!o)return;const i=t.width,n=i/2,r=n-1,a=e.color||"#06c536",l=e.fillColor||a,c=e.borderColor||a,s=e.fillOpacity??.06,d=e.borderOpacity??.92;o.clearRect(0,0,i,i),o.save(),o.beginPath(),o.arc(n,n,r,0,2*Math.PI),o.clip();const f=o.createRadialGradient(n,n,0,n,n,r),h=Math.min(.8,s+.85*(d-s));f.addColorStop(0,et(l,s)),f.addColorStop(.85,et(l,s)),f.addColorStop(.92,et(c,s+.3*(h-s))),f.addColorStop(.96,et(c,s+.7*(h-s))),f.addColorStop(1,et(c,h)),o.fillStyle=f,o.fillRect(0,0,i,i),o.restore()})(e,t);const o=t.borderColor||t.color||"#06c536";return{data:E([G(P(t.center,t.radius),{kind:"defence-border"})]),canvasSources:[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:_t(t.center,t.radius),animate:!0}}],layers:[{id:`${t.id}-defence-circle`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}},{id:`${t.id}-defence-border`,type:"line",filter:["==",["get","kind"],"defence-border"],paint:{"line-color":o,"line-opacity":t.borderOpacity??.92,"line-width":t.borderWidth??2}}]}},vt=(t,e=0)=>{const o=Math.max(1,t.sourceWidth??220),i=Math.max(1,t.targetWidth??45),n=(t=>{const e=t.target||$(t.center,t.distance||0,t.bearing||0),o=void 0!==t.target?x(t.center,t.target):M(t.bearing||0),i=$(t.center,t.startWidth/2,o-90),n=$(t.center,t.startWidth/2,o+90);return{polygon:{type:"Polygon",coordinates:[[i,$(e,t.endWidth/2,o-90),$(e,t.endWidth/2,o+90),n,i]]},centerLine:{type:"LineString",coordinates:[t.center,e]}}})({center:t.center,target:t.target,startWidth:o,endWidth:i}),r=[G(n.polygon,{kind:"countermeasure-channel"}),G(n.centerLine,{kind:"countermeasure-line"})],a=k(t.center,t.target),l=x(t.center,t.target),c=Math.max(0,Math.floor(t.particleCount??18)),s=Math.max(300,t.particleDuration??1200),d=e%s/s,f=Math.max(1,t.particleRadius??2.8);if(a>0)for(let h=0;h<c;h+=1){const e=(d+h/c)%1;r.push(G({type:"Point",coordinates:$(t.center,a*e,l)},{kind:"countermeasure-particle",opacity:.25+.75*e,radius:f*(.7+.3*e)}))}if(!1!==t.targetRipple){const o=Math.max(1,Math.floor(t.targetRippleCount??2)),i=Math.max(10,t.targetRippleRadius??120),n=Math.max(300,t.targetRippleDuration??900),a=e%n/n;for(let e=0;e<o;e+=1){const n=(a+e/o)%1,l="forcedLanding"===t.mode?1-n:n;r.push(G(P(t.target,Math.max(2,i*l)),{kind:"countermeasure-target-ripple",opacity:.9*Math.sin(Math.PI*n)}))}}return E(r)},bt=t=>{const e=t.color??"#a855f7",o=t.lineColor??"#f0abfc",i=Math.max(1,t.lineWidth??2.5);return{data:vt(t),layers:[{id:`${t.id}-countermeasure-channel`,type:"fill",filter:["==",["get","kind"],"countermeasure-channel"],paint:{"fill-color":t.channelColor??e,"fill-opacity":t.channelOpacity??.16}},{id:`${t.id}-countermeasure-glow`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":.28*(t.lineOpacity??.92),"line-width":4*i,"line-blur":1.4*i}},{id:`${t.id}-countermeasure-line`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":t.lineOpacity??.92,"line-width":i}},{id:`${t.id}-countermeasure-target-ripple`,type:"line",filter:["==",["get","kind"],"countermeasure-target-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.9],"line-width":Math.max(1,t.targetRippleWidth??2.5)}},{id:`${t.id}-countermeasure-particle`,type:"circle",filter:["==",["get","kind"],"countermeasure-particle"],paint:{"circle-color":t.particleColor??o,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.8],"circle-blur":.18,"circle-stroke-color":"#ffffff","circle-stroke-opacity":.45,"circle-stroke-width":.5}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(vt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},Mt=(t,e=0)=>{const o=[],i=new Set,n=Math.max(0,Math.floor(t.particleCount??5)),r=Math.max(300,t.particleDuration??1600),a=e%r/r,l=Math.max(1,t.particleRadius??2.5);if(t.links.forEach((e,r)=>{const c=e.color??("detection"===(s=e.type)?"#38bdf8":"command"===s?"#22d3ee":"#f97316");var s;const d=k(e.from,e.to),f=x(e.from,e.to);if(o.push(G({type:"LineString",coordinates:[e.from,e.to]},{kind:"coordination-link",linkType:e.type,color:c})),!1!==t.showNodes&&[e.from,e.to].forEach(t=>{const e=`${t[0]},${t[1]}`;i.has(e)||(i.add(e),o.push(G({type:"Point",coordinates:t},{kind:"coordination-node",color:c})))}),!(d<=0))for(let i=0;i<n;i+=1){const s=(a+i/n+r/t.links.length)%1;o.push(G({type:"Point",coordinates:$(e.from,d*s,f)},{kind:"coordination-particle",color:c,opacity:.35+.65*s,radius:l}))}}),!1!==t.targetRipple){const i=Math.max(300,t.targetRippleDuration??1200),n=e%i/i,r=Math.max(10,t.targetRippleRadius??100)*n;o.push(G(P(t.center,Math.max(2,r)),{kind:"coordination-target-ripple",opacity:.9*(1-n)}))}return E(o)},$t=t=>{const e=Math.max(1,t.lineWidth??2.2),o=t.lineOpacity??.9;return{data:Mt(t),layers:[{id:`${t.id}-coordination-detection`,type:"line",filter:["==",["get","linkType"],"detection"],paint:{"line-color":["coalesce",["get","color"],"#38bdf8"],"line-opacity":o,"line-width":e,"line-dasharray":[2,2]}},{id:`${t.id}-coordination-command`,type:"line",filter:["==",["get","linkType"],"command"],paint:{"line-color":["coalesce",["get","color"],"#22d3ee"],"line-opacity":o,"line-width":e,"line-dasharray":[.5,1.8]}},{id:`${t.id}-coordination-countermeasure`,type:"line",filter:["==",["get","linkType"],"countermeasure"],paint:{"line-color":["coalesce",["get","color"],"#f97316"],"line-opacity":o,"line-width":e+.8}},{id:`${t.id}-coordination-target-ripple`,type:"line",filter:["==",["get","kind"],"coordination-target-ripple"],paint:{"line-color":"#ff3b30","line-opacity":["coalesce",["get","opacity"],.9],"line-width":2.5}},{id:`${t.id}-coordination-node`,type:"circle",filter:["==",["get","kind"],"coordination-node"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-radius":Math.max(2,t.nodeRadius??5),"circle-stroke-color":"#ffffff","circle-stroke-width":1.5}},{id:`${t.id}-coordination-particle`,type:"circle",filter:["==",["get","kind"],"coordination-particle"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.5],"circle-blur":.1}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(Mt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},kt=(t,e=0)=>{const o=[G({type:"LineString",coordinates:[t.center,t.spoofedPosition]},{kind:"spoofing-offset"})],i=k(t.center,t.spoofedPosition),n=x(t.center,t.spoofedPosition),r=Math.max(0,Math.floor(t.particleCount??10)),a=Math.max(300,t.particleDuration??1800),l=e%a/a;if(!1!==t.showTruePosition&&o.push(G({type:"Point",coordinates:t.center},{kind:"spoofing-true-position"})),!1!==t.showSpoofedPosition&&o.push(G({type:"Point",coordinates:t.spoofedPosition},{kind:"spoofing-ghost"})),i>0)for(let c=0;c<r;c+=1){const e=(l+c/r)%1;o.push(G({type:"Point",coordinates:$(t.center,i*e,n)},{kind:"spoofing-particle",opacity:.25+.75*e}))}if(!1!==t.ripple){const i=Math.max(1,Math.floor(t.rippleCount??2)),n=Math.max(300,t.rippleDuration??1200),r=Math.max(10,t.rippleRadius??120),a=e%n/n;for(let e=0;e<i;e+=1){const n=(a+e/i)%1;o.push(G(P(t.spoofedPosition,Math.max(2,r*n)),{kind:"spoofing-ripple",opacity:.75*(1-n)}))}}return E(o)},xt=t=>{const e=t.color??"#8b5cf6";return{data:kt(t),layers:[{id:`${t.id}-spoofing-offset`,type:"line",filter:["==",["get","kind"],"spoofing-offset"],layout:{"line-cap":"round"},paint:{"line-color":t.lineColor??e,"line-opacity":t.lineOpacity??.82,"line-width":Math.max(1,t.lineWidth??2),"line-dasharray":[1.2,2]}},{id:`${t.id}-spoofing-ripple`,type:"line",filter:["==",["get","kind"],"spoofing-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.75],"line-width":2}},{id:`${t.id}-spoofing-true-position`,type:"circle",filter:["==",["get","kind"],"spoofing-true-position"],paint:{"circle-color":"#ffffff","circle-radius":5,"circle-stroke-color":e,"circle-stroke-width":2}},{id:`${t.id}-spoofing-ghost`,type:"circle",filter:["==",["get","kind"],"spoofing-ghost"],paint:{"circle-color":e,"circle-opacity":t.ghostOpacity??.42,"circle-radius":Math.max(2,t.ghostRadius??8),"circle-stroke-color":"#ffffff","circle-stroke-opacity":.8,"circle-stroke-width":1.5}},{id:`${t.id}-spoofing-particle`,type:"circle",filter:["==",["get","kind"],"spoofing-particle"],paint:{"circle-color":e,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":Math.max(1,t.particleRadius??2.5),"circle-blur":.12}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(kt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},At="__electronic_fence_id",Ft=t=>JSON.parse(JSON.stringify(t)),Ct=t=>{const e=t.map(t=>{const e=Number(t[0]),o=Number(t[1]);if(!Number.isFinite(e)||!Number.isFinite(o))throw new Error("电子围栏坐标必须是有限数字。");return[e,o]});if(e.length<3)throw new Error("电子围栏的每个环至少需要 3 个不同坐标。");var o,i;if(o=e[0],i=e[e.length-1],(o[0]!==i[0]||o[1]!==i[1])&&e.push([...e[0]]),e.length<4)throw new Error("电子围栏 Polygon 环无效。");return e},Pt=t=>{if("string"!=typeof t.id||!t.id.trim())throw new Error("电子围栏必须提供非空字符串 id。");if(!t.geometry||"Polygon"!==t.geometry.type)throw new Error(`电子围栏 ${t.id} 仅支持 Polygon geometry。`);const e=Ft(t.properties||{});return{type:"Feature",id:t.id,geometry:{type:"Polygon",coordinates:t.geometry.coordinates.map(Ct)},properties:e}};class St{constructor(){this.features=new Map,this.states=new Map,this.activeIds=new Set,this.hiddenIds=new Set}setData(t){const e=new Map;t.features.forEach(t=>{const o=Pt(t);if(e.has(o.id))throw new Error(`电子围栏 id 重复:${o.id}`);e.set(o.id,o)}),this.features=e,this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}add(t){const e=Pt(t);if(this.features.has(e.id))throw new Error(`电子围栏 id 已存在:${e.id}`);return this.features.set(e.id,e),e.id}update(t,e){const o=this.requireFeature(t);this.features.set(t,((t,e)=>{const o=t.properties||{},i=e.properties||{},n=i.style?{...o.style||{},...i.style}:o.style;return Pt({...Ft(t),geometry:e.geometry?Ft(e.geometry):Ft(t.geometry),properties:{...Ft(o),...Ft(i),...n?{style:n}:{}}})})(o,e))}remove(t){this.requireFeature(t),this.features.delete(t),this.states.delete(t),this.activeIds.delete(t),this.hiddenIds.delete(t)}clear(){this.features.clear(),this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}setActive(t,e){this.requireFeature(t),e?this.activeIds.add(t):this.activeIds.delete(t)}setState(t,e){if(this.requireFeature(t),"normal"!==e&&"warning"!==e&&"alarm"!==e&&"disabled"!==e)throw new Error(`电子围栏 ${t} 的渲染状态无效。`);"normal"===e?this.states.delete(t):this.states.set(t,e)}setVisible(t,e){this.requireFeature(t),e?this.hiddenIds.delete(t):this.hiddenIds.add(t)}isActive(t){return this.activeIds.has(t)}getState(t){return this.requireFeature(t),this.states.get(t)||"normal"}get(t){const e=this.features.get(t);return e?Ft(e):void 0}values(){return Array.from(this.features.values())}visibleValues(){return this.values().filter(t=>!this.hiddenIds.has(t.id))}requireFeature(t){const e=this.features.get(t);if(!e)throw new Error(`电子围栏不存在:${t}`);return e}}const Ot=(t,e,o,i=!1)=>{const n=void 0===t?e:Number(t);if(!Number.isFinite(n)||i&&n<=0)throw new Error(`${o} 必须是${i?"大于 0 的":"有限"}数字。`);return n},Lt=(t,e)=>{if(!t.trim())throw new Error("电子围栏插件 id 不能为空。");Ot(e.baseHeight,0,"defaults.baseHeight"),Ot(e.height,0,"defaults.height",!0),Ot(e.thickness,1,"defaults.thickness",!0)},It=t=>({baseHeight:Ot(t.baseHeight,0,"defaults.baseHeight"),height:Ot(t.height,0,"defaults.height",!0),thickness:Ot(t.thickness,1,"defaults.thickness",!0)}),Wt=(t,e)=>"normal"!==t?t:e?"active":"normal",Nt=t=>{var e,o;return{...{...t.defaults.normal,...(null==(e=t.overrides)?void 0:e.normal)||{}},..."normal"===t.state?{}:{...t.defaults[t.state],...(null==(o=t.overrides)?void 0:o[t.state])||{}}}},Rt=(t,e)=>{const o=e/2,i=[];return t.coordinates.forEach(t=>{const e=[];for(let o=0;o<t.length-1;o+=1){const i=[t[o][0],t[o][1]],n=[t[o+1][0],t[o+1][1]],r=k(i,n);r<.01||e.push({start:i,end:n,length:r,bearing:x(i,n)})}const n=e.reduce((t,e)=>t+e.length,0);let r=0;e.forEach(t=>{const e=$(t.start,o,t.bearing+180),a=$(t.end,o,t.bearing);i.push({startLeft:$(e,o,t.bearing-90),startRight:$(e,o,t.bearing+90),endLeft:$(a,o,t.bearing-90),endRight:$(a,o,t.bearing+90),startProgress:n?r/n:0,endProgress:n?(r+t.length)/n:1}),r+=t.length})}),i},qt=t=>({type:"MultiPolygon",coordinates:t.map(t=>[[t.startLeft,t.endLeft,t.endRight,t.startRight,t.startLeft]])}),Gt=(t,e,o)=>Math.min(o,Math.max(e,t)),Et=t=>{const e=t.trim().toLowerCase();if(e.startsWith("#")){const t=e.slice(1),o=3===t.length||4===t.length?t.split("").map(t=>t+t).join(""):t;if(6===o.length||8===o.length){const t=Number.parseInt(o,16);if(Number.isFinite(t))return[(t>>(8===o.length?24:16)&255)/255,(t>>(8===o.length?16:8)&255)/255,(t>>(8===o.length?8:0)&255)/255,8===o.length?(255&t)/255:1]}}const o=e.match(/^rgba?\(([^)]+)\)$/);if(o){const t=o[1].split(",").map(t=>Number(t.trim()));if(t.length>=3&&t.every(t=>Number.isFinite(t)))return[Gt(t[0]/255,0,1),Gt(t[1]/255,0,1),Gt(t[2]/255,0,1),Gt(t[3]??1,0,1)]}throw new Error(`暂不支持的围栏颜色格式:${t}`)},jt=(t,e=1)=>{const[o,i,n,r]=Et(t);return`rgba(${Math.round(255*o)}, ${Math.round(255*i)}, ${Math.round(255*n)}, ${Gt(r*e,0,1)})`},Dt=Gt,Tt=t=>({type:"FeatureCollection",features:t.visibleValues().map(t=>({type:"Feature",id:`${t.id}:interaction`,geometry:Ft(t.geometry),properties:{[At]:t.id}}))}),Vt=t=>{let e;const o=e=>{var o;if(!t.map.getLayer(t.layerId))return;const i=t.map.queryRenderedFeatures(e.point,{layers:[t.layerId]})[0],n=null==(o=null==i?void 0:i.properties)?void 0:o[At];return"string"==typeof n?n:void 0},i=(e,o,i)=>{const n=t.store.get(o);n&&t.map.fire(`fence.${e}`,{instanceId:t.instanceId,renderer:t.renderer,id:o,feature:n,originalEvent:i})},n=t=>{const e=o(t);e&&i("click",e,t)},r=t=>{const n=o(t);n!==e&&(e&&i("mouseleave",e,t),e=n,e&&i("mouseenter",e,t))},a=t=>{e&&(i("mouseleave",e,t),e=void 0)};return t.map.on("click",n),t.map.on("mousemove",r),t.map.on("mouseout",a),()=>{t.map.off("click",n),t.map.off("mousemove",r),t.map.off("mouseout",a)}},zt=t=>t instanceof Error&&"Style is not done loading."===t.message,Yt=(t,e,o)=>{e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",o?"visible":"none")})},Ut=t=>{let e=!1;const o=()=>{if(e)throw new Error(`电子围栏插件 ${t.id} 已销毁。`)};return{id:t.id,renderer:t.renderer,setData(e){o(),t.store.setData(e),t.refresh()},add(e){o();const i=t.store.add(e);return t.refresh(),i},update(e,i){o(),t.store.update(e,i),t.refresh()},removeFeature(e){o(),t.store.remove(e),t.refresh()},clear(){o(),t.store.clear(),t.refresh()},setFeatureState(e,i){o(),t.store.setState(e,i),t.refresh()},setFeatureActive(e,i){o(),t.store.setActive(e,i),t.refresh()},setFeatureVisible(e,i){o(),t.store.setVisible(e,i),t.refresh()},show(){o(),t.setPluginVisible(!0)},hide(){o(),t.setPluginVisible(!1)},destroy(){e||(e=!0,t.destroy())}}},Bt="__electronic_fence_kind",Ht="__electronic_fence_color",Jt="__electronic_fence_outline_color",Xt="__electronic_fence_outline_width",Kt="__electronic_fence_base",Qt="__electronic_fence_top",Zt={normal:{color:"#d8b4fe",opacity:.28,outlineColor:"#f5e9ff",outlineWidth:1.5},active:{color:"#c084fc",opacity:.42,outlineColor:"#ffffff",outlineWidth:2.5},warning:{color:"#f59e0b",opacity:.38,outlineColor:"#fde68a",outlineWidth:2},alarm:{color:"#ef4444",opacity:.48,outlineColor:"#ffffff",outlineWidth:2.5},disabled:{color:"#94a3b8",opacity:.16,outlineColor:"#cbd5e1",outlineWidth:1}},te=(t,e)=>{const o=[],i=It(e.defaults);return t.visibleValues().forEach(n=>{const r=Wt(t.getState(n.id),t.isActive(n.id)),a=Nt({defaults:Zt,overrides:e.styles,state:r}),l=Rt(n.geometry,i.thickness),c={[At]:n.id,[Ht]:jt(a.color,Dt(a.opacity,0,1)),[Jt]:jt(a.outlineColor),[Xt]:Math.max(0,a.outlineWidth),[Kt]:i.baseHeight,[Qt]:i.baseHeight+i.height};l.length&&o.push({type:"Feature",id:`${n.id}:wall`,geometry:qt(l),properties:{...c,[Bt]:"wall"}}),o.push({type:"Feature",id:`${n.id}:boundary`,geometry:n.geometry,properties:{...c,[Bt]:"boundary"}})}),{type:"FeatureCollection",features:o}},ee=[{thicknessScale:.08,opacity:1},{thicknessScale:.22,opacity:.56},{thicknessScale:.45,opacity:.28},{thicknessScale:.8,opacity:.12},{thicknessScale:1.3,opacity:.045}],oe={normal:{color:"#d8b4fe",opacity:.2,outlineColor:"#f5e9ff",outlineWidth:1.5,glowStrength:1,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.18},active:{color:"#e9d5ff",opacity:.28,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.25,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.2},warning:{color:"#f59e0b",opacity:.25,outlineColor:"#fde68a",outlineWidth:2,glowStrength:1.1,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.18},alarm:{color:"#ef4444",opacity:.3,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.35,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.2},disabled:{color:"#94a3b8",opacity:.12,outlineColor:"#cbd5e1",outlineWidth:1,glowStrength:0,flowColor:"#ffffff",flowCount:0,flowLineStyle:"dashed",flowWidth:0}},ie=(t,o)=>{const i=e.MercatorCoordinate.fromLngLat(t,o);return[i.x,i.y,i.z]},ne=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],re=(t,e,o)=>{const i=ne(e,t),n=ne(o,t);return(t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]})([i[1]*n[2]-i[2]*n[1],i[2]*n[0]-i[0]*n[2],i[0]*n[1]-i[1]*n[0]])},ae=(t,e,o,i,n)=>{const r=re(e[0],e[1],e[2]);[0,1,2,0,2,3].forEach(a=>{((t,e,o,i,n,r)=>{t.push(...e,...o,i,n,...r.color,r.flowColor[0],r.flowColor[1],r.flowColor[2],r.glowStrength,r.flowWidth,r.flowCount,r.flowLineStyle)})(t,e[a],r,o[a],i[a],n)})},le=(t,e,o,i,n)=>{const r=o+i,a=ie(e.startLeft,o),l=ie(e.startRight,o),c=ie(e.endLeft,o),s=ie(e.endRight,o),d=ie(e.startLeft,r),f=ie(e.startRight,r),h=ie(e.endLeft,r),p=ie(e.endRight,r);ae(t,[d,h,p,f],[1,1,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),ae(t,[a,c,h,d],[0,0,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),ae(t,[s,l,f,p],[0,0,1,1],[e.endProgress,e.startProgress,e.startProgress,e.endProgress],n)},ce=(t,e,o)=>{const i=ee.map(()=>[]),n=[],r=It(e.defaults);let a=!1;t.visibleValues().forEach(l=>{const c=t.isActive(l.id),s=Wt(t.getState(l.id),c),d=Nt({defaults:oe,overrides:e.styles,state:s}),f=o.enabled&&("all"===o.scope||(t=>"active"===t||"warning"===t||"alarm"===t)(s)),h=((t,e)=>{const o=Et(t.color),i=Et(t.flowColor),n=e&&t.flowCount>0?Math.round(Dt(t.flowCount,1,8)):0;return{color:[o[0],o[1],o[2],Dt(o[3]*t.opacity,0,1)],flowColor:i,glowStrength:Dt(t.glowStrength,0,4),flowCount:n,flowLineStyle:"solid"===t.flowLineStyle?0:1,flowWidth:n>0?Dt(t.flowWidth,.01,.49):0}})(d,f);Rt(l.geometry,r.thickness).forEach(t=>{le(n,t,r.baseHeight,r.height,h)}),h.glowStrength>0&&ee.forEach((t,e)=>{const o=r.thickness*(1+Math.min(h.glowStrength,2)*t.thicknessScale);Rt(l.geometry,o).forEach(t=>{le(i[e],t,r.baseHeight,r.height,h)})}),a||(a=h.flowCount>0&&h.flowWidth>0)});const l=i.reduce((t,e)=>t+e.length,0),c=new Float32Array(l+n.length),s=[];let d=0;i.forEach((t,e)=>{const o=t.length/19;o>0&&s.push({first:d/19,count:o,opacity:ee[e].opacity}),c.set(t,d),d+=t.length});const f=d/19;return c.set(n,d),{vertices:c,glowPasses:s,bodyFirst:f,bodyVertexCount:n.length/19,animated:a}},se=(t,e,o)=>{const i=t.createShader(e);if(!i)throw new Error("无法创建电子围栏 WebGL shader。");if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(i)||"未知 shader 编译错误";throw t.deleteShader(i),new Error(`电子围栏 WebGL shader 编译失败:${e}`)}return i},de=(t,e,o)=>{const i=t.getUniformLocation(e,o);if(!i)throw new Error(`电子围栏 WebGL uniform 不存在:${o}`);return i};class fe{constructor(t,e){this.type="custom",this.renderingMode="3d",this.geometry={vertices:new Float32Array,glowPasses:[],bodyFirst:0,bodyVertexCount:0,animated:!1},this.visible=!0,this.id=t,this.animation=e}setGeometry(t){var e;this.geometry=t,this.uploadGeometry(),null==(e=this.map)||e.triggerRepaint()}setVisible(t){var e;this.visible=t,null==(e=this.map)||e.triggerRepaint()}onAdd(t,e){if(this.map=t,this.gl=e,this.program=(t=>{const e="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext,o=e?"#version 300 es\n precision highp float;\n in vec3 a_position;\n in vec3 a_normal;\n in float a_height_ratio;\n in float a_path_progress;\n in vec4 a_color;\n in vec3 a_flow_color;\n in float a_glow_strength;\n in float a_flow_width;\n in float a_flow_count;\n in float a_flow_line_style;\n uniform mat4 u_matrix;\n out vec3 v_normal;\n out float v_height_ratio;\n out float v_path_progress;\n out vec4 v_color;\n out vec3 v_flow_color;\n out float v_glow_strength;\n out float v_flow_width;\n out float v_flow_count;\n out float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ":"\n precision highp float;\n attribute vec3 a_position;\n attribute vec3 a_normal;\n attribute float a_height_ratio;\n attribute float a_path_progress;\n attribute vec4 a_color;\n attribute vec3 a_flow_color;\n attribute float a_glow_strength;\n attribute float a_flow_width;\n attribute float a_flow_count;\n attribute float a_flow_line_style;\n uniform mat4 u_matrix;\n varying vec3 v_normal;\n varying float v_height_ratio;\n varying float v_path_progress;\n varying vec4 v_color;\n varying vec3 v_flow_color;\n varying float v_glow_strength;\n varying float v_flow_width;\n varying float v_flow_count;\n varying float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ",i="\n precision highp float;\n uniform float u_time;\n uniform float u_speed;\n uniform float u_animation_enabled;\n uniform float u_glow_pass;\n uniform float u_glow_opacity;\n VARYING vec3 v_normal;\n VARYING float v_height_ratio;\n VARYING float v_path_progress;\n VARYING vec4 v_color;\n VARYING vec3 v_flow_color;\n VARYING float v_glow_strength;\n VARYING float v_flow_width;\n VARYING float v_flow_count;\n VARYING float v_flow_line_style;\n void main() {\n float bandCore = 0.0;\n float bandGlow = 0.0;\n float verticalFace = 1.0 - smoothstep(\n 0.82,\n 0.98,\n abs(normalize(v_normal).z)\n );\n\n if (\n u_animation_enabled > 0.5 &&\n v_flow_count > 0.5 &&\n v_flow_width > 0.0001\n ) {\n float count = max(v_flow_count, 1.0);\n float phase = fract(\n v_height_ratio * count + u_time * u_speed * count\n );\n float bandDistance = abs(phase - 0.5);\n float dashPhase = fract(\n v_path_progress * 36.0 - u_time * u_speed * 2.4\n );\n float dash = smoothstep(0.02, 0.1, dashPhase) *\n (1.0 - smoothstep(0.62, 0.74, dashPhase));\n float linePattern = v_flow_line_style > 0.5 ? dash : 1.0;\n\n bandCore = 1.0 - smoothstep(\n max(v_flow_width * 0.08, 0.001),\n max(v_flow_width * 0.42, 0.003),\n bandDistance\n );\n float glowDistance = bandDistance / max(v_flow_width, 0.001);\n bandGlow = exp(\n -glowDistance * glowDistance * 2.6\n );\n bandCore *= linePattern * verticalFace;\n bandGlow *= verticalFace;\n }\n\n if (u_glow_pass > 0.5) {\n float glowAlpha = clamp(\n (v_color.a * 0.003 + bandGlow * 0.085) *\n v_glow_strength * u_glow_opacity,\n 0.0,\n 0.14\n );\n OUTPUT_COLOR = vec4(v_color.rgb, glowAlpha);\n return;\n }\n\n float faceLight = 0.88 + 0.12 * abs(normalize(v_normal).z);\n vec3 bodyColor = v_color.rgb * faceLight;\n vec3 color = mix(bodyColor, v_flow_color, bandCore);\n float alpha = clamp(\n v_color.a + bandCore * 0.68,\n 0.0,\n 1.0\n );\n OUTPUT_COLOR = vec4(color, alpha);\n }\n ",n=(t,e,o)=>t.split(e).join(o),r=e?`#version 300 es\n ${n(n(i,"VARYING","in"),"OUTPUT_COLOR","fragmentColor").replace("precision highp float;","precision highp float;\n out vec4 fragmentColor;")}\n `:n(n(i,"VARYING","varying"),"OUTPUT_COLOR","gl_FragColor"),a=se(t,t.VERTEX_SHADER,o),l=se(t,t.FRAGMENT_SHADER,r),c=t.createProgram();if(!c)throw t.deleteShader(a),t.deleteShader(l),new Error("无法创建电子围栏 WebGL program。");if(t.attachShader(c,a),t.attachShader(c,l),t.linkProgram(c),t.deleteShader(a),t.deleteShader(l),!t.getProgramParameter(c,t.LINK_STATUS)){const e=t.getProgramInfoLog(c)||"未知 program 链接错误";throw t.deleteProgram(c),new Error(`电子围栏 WebGL program 链接失败:${e}`)}return c})(e),this.locations=((t,e)=>({position:t.getAttribLocation(e,"a_position"),normal:t.getAttribLocation(e,"a_normal"),heightRatio:t.getAttribLocation(e,"a_height_ratio"),pathProgress:t.getAttribLocation(e,"a_path_progress"),color:t.getAttribLocation(e,"a_color"),flowColor:t.getAttribLocation(e,"a_flow_color"),glowStrength:t.getAttribLocation(e,"a_glow_strength"),flowWidth:t.getAttribLocation(e,"a_flow_width"),flowCount:t.getAttribLocation(e,"a_flow_count"),flowLineStyle:t.getAttribLocation(e,"a_flow_line_style"),matrix:de(t,e,"u_matrix"),time:de(t,e,"u_time"),speed:de(t,e,"u_speed"),animationEnabled:de(t,e,"u_animation_enabled"),glowPass:de(t,e,"u_glow_pass"),glowOpacity:de(t,e,"u_glow_opacity")}))(e,this.program),this.buffer=e.createBuffer()||void 0,!this.buffer)throw new Error("无法创建电子围栏 WebGL 顶点缓冲。");this.uploadGeometry(e)}render(t,e){if(!(this.visible&&this.program&&this.buffer&&this.locations&&(this.geometry.glowPasses.length||this.geometry.bodyVertexCount)))return;const o=19*Float32Array.BYTES_PER_ELEMENT,i=(e,i,n)=>{t.enableVertexAttribArray(e),t.vertexAttribPointer(e,i,t.FLOAT,!1,o,n*Float32Array.BYTES_PER_ELEMENT)};t.useProgram(this.program),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),i(this.locations.position,3,0),i(this.locations.normal,3,3),i(this.locations.heightRatio,1,6),i(this.locations.pathProgress,1,7),i(this.locations.color,4,8),i(this.locations.flowColor,3,12),i(this.locations.glowStrength,1,15),i(this.locations.flowWidth,1,16),i(this.locations.flowCount,1,17),i(this.locations.flowLineStyle,1,18),t.uniformMatrix4fv(this.locations.matrix,!1,e.defaultProjectionData.mainMatrix),t.uniform1f(this.locations.time,performance.now()/1e3),t.uniform1f(this.locations.speed,this.animation.speed),t.uniform1f(this.locations.animationEnabled,this.animation.enabled?1:0),t.enable(t.BLEND),t.enable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.depthMask(!1),this.geometry.glowPasses.length&&(t.blendFunc(t.SRC_ALPHA,t.ONE),t.uniform1f(this.locations.glowPass,1),this.geometry.glowPasses.forEach(e=>{t.uniform1f(this.locations.glowOpacity,e.opacity),t.drawArrays(t.TRIANGLES,e.first,e.count)})),this.geometry.bodyVertexCount&&(t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.uniform1f(this.locations.glowPass,0),t.uniform1f(this.locations.glowOpacity,0),t.drawArrays(t.TRIANGLES,this.geometry.bodyFirst,this.geometry.bodyVertexCount)),t.depthMask(!0),t.bindBuffer(t.ARRAY_BUFFER,null)}onRemove(t,e){this.buffer&&e.deleteBuffer(this.buffer),this.program&&e.deleteProgram(this.program),this.map=void 0,this.gl=void 0,this.buffer=void 0,this.program=void 0,this.locations=void 0}uploadGeometry(t){const e=t||this.gl;e&&this.buffer&&(e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bufferData(e.ARRAY_BUFFER,this.geometry.vertices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null))}}const he=(t,e)=>t?"string"==typeof t&&m(t)?_(t,{token:e}):t:_("openfreemap-liberty");t.maplibregl=e,t.BASE_MAP_TYPES=y,t.OPENFREEMAP_STYLES=a,t.OPENFREEMAP_STYLE_BASE_URL=n,t.OPENFREEMAP_STYLE_TYPES=l,t.TDT_STYLE_TYPES=["tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],t.addBreachAlert=(t,e)=>{const o=e.id,i=`${o}-fence-source`,n=`${o}-fence-fill`,r=`${o}-fence-line`,a=`${o}-ripple-source`,l=`${o}-ripple-line`;let c,s,d,f={...e},h=!1,p=!1,u=!1,g=!1,y=0;const m=()=>f.fenceColor??"#1677ff",_=()=>f.fenceFillColor??m(),w=()=>f.fenceFillOpacity??.1,v=()=>f.fenceBorderWidth??2,b=()=>f.fenceBorderOpacity??.9,M=()=>f.fenceAlertColor??"#ff3b30",$=()=>f.rippleColor??M(),k=e=>{const o=t.getSource(a);o&&o.setData(e)},x=t=>{const e=Math.max(20,f.rippleRadius??800),o=Math.max(1,f.rippleCount??3),i=Math.max(400,f.rippleDuration??1500),n=Math.max(1,f.rippleLineWidth??3),r=performance.now(),a=l=>{k(((t,e,o,i,n,r)=>{const a=[];for(let l=0;l<o;l+=1){const c=(r/i+l/o)%1,s=c*e;s<1||a.push(G(P(t,s),{kind:"ring",opacity:.95*(1-c),width:n*(1-.3*c)}))}return E(a)})(t,e,o,i,n,l-r)),y=requestAnimationFrame(a)};y=requestAnimationFrame(a)},A=()=>{if(!u)return;const e=m(),o=_();t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",o),t.setPaintProperty(n,"fill-opacity",w())),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-width",v()),t.setPaintProperty(r,"line-opacity",b()))},F=()=>{const e=f.tacticalColor??M(),o=Math.max(1,f.tacticalBorderWidth??4),i="viewport"===f.tacticalScope?12:0,n=Math.max(60,f.fenceFlashInterval??200),r=t.getContainer(),a=document.createElement("div");a.style.position="absolute",a.style.inset=`${i}px`,a.style.border=`${o}px solid ${e}`,a.style.boxShadow=`inset 0 0 ${6*o}px ${e}`,a.style.pointerEvents="none",a.style.zIndex="5",a.style.opacity="1",r.appendChild(a),d=a;let l=!0;s=setInterval(()=>{l=!l,a.style.opacity=l?"1":"0.15"},n)},C=()=>{const e=(t=>{if(!t)return[];if(Array.isArray(t))return[{type:"Polygon",coordinates:t}];switch(t.type){case"Polygon":return[t];case"MultiPolygon":return t.coordinates.map(t=>({type:"Polygon",coordinates:t}));case"Feature":{const e=t.geometry;return"Polygon"===(null==e?void 0:e.type)?[e]:"MultiPolygon"===(null==e?void 0:e.type)?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):[]}case"FeatureCollection":{const e=[];for(const o of t.features){const t=o.geometry;"Polygon"===(null==t?void 0:t.type)?e.push(t):"MultiPolygon"===(null==t?void 0:t.type)&&e.push(...t.coordinates.map(t=>({type:"Polygon",coordinates:t})))}return e}default:return[]}})(f.fence);if(0===e.length)return;const o=E(e.map(t=>G(t,{kind:"fence"})));if(u){const e=t.getSource(i);e&&e.setData(o),A()}else t.getSource(i)?t.getSource(i).setData(o):t.addSource(i,{type:"geojson",data:o}),t.getLayer(n)||t.addLayer({id:n,type:"fill",source:i,filter:["==",["get","kind"],"fence"],paint:{"fill-color":_(),"fill-opacity":w()}},f.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get","kind"],"fence"],paint:{"line-color":m(),"line-width":v(),"line-opacity":b()}},f.beforeId),u=!0,T(t,[n,r],!1!==f.visible)},S=()=>{p&&!h&&O()},O=()=>{if(!h)try{C(),t.getSource(a)||t.addSource(a,{type:"geojson",data:E([])}),t.getLayer(l)?t.getLayer(l)&&t.setPaintProperty(l,"line-color",$()):(t.addLayer({id:l,type:"line",source:a,filter:["==",["get","kind"],"ring"],paint:{"line-color":$(),"line-opacity":["coalesce",["get","opacity"],.9],"line-width":["coalesce",["get","width"],3]}},f.beforeId),T(t,[l],!1!==f.visible)),p=!1,t.off("styledata",S)}catch(e){if(!V(e))throw e;p||(p=!0,t.on("styledata",S))}},L=()=>{c&&(clearInterval(c),c=void 0),y&&(cancelAnimationFrame(y),y=0),k(E([])),s&&(clearInterval(s),s=void 0),d&&(d.remove(),d=void 0),A()};return O(),{id:o,update(t){h||(f={...f,...t,id:o},O())},show(){h||(f={...f,visible:!0},T(t,[n,r,l],!0))},hide(){h||(f={...f,visible:!1},T(t,[n,r,l],!1))},remove(){h||(h=!0,p&&(p=!1,t.off("styledata",S)),L(),j(t,l),j(t,r),j(t,n),D(t,a),D(t,i),u=!1)},trigger(e){if(h)return;g&&L();const o=e??f.center;g=!0,!1!==f.fenceFlash&&(()=>{if(!u)return;const e=M(),o=Math.max(60,f.fenceFlashInterval??200);let i=!0;t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",e),t.setPaintProperty(n,"fill-opacity",.42)),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-opacity",1)),c=setInterval(()=>{i=!i;const e=i?.42:.08,o=i?1:.4;t.getLayer(n)&&t.setPaintProperty(n,"fill-opacity",e),t.getLayer(r)&&t.setPaintProperty(r,"line-opacity",o)},o)})(),!1!==f.ripple&&x(o),f.tacticalFlash&&F()},reset(){h||(L(),g=!1)},isActive:()=>g}},t.addBreathingCircle=(t,e)=>z(t,e,X),t.addCoordinatedCountermeasure=(t,e)=>z(t,e,$t),t.addCountermeasureBeam=(t,e)=>z(t,e,bt),t.addDefenceCircle=(t,e)=>z(t,e,wt),t.addDirectionalPulse=(t,e)=>z(t,e,ht),t.addNavigationSpoofing=(t,e)=>z(t,e,xt),t.addPulseMarker=(t,e)=>z(t,e,U),t.addRadarPowerGroup=(t,e)=>{const{source:o,layers:i}=(t=>{const e=`${t}-source`;return{source:e,layers:[{id:`${t}-fill`,type:"fill",source:e,filter:["==",["get","kind"],"fill"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-core`,type:"fill",source:e,filter:["==",["get","kind"],"core"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-ring`,type:"line",source:e,filter:["==",["get","kind"],"ring"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.95],"line-width":["coalesce",["get","width"],2]}},{id:`${t}-crosshair`,type:"line",source:e,filter:["==",["get","kind"],"crosshair"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.5],"line-width":["coalesce",["get","width"],1.4]}},{id:`${t}-labels`,type:"symbol",source:e,filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":["coalesce",["get","size"],12],"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":["coalesce",["get","color"],"#38ff4a"],"text-opacity":["coalesce",["get","opacity"],.92],"text-halo-color":["coalesce",["get","haloColor"],"rgba(15, 23, 42, 0.42)"],"text-halo-width":1}}]}})(e.id);let n=[...e.radars??[]],r=!1;t.addSource(o,{type:"geojson",data:I}),i.forEach(o=>{t.addLayer(o,e.beforeId)});const a=t.getSource(o),l=i.map(t=>t.id),c=e=>{l.forEach(o=>{t.getLayer(o)&&t.setLayoutProperty(o,"visibility",e?"visible":"none")})},s=t=>{r||(n=t.map(t=>({...t})),a.setData(q(n)))};return n.length>0&&s(n),!1===e.visible&&c(!1),{id:e.id,sourceId:o,layerIds:l,setData:s,updateRadar(t,e){const o=n.findIndex(e=>e.id===t);o<0||r||(n[o]={...n[o],...e,id:t},a.setData(q(n)))},setRadarVisible(t,e){const o=n.find(e=>e.id===t);o&&!r&&(o.visible=e,a.setData(q(n)))},removeRadar(t){r||(n=n.filter(e=>e.id!==t),a.setData(q(n)))},show(){r||c(!0)},hide(){r||c(!1)},remove(){r||(r=!0,[...l].reverse().forEach(e=>((t,e)=>{t.getLayer(e)&&t.removeLayer(e)})(t,e)),((t,e)=>{t.getSource(e)&&t.removeSource(e)})(t,o))}}},t.addRadarSweep=(t,e)=>z(t,e,mt),t.addRingPulseMarker=(t,e)=>z(t,e,H),t.addSectorScan=(t,e)=>z(t,e,dt),t.addStandardElectronicFenceLayer=(t,e)=>{Lt(e.id,e.defaults);const o=new St,i=`${e.id}-standard-source`,n=`${e.id}-standard-extrusion`,r=`${e.id}-standard-outline`,a=`${e.id}-standard-interaction`,l=[n,r,...!1===e.interactive?[]:[a]];let c=te(o,e),s=!1!==e.visible,d=!1;const f=()=>{if(!d)try{t.getSource(i)||t.addSource(i,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer({id:n,type:"fill-extrusion",source:i,filter:["==",["get",Bt],"wall"],paint:{"fill-extrusion-color":["get",Ht],"fill-extrusion-opacity":1,"fill-extrusion-base":["get",Kt],"fill-extrusion-height":["get",Qt],"fill-extrusion-vertical-gradient":!0}},e.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get",Bt],"boundary"],paint:{"line-color":["get",Jt],"line-width":["get",Xt],"line-opacity":1}},e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:i,filter:["==",["get",Bt],"boundary"],paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),Yt(t,l,s)}catch(o){if(!zt(o))throw o}},h=()=>{f()};t.on("styledata",h),f();const p=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"standard",layerId:a,store:o});return Ut({id:e.id,renderer:"standard",store:o,refresh:()=>{c=te(o,e);const n=t.getSource(i);n?n.setData(c):f()},setPluginVisible(e){s=e,f(),Yt(t,l,s)},destroy(){d=!0,t.off("styledata",h),p(),[...l].reverse().forEach(e=>{t.getLayer(e)&&t.removeLayer(e)}),t.getSource(i)&&t.removeSource(i)}})},t.addTargetLock=(t,o)=>{const i=o.id;let n,r={...o},a=!1;const l=document.createElement("div"),c=document.createElement("div"),s=Array.from({length:4},()=>document.createElement("div")),d=Array.from({length:4},()=>document.createElement("div"));l.dataset.effectId=i,l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.pointerEvents="none",c.style.position="absolute",c.style.inset="0",l.appendChild(c),s.forEach(t=>{t.style.position="absolute",t.style.boxSizing="border-box",c.appendChild(t)}),d.forEach(t=>{t.style.position="absolute",l.appendChild(t)});const f=new e.Marker({element:l,anchor:"center"}).setLngLat(r.center).addTo(t),h=()=>{const t=r.color??"#ff3b30",e=Math.max(24,r.size??72),o=Math.max(1,r.lineWidth??2),i=Math.min(e/2,Math.max(2*o,r.cornerLength??18)),a=Math.max(2,r.crosshairLength??10),h=Math.max(0,r.crosshairGap??5);f.setLngLat(r.center),l.style.width=`${e}px`,l.style.height=`${e}px`,l.style.display=!1===r.visible?"none":"block",l.style.opacity=`${Math.min(1,Math.max(0,r.opacity??1))}`,s.forEach(t=>{t.style.width=`${i}px`,t.style.height=`${i}px`,t.style.border="0"}),Object.assign(s[0].style,{left:"0",top:"0",borderLeft:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[1].style,{right:"0",top:"0",borderRight:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[2].style,{right:"0",bottom:"0",borderRight:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),Object.assign(s[3].style,{left:"0",bottom:"0",borderLeft:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),d.forEach(e=>{e.style.display=!1===r.showCrosshair?"none":"block",e.style.background=t}),Object.assign(d[0].style,{width:`${o}px`,height:`${a}px`,left:"50%",bottom:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[1].style,{width:`${o}px`,height:`${a}px`,left:"50%",top:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[2].style,{width:`${a}px`,height:`${o}px`,right:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),Object.assign(d[3].style,{width:`${a}px`,height:`${o}px`,left:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),null==n||n.cancel(),n=void 0,c.style.transform="rotate(0deg)",!1!==r.rotate&&(n=c.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:Math.max(300,r.rotationDuration??2400),iterations:1/0}))};return h(),{id:i,update(t){a||(r={...r,...t,id:i},h())},show(){a||(r={...r,visible:!0},l.style.display="block")},hide(){a||(r={...r,visible:!1},l.style.display="none")},remove(){a||(a=!0,null==n||n.cancel(),n=void 0,f.remove())}}},t.addWebGLElectronicFenceLayer=(t,e)=>{Lt(e.id,e.defaults);const o=(t=>({enabled:(null==t?void 0:t.enabled)??!0,fps:Math.round(Dt((null==t?void 0:t.fps)??30,1,60)),speed:Math.max(0,(null==t?void 0:t.speed)??.35),scope:(null==t?void 0:t.scope)??"all"}))(e.animation),i=new St,n=`${e.id}-webgl`,r=`${e.id}-webgl-interaction-source`,a=`${e.id}-webgl-interaction`,l=new fe(n,o);let c=Tt(i),s=ce(i,e,o),d=!1!==e.visible,f=!1,h=0,p=0;const u=()=>{h&&(cancelAnimationFrame(h),h=0)},g=e=>{!f&&d&&s.animated?(("undefined"==typeof document||!document.hidden)&&e-p>=1e3/o.fps&&(p=e,t.triggerRepaint()),h=requestAnimationFrame(g)):h=0},y=()=>{const e=o.enabled&&d&&s.animated&&!!t.getLayer(n);e&&!h?(p=0,h=requestAnimationFrame(g)):e||u()},m=()=>{if(!f)try{!1===e.interactive||t.getSource(r)||t.addSource(r,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer(l,e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:r,paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),l.setVisible(d),Yt(t,!1===e.interactive?[]:[a],d),y()}catch(o){if(!zt(o))throw o}},_=()=>{m()};l.setGeometry(s),t.on("styledata",_),m();const w=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"webgl",layerId:a,store:i});return Ut({id:e.id,renderer:"webgl",store:i,refresh:()=>{s=ce(i,e,o),c=Tt(i),l.setGeometry(s);const n=t.getSource(r);n&&n.setData(c),m(),y()},setPluginVisible(o){d=o,l.setVisible(d),m(),Yt(t,!1===e.interactive?[]:[a],d),y()},destroy(){f=!0,u(),t.off("styledata",_),w(),t.getLayer(a)&&t.removeLayer(a),t.getLayer(n)&&t.removeLayer(n),t.getSource(r)&&t.removeSource(r)}})},t.createFenceCircle=(t,e,o)=>C(t,e,o),t.createMap=t=>{const{style:o,tdtToken:i,...n}=t;return new e.Map({...n,style:he(o,i)})},t.createTiandituImageStyle=u,t.createTiandituRasterSource=h,t.getBaseMapStyle=_,t.getMaplibreToolsConfig=i,t.getOpenFreeMapStyle=c,t.isBaseMapType=m,t.setBaseMap=(t,e,o={})=>{const{diff:i=!1,...n}=o;t.setStyle(_(e,n),{diff:i})},t.setMaplibreToolsConfig=t=>{Object.assign(o,t)},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maplibre-gl")):"function"==typeof define&&define.amd?define(["exports","maplibre-gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BitAllTechMaplibreCore={},t.maplibregl)}(this,function(t,e){"use strict";const o={},i=()=>({...o}),n="https://tiles.openfreemap.org/styles",r=(t,e,o)=>({type:t,label:e,style:`${n}/${o}`}),a={"openfreemap-liberty":r("openfreemap-liberty","OpenFreeMap Liberty","liberty"),"openfreemap-bright":r("openfreemap-bright","OpenFreeMap Bright","bright"),"openfreemap-positron":r("openfreemap-positron","OpenFreeMap Positron","positron"),"openfreemap-dark":r("openfreemap-dark","OpenFreeMap Dark","dark"),"openfreemap-fiord":r("openfreemap-fiord","OpenFreeMap Fiord","fiord")},l=Object.keys(a),c=(t="openfreemap-liberty")=>a[t].style,s=["0","1","2","3","4","5","6","7"],d="© 天地图",f=(t,e)=>{const o=(t=>{const e=t||i().tdtToken;if(!e)throw new Error("Tianditu token is required. Pass token or call setMaplibreToolsConfig({ tdtToken }).");return e})(e);return s.map(e=>`https://t${e}.tianditu.gov.cn/DataServer?T=${t}&x={x}&y={y}&l={z}&tk=${o}`)},h=(t,e={})=>({type:"raster",tiles:f(t,e.token),tileSize:256,minzoom:0,maxzoom:18,attribution:d}),p=(t={})=>({type:"raster",tiles:f("vec_w",t.token),tileSize:256,minzoom:0,maxzoom:18,attribution:d}),u=(t={})=>{const e=!1!==t.label,o={"tdt-image":h("img_w",t)},i=[{id:"tdt-image",type:"raster",source:"tdt-image"}];return e&&(o["tdt-image-label"]=h("cia_w",t),i.push({id:"tdt-image-label",type:"raster",source:"tdt-image-label"})),{version:8,sources:o,layers:i}},g=(t={})=>{const e=!1!==t.label,o={"tdt-mvt":p(t)},i=[{id:"tdt-mvt",type:"raster",source:"tdt-mvt"}];return e&&(o["tdt-mvt-label"]=h("cva_w",t),i.push({id:"tdt-mvt-label",type:"raster",source:"tdt-mvt-label"})),{version:8,sources:o,layers:i}},y=[...Object.keys(a),"tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],m=t=>y.includes(t),_=(t="openfreemap-liberty",e={})=>"tdt-image"===t?u({...e,label:!1}):"tdt-image-label"===t?u({...e,label:!0}):"tdt-mvt"===t?g({...e,label:!1}):"tdt-mvt-label"===t?g({...e,label:!0}):c(t),w=6378137,v=t=>t*Math.PI/180,b=t=>180*t/Math.PI,M=t=>(t%360+360)%360,$=(t,e,o)=>{const i=e/w,n=v(o),r=v(t[1]),a=v(t[0]),l=Math.asin(Math.sin(r)*Math.cos(i)+Math.cos(r)*Math.sin(i)*Math.cos(n)),c=a+Math.atan2(Math.sin(n)*Math.sin(i)*Math.cos(r),Math.cos(i)-Math.sin(r)*Math.sin(l));return[(s=b(c),s>180?s-360:s<-180?s+360:s),b(l)];var s},k=(t,e)=>{const o=v(e[1]-t[1]),i=v(e[0]-t[0]),n=v(t[1]),r=v(e[1]),a=Math.sin(o/2)*Math.sin(o/2)+Math.cos(n)*Math.cos(r)*Math.sin(i/2)*Math.sin(i/2);return 12756274*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))},x=(t,e)=>{const o=v(t[1]),i=v(e[1]),n=v(e[0]-t[0]),r=Math.sin(n)*Math.cos(i),a=Math.cos(o)*Math.sin(i)-Math.sin(o)*Math.cos(i)*Math.cos(n);return M(b(Math.atan2(r,a)))},A=(t,e,o=64)=>{const i=((t,e)=>{const o=M(e)-M(t);return o<=0?o+360:o})(t,e),n=Math.max(12,Math.ceil(o*i/360));return Array.from({length:n+1},(e,o)=>M(t+i*o/n))},F=(t,e,o=64)=>(t=>{if(0===t.length)return t;const[e,o]=t[0],i=t[t.length-1];return i[0]===e&&i[1]===o?t:[...t,[e,o]]})(Array.from({length:o},(i,n)=>$(t,e,360*n/o))),C=(t,e,o=64)=>({type:"Polygon",coordinates:[F(t,e,o)]}),P=(t,e,o=64)=>({type:"LineString",coordinates:F(t,e,o)}),S=(t,e,o,i,n=64)=>{const r=A(o,i,n).map(o=>$(t,e,o));return{type:"Polygon",coordinates:[[t,...r,t]]}},O=(t,e,o,i,n=64)=>({type:"LineString",coordinates:A(o,i,n).map(o=>$(t,e,o))}),L=(t,e,o)=>({type:"LineString",coordinates:[t,$(t,e,o)]}),I={type:"FeatureCollection",features:[]},R=(t,e)=>({type:"Feature",geometry:t,properties:e}),q=(t,e)=>Math.max(0,Math.min(1,t??e)),W=t=>{var e;if(!1===t.visible)return[];const o=t.color??"#38ff4a",i=t.ringColor??o,n=Math.max(0,Math.floor(t.ringCount??4)),r=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),a=[];t.fillOpacity&&t.fillOpacity>0&&a.push(R(C(t.center,t.radius),{radarId:t.id,kind:"fill",color:t.fillColor??o,opacity:q(t.fillOpacity,0)}));for(let l=n;l>=1;l-=1){const o=t.radius*l/n;if(a.push(R(P(t.center,o),{radarId:t.id,kind:"ring",color:i,opacity:q(t.ringOpacity,.95),width:Math.max(0,t.ringWidth??2)})),!1!==t.showDistanceLabels){const n=(null==(e=t.distanceLabelFormatter)?void 0:e.call(t,o,l))??`${Math.round(o)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(e=>{a.push(R({type:"Point",coordinates:$(t.center,o,e.bearing)},{radarId:t.id,kind:"distance-label",text:n,textAnchor:e.textAnchor,color:t.distanceLabelColor??i,opacity:q(t.distanceLabelOpacity,.92),haloColor:t.distanceLabelHaloColor??"rgba(15, 23, 42, 0.42)",size:t.distanceLabelSize??12}))})}}return!1!==t.showCrosshair&&a.push(R({type:"LineString",coordinates:[$(t.center,t.radius,180),$(t.center,t.radius,0)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:q(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)}),R({type:"LineString",coordinates:[$(t.center,t.radius,270),$(t.center,t.radius,90)]},{radarId:t.id,kind:"crosshair",color:t.crosshairColor??i,opacity:q(t.crosshairOpacity,.5),width:Math.max(0,t.crosshairWidth??1.4)})),a.push(R(C(t.center,r),{radarId:t.id,kind:"core",color:t.coreColor??o,opacity:q(t.fillOpacity,0)})),a},N=t=>({type:"FeatureCollection",features:t.flatMap(W)}),G=(t,e)=>({type:"Feature",geometry:t,properties:e}),E=t=>({type:"FeatureCollection",features:t}),j=(t,e)=>{t.getLayer(e)&&t.removeLayer(e)},D=(t,e)=>{t.getSource(e)&&t.removeSource(e)},T=(t,e,o)=>{const i=o?"visible":"none";e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",i)})},V=t=>t instanceof Error&&"Style is not done loading."===t.message,z=(t,e,o)=>{const i=e.id,n=`${i}-source`;let r,a={...e},l=[],c=[n],s=!1,d=!1;const f=()=>{null==r||r(),r=void 0,[...l].reverse().forEach(e=>{j(t,e)}),[...c].reverse().forEach(e=>{D(t,e)}),l=[],c=[n]},h=e=>{const o=t.getSource(n);o&&o.setData(e)},p=()=>{try{(()=>{var e,i,d;if(s)return;f();const p=o(a);t.addSource(n,{type:"geojson",data:p.data}),null==(e=p.canvasSources)||e.forEach(e=>{t.addSource(e.id,e.source)}),c=[n,...(null==(i=p.canvasSources)?void 0:i.map(t=>t.id))||[]],l=p.layers.map(t=>t.id),p.layers.forEach(e=>{var o;const i="raster"===e.type&&(null==(o=p.canvasSources)?void 0:o[0])?p.canvasSources[0].id:n;t.addLayer({...e,source:i},a.beforeId)}),T(t,l,!1!==a.visible),null==(d=p.canvasSources)||d.forEach(e=>{var o;const i=t.style,n=null==(o=null==i?void 0:i.tileManagers)?void 0:o[e.id];if(!n||!n.t)return;const r=n.used;n.used=!0;const a=t;n.update(a.transform,a.terrain),n.used=r}),p.startAnimation&&(r=p.startAnimation({getOptions:()=>a,setData:h,requestRender:()=>t.triggerRepaint()})||void 0)})(),d&&(d=!1,t.off("styledata",u))}catch(e){if(!V(e))throw e;d||(d=!0,t.on("styledata",u))}},u=()=>{d&&!s&&p()},g=()=>{s||p()};return g(),{id:i,update(t){s||(a={...a,...t,id:i},g())},show(){s||(a={...a,visible:!0},T(t,l,!0))},hide(){s||(a={...a,visible:!1},T(t,l,!1))},remove(){s||(s=!0,d&&(d=!1,t.off("styledata",u)),f())}}},Y=(t,e=0)=>{const o=Math.max(10,t.radius??70),i=Math.max(o,t.maxRadius??2.3*o),n=Math.max(1,t.pulseCount??2),r=Math.max(1,t.lineWidth??2),a=t.pulseOpacity??.9,l=[G(C(t.center,o),{kind:"core"})];for(let c=0;c<n;c+=1){const s=(e+c/n)%1,d=o+(i-o)*s;l.push(G(P(t.center,d),{kind:"pulse",opacity:a*(1-s),width:r*(1-.35*s)}))}return E(l)},U=t=>{const e=t.color||"#ff3b30",o=t.fillColor||e;return{data:Y(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":t.fillOpacity??.28}},{id:`${t.id}-pulse`,type:"line",filter:["==",["get","kind"],"pulse"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.pulseOpacity??.9],"line-width":["coalesce",["get","width"],t.lineWidth??2]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800);let i=0;const n=performance.now(),r=a=>{const l=t();e(Y(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},B=(t,e=0)=>{const o=Math.max(16,t.radius??110),i=Math.max(0,t.pulseScale??.16),n=(1-Math.cos(e*Math.PI*2))/2,r=o*(1+i*n),a=Math.max(1,t.ringCount??3),l=Math.max(2.2*r,t.maxRadius??o*(2.5*a)),c=l/a,s=t.fillOpacity??.28,d=[G(C(t.center,r),{kind:"core",opacity:s*(.88+.2*n)}),G(P(t.center,1.06*r),{kind:"core-ring",opacity:(t.lineOpacity??.95)*(.8+.2*n),width:Math.max(1,(t.lineWidth??3)*(.92+.12*n))})];for(let f=0;f<a;f+=1){const o=(f+e+1)*c%l||l,i=o/l;d.push(G(P(t.center,o),{kind:"ring",opacity:Math.max(.18,(t.lineOpacity??.95)*(1-.42*i)),width:Math.max(1,(t.lineWidth??3)*(1-.18*i))}))}return E(d)},H=t=>{const e=t.color||"#ef4444",o=t.fillColor||e;return{data:B(t),layers:[{id:`${t.id}-core`,type:"fill",filter:["==",["get","kind"],"core"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-rings`,type:"line",filter:["any",["==",["get","kind"],"ring"]],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],t.lineOpacity??.95],"line-width":["coalesce",["get","width"],t.lineWidth??3]}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(600,t().duration??2e3);let i=0;const n=performance.now(),r=a=>{const l=t();e(B(l,(a-n)%o/o)),i=requestAnimationFrame(r)};return i=requestAnimationFrame(r),()=>{cancelAnimationFrame(i)}}}},J=(t,e=0)=>{const o=Math.max(1,t.radius??90),i=Math.max(1,t.minRadius??.78*o),n=Math.max(i,t.maxRadius??1.22*o),r=(1-Math.cos(e*Math.PI*2))/2,a=i+(n-i)*r,l=t.fillOpacity??.28,c=t.minFillOpacity??.46*l,s=t.strokeOpacity??.82,d=t.minStrokeOpacity??.38*s,f=1-r,h=[G(C(t.center,a),{kind:"breathing-fill",opacity:c+(l-c)*f})];return(t.strokeWidth??2)>0&&h.push(G(P(t.center,a),{kind:"breathing-stroke",opacity:d+(s-d)*f})),E(h)},X=t=>{const e=t.color||"#1677ff",o=t.fillColor||e,i=t.strokeColor||e,n=Math.max(0,t.strokeWidth??2);return{data:J(t),layers:[{id:`${t.id}-breathing-fill`,type:"fill",filter:["==",["get","kind"],"breathing-fill"],paint:{"fill-color":o,"fill-opacity":["coalesce",["get","opacity"],t.fillOpacity??.28]}},{id:`${t.id}-breathing-stroke`,type:"line",filter:["==",["get","kind"],"breathing-stroke"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":i,"line-opacity":["coalesce",["get","opacity"],t.strokeOpacity??.82],"line-width":n}}],startAnimation({getOptions:t,setData:e}){const o=Math.max(400,t().duration??1800),i=performance.now();let n=0;const r=a=>{const l=t();e(J(l,(a-i)%o/o)),n=requestAnimationFrame(r)};return n=requestAnimationFrame(r),()=>{cancelAnimationFrame(n)}}}},K=(t,e,o)=>Math.min(o,Math.max(e,t)),Q=t=>{const e=t.trim(),o=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const t=o[1],e=3===t.length?t.split("").map(t=>t+t).join(""):t;return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const i=e.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(i)return[K(Number(i[1]),0,255),K(Number(i[2]),0,255),K(Number(i[3]),0,255)]},Z=t=>(t%360+360)%360,tt=t=>(t-90)*Math.PI/180,et=(t,e)=>{const o=Q(t);return o?`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${K(e,0,1)})`:t},ot=t=>t*(2-t),it=(t,e)=>{const o=t.length-1;if(e<=0)return t[0];if(e>=o)return t[o];const i=Math.floor(e),n=e-i,[r,a]=[Q(t[i]),Q(t[i+1])];if(!r||!a)return t[Math.round(e)];const[l,c,s]=((t,e,o)=>[Math.round(t[0]+(e[0]-t[0])*o),Math.round(t[1]+(e[1]-t[1])*o),Math.round(t[2]+(e[2]-t[2])*o)])(r,a,n);return`rgb(${l},${c},${s})`},nt=(t,e)=>{const o=$(t,e,0)[1],i=$(t,e,90)[0],n=$(t,e,180)[1],r=$(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},rt=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2?o:void 0},at=(t,e,o=0)=>{const i=t.getContext("2d"),n=rt(e);if(!i||!e.gradient||!n)return;const r=t.width,a=r/2,l=a-2,c=e.startAngle+o,s=((t,e)=>{const o=Z(e)-Z(t);return o<=0?o+360:o})(c,e.endAngle+o),d=tt(c),f=d+s*Math.PI/180,h=e.gradient.opacity??e.opacity??.28,p=e.gradient.centerOpacity??.25*h,u=e.gradient.edgeOpacity??h,g=i.createRadialGradient(a,a,0,a,a,l);n.forEach((t,e)=>{const o=e/Math.max(1,n.length-1),i=p+(u-p)*o;g.addColorStop(o,et(t,i))}),i.clearRect(0,0,r,r),i.save(),i.beginPath(),i.moveTo(a,a),i.arc(a,a,l,d,f,!1),i.closePath(),i.clip(),i.fillStyle=g,i.fillRect(0,0,r,r),i.restore()},lt=t=>{if(!rt(t))return;const e=(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})();return at(e,t),e},ct=(t,e,o)=>rt(t)?[]:[G(S(t.center,t.radius,e,o),{kind:"sector",color:t.color||"#ff453a",opacity:t.opacity??.28})],st=(t,e=0)=>{const o=t.startAngle+e,i=t.endAngle+e,n=[...ct(t,o,i),G(L(t.center,t.radius,o),{kind:"frame"}),G(L(t.center,t.radius,i),{kind:"frame"})];return E(n)},dt=t=>{const e=lt(t),o=e?{id:`${t.id}-sector-fill`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-sector-fill`,type:"fill",filter:["==",["get","kind"],"sector"],paint:{"fill-color":["coalesce",["get","color"],t.color||"#ff453a"],"fill-opacity":["coalesce",["get","opacity"],t.opacity??.28],"fill-antialias":!1}};return{data:st(t),canvasSources:e?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:nt(t.center,t.radius),animate:!1}}]:void 0,layers:[o,{id:`${t.id}-sector-frame`,type:"line",filter:["==",["get","kind"],"frame"],paint:{"line-color":t.outlineColor||t.color||"#ff453a","line-opacity":t.outlineOpacity??.95,"line-width":t.outlineWidth??2}}],startAnimation:t.rotationSpeed&&0!==t.rotationSpeed?({getOptions:t,setData:o,requestRender:i})=>{const n=performance.now();let r=0,a=-1/0;const l=c=>{const s=t(),d=s.frameRate??30;if(c-a>=(d>0?1e3/d:0)){const t=(c-n)/1e3*(s.rotationSpeed||0),r=(s.outlineOpacity??.95)>0&&(s.outlineWidth??2)>0;e&&(at(e,s,t),i()),e&&!r||o(st(s,t)),a=c}r=requestAnimationFrame(l)};return r=requestAnimationFrame(l),()=>{cancelAnimationFrame(r)}}:void 0}},ft=(t,e)=>{const o=Math.max(40,t.radius),i=t.direction??270,n=Math.min(180,Math.max(8,t.spread??72)),r=Math.max(1,t.lineCount??7),a=Math.max(20,t.lineSpacing??Math.max(80,o/9)),l=e??0,c=Math.max(0,Math.min(.35*o,t.innerRadius??Math.min(.4*a,120))),s=i-n/2,d=i+n/2,f=[];for(let h=0;h<r;h+=1){const e=c+l+h*a;if(e>o)continue;const i=e/o,n=1-h/Math.max(1,r);f.push(G(O(t.center,e,s,d),{kind:"directional-pulse-line",opacity:Math.max(.08,(t.opacity??.92)*(.42+.58*n)*(1-.28*i)),width:Math.max(1,(t.lineWidth??2.8)*(.86+.24*n)*(1-.08*i))}))}return E(f)},ht=t=>({data:ft(t),layers:[{id:`${t.id}-directional-pulse`,type:"line",filter:["==",["get","kind"],"directional-pulse-line"],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.color||"#ef4444","line-opacity":["coalesce",["get","opacity"],t.opacity??.92],"line-width":["coalesce",["get","width"],t.lineWidth??2.8]}}],startAnimation:t.speed&&t.speed>0?({getOptions:t,setData:e})=>{const o=performance.now();let i=0;const n=r=>{const a=t(),l=Math.max(40,a.radius),c=Math.max(20,a.lineSpacing??Math.max(80,l/9)),s=(r-o)/1e3*(a.speed??0)%c;e(ft(a,s)),i=requestAnimationFrame(n)};return i=requestAnimationFrame(n),()=>{cancelAnimationFrame(i)}}:void 0}),pt=t=>{var e;const o=null==(e=t.gradient)?void 0:e.colors;return Array.isArray(o)&&o.length>=2},ut=(t,e)=>{const o=$(t,e,0)[1],i=$(t,e,90)[0],n=$(t,e,180)[1],r=$(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},gt=(t,e,o=0)=>{const i=t.getContext("2d"),n=e.gradient,r=null==n?void 0:n.colors;if(!i||!n||!r||r.length<2)return;const a=t.width,l=a/2,c=l-2,s=Math.max(12,e.sweepAngle??42),d=e.tailOpacity??.04,f=Math.max(.24,e.opacity??.3),h=(e.sweepStartAngle??0)+o,p=h,u=h+s,g=s;i.clearRect(0,0,a,a);const y=i.createConicGradient(tt(p),l,l),m=g/360,_=Math.min(1,f+.08);for(let w=0;w<=128;w++){const t=w/128,e=d+(_-d)*ot(t),o=t*(r.length-1),i=it(r,o);y.addColorStop(t*m,et(i,Math.max(0,e)))}i.save(),i.beginPath(),i.moveTo(l,l),i.arc(l,l,c,tt(p),tt(u),!1),i.closePath(),i.fillStyle=y,i.fill(),i.restore()},yt=(t,e=0)=>{var o;const i=Math.max(0,t.ringCount??4),n=Math.max(12,t.sweepAngle??42),r=t.headOpacity??Math.max(.24,t.opacity??.3),a=(t.sweepStartAngle??0)+e,l=!1!==t.showCrosshair,c=!1!==t.showDistanceLabels,s=Math.max(20,t.coreRadius??Math.min(160,.035*t.radius)),d=pt(t),f=[];for(let h=i;h>=1;h-=1){const e=t.radius*h/i;if(f.push(G(P(t.center,e),{kind:"ring"})),c){const i=(null==(o=t.distanceLabelFormatter)?void 0:o.call(t,e,h))??`${Math.round(e)}`;[{bearing:0,textAnchor:"bottom"},{bearing:90,textAnchor:"left"},{bearing:180,textAnchor:"top"},{bearing:270,textAnchor:"right"}].forEach(o=>{f.push(G({type:"Point",coordinates:$(t.center,e,o.bearing)},{kind:"distance-label",text:i,textAnchor:o.textAnchor}))})}}return l&&f.push(G({type:"LineString",coordinates:[$(t.center,t.radius,180),$(t.center,t.radius,0)]},{kind:"crosshair"}),G({type:"LineString",coordinates:[$(t.center,t.radius,270),$(t.center,t.radius,90)]},{kind:"crosshair"})),f.push(G(C(t.center,s),{kind:"core"})),d||f.push(G(S(t.center,t.radius,a,a+n),{kind:"sweep",opacity:r})),E(f)},mt=t=>{const e=pt(t),o=e?(()=>{const t=document.createElement("canvas");return t.width=768,t.height=768,t})():void 0,i=0!==(t.rotationSpeed??36);o&>(o,t);const n=o?{id:`${t.id}-radar-trail`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}}:{id:`${t.id}-radar-trail`,type:"fill",filter:["==",["get","kind"],"sweep"],paint:{"fill-color":t.color||"#22c55e","fill-opacity":["coalesce",["get","opacity"],t.opacity??.32]}};return{data:yt(t),canvasSources:o?[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:o,coordinates:ut(t.center,t.radius),animate:i}}]:void 0,layers:[n,{id:`${t.id}-radar-rings`,type:"line",filter:["==",["get","kind"],"ring"],paint:{"line-color":t.ringColor||t.color||"#22c55e","line-opacity":t.ringOpacity??.95,"line-width":t.ringWidth??2}},{id:`${t.id}-radar-crosshair`,type:"line",filter:["==",["get","kind"],"crosshair"],paint:{"line-color":t.crosshairColor||t.ringColor||t.color||"#22c55e","line-opacity":t.crosshairOpacity??.5,"line-width":t.crosshairWidth??1.4}},{id:`${t.id}-radar-distance-labels`,type:"symbol",filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":t.distanceLabelSize??12,"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":t.distanceLabelColor||t.ringColor||t.color||"#22c55e","text-opacity":t.distanceLabelOpacity??.92,"text-halo-color":t.distanceLabelHaloColor||"rgba(15, 23, 42, 0.42)","text-halo-width":1}}],startAnimation:i?({getOptions:t,setData:i})=>{const n=performance.now();let r=0;const a=l=>{const c=t(),s=(l-n)/1e3*(c.rotationSpeed??36);o&>(o,c,s),e||i(yt(c,s)),r=requestAnimationFrame(a)};return r=requestAnimationFrame(a),()=>{cancelAnimationFrame(r)}}:void 0}},_t=(t,e)=>{const o=$(t,e,0)[1],i=$(t,e,90)[0],n=$(t,e,180)[1],r=$(t,e,270)[0];return[[r,o],[i,o],[i,n],[r,n]]},wt=t=>{const e=(()=>{const t=document.createElement("canvas");return t.width=512,t.height=512,t})();((t,e)=>{const o=t.getContext("2d");if(!o)return;const i=t.width,n=i/2,r=n-1,a=e.color||"#06c536",l=e.fillColor||a,c=e.borderColor||a,s=e.fillOpacity??.06,d=e.borderOpacity??.92;o.clearRect(0,0,i,i),o.save(),o.beginPath(),o.arc(n,n,r,0,2*Math.PI),o.clip();const f=o.createRadialGradient(n,n,0,n,n,r),h=Math.min(.8,s+.85*(d-s));f.addColorStop(0,et(l,s)),f.addColorStop(.85,et(l,s)),f.addColorStop(.92,et(c,s+.3*(h-s))),f.addColorStop(.96,et(c,s+.7*(h-s))),f.addColorStop(1,et(c,h)),o.fillStyle=f,o.fillRect(0,0,i,i),o.restore()})(e,t);const o=t.borderColor||t.color||"#06c536";return{data:E([G(P(t.center,t.radius),{kind:"defence-border"})]),canvasSources:[{id:`${t.id}-canvas-source`,source:{type:"canvas",canvas:e,coordinates:_t(t.center,t.radius),animate:!0}}],layers:[{id:`${t.id}-defence-circle`,type:"raster",paint:{"raster-opacity":1,"raster-fade-duration":0}},{id:`${t.id}-defence-border`,type:"line",filter:["==",["get","kind"],"defence-border"],paint:{"line-color":o,"line-opacity":t.borderOpacity??.92,"line-width":t.borderWidth??2}}]}},vt=(t,e=0)=>{const o=Math.max(1,t.sourceWidth??220),i=Math.max(1,t.targetWidth??45),n=(t=>{const e=t.target||$(t.center,t.distance||0,t.bearing||0),o=void 0!==t.target?x(t.center,t.target):M(t.bearing||0),i=$(t.center,t.startWidth/2,o-90),n=$(t.center,t.startWidth/2,o+90);return{polygon:{type:"Polygon",coordinates:[[i,$(e,t.endWidth/2,o-90),$(e,t.endWidth/2,o+90),n,i]]},centerLine:{type:"LineString",coordinates:[t.center,e]}}})({center:t.center,target:t.target,startWidth:o,endWidth:i}),r=[G(n.polygon,{kind:"countermeasure-channel"}),G(n.centerLine,{kind:"countermeasure-line"})],a=k(t.center,t.target),l=x(t.center,t.target),c=Math.max(0,Math.floor(t.particleCount??18)),s=Math.max(300,t.particleDuration??1200),d=e%s/s,f=Math.max(1,t.particleRadius??2.8);if(a>0)for(let h=0;h<c;h+=1){const e=(d+h/c)%1;r.push(G({type:"Point",coordinates:$(t.center,a*e,l)},{kind:"countermeasure-particle",opacity:.25+.75*e,radius:f*(.7+.3*e)}))}if(!1!==t.targetRipple){const o=Math.max(1,Math.floor(t.targetRippleCount??2)),i=Math.max(10,t.targetRippleRadius??120),n=Math.max(300,t.targetRippleDuration??900),a=e%n/n;for(let e=0;e<o;e+=1){const n=(a+e/o)%1,l="forcedLanding"===t.mode?1-n:n;r.push(G(P(t.target,Math.max(2,i*l)),{kind:"countermeasure-target-ripple",opacity:.9*Math.sin(Math.PI*n)}))}}return E(r)},bt=t=>{const e=t.color??"#a855f7",o=t.lineColor??"#f0abfc",i=Math.max(1,t.lineWidth??2.5);return{data:vt(t),layers:[{id:`${t.id}-countermeasure-channel`,type:"fill",filter:["==",["get","kind"],"countermeasure-channel"],paint:{"fill-color":t.channelColor??e,"fill-opacity":t.channelOpacity??.16}},{id:`${t.id}-countermeasure-glow`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":.28*(t.lineOpacity??.92),"line-width":4*i,"line-blur":1.4*i}},{id:`${t.id}-countermeasure-line`,type:"line",filter:["==",["get","kind"],"countermeasure-line"],layout:{"line-cap":"round"},paint:{"line-color":o,"line-opacity":t.lineOpacity??.92,"line-width":i}},{id:`${t.id}-countermeasure-target-ripple`,type:"line",filter:["==",["get","kind"],"countermeasure-target-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.9],"line-width":Math.max(1,t.targetRippleWidth??2.5)}},{id:`${t.id}-countermeasure-particle`,type:"circle",filter:["==",["get","kind"],"countermeasure-particle"],paint:{"circle-color":t.particleColor??o,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.8],"circle-blur":.18,"circle-stroke-color":"#ffffff","circle-stroke-opacity":.45,"circle-stroke-width":.5}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(vt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},Mt=(t,e=0)=>{const o=[],i=new Set,n=Math.max(0,Math.floor(t.particleCount??5)),r=Math.max(300,t.particleDuration??1600),a=e%r/r,l=Math.max(1,t.particleRadius??2.5);if(t.links.forEach((e,r)=>{const c=e.color??("detection"===(s=e.type)?"#38bdf8":"command"===s?"#22d3ee":"#f97316");var s;const d=k(e.from,e.to),f=x(e.from,e.to);if(o.push(G({type:"LineString",coordinates:[e.from,e.to]},{kind:"coordination-link",linkType:e.type,color:c})),!1!==t.showNodes&&[e.from,e.to].forEach(t=>{const e=`${t[0]},${t[1]}`;i.has(e)||(i.add(e),o.push(G({type:"Point",coordinates:t},{kind:"coordination-node",color:c})))}),!(d<=0))for(let i=0;i<n;i+=1){const s=(a+i/n+r/t.links.length)%1;o.push(G({type:"Point",coordinates:$(e.from,d*s,f)},{kind:"coordination-particle",color:c,opacity:.35+.65*s,radius:l}))}}),!1!==t.targetRipple){const i=Math.max(300,t.targetRippleDuration??1200),n=e%i/i,r=Math.max(10,t.targetRippleRadius??100)*n;o.push(G(P(t.center,Math.max(2,r)),{kind:"coordination-target-ripple",opacity:.9*(1-n)}))}return E(o)},$t=t=>{const e=Math.max(1,t.lineWidth??2.2),o=t.lineOpacity??.9;return{data:Mt(t),layers:[{id:`${t.id}-coordination-detection`,type:"line",filter:["==",["get","linkType"],"detection"],paint:{"line-color":["coalesce",["get","color"],"#38bdf8"],"line-opacity":o,"line-width":e,"line-dasharray":[2,2]}},{id:`${t.id}-coordination-command`,type:"line",filter:["==",["get","linkType"],"command"],paint:{"line-color":["coalesce",["get","color"],"#22d3ee"],"line-opacity":o,"line-width":e,"line-dasharray":[.5,1.8]}},{id:`${t.id}-coordination-countermeasure`,type:"line",filter:["==",["get","linkType"],"countermeasure"],paint:{"line-color":["coalesce",["get","color"],"#f97316"],"line-opacity":o,"line-width":e+.8}},{id:`${t.id}-coordination-target-ripple`,type:"line",filter:["==",["get","kind"],"coordination-target-ripple"],paint:{"line-color":"#ff3b30","line-opacity":["coalesce",["get","opacity"],.9],"line-width":2.5}},{id:`${t.id}-coordination-node`,type:"circle",filter:["==",["get","kind"],"coordination-node"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-radius":Math.max(2,t.nodeRadius??5),"circle-stroke-color":"#ffffff","circle-stroke-width":1.5}},{id:`${t.id}-coordination-particle`,type:"circle",filter:["==",["get","kind"],"coordination-particle"],paint:{"circle-color":["coalesce",["get","color"],"#ffffff"],"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":["coalesce",["get","radius"],2.5],"circle-blur":.1}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(Mt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},kt=(t,e=0)=>{const o=[G({type:"LineString",coordinates:[t.center,t.spoofedPosition]},{kind:"spoofing-offset"})],i=k(t.center,t.spoofedPosition),n=x(t.center,t.spoofedPosition),r=Math.max(0,Math.floor(t.particleCount??10)),a=Math.max(300,t.particleDuration??1800),l=e%a/a;if(!1!==t.showTruePosition&&o.push(G({type:"Point",coordinates:t.center},{kind:"spoofing-true-position"})),!1!==t.showSpoofedPosition&&o.push(G({type:"Point",coordinates:t.spoofedPosition},{kind:"spoofing-ghost"})),i>0)for(let c=0;c<r;c+=1){const e=(l+c/r)%1;o.push(G({type:"Point",coordinates:$(t.center,i*e,n)},{kind:"spoofing-particle",opacity:.25+.75*e}))}if(!1!==t.ripple){const i=Math.max(1,Math.floor(t.rippleCount??2)),n=Math.max(300,t.rippleDuration??1200),r=Math.max(10,t.rippleRadius??120),a=e%n/n;for(let e=0;e<i;e+=1){const n=(a+e/i)%1;o.push(G(P(t.spoofedPosition,Math.max(2,r*n)),{kind:"spoofing-ripple",opacity:.75*(1-n)}))}}return E(o)},xt=t=>{const e=t.color??"#8b5cf6";return{data:kt(t),layers:[{id:`${t.id}-spoofing-offset`,type:"line",filter:["==",["get","kind"],"spoofing-offset"],layout:{"line-cap":"round"},paint:{"line-color":t.lineColor??e,"line-opacity":t.lineOpacity??.82,"line-width":Math.max(1,t.lineWidth??2),"line-dasharray":[1.2,2]}},{id:`${t.id}-spoofing-ripple`,type:"line",filter:["==",["get","kind"],"spoofing-ripple"],paint:{"line-color":e,"line-opacity":["coalesce",["get","opacity"],.75],"line-width":2}},{id:`${t.id}-spoofing-true-position`,type:"circle",filter:["==",["get","kind"],"spoofing-true-position"],paint:{"circle-color":"#ffffff","circle-radius":5,"circle-stroke-color":e,"circle-stroke-width":2}},{id:`${t.id}-spoofing-ghost`,type:"circle",filter:["==",["get","kind"],"spoofing-ghost"],paint:{"circle-color":e,"circle-opacity":t.ghostOpacity??.42,"circle-radius":Math.max(2,t.ghostRadius??8),"circle-stroke-color":"#ffffff","circle-stroke-opacity":.8,"circle-stroke-width":1.5}},{id:`${t.id}-spoofing-particle`,type:"circle",filter:["==",["get","kind"],"spoofing-particle"],paint:{"circle-color":e,"circle-opacity":["coalesce",["get","opacity"],1],"circle-radius":Math.max(1,t.particleRadius??2.5),"circle-blur":.12}}],startAnimation:({getOptions:t,setData:e})=>{let o=0;const i=performance.now(),n=r=>{e(kt(t(),r-i)),o=requestAnimationFrame(n)};return o=requestAnimationFrame(n),()=>cancelAnimationFrame(o)}}},At="__electronic_fence_id",Ft=t=>JSON.parse(JSON.stringify(t)),Ct=t=>{const e=t.map(t=>{const e=Number(t[0]),o=Number(t[1]);if(!Number.isFinite(e)||!Number.isFinite(o))throw new Error("电子围栏坐标必须是有限数字。");return[e,o]});if(e.length<3)throw new Error("电子围栏的每个环至少需要 3 个不同坐标。");var o,i;if(o=e[0],i=e[e.length-1],(o[0]!==i[0]||o[1]!==i[1])&&e.push([...e[0]]),e.length<4)throw new Error("电子围栏 Polygon 环无效。");return e},Pt=t=>{if("string"!=typeof t.id||!t.id.trim())throw new Error("电子围栏必须提供非空字符串 id。");if(!t.geometry||"Polygon"!==t.geometry.type)throw new Error(`电子围栏 ${t.id} 仅支持 Polygon geometry。`);const e=Ft(t.properties||{});return{type:"Feature",id:t.id,geometry:{type:"Polygon",coordinates:t.geometry.coordinates.map(Ct)},properties:e}};class St{constructor(){this.features=new Map,this.states=new Map,this.activeIds=new Set,this.hiddenIds=new Set}setData(t){const e=new Map;t.features.forEach(t=>{const o=Pt(t);if(e.has(o.id))throw new Error(`电子围栏 id 重复:${o.id}`);e.set(o.id,o)}),this.features=e,this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}add(t){const e=Pt(t);if(this.features.has(e.id))throw new Error(`电子围栏 id 已存在:${e.id}`);return this.features.set(e.id,e),e.id}update(t,e){const o=this.requireFeature(t);this.features.set(t,((t,e)=>{const o=t.properties||{},i=e.properties||{},n=i.style?{...o.style||{},...i.style}:o.style;return Pt({...Ft(t),geometry:e.geometry?Ft(e.geometry):Ft(t.geometry),properties:{...Ft(o),...Ft(i),...n?{style:n}:{}}})})(o,e))}remove(t){this.requireFeature(t),this.features.delete(t),this.states.delete(t),this.activeIds.delete(t),this.hiddenIds.delete(t)}clear(){this.features.clear(),this.states.clear(),this.activeIds.clear(),this.hiddenIds.clear()}setActive(t,e){this.requireFeature(t),e?this.activeIds.add(t):this.activeIds.delete(t)}setState(t,e){if(this.requireFeature(t),"normal"!==e&&"warning"!==e&&"alarm"!==e&&"disabled"!==e)throw new Error(`电子围栏 ${t} 的渲染状态无效。`);"normal"===e?this.states.delete(t):this.states.set(t,e)}setVisible(t,e){this.requireFeature(t),e?this.hiddenIds.delete(t):this.hiddenIds.add(t)}isActive(t){return this.activeIds.has(t)}getState(t){return this.requireFeature(t),this.states.get(t)||"normal"}get(t){const e=this.features.get(t);return e?Ft(e):void 0}values(){return Array.from(this.features.values())}visibleValues(){return this.values().filter(t=>!this.hiddenIds.has(t.id))}requireFeature(t){const e=this.features.get(t);if(!e)throw new Error(`电子围栏不存在:${t}`);return e}}const Ot=(t,e,o,i=!1)=>{const n=void 0===t?e:Number(t);if(!Number.isFinite(n)||i&&n<=0)throw new Error(`${o} 必须是${i?"大于 0 的":"有限"}数字。`);return n},Lt=(t,e)=>{if(!t.trim())throw new Error("电子围栏插件 id 不能为空。");Ot(e.baseHeight,0,"defaults.baseHeight"),Ot(e.height,0,"defaults.height",!0),Ot(e.thickness,1,"defaults.thickness",!0)},It=t=>({baseHeight:Ot(t.baseHeight,0,"defaults.baseHeight"),height:Ot(t.height,0,"defaults.height",!0),thickness:Ot(t.thickness,1,"defaults.thickness",!0)}),Rt=(t,e)=>"normal"!==t?t:e?"active":"normal",qt=t=>{var e,o;return{...{...t.defaults.normal,...(null==(e=t.overrides)?void 0:e.normal)||{}},..."normal"===t.state?{}:{...t.defaults[t.state],...(null==(o=t.overrides)?void 0:o[t.state])||{}}}},Wt=(t,e)=>{const o=e/2,i=[];return t.coordinates.forEach(t=>{const e=[];for(let o=0;o<t.length-1;o+=1){const i=[t[o][0],t[o][1]],n=[t[o+1][0],t[o+1][1]],r=k(i,n);r<.01||e.push({start:i,end:n,length:r,bearing:x(i,n)})}const n=e.reduce((t,e)=>t+e.length,0);let r=0;e.forEach(t=>{const e=$(t.start,o,t.bearing+180),a=$(t.end,o,t.bearing);i.push({startLeft:$(e,o,t.bearing-90),startRight:$(e,o,t.bearing+90),endLeft:$(a,o,t.bearing-90),endRight:$(a,o,t.bearing+90),startProgress:n?r/n:0,endProgress:n?(r+t.length)/n:1}),r+=t.length})}),i},Nt=t=>({type:"MultiPolygon",coordinates:t.map(t=>[[t.startLeft,t.endLeft,t.endRight,t.startRight,t.startLeft]])}),Gt=(t,e,o)=>Math.min(o,Math.max(e,t)),Et=t=>{const e=t.trim().toLowerCase();if(e.startsWith("#")){const t=e.slice(1),o=3===t.length||4===t.length?t.split("").map(t=>t+t).join(""):t;if(6===o.length||8===o.length){const t=Number.parseInt(o,16);if(Number.isFinite(t))return[(t>>(8===o.length?24:16)&255)/255,(t>>(8===o.length?16:8)&255)/255,(t>>(8===o.length?8:0)&255)/255,8===o.length?(255&t)/255:1]}}const o=e.match(/^rgba?\(([^)]+)\)$/);if(o){const t=o[1].split(",").map(t=>Number(t.trim()));if(t.length>=3&&t.every(t=>Number.isFinite(t)))return[Gt(t[0]/255,0,1),Gt(t[1]/255,0,1),Gt(t[2]/255,0,1),Gt(t[3]??1,0,1)]}throw new Error(`暂不支持的围栏颜色格式:${t}`)},jt=(t,e=1)=>{const[o,i,n,r]=Et(t);return`rgba(${Math.round(255*o)}, ${Math.round(255*i)}, ${Math.round(255*n)}, ${Gt(r*e,0,1)})`},Dt=Gt,Tt=t=>({type:"FeatureCollection",features:t.visibleValues().map(t=>({type:"Feature",id:`${t.id}:interaction`,geometry:Ft(t.geometry),properties:{[At]:t.id}}))}),Vt=t=>{let e;const o=e=>{var o;if(!t.map.getLayer(t.layerId))return;const i=t.map.queryRenderedFeatures(e.point,{layers:[t.layerId]})[0],n=null==(o=null==i?void 0:i.properties)?void 0:o[At];return"string"==typeof n?n:void 0},i=(e,o,i)=>{const n=t.store.get(o);n&&t.map.fire(`fence.${e}`,{instanceId:t.instanceId,renderer:t.renderer,id:o,feature:n,originalEvent:i})},n=t=>{const e=o(t);e&&i("click",e,t)},r=t=>{const n=o(t);n!==e&&(e&&i("mouseleave",e,t),e=n,e&&i("mouseenter",e,t))},a=t=>{e&&(i("mouseleave",e,t),e=void 0)};return t.map.on("click",n),t.map.on("mousemove",r),t.map.on("mouseout",a),()=>{t.map.off("click",n),t.map.off("mousemove",r),t.map.off("mouseout",a)}},zt=t=>t instanceof Error&&"Style is not done loading."===t.message,Yt=(t,e,o)=>{e.forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",o?"visible":"none")})},Ut=t=>{let e=!1;const o=()=>{if(e)throw new Error(`电子围栏插件 ${t.id} 已销毁。`)};return{id:t.id,renderer:t.renderer,setData(e){o(),t.store.setData(e),t.refresh()},add(e){o();const i=t.store.add(e);return t.refresh(),i},update(e,i){o(),t.store.update(e,i),t.refresh()},removeFeature(e){o(),t.store.remove(e),t.refresh()},clear(){o(),t.store.clear(),t.refresh()},setFeatureState(e,i){o(),t.store.setState(e,i),t.refresh()},setFeatureActive(e,i){o(),t.store.setActive(e,i),t.refresh()},setFeatureVisible(e,i){o(),t.store.setVisible(e,i),t.refresh()},show(){o(),t.setPluginVisible(!0)},hide(){o(),t.setPluginVisible(!1)},destroy(){e||(e=!0,t.destroy())}}},Bt="__electronic_fence_kind",Ht="__electronic_fence_color",Jt="__electronic_fence_outline_color",Xt="__electronic_fence_outline_width",Kt="__electronic_fence_base",Qt="__electronic_fence_top",Zt={normal:{color:"#d8b4fe",opacity:.28,outlineColor:"#f5e9ff",outlineWidth:1.5},active:{color:"#c084fc",opacity:.42,outlineColor:"#ffffff",outlineWidth:2.5},warning:{color:"#f59e0b",opacity:.38,outlineColor:"#fde68a",outlineWidth:2},alarm:{color:"#ef4444",opacity:.48,outlineColor:"#ffffff",outlineWidth:2.5},disabled:{color:"#94a3b8",opacity:.16,outlineColor:"#cbd5e1",outlineWidth:1}},te=(t,e)=>{const o=[],i=It(e.defaults);return t.visibleValues().forEach(n=>{const r=Rt(t.getState(n.id),t.isActive(n.id)),a=qt({defaults:Zt,overrides:e.styles,state:r}),l=Wt(n.geometry,i.thickness),c={[At]:n.id,[Ht]:jt(a.color,Dt(a.opacity,0,1)),[Jt]:jt(a.outlineColor),[Xt]:Math.max(0,a.outlineWidth),[Kt]:i.baseHeight,[Qt]:i.baseHeight+i.height};l.length&&o.push({type:"Feature",id:`${n.id}:wall`,geometry:Nt(l),properties:{...c,[Bt]:"wall"}}),o.push({type:"Feature",id:`${n.id}:boundary`,geometry:n.geometry,properties:{...c,[Bt]:"boundary"}})}),{type:"FeatureCollection",features:o}},ee=[{thicknessScale:.08,opacity:1},{thicknessScale:.22,opacity:.56},{thicknessScale:.45,opacity:.28},{thicknessScale:.8,opacity:.12},{thicknessScale:1.3,opacity:.045}],oe={normal:{color:"#d8b4fe",opacity:.2,outlineColor:"#f5e9ff",outlineWidth:1.5,glowStrength:1,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.18},active:{color:"#e9d5ff",opacity:.28,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.25,flowColor:"#ffffff",flowCount:3,flowLineStyle:"dashed",flowWidth:.2},warning:{color:"#f59e0b",opacity:.25,outlineColor:"#fde68a",outlineWidth:2,glowStrength:1.1,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.18},alarm:{color:"#ef4444",opacity:.3,outlineColor:"#ffffff",outlineWidth:2.5,glowStrength:1.35,flowColor:"#ffffff",flowCount:4,flowLineStyle:"dashed",flowWidth:.2},disabled:{color:"#94a3b8",opacity:.12,outlineColor:"#cbd5e1",outlineWidth:1,glowStrength:0,flowColor:"#ffffff",flowCount:0,flowLineStyle:"dashed",flowWidth:0}},ie=(t,o)=>{const i=e.MercatorCoordinate.fromLngLat(t,o);return[i.x,i.y,i.z]},ne=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],re=(t,e,o)=>{const i=ne(e,t),n=ne(o,t);return(t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]})([i[1]*n[2]-i[2]*n[1],i[2]*n[0]-i[0]*n[2],i[0]*n[1]-i[1]*n[0]])},ae=(t,e,o,i,n)=>{const r=re(e[0],e[1],e[2]);[0,1,2,0,2,3].forEach(a=>{((t,e,o,i,n,r)=>{t.push(...e,...o,i,n,...r.color,r.flowColor[0],r.flowColor[1],r.flowColor[2],r.glowStrength,r.flowWidth,r.flowCount,r.flowLineStyle)})(t,e[a],r,o[a],i[a],n)})},le=(t,e,o,i,n)=>{const r=o+i,a=ie(e.startLeft,o),l=ie(e.startRight,o),c=ie(e.endLeft,o),s=ie(e.endRight,o),d=ie(e.startLeft,r),f=ie(e.startRight,r),h=ie(e.endLeft,r),p=ie(e.endRight,r);ae(t,[d,h,p,f],[1,1,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),ae(t,[a,c,h,d],[0,0,1,1],[e.startProgress,e.endProgress,e.endProgress,e.startProgress],n),ae(t,[s,l,f,p],[0,0,1,1],[e.endProgress,e.startProgress,e.startProgress,e.endProgress],n)},ce=(t,e,o)=>{const i=ee.map(()=>[]),n=[],r=It(e.defaults);let a=!1;t.visibleValues().forEach(l=>{const c=t.isActive(l.id),s=Rt(t.getState(l.id),c),d=qt({defaults:oe,overrides:e.styles,state:s}),f=o.enabled&&("all"===o.scope||(t=>"active"===t||"warning"===t||"alarm"===t)(s)),h=((t,e)=>{const o=Et(t.color),i=Et(t.flowColor),n=e&&t.flowCount>0?Math.round(Dt(t.flowCount,1,8)):0;return{color:[o[0],o[1],o[2],Dt(o[3]*t.opacity,0,1)],flowColor:i,glowStrength:Dt(t.glowStrength,0,4),flowCount:n,flowLineStyle:"solid"===t.flowLineStyle?0:1,flowWidth:n>0?Dt(t.flowWidth,.01,.49):0}})(d,f);Wt(l.geometry,r.thickness).forEach(t=>{le(n,t,r.baseHeight,r.height,h)}),h.glowStrength>0&&ee.forEach((t,e)=>{const o=r.thickness*(1+Math.min(h.glowStrength,2)*t.thicknessScale);Wt(l.geometry,o).forEach(t=>{le(i[e],t,r.baseHeight,r.height,h)})}),a||(a=h.flowCount>0&&h.flowWidth>0)});const l=i.reduce((t,e)=>t+e.length,0),c=new Float32Array(l+n.length),s=[];let d=0;i.forEach((t,e)=>{const o=t.length/19;o>0&&s.push({first:d/19,count:o,opacity:ee[e].opacity}),c.set(t,d),d+=t.length});const f=d/19;return c.set(n,d),{vertices:c,glowPasses:s,bodyFirst:f,bodyVertexCount:n.length/19,animated:a}},se=(t,e,o)=>{const i=t.createShader(e);if(!i)throw new Error("无法创建电子围栏 WebGL shader。");if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(i)||"未知 shader 编译错误";throw t.deleteShader(i),new Error(`电子围栏 WebGL shader 编译失败:${e}`)}return i},de=(t,e,o)=>{const i=t.getUniformLocation(e,o);if(!i)throw new Error(`电子围栏 WebGL uniform 不存在:${o}`);return i};class fe{constructor(t,e){this.type="custom",this.renderingMode="3d",this.geometry={vertices:new Float32Array,glowPasses:[],bodyFirst:0,bodyVertexCount:0,animated:!1},this.visible=!0,this.id=t,this.animation=e}setGeometry(t){var e;this.geometry=t,this.uploadGeometry(),null==(e=this.map)||e.triggerRepaint()}setVisible(t){var e;this.visible=t,null==(e=this.map)||e.triggerRepaint()}onAdd(t,e){if(this.map=t,this.gl=e,this.program=(t=>{const e="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext,o=e?"#version 300 es\n precision highp float;\n in vec3 a_position;\n in vec3 a_normal;\n in float a_height_ratio;\n in float a_path_progress;\n in vec4 a_color;\n in vec3 a_flow_color;\n in float a_glow_strength;\n in float a_flow_width;\n in float a_flow_count;\n in float a_flow_line_style;\n uniform mat4 u_matrix;\n out vec3 v_normal;\n out float v_height_ratio;\n out float v_path_progress;\n out vec4 v_color;\n out vec3 v_flow_color;\n out float v_glow_strength;\n out float v_flow_width;\n out float v_flow_count;\n out float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ":"\n precision highp float;\n attribute vec3 a_position;\n attribute vec3 a_normal;\n attribute float a_height_ratio;\n attribute float a_path_progress;\n attribute vec4 a_color;\n attribute vec3 a_flow_color;\n attribute float a_glow_strength;\n attribute float a_flow_width;\n attribute float a_flow_count;\n attribute float a_flow_line_style;\n uniform mat4 u_matrix;\n varying vec3 v_normal;\n varying float v_height_ratio;\n varying float v_path_progress;\n varying vec4 v_color;\n varying vec3 v_flow_color;\n varying float v_glow_strength;\n varying float v_flow_width;\n varying float v_flow_count;\n varying float v_flow_line_style;\n void main() {\n gl_Position = u_matrix * vec4(a_position, 1.0);\n v_normal = a_normal;\n v_height_ratio = a_height_ratio;\n v_path_progress = a_path_progress;\n v_color = a_color;\n v_flow_color = a_flow_color;\n v_glow_strength = a_glow_strength;\n v_flow_width = a_flow_width;\n v_flow_count = a_flow_count;\n v_flow_line_style = a_flow_line_style;\n }\n ",i="\n precision highp float;\n uniform float u_time;\n uniform float u_speed;\n uniform float u_animation_enabled;\n uniform float u_glow_pass;\n uniform float u_glow_opacity;\n VARYING vec3 v_normal;\n VARYING float v_height_ratio;\n VARYING float v_path_progress;\n VARYING vec4 v_color;\n VARYING vec3 v_flow_color;\n VARYING float v_glow_strength;\n VARYING float v_flow_width;\n VARYING float v_flow_count;\n VARYING float v_flow_line_style;\n void main() {\n float bandCore = 0.0;\n float bandGlow = 0.0;\n float verticalFace = 1.0 - smoothstep(\n 0.82,\n 0.98,\n abs(normalize(v_normal).z)\n );\n\n if (\n u_animation_enabled > 0.5 &&\n v_flow_count > 0.5 &&\n v_flow_width > 0.0001\n ) {\n float count = max(v_flow_count, 1.0);\n float phase = fract(\n v_height_ratio * count + u_time * u_speed * count\n );\n float bandDistance = abs(phase - 0.5);\n float dashPhase = fract(\n v_path_progress * 36.0 - u_time * u_speed * 2.4\n );\n float dash = smoothstep(0.02, 0.1, dashPhase) *\n (1.0 - smoothstep(0.62, 0.74, dashPhase));\n float linePattern = v_flow_line_style > 0.5 ? dash : 1.0;\n\n bandCore = 1.0 - smoothstep(\n max(v_flow_width * 0.08, 0.001),\n max(v_flow_width * 0.42, 0.003),\n bandDistance\n );\n float glowDistance = bandDistance / max(v_flow_width, 0.001);\n bandGlow = exp(\n -glowDistance * glowDistance * 2.6\n );\n bandCore *= linePattern * verticalFace;\n bandGlow *= verticalFace;\n }\n\n if (u_glow_pass > 0.5) {\n float glowAlpha = clamp(\n (v_color.a * 0.003 + bandGlow * 0.085) *\n v_glow_strength * u_glow_opacity,\n 0.0,\n 0.14\n );\n OUTPUT_COLOR = vec4(v_color.rgb, glowAlpha);\n return;\n }\n\n float faceLight = 0.88 + 0.12 * abs(normalize(v_normal).z);\n vec3 bodyColor = v_color.rgb * faceLight;\n vec3 color = mix(bodyColor, v_flow_color, bandCore);\n float alpha = clamp(\n v_color.a + bandCore * 0.68,\n 0.0,\n 1.0\n );\n OUTPUT_COLOR = vec4(color, alpha);\n }\n ",n=(t,e,o)=>t.split(e).join(o),r=e?`#version 300 es\n ${n(n(i,"VARYING","in"),"OUTPUT_COLOR","fragmentColor").replace("precision highp float;","precision highp float;\n out vec4 fragmentColor;")}\n `:n(n(i,"VARYING","varying"),"OUTPUT_COLOR","gl_FragColor"),a=se(t,t.VERTEX_SHADER,o),l=se(t,t.FRAGMENT_SHADER,r),c=t.createProgram();if(!c)throw t.deleteShader(a),t.deleteShader(l),new Error("无法创建电子围栏 WebGL program。");if(t.attachShader(c,a),t.attachShader(c,l),t.linkProgram(c),t.deleteShader(a),t.deleteShader(l),!t.getProgramParameter(c,t.LINK_STATUS)){const e=t.getProgramInfoLog(c)||"未知 program 链接错误";throw t.deleteProgram(c),new Error(`电子围栏 WebGL program 链接失败:${e}`)}return c})(e),this.locations=((t,e)=>({position:t.getAttribLocation(e,"a_position"),normal:t.getAttribLocation(e,"a_normal"),heightRatio:t.getAttribLocation(e,"a_height_ratio"),pathProgress:t.getAttribLocation(e,"a_path_progress"),color:t.getAttribLocation(e,"a_color"),flowColor:t.getAttribLocation(e,"a_flow_color"),glowStrength:t.getAttribLocation(e,"a_glow_strength"),flowWidth:t.getAttribLocation(e,"a_flow_width"),flowCount:t.getAttribLocation(e,"a_flow_count"),flowLineStyle:t.getAttribLocation(e,"a_flow_line_style"),matrix:de(t,e,"u_matrix"),time:de(t,e,"u_time"),speed:de(t,e,"u_speed"),animationEnabled:de(t,e,"u_animation_enabled"),glowPass:de(t,e,"u_glow_pass"),glowOpacity:de(t,e,"u_glow_opacity")}))(e,this.program),this.buffer=e.createBuffer()||void 0,!this.buffer)throw new Error("无法创建电子围栏 WebGL 顶点缓冲。");this.uploadGeometry(e)}render(t,e){if(!(this.visible&&this.program&&this.buffer&&this.locations&&(this.geometry.glowPasses.length||this.geometry.bodyVertexCount)))return;const o=19*Float32Array.BYTES_PER_ELEMENT,i=(e,i,n)=>{t.enableVertexAttribArray(e),t.vertexAttribPointer(e,i,t.FLOAT,!1,o,n*Float32Array.BYTES_PER_ELEMENT)};t.useProgram(this.program),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),i(this.locations.position,3,0),i(this.locations.normal,3,3),i(this.locations.heightRatio,1,6),i(this.locations.pathProgress,1,7),i(this.locations.color,4,8),i(this.locations.flowColor,3,12),i(this.locations.glowStrength,1,15),i(this.locations.flowWidth,1,16),i(this.locations.flowCount,1,17),i(this.locations.flowLineStyle,1,18),t.uniformMatrix4fv(this.locations.matrix,!1,e.defaultProjectionData.mainMatrix),t.uniform1f(this.locations.time,performance.now()/1e3),t.uniform1f(this.locations.speed,this.animation.speed),t.uniform1f(this.locations.animationEnabled,this.animation.enabled?1:0),t.enable(t.BLEND),t.enable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.depthMask(!1),this.geometry.glowPasses.length&&(t.blendFunc(t.SRC_ALPHA,t.ONE),t.uniform1f(this.locations.glowPass,1),this.geometry.glowPasses.forEach(e=>{t.uniform1f(this.locations.glowOpacity,e.opacity),t.drawArrays(t.TRIANGLES,e.first,e.count)})),this.geometry.bodyVertexCount&&(t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.uniform1f(this.locations.glowPass,0),t.uniform1f(this.locations.glowOpacity,0),t.drawArrays(t.TRIANGLES,this.geometry.bodyFirst,this.geometry.bodyVertexCount)),t.depthMask(!0),t.bindBuffer(t.ARRAY_BUFFER,null)}onRemove(t,e){this.buffer&&e.deleteBuffer(this.buffer),this.program&&e.deleteProgram(this.program),this.map=void 0,this.gl=void 0,this.buffer=void 0,this.program=void 0,this.locations=void 0}uploadGeometry(t){const e=t||this.gl;e&&this.buffer&&(e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bufferData(e.ARRAY_BUFFER,this.geometry.vertices,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null))}}const he=(t,e)=>t?"string"==typeof t&&m(t)?_(t,{token:e}):t:_("openfreemap-liberty");t.maplibregl=e,t.BASE_MAP_TYPES=y,t.OPENFREEMAP_STYLES=a,t.OPENFREEMAP_STYLE_BASE_URL=n,t.OPENFREEMAP_STYLE_TYPES=l,t.TDT_STYLE_TYPES=["tdt-image","tdt-image-label","tdt-mvt","tdt-mvt-label"],t.addBreachAlert=(t,e)=>{const o=e.id,i=`${o}-fence-source`,n=`${o}-fence-fill`,r=`${o}-fence-line`,a=`${o}-ripple-source`,l=`${o}-ripple-line`;let c,s,d,f={...e},h=!1,p=!1,u=!1,g=!1,y=0;const m=()=>f.fenceColor??"#1677ff",_=()=>f.fenceFillColor??m(),w=()=>f.fenceFillOpacity??.1,v=()=>f.fenceBorderWidth??2,b=()=>f.fenceBorderOpacity??.9,M=()=>f.fenceAlertColor??"#ff3b30",$=()=>f.rippleColor??M(),k=e=>{const o=t.getSource(a);o&&o.setData(e)},x=t=>{const e=Math.max(20,f.rippleRadius??800),o=Math.max(1,f.rippleCount??3),i=Math.max(400,f.rippleDuration??1500),n=Math.max(1,f.rippleLineWidth??3),r=performance.now(),a=l=>{k(((t,e,o,i,n,r)=>{const a=[];for(let l=0;l<o;l+=1){const c=(r/i+l/o)%1,s=c*e;s<1||a.push(G(P(t,s),{kind:"ring",opacity:.95*(1-c),width:n*(1-.3*c)}))}return E(a)})(t,e,o,i,n,l-r)),y=requestAnimationFrame(a)};y=requestAnimationFrame(a)},A=()=>{if(!u)return;const e=m(),o=_();t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",o),t.setPaintProperty(n,"fill-opacity",w())),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-width",v()),t.setPaintProperty(r,"line-opacity",b()))},F=()=>{const e=f.tacticalColor??M(),o=Math.max(1,f.tacticalBorderWidth??4),i="viewport"===f.tacticalScope?12:0,n=Math.max(60,f.fenceFlashInterval??200),r=t.getContainer(),a=document.createElement("div");a.style.position="absolute",a.style.inset=`${i}px`,a.style.border=`${o}px solid ${e}`,a.style.boxShadow=`inset 0 0 ${6*o}px ${e}`,a.style.pointerEvents="none",a.style.zIndex="5",a.style.opacity="1",r.appendChild(a),d=a;let l=!0;s=setInterval(()=>{l=!l,a.style.opacity=l?"1":"0.15"},n)},C=()=>{const e=(t=>{if(!t)return[];if(Array.isArray(t))return[{type:"Polygon",coordinates:t}];switch(t.type){case"Polygon":return[t];case"MultiPolygon":return t.coordinates.map(t=>({type:"Polygon",coordinates:t}));case"Feature":{const e=t.geometry;return"Polygon"===(null==e?void 0:e.type)?[e]:"MultiPolygon"===(null==e?void 0:e.type)?e.coordinates.map(t=>({type:"Polygon",coordinates:t})):[]}case"FeatureCollection":{const e=[];for(const o of t.features){const t=o.geometry;"Polygon"===(null==t?void 0:t.type)?e.push(t):"MultiPolygon"===(null==t?void 0:t.type)&&e.push(...t.coordinates.map(t=>({type:"Polygon",coordinates:t})))}return e}default:return[]}})(f.fence);if(0===e.length)return;const o=E(e.map(t=>G(t,{kind:"fence"})));if(u){const e=t.getSource(i);e&&e.setData(o),A()}else t.getSource(i)?t.getSource(i).setData(o):t.addSource(i,{type:"geojson",data:o}),t.getLayer(n)||t.addLayer({id:n,type:"fill",source:i,filter:["==",["get","kind"],"fence"],paint:{"fill-color":_(),"fill-opacity":w()}},f.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get","kind"],"fence"],paint:{"line-color":m(),"line-width":v(),"line-opacity":b()}},f.beforeId),u=!0,T(t,[n,r],!1!==f.visible)},S=()=>{p&&!h&&O()},O=()=>{if(!h)try{C(),t.getSource(a)||t.addSource(a,{type:"geojson",data:E([])}),t.getLayer(l)?t.getLayer(l)&&t.setPaintProperty(l,"line-color",$()):(t.addLayer({id:l,type:"line",source:a,filter:["==",["get","kind"],"ring"],paint:{"line-color":$(),"line-opacity":["coalesce",["get","opacity"],.9],"line-width":["coalesce",["get","width"],3]}},f.beforeId),T(t,[l],!1!==f.visible)),p=!1,t.off("styledata",S)}catch(e){if(!V(e))throw e;p||(p=!0,t.on("styledata",S))}},L=()=>{c&&(clearInterval(c),c=void 0),y&&(cancelAnimationFrame(y),y=0),k(E([])),s&&(clearInterval(s),s=void 0),d&&(d.remove(),d=void 0),A()};return O(),{id:o,update(t){h||(f={...f,...t,id:o},O())},show(){h||(f={...f,visible:!0},T(t,[n,r,l],!0))},hide(){h||(f={...f,visible:!1},T(t,[n,r,l],!1))},remove(){h||(h=!0,p&&(p=!1,t.off("styledata",S)),L(),j(t,l),j(t,r),j(t,n),D(t,a),D(t,i),u=!1)},trigger(e){if(h)return;g&&L();const o=e??f.center;g=!0,!1!==f.fenceFlash&&(()=>{if(!u)return;const e=M(),o=Math.max(60,f.fenceFlashInterval??200);let i=!0;t.getLayer(n)&&(t.setPaintProperty(n,"fill-color",e),t.setPaintProperty(n,"fill-opacity",.42)),t.getLayer(r)&&(t.setPaintProperty(r,"line-color",e),t.setPaintProperty(r,"line-opacity",1)),c=setInterval(()=>{i=!i;const e=i?.42:.08,o=i?1:.4;t.getLayer(n)&&t.setPaintProperty(n,"fill-opacity",e),t.getLayer(r)&&t.setPaintProperty(r,"line-opacity",o)},o)})(),!1!==f.ripple&&x(o),f.tacticalFlash&&F()},reset(){h||(L(),g=!1)},isActive:()=>g}},t.addBreathingCircle=(t,e)=>z(t,e,X),t.addCoordinatedCountermeasure=(t,e)=>z(t,e,$t),t.addCountermeasureBeam=(t,e)=>z(t,e,bt),t.addDefenceCircle=(t,e)=>z(t,e,wt),t.addDirectionalPulse=(t,e)=>z(t,e,ht),t.addNavigationSpoofing=(t,e)=>z(t,e,xt),t.addPulseMarker=(t,e)=>z(t,e,U),t.addRadarPowerGroup=(t,e)=>{const{source:o,layers:i}=(t=>{const e=`${t}-source`;return{source:e,layers:[{id:`${t}-fill`,type:"fill",source:e,filter:["==",["get","kind"],"fill"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-core`,type:"fill",source:e,filter:["==",["get","kind"],"core"],paint:{"fill-color":["coalesce",["get","color"],"#38ff4a"],"fill-opacity":["coalesce",["get","opacity"],0]}},{id:`${t}-ring`,type:"line",source:e,filter:["==",["get","kind"],"ring"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.95],"line-width":["coalesce",["get","width"],2]}},{id:`${t}-crosshair`,type:"line",source:e,filter:["==",["get","kind"],"crosshair"],paint:{"line-color":["coalesce",["get","color"],"#38ff4a"],"line-opacity":["coalesce",["get","opacity"],.5],"line-width":["coalesce",["get","width"],1.4]}},{id:`${t}-labels`,type:"symbol",source:e,filter:["==",["get","kind"],"distance-label"],layout:{"text-field":["get","text"],"text-size":["coalesce",["get","size"],12],"text-anchor":["get","textAnchor"],"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":["coalesce",["get","color"],"#38ff4a"],"text-opacity":["coalesce",["get","opacity"],.92],"text-halo-color":["coalesce",["get","haloColor"],"rgba(15, 23, 42, 0.42)"],"text-halo-width":1}}]}})(e.id);let n=[...e.radars??[]],r=!1;t.addSource(o,{type:"geojson",data:I}),i.forEach(o=>{t.addLayer(o,e.beforeId)});const a=t.getSource(o),l=i.map(t=>t.id),c=e=>{l.forEach(o=>{t.getLayer(o)&&t.setLayoutProperty(o,"visibility",e?"visible":"none")})},s=t=>{r||(n=t.map(t=>({...t})),a.setData(N(n)))};return n.length>0&&s(n),!1===e.visible&&c(!1),{id:e.id,sourceId:o,layerIds:l,setData:s,updateRadar(t,e){const o=n.findIndex(e=>e.id===t);o<0||r||(n[o]={...n[o],...e,id:t},a.setData(N(n)))},setRadarVisible(t,e){const o=n.find(e=>e.id===t);o&&!r&&(o.visible=e,a.setData(N(n)))},removeRadar(t){r||(n=n.filter(e=>e.id!==t),a.setData(N(n)))},show(){r||c(!0)},hide(){r||c(!1)},remove(){r||(r=!0,[...l].reverse().forEach(e=>((t,e)=>{t.getLayer(e)&&t.removeLayer(e)})(t,e)),((t,e)=>{t.getSource(e)&&t.removeSource(e)})(t,o))}}},t.addRadarSweep=(t,e)=>z(t,e,mt),t.addRingPulseMarker=(t,e)=>z(t,e,H),t.addSectorScan=(t,e)=>z(t,e,dt),t.addStandardElectronicFenceLayer=(t,e)=>{Lt(e.id,e.defaults);const o=new St,i=`${e.id}-standard-source`,n=`${e.id}-standard-extrusion`,r=`${e.id}-standard-outline`,a=`${e.id}-standard-interaction`,l=[n,r,...!1===e.interactive?[]:[a]];let c=te(o,e),s=!1!==e.visible,d=!1;const f=()=>{if(!d)try{t.getSource(i)||t.addSource(i,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer({id:n,type:"fill-extrusion",source:i,filter:["==",["get",Bt],"wall"],paint:{"fill-extrusion-color":["get",Ht],"fill-extrusion-opacity":1,"fill-extrusion-base":["get",Kt],"fill-extrusion-height":["get",Qt],"fill-extrusion-vertical-gradient":!0}},e.beforeId),t.getLayer(r)||t.addLayer({id:r,type:"line",source:i,filter:["==",["get",Bt],"boundary"],paint:{"line-color":["get",Jt],"line-width":["get",Xt],"line-opacity":1}},e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:i,filter:["==",["get",Bt],"boundary"],paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),Yt(t,l,s)}catch(o){if(!zt(o))throw o}},h=()=>{f()};t.on("styledata",h),f();const p=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"standard",layerId:a,store:o});return Ut({id:e.id,renderer:"standard",store:o,refresh:()=>{c=te(o,e);const n=t.getSource(i);n?n.setData(c):f()},setPluginVisible(e){s=e,f(),Yt(t,l,s)},destroy(){d=!0,t.off("styledata",h),p(),[...l].reverse().forEach(e=>{t.getLayer(e)&&t.removeLayer(e)}),t.getSource(i)&&t.removeSource(i)}})},t.addTargetLock=(t,o)=>{const i=o.id;let n,r={...o},a=!1;const l=document.createElement("div"),c=document.createElement("div"),s=Array.from({length:4},()=>document.createElement("div")),d=Array.from({length:4},()=>document.createElement("div"));l.dataset.effectId=i,l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.pointerEvents="none",c.style.position="absolute",c.style.inset="0",l.appendChild(c),s.forEach(t=>{t.style.position="absolute",t.style.boxSizing="border-box",c.appendChild(t)}),d.forEach(t=>{t.style.position="absolute",l.appendChild(t)});const f=new e.Marker({element:l,anchor:"center"}).setLngLat(r.center).addTo(t),h=()=>{const t=r.color??"#ff3b30",e=Math.max(24,r.size??72),o=Math.max(1,r.lineWidth??2),i=Math.min(e/2,Math.max(2*o,r.cornerLength??18)),a=Math.max(2,r.crosshairLength??10),h=Math.max(0,r.crosshairGap??5);f.setLngLat(r.center),l.style.width=`${e}px`,l.style.height=`${e}px`,l.style.display=!1===r.visible?"none":"block",l.style.opacity=`${Math.min(1,Math.max(0,r.opacity??1))}`,s.forEach(t=>{t.style.width=`${i}px`,t.style.height=`${i}px`,t.style.border="0"}),Object.assign(s[0].style,{left:"0",top:"0",borderLeft:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[1].style,{right:"0",top:"0",borderRight:`${o}px solid ${t}`,borderTop:`${o}px solid ${t}`}),Object.assign(s[2].style,{right:"0",bottom:"0",borderRight:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),Object.assign(s[3].style,{left:"0",bottom:"0",borderLeft:`${o}px solid ${t}`,borderBottom:`${o}px solid ${t}`}),d.forEach(e=>{e.style.display=!1===r.showCrosshair?"none":"block",e.style.background=t}),Object.assign(d[0].style,{width:`${o}px`,height:`${a}px`,left:"50%",bottom:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[1].style,{width:`${o}px`,height:`${a}px`,left:"50%",top:`calc(50% + ${h}px)`,transform:"translateX(-50%)"}),Object.assign(d[2].style,{width:`${a}px`,height:`${o}px`,right:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),Object.assign(d[3].style,{width:`${a}px`,height:`${o}px`,left:`calc(50% + ${h}px)`,top:"50%",transform:"translateY(-50%)"}),null==n||n.cancel(),n=void 0,c.style.transform="rotate(0deg)",!1!==r.rotate&&(n=c.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:Math.max(300,r.rotationDuration??2400),iterations:1/0}))};return h(),{id:i,update(t){a||(r={...r,...t,id:i},h())},show(){a||(r={...r,visible:!0},l.style.display="block")},hide(){a||(r={...r,visible:!1},l.style.display="none")},remove(){a||(a=!0,null==n||n.cancel(),n=void 0,f.remove())}}},t.addWebGLElectronicFenceLayer=(t,e)=>{Lt(e.id,e.defaults);const o=(t=>({enabled:(null==t?void 0:t.enabled)??!0,fps:Math.round(Dt((null==t?void 0:t.fps)??30,1,60)),speed:Math.max(0,(null==t?void 0:t.speed)??.35),scope:(null==t?void 0:t.scope)??"all"}))(e.animation),i=new St,n=`${e.id}-webgl`,r=`${e.id}-webgl-interaction-source`,a=`${e.id}-webgl-interaction`,l=new fe(n,o);let c=Tt(i),s=ce(i,e,o),d=!1!==e.visible,f=!1,h=0,p=0;const u=()=>{h&&(cancelAnimationFrame(h),h=0)},g=e=>{!f&&d&&s.animated?(("undefined"==typeof document||!document.hidden)&&e-p>=1e3/o.fps&&(p=e,t.triggerRepaint()),h=requestAnimationFrame(g)):h=0},y=()=>{const e=o.enabled&&d&&s.animated&&!!t.getLayer(n);e&&!h?(p=0,h=requestAnimationFrame(g)):e||u()},m=()=>{if(!f)try{!1===e.interactive||t.getSource(r)||t.addSource(r,{type:"geojson",data:c}),t.getLayer(n)||t.addLayer(l,e.beforeId),!1===e.interactive||t.getLayer(a)||t.addLayer({id:a,type:"fill",source:r,paint:{"fill-color":"#000000","fill-opacity":0}},e.beforeId),l.setVisible(d),Yt(t,!1===e.interactive?[]:[a],d),y()}catch(o){if(!zt(o))throw o}},_=()=>{m()};l.setGeometry(s),t.on("styledata",_),m();const w=!1===e.interactive?()=>{}:Vt({map:t,instanceId:e.id,renderer:"webgl",layerId:a,store:i});return Ut({id:e.id,renderer:"webgl",store:i,refresh:()=>{s=ce(i,e,o),c=Tt(i),l.setGeometry(s);const n=t.getSource(r);n&&n.setData(c),m(),y()},setPluginVisible(o){d=o,l.setVisible(d),m(),Yt(t,!1===e.interactive?[]:[a],d),y()},destroy(){f=!0,u(),t.off("styledata",_),w(),t.getLayer(a)&&t.removeLayer(a),t.getLayer(n)&&t.removeLayer(n),t.getSource(r)&&t.removeSource(r)}})},t.createFenceCircle=(t,e,o)=>C(t,e,o),t.createMap=t=>{const{style:o,tdtToken:i,...n}=t;return new e.Map({...n,style:he(o,i)})},t.createTiandituImageStyle=u,t.createTiandituRasterSource=h,t.getBaseMapStyle=_,t.getMaplibreToolsConfig=i,t.getOpenFreeMapStyle=c,t.isBaseMapType=m,t.setBaseMap=(t,e,o={})=>{const{diff:i=!1,...n}=o;t.setStyle(_(e,n),{diff:i})},t.setMaplibreToolsConfig=t=>{Object.assign(o,t)},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -125,6 +125,8 @@ export interface SectorScanOptions extends BaseEffectOptions {
|
|
|
125
125
|
outlineWidth?: number;
|
|
126
126
|
/** 旋转速度,单位度/秒;不传或为 0 时静止。 */
|
|
127
127
|
rotationSpeed?: number;
|
|
128
|
+
/** 动画帧率上限,单位 FPS;默认 30,传 0 表示不限制。 */
|
|
129
|
+
frameRate?: number;
|
|
128
130
|
}
|
|
129
131
|
/** 定向脉冲:一组沿指定方向推进的弧线。 */
|
|
130
132
|
export interface DirectionalPulseOptions extends BaseEffectOptions {
|