bigmap-plugin 1.0.4 → 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.
@@ -1,21 +1,21 @@
1
- (function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.BigmapPlugin={},g.Vue))})(this,(function(g,o){"use strict";const dt={debug:10,info:20,warn:30,error:40,silent:Number.POSITIVE_INFINITY},ve="[sems-map]";function Yn(){try{const e=typeof process<"u"?process.env:void 0;if(e&&e.NODE_ENV==="production")return"warn"}catch{}return"debug"}let Pe=Yn();function qn(e){Pe=e}function Kn(){return Pe}function Ce(e){return dt[e]>=dt[Pe]}const w={debug(...e){Ce("debug")&&console.debug(ve,...e)},info(...e){Ce("info")&&console.info(ve,...e)},warn(...e){Ce("warn")&&console.warn(ve,...e)},error(...e){Ce("error")&&console.error(ve,...e)}},ft=Symbol("originalHandler");class Be{constructor(){this.events=new Map}on(t,n){return this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n),()=>this.off(t,n)}once(t,n){const r=i=>{n(i),this.off(t,r)};return r[ft]=n,this.on(t,r)}off(t,n){if(!n){this.events.delete(t);return}const r=this.events.get(t);if(!r)return;const i=r.findIndex(a=>a===n||a[ft]===n);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(t)}async emit(t,n){const r=this.events.get(t);if(!r||r.length===0)return;const i=r.slice(),a=[];for(const l of i)try{const s=l(n);s&&typeof s.then=="function"&&a.push(s.catch(u=>{w.error(`[EventBus] Error in async handler for event "${String(t)}":`,u)}))}catch(s){w.error(`[EventBus] Error in handler for event "${String(t)}":`,s)}a.length>0&&await Promise.all(a)}clear(){this.events.clear()}getStats(){return Array.from(this.events.entries()).map(([t,n])=>({event:String(t),handlerCount:n.length}))}}const Xn=new Be,oe=new Map;function q(e){oe.set(e.type,e)}q({type:"area",name:"测面积",defaultSize:15,icon:"area",toolbarOrder:4,buildConfig:({shared:e})=>({material:e.fill,labelOptions:e.label})}),q({type:"polygon",name:"绘制多边形",defaultSize:14,icon:"polygon",toolbarOrder:1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})}),q({type:"circle",name:"绘制圆形",defaultSize:17,icon:"circle",toolbarOrder:2,buildConfig:({bmgl:e,config:t,shared:n})=>({material:n.fill,width:n.width,controlLine:{permanent:!0,lineStyle:{width:n.width,clampToGround:!0,material:n.border},textStyle:{font:t.labelFont,disableDepthTestDistance:1/0,verticalOrigin:e.VerticalOrigin.BOTTOM}}})}),q({type:"azimuth",name:"测方位",defaultSize:15,icon:"azimuth",toolbarOrder:6,buildConfig:({bmgl:e,config:t})=>({clampToGround:!0,material:new e.PolylineArrowMaterialProperty(e.Color.fromCssColorString(t.fillColor)),width:t.arrowWidth,labelOptions:{fillColor:e.Color.YELLOW}})}),q({type:"ruler",name:"测距离",defaultSize:15,icon:"ruler",toolbarOrder:5,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill,labelOptions:t.label})}),q({type:"polyline",name:"绘制线",defaultSize:16,icon:"polyline",toolbarOrder:3,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill})}),q({type:"triangle",name:"绘制三角形",defaultSize:16,icon:"triangle",inDefaultToolbar:!1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:4,material:t.fill})}),q({type:"rectangle",name:"绘制矩形",defaultSize:16,icon:"rectangle",toolbarOrder:0,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})});function Zn(e){oe.set(e.type,e)}function ht(e){return oe.get(e)}function gt(){return[...oe.values()]}function pt(){return[...oe.values()].filter(e=>e.inDefaultToolbar!==!1).sort((e,t)=>(e.toolbarOrder??Number.MAX_SAFE_INTEGER)-(t.toolbarOrder??Number.MAX_SAFE_INTEGER))}function mt(){return pt().map(e=>({icon:e.type,name:e.name,size:e.defaultSize}))}const be="/libs",te={lng:104.03770513,lat:30.48187111,height:2e4},Ee={heading:6.267876539812834,pitch:-1.3962634015954636,roll:.00016118230151462853},Te={FLY_TO:2,MORPH:.8,WAVE:3e3},ne={BATCH_SIZE:200,YIELD_BUDGET_MS:8,DEBOUNCE_DELAY:300,GRID_SIZE:.1},Re=mt(),wt={spacing:150,width:2},yt={autoPlay:!1,speed:1,loop:!1,follow:!1,followHeight:2e3,trailTime:10,duration:0,interval:1,markerColor:"#ff3b30",markerSize:12,markerIcon:"",lineColor:"#0a84ff",lineWidth:4,maxPoints:2e4},vt={fillColor:"#000000",fillAlpha:.8,outlineColor:"#44d5ff",outlineAlpha:1,outlineWidth:4,showOutline:!0},ze={containerId:"bigmap-container",libsUrl:be,mapType:"3d",position:te,mapId:"bigemap.cebjohn0",terrainId:"bigemap.dc-terrain",showSearch:!1,showControls:!0,showStatus:!1,showDeleteControls:!0,tools:Re,searchDebounceTime:ne.DEBOUNCE_DELAY},H={METERS_PER_DEGREE_LAT:111320,METERS_PER_DEGREE_LAT_APPROX:111e3,CAMERA_FOV_DEGREES:60,MIN_CAMERA_HEIGHT:1e3},Ct=500,bt=800,Jn=200,Qn=900,Et=1e4,er=100,tr=1e3,Tt={NEAR:3e3,NEAR_VALUE:1,FAR:1e5,FAR_VALUE:.1},nr=6,rr=1001,R={1:{color:"#9E9E9E",text:"未发布"},2:{color:"#2196F3",text:"已发布"},3:{color:"#FF9800",text:"未完成"},4:{color:"#4CAF50",text:"已完成"},5:{color:"#FF5722",text:"整改"},6:{color:"#E91E63",text:"整改中"},7:{color:"#8BC34A",text:"整改完成"},8:{color:"#009688",text:"合格"},9:{color:"#00BCD4",text:"整改合格"},10:{color:"#F44336",text:"不合格"},11:{color:"#9C27B0",text:"变观中"},12:{color:"#673AB7",text:"已变观"},13:{color:"#607D8B",text:"任务终止"},default:{color:"#2196F3",text:"未知状态"}},ir=e=>R[e]||R.default;function ar(e){if(!e)return{};const t={};for(const n of Object.keys(e)){const r=e[n];r!==void 0&&(t[n]=r)}return t}function Fe(...e){const t={...ze};for(const n of e){const r=ar(n);Object.assign(t,r),r.geoserver&&(t.geoserver={...t.geoserver||{},...r.geoserver})}return t}function or(e,t){return Fe(e,t)}class St{constructor(t){this.config=Fe(t)}get(t){return this.config[t]}set(t,n){this.config[t]=n}getAll(){return{...this.config}}update(t){this.config=Fe(this.config,t)}reset(){this.config={...ze}}}class Dt{constructor(){this.resources=new Set}register(t){this.resources.add(t)}unregister(t){this.resources.delete(t)}async cleanup(){const t=Array.from(this.resources);this.resources.clear(),await Promise.allSettled(t.map(async n=>{try{await n()}catch(r){w.error("[ResourceManager] Error during cleanup:",r)}}))}getResourceCount(){return this.resources.size}}function lr(e){return{isReady:!1,isLoading:!1,mapType:e==="2d"?"2d":"3d",cameraPosition:{lng:0,lat:0,height:0,altitude:0,heading:0,pitch:0,roll:0},bounds:null,error:null}}function sr(e){return{configManager:new St(e),eventBus:new Be,resourceManager:new Dt,map:o.shallowRef(null),state:o.ref(lr(e.mapType||"3d")),cancelled:{value:!1},destroyed:{value:!1},initializing:{value:!1}}}const Mt=be,Oe={"bigemap-2d":{name:"BigMap 2D",path:"/libs/bigemap/bigemap.js",dependencies:["bigemap-2d-css"]},"bigemap-2d-css":{name:"BigMap 2D CSS",path:"/libs/bigemap/bigemap.css",isCss:!0},"bigemap-3d":{name:"BigMap 3D",path:"/bigemap-gl.js/v1.1.0/bigemap-gl.js",dependencies:["bigemap-3d-css"]},"bigemap-3d-css":{name:"BigMap 3D CSS",path:"/libs/bigemap/widgets.css",isCss:!0},"bmgl-plot":{name:"BigMap Plot",path:"/libs/bigemap/bmgl-plot.min.js",dependencies:["bigemap-3d"]},"circle-wave":{name:"Circle Wave",path:"/libs/bigemap/circleWave.js",dependencies:["bmgl-plot"]},"bm-geometry-util":{name:"BigMap Geometry Util",path:"/libs/bigemap/bm.geometryutil.js",dependencies:["bigemap-3d"]},"move-marker":{name:"BigMap Move Marker",path:"/libs/bigemap/moveMarker.js",dependencies:["bigemap-3d","bm-geometry-util"]},"bmgl-header":{name:"BMGL Sandcastle Header",path:"/libs/bigemap/bmgl-header.js",dependencies:["bigemap-3d"]}};function Ge(e,t,n){if(e.path.startsWith("/libs/"))return n+e.path.slice(5);if(e.path.startsWith("/")){if(!t)throw new Error(`未配置 serverUrl,无法解析地图资源路径: ${e.path}`);return t.replace(/\/$/,"")+e.path}return e.path}const Se=3e4;class It{constructor(){this.loaded=new Set,this.pending=new Map}loadJs(t){return new Promise((n,r)=>{if(document.querySelector(`script[src="${t}"]`)){n();return}const i=document.createElement("script");i.src=t,i.async=!0;let a=!1;const l=setTimeout(()=>{a||(a=!0,i.remove(),r(new Error(`脚本加载超时(${Se/1e3}s): ${t}`)))},Se);i.onload=()=>{a||(a=!0,clearTimeout(l),n())},i.onerror=()=>{a||(a=!0,clearTimeout(l),i.remove(),r(new Error(`脚本加载失败: ${t}`)))},document.head.appendChild(i)})}loadCss(t){return new Promise((n,r)=>{if(document.querySelector(`link[href="${t}"]`)){n();return}const i=document.createElement("link");i.rel="stylesheet",i.href=t;let a=!1;const l=setTimeout(()=>{a||(a=!0,i.remove(),r(new Error(`样式加载超时(${Se/1e3}s): ${t}`)))},Se);i.onload=()=>{a||(a=!0,clearTimeout(l),n())},i.onerror=()=>{a||(a=!0,clearTimeout(l),i.remove(),r(new Error(`样式加载失败: ${t}`)))},document.head.appendChild(i)})}loadResource(t,n,r){const i=Ge(t,n,r);if(this.loaded.has(i))return Promise.resolve();if(this.pending.has(i))return this.pending.get(i);const a=t.isCss?this.loadCss(i):this.loadJs(i);return this.pending.set(i,a),a.then(()=>{this.loaded.add(i)}).finally(()=>{this.pending.delete(i)}),a}async loadWithDependencies(t,n,r,i){const l={...Oe,...i}[t];if(!l)throw new Error(`库配置未找到: ${t}`);for(const s of l.dependencies||[])await this.loadWithDependencies(s,n,r,i);await this.loadResource(l,n,r)}async loadScripts(t,n,r=Mt,i){await Promise.all(t.map(a=>this.loadWithDependencies(a,n,r,i)))}isLoaded(t,n,r){const i=Oe[t];if(!i||i.path.startsWith("/")&&!i.path.startsWith("/libs/")&&!n)return!1;const a=Ge(i,n||"",r||Mt);return this.loaded.has(a)}clearLoaded(){this.loaded.clear(),this.pending.clear()}}const Ue=new It;let le=null;function At(e){le=e}function D(){return le||(typeof window<"u"&&window.bmgl?(le=window.bmgl,le):null)}function N(){const e=D();if(!e)throw new Error("bmgl 库未就绪:请确保地图初始化完成后再调用该能力");return e}async function xt(e=3e3){const t=D();return t||new Promise((n,r)=>{const i=Date.now(),a=setInterval(()=>{const l=D();l?(clearInterval(a),n(l)):Date.now()-i>e&&(clearInterval(a),r(new Error("bmgl 加载超时")))},50)})}class Z{constructor(){this.entries=new Map}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}register(t,n,r,i){this.entries.set(t,{map:n,eventBus:r,resourceManager:i})}get(t){return this.entries.get(t)?.map}has(t){return this.entries.has(t)}getEventBus(t){return this.entries.get(t)?.eventBus}getResourceManager(t){return this.entries.get(t)?.resourceManager}async unregister(t){const n=this.entries.get(t);if(n&&(this.entries.delete(t),await n.resourceManager.cleanup(),n.eventBus.clear(),!n.map.isDestroyed?.()))try{n.map.destroy()}catch(r){w.error("[MapManager] Error destroying map:",r)}}getAllMapIds(){return Array.from(this.entries.keys())}async cleanupAll(){const t=this.getAllMapIds();await Promise.all(t.map(n=>this.unregister(n)))}}const se=Z.getInstance();function cr(e,t=3e3){return new Promise((n,r)=>{const i=Date.now(),a=setInterval(()=>{document.getElementById(e)?(clearInterval(a),n()):Date.now()-i>t&&(clearInterval(a),r(new Error(`容器未找到: ${e}`)))},16)})}async function ur(e){const t=e.configManager.get("containerId");if(!t)throw new Error("容器ID未定义");return await cr(t),t}async function dr(e){const t=e.configManager.get("serverUrl"),n=e.configManager.get("accessToken"),r=e.configManager.get("libsUrl"),i=e.configManager.get("extraLibs");try{await Ue.loadScripts(["bigemap-3d","bmgl-plot","circle-wave"],t,r,i)}catch(l){throw w.error("[loadBmglScripts] 地图服务连接失败,请确认 serverUrl 可达且服务已启动:",l),new Error("地图服务连接失败,请确认服务器地址正确且服务已启动")}const a=D();if(!a)throw new Error("BMGL 库加载失败");At(a),a.Config.HTTP_URL=t,n&&(console.log("accessToken",n),a.Config.accessToken=n),fr(a)}function fr(e){e.RequestScheduler&&(e.RequestScheduler.maximumRequests=120,e.RequestScheduler.maximumRequestsPerServer=18)}function hr(e){const t=D(),n=e.configManager.get("containerId");if(!t||!n)throw new Error("地图实例创建失败:BMGL 库或容器 ID 未就绪");const r=new t.Viewer(n,{mapId:e.configManager.get("mapId"),terrainId:e.configManager.get("terrainId"),requestRenderMode:!1,selectionIndicator:!1,infoBox:!1});return gr(r,e.state.value.mapType),r}function gr(e,t){t==="3d"&&(e.scene.globe.depthTestAgainstTerrain=!0);const n=e.scene,r=e.scene.globe;n.preloadFlightDestinations=!0,r.tileCacheSize=1e3,r.preloadAncestors=!0,r.preloadSiblings=!0,r.maximumScreenSpaceError=1.5}async function pr(e,t,n){if(se.has(n))try{await se.unregister(n)}catch(r){w.warn(`[registerMap] 清理残留地图实例失败 (${n}):`,r)}se.register(n,t,e.eventBus,e.resourceManager)}function Lt(e){return typeof e=="number"&&!Number.isNaN(e)?e:1e4}function Nt(e,t,n){const r=D();if(!r)throw new Error("BMGL 库未加载,无法构造相机目标位置");return r.Cartesian3.fromDegrees(e,t,n)}function kt(){return{heading:Ee.heading,pitch:Ee.pitch,roll:Ee.roll}}function mr(e){const t=e.configManager.get("position");t&&e.map.value?.camera.flyTo({destination:Nt(t.lng,t.lat,Lt(t.height)),orientation:kt(),duration:Te.FLY_TO})}function wr(e,t,n,r){e.map.value&&e.map.value.camera.flyTo({destination:Nt(t,n,Lt(r)),orientation:kt(),duration:Te.FLY_TO})}function yr(e){const t=D();if(!e.map.value||!t)return null;const n=e.map.value.camera.computeViewRectangle();return n?{minx:t.Math.toDegrees(n.west),maxx:t.Math.toDegrees(n.east),miny:t.Math.toDegrees(n.south),maxy:t.Math.toDegrees(n.north)}:vr(e)}function vr(e){const t=D();if(!t)return null;const n=e.map.value,r=n.scene.globe.ellipsoid;try{const i=n.camera.pickEllipsoid(new t.Cartesian2(0,0),r),a=n.camera.pickEllipsoid(new t.Cartesian2(n.scene.canvas.clientWidth,n.scene.canvas.clientHeight),r);if(!i||!a)return null;const l=r.cartesianToCartographic(i),s=r.cartesianToCartographic(a);return{minx:t.Math.toDegrees(l.longitude),maxx:t.Math.toDegrees(s.longitude),miny:t.Math.toDegrees(s.latitude),maxy:t.Math.toDegrees(l.latitude)}}catch{return null}}function Cr(e){return e.initializing.value||!!e.map.value||e.destroyed.value}async function br(e){if(!Cr(e)){e.cancelled.value=!1,e.initializing.value=!0,e.state.value.isLoading=!0,e.state.value.error=null;try{await Er(e)}catch(t){throw e.state.value.error=t instanceof Error?t:new Error(String(t)),await e.eventBus.emit("map:error",t),t}finally{e.initializing.value=!1,e.state.value.isLoading=!1}}}async function Er(e){const t=await ur(e);if(await dr(e),e.cancelled.value)return;const n=hr(e);if(e.cancelled.value){Tr(n);return}e.map.value=n,await pr(e,n,t),await mr(e),!e.cancelled.value&&(e.state.value.isReady=!0,await e.eventBus.emit("map:ready"))}function Tr(e){try{e.destroy()}catch(t){w.error("[useMap] 销毁未注册的地图实例失败:",t)}}async function _t(e){if(e.cancelled.value=!0,e.destroyed.value=!0,!e.map.value)return;const t=e.configManager.get("containerId");if(e.map.value=null,e.state.value.isReady=!1,t)try{await se.unregister(t)}catch(n){w.error("[useMap] 销毁地图失败:",n)}}function Vt(e,t,n){const r=D();if(!r)throw new Error("BMGL 库未加载,无法构造目标视角");return{destination:r.Cartesian3.fromDegrees(e,t,n),orientation:{heading:0,pitch:r.Math.toRadians(-90),roll:0}}}function Sr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="2d"))try{const n=D();if(!n)throw new Error("BMGL 库未加载,无法切换 2D 模式");const r=n.Cartographic.fromCartesian(t.camera.position);t.scene.morphTo2D?.(0),e.state.value.mapType="2d",e.eventBus.emit("map:mode-changed","2d"),t.camera.setView(Vt(n.Math.toDegrees(r.longitude),n.Math.toDegrees(r.latitude),r.height))}catch(n){w.error("切换到2D模式失败:",n)}}function Dr(e){const t=D();if(!t)throw new Error("BMGL 库未加载,无法计算 3D 目标视图");const n=t.Cartographic.fromCartesian(e.map.value.camera.position),r={lng:t.Math.toDegrees(n.longitude),lat:t.Math.toDegrees(n.latitude),height:Math.max(n.height,1e4)},i=yr(e);if(!i)return r;const a=(i.minx+i.maxx)/2,l=(i.miny+i.maxy)/2,s=(i.maxx-i.minx)*Math.cos(l*Math.PI/180)*H.METERS_PER_DEGREE_LAT_APPROX,u=(i.maxy-i.miny)*H.METERS_PER_DEGREE_LAT_APPROX,d=Math.max(s,u),c=t.Math.toRadians(H.CAMERA_FOV_DEGREES),f=Math.max(d/(2*Math.tan(c/2)),H.MIN_CAMERA_HEIGHT);return{lng:a,lat:l,height:f}}function Mr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="3d"))try{const n=Dr(e);t.scene.morphTo3D?.(0),e.state.value.mapType="3d",e.eventBus.emit("map:mode-changed","3d"),setTimeout(()=>{e.map.value&&e.map.value.camera.setView(Vt(n.lng,n.lat,n.height))},bt)}catch(n){w.error("切换到3D模式失败:",n)}}function Ir(e){e.state.value.mapType==="2d"?Mr(e):Sr(e)}function Pt(e){const t=sr(e),n=(i,a,l)=>wr(t,i,a,l),r=()=>Ir(t);return o.onBeforeUnmount(()=>{_t(t)}),{map:t.map,state:t.state,initMap:()=>br(t),setView:n,toggleMapType:r,destroy:()=>_t(t),on:t.eventBus.on.bind(t.eventBus),once:t.eventBus.once.bind(t.eventBus),off:t.eventBus.off.bind(t.eventBus),emit:t.eventBus.emit.bind(t.eventBus)}}function Ar(e){return{billboardCollection:null,billboardMap:new Map,pointDataCache:[],cacheIdIndex:new Map,gridIndex:null,gridSize:e,scaleByDistance:null}}function Bt(e,t,n){const r=Math.floor(t/e),i=Math.floor(n/e);return`${r},${i}`}function Rt(e,t){const n=Bt(e.gridSize,t.lng,t.lat),r=e.gridIndex?.get(n);r?r.push(t):e.gridIndex?.set(n,[t])}function zt(e,t){if(!e.gridIndex)return;const n=Bt(e.gridSize,t.lng,t.lat),r=e.gridIndex.get(n);if(!r)return;const i=r.indexOf(t);i>-1&&r.splice(i,1),r.length===0&&e.gridIndex.delete(n)}const xr=1e5;function Lr(e,t){const n=[];if(!e.gridIndex)return n;const r=Math.floor(t.west/e.gridSize),i=Math.floor(t.south/e.gridSize),a=Math.floor(t.east/e.gridSize),l=Math.floor(t.north/e.gridSize),s=(a-r+1)*(l-i+1),u=d=>d.lng>=t.west&&d.lng<=t.east&&d.lat>=t.south&&d.lat<=t.north;if(s>xr){for(const d of e.pointDataCache)u(d)&&n.push(d);return n}for(let d=r;d<=a;d++)for(let c=i;c<=l;c++){const f=e.gridIndex.get(`${d},${c}`)||[];for(const h of f)u(h)&&n.push(h)}return n}function Nr(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const[a,l]of e)a<t&&(t=a),l<n&&(n=l),a>r&&(r=a),l>i&&(i=l);return{west:t,south:n,east:r,north:i}}function kr(e){const[t,n]=e.center,r=e.radius/(H.METERS_PER_DEGREE_LAT*Math.cos(n*Math.PI/180)),i=e.radius/H.METERS_PER_DEGREE_LAT;return{west:t-r,east:t+r,south:n-i,north:n+i}}function _r(e){return e.type==="circle"?kr(e):Nr(e.coordinates)}function Vr(e,t){const[n,r]=e;let i=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const[s,u]=t[a],[d,c]=t[l];u>r!=c>r&&n<(d-s)*(r-u)/(c-u)+s&&(i=!i)}return i}function Pr(e,t){const[n,r]=t.center,i=t.radius*t.radius,a=(e.lng-n)*H.METERS_PER_DEGREE_LAT*Math.cos(r*Math.PI/180),l=(e.lat-r)*H.METERS_PER_DEGREE_LAT;return a*a+l*l<=i}function Br(e,t){return t.type==="circle"?e.filter(n=>Pr(n,t)):t.type==="polygon"||t.type==="triangle"?e.filter(n=>Vr([n.lng,n.lat],t.coordinates)):e}function Rr(e,t){if(!e.gridIndex||e.pointDataCache.length===0)return[];const n=_r(t);let r=Lr(e,n);return t.type!=="rectangle"&&(r=Br(r,t)),r}function zr(e,t){const{field:n,keyword:r,limit:i=10,caseSensitive:a=!1}=t,l=a?r.trim():r.trim().toLowerCase(),s=Array.isArray(n)?n:[n],u=[];for(const d of e.pointDataCache)if(s.some(f=>{const h=d[f];return h==null?!1:(a?String(h):String(h).toLowerCase()).includes(l)})&&(u.push(d),u.length>=i))break;return u}const Fr={lng:"lng",lat:"lat",altitude:"altitude",id:"id"};let Ft=0,Ot=!1,Gt=!1;function Or(){return Ot||(Ot=!0,w.warn("[useMapPoint] 检测到未提供 id 的点位,已启用自增 id 自动生成;建议通过 fieldMapping.id 提供稳定 id 以支持 updatePoints 精确定位")),Ft+=1,`__auto_${Ft}`}function Gr(){return typeof MessageChannel<"u"?new Promise(e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(0)}):new Promise(e=>setTimeout(e,0))}function Ur(e,t){if(!t.scaleByDistance){const n=Tt;t.scaleByDistance=new e.NearFarScalar(n.NEAR,n.NEAR_VALUE,n.FAR,n.FAR_VALUE)}return t.scaleByDistance}function Ut(e){const t=Ar(ne.GRID_SIZE),n=async()=>{if(!t.billboardCollection&&e.value){const d=D();d&&(t.billboardCollection=e.value.scene.primitives.add(new d.BillboardCollection))}return t.billboardCollection},r=()=>{if(t.billboardCollection)try{t.billboardCollection.removeAll()}catch(d){w.warn("[useMapPoint] removeAll billboard 失败:",d)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null},i=d=>{const c=t.cacheIdIndex.get(d);if(c===void 0)return;const f=t.pointDataCache[c],h=t.billboardMap.get(d);if(h&&t.billboardCollection)try{t.billboardCollection.remove(h)}catch(p){w.warn("[useMapPoint] 移除旧 billboard 失败:",p)}return t.billboardMap.delete(d),zt(t,f),c},a=(d,c,f,h)=>{const p=parseFloat(c[f.fieldMapping.lng])||0,b=parseFloat(c[f.fieldMapping.lat])||0,v=parseFloat(c[f.fieldMapping.altitude])||0,m=d.Cartesian3.fromDegrees(p,b,v),C=t.billboardCollection.add({position:m,image:c.icon,width:c.width||f.width,height:c.height||f.height,scaleByDistance:Ur(d,t),id:h,disableDepthTestDistance:Tt.NEAR,verticalOrigin:d.VerticalOrigin.BOTTOM});return C.pointData=c,{billboard:C,position:m,lng:p,lat:b,altitude:v}},l=async(d,c,f,h="append")=>{try{if(h==="replace"&&r(),!await n())return;const b=D();if(!b)return;const v={width:c?.width||20,height:c?.height||20,fieldMapping:{...Fr,...c?.fieldMapping||{}}},m=performance.now();t.gridIndex||(t.gridIndex=new Map);const C=Array.isArray(d)?d:[],y=C.length,E=ne.BATCH_SIZE,_=ne.YIELD_BUDGET_MS;let S=performance.now(),A=0;for(let V=0;V<y;V+=E){const U=C.slice(V,V+E);for(const z of U){if(!z.icon){A+=1,Gt||(Gt=!0,w.warn("[useMapPoint] 检测到缺失 icon 的点位,已跳过渲染;请在数据层通过 iconManager 预生成 icon 后传入"));continue}const M=z[v.fieldMapping.id],I=M!=null&&M!==""?String(M):Or(),F=i(I),{billboard:k,position:Y,lng:K,lat:pe,altitude:me}=a(b,z,v,I);t.billboardMap.set(I,k);const X={...z,id:I,lng:K,lat:pe,altitude:me,icon:z.icon};F!==void 0?t.pointDataCache[F]=X:(t.cacheIdIndex.set(I,t.pointDataCache.length),t.pointDataCache.push(X)),Rt(t,X)}V+E<y&&performance.now()-S>=_&&(await Gr(),S=performance.now())}A>0&&w.warn(`[useMapPoint] 本次加载跳过 ${A} 个缺失 icon 的点位`),console.log(`[useMapPoint] ${h} ${C.length} 个点位 billboard 渲染耗时:${(performance.now()-m).toFixed(0)}ms`)}catch(p){throw w.error("加载点位失败:",p),p}},s=async d=>{const c=D();for(const f of d){const h=String(f.id),p=t.billboardMap.get(h);if(p){if(f.icon&&(p.image=f.icon),f.width!==void 0&&(p.width=f.width),f.height!==void 0&&(p.height=f.height),c&&f.lng!==void 0&&f.lat!==void 0){const b=c.Cartesian3.fromDegrees(Number(f.lng),Number(f.lat),Number(f.altitude??0));p.position=b;const v=t.cacheIdIndex.get(h);if(v!==void 0){const m=t.pointDataCache[v];zt(t,m),m.lng=Number(f.lng),m.lat=Number(f.lat),f.altitude!==void 0&&(m.altitude=Number(f.altitude)),Rt(t,m)}}if(f.name!==void 0){const b=t.cacheIdIndex.get(h);b!==void 0&&(t.pointDataCache[b].name=String(f.name))}}}},u=async()=>{r()};return o.onUnmounted(()=>{try{const d=e.value?.scene;if(d?.primitives&&t.billboardCollection)try{d.primitives.remove(t.billboardCollection)}catch(c){w.warn("[useMapPoint] remove billboardCollection error:",c)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null,t.billboardCollection=null}catch(d){w.warn("[useMapPoint] onUnmounted cleanup error:",d)}}),{loadPoints:l,searchByShape:d=>Rr(t,d),searchByText:d=>zr(t,d),updatePoints:s,clearPoints:u}}function $t(e){return e?.rectangle?"rectangle":e?.polygon?"polygon":e?.polyline?"polyline":e?.ellipse||e?.position&&e?.billboard?"circle":"polygon"}function $e(e){if(e.length===0)return e;const t=e[0],n=e[e.length-1];return(Array.isArray(t)?t[0]===n[0]&&t[1]===n[1]:t.lng===n.lng&&t.lat===n.lat)?[...e]:[...e,t]}function $r(e,t=0){const n=D();return n?n.Cartesian3.fromDegrees(e.lng,e.lat,t):null}function Wt(e){const t=D();return t?{lng:t.Math.toDegrees(e.longitude),lat:t.Math.toDegrees(e.latitude)}:null}function De(e){const t=D();if(!t)return null;const n=t.Cartographic.fromCartesian(e);return Wt(n)}function We(e,t){return[[e.lng,e.lat],[t.lng,e.lat],[t.lng,t.lat],[e.lng,t.lat],[e.lng,e.lat]]}const ce={fillColor:"#ff0000",strokeColor:"#00ff00",lineColor:"#3366ff",strokeWidth:3,fillAlpha:.1,strokeAlpha:1,pointColor:"#ff0000",pixelSize:10,radius:1e3};function B(e,t){return N().Color.fromCssColorString(e).withAlpha(t)}function Ht(e){const t=N();return e.map(n=>Array.isArray(n)?t.Cartesian3.fromDegrees(n[0],n[1]):t.Cartesian3.fromDegrees(n.lng,n.lat))}function Wr(e,t=!0){const n=N(),r=ce;if(!e.coordinates||e.coordinates.length<3)throw new Error("多边形需要至少3个坐标点");const i=$e(e.coordinates),a=Ht(i),l=new n.Entity({polygon:{hierarchy:new n.PolygonHierarchy(a),material:B(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),s=new n.Entity({polyline:{positions:a,width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:l,strokeEntity:s,positions:a,closedCoordinates:i}}function Hr(e,t=!0){const n=N(),r=ce;if(!e.lineCoordinates||e.lineCoordinates.length<4)throw new Error("线段需要至少2个点");return{entity:new n.Entity({polyline:{positions:n.Cartesian3.fromDegreesArray(e.lineCoordinates),width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.lineColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}})}}function jr(e){const t=N(),n=ce;if(!e.center)throw new Error("圆形需要中心点坐标");const r=e.radius??n.radius;return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.center.lng,e.center.lat),ellipse:{semiMinorAxis:r,semiMajorAxis:r,height:0,material:B(e.fillColor??n.fillColor,e.fillAlpha??n.fillAlpha),outline:!0,outlineColor:B(e.strokeColor??n.strokeColor,e.strokeAlpha??n.strokeAlpha),outlineWidth:e.strokeWidth??n.strokeWidth}}),center:e.center,radius:r}}function Yr(e,t=!0){const n=N(),r=ce;if(!e.coordinates||e.coordinates.length<2)throw new Error("矩形需要两个对角点坐标");const[i,a]=e.coordinates,l=n.Rectangle.fromDegrees(Math.min(i.lng,a.lng),Math.min(i.lat,a.lat),Math.max(i.lng,a.lng),Math.max(i.lat,a.lat)),s=new n.Entity({rectangle:{coordinates:l,material:B(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),u=We(i,a),d=new n.Entity({polyline:{positions:Ht(u),width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:s,strokeEntity:d,coordinates:u}}function qr(e){const t=N(),n=ce;if(!e.point)throw new Error("点需要坐标");return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.point.lng,e.point.lat),point:{pixelSize:e.pixelSize??n.pixelSize,color:B(e.pointColor??n.pointColor,1),heightReference:t.HeightReference.CLAMP_TO_GROUND}}),point:[e.point.lng,e.point.lat]}}function Kr(e){const t=N();return!!(t.SceneMode&&e.scene.mode===t.SceneMode.SCENE2D)}const Xr={polygon:(e,t,n)=>{const r=Wr(e,t),i=n.entities.add(r.fillEntity),a=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:i,stroke:a},coordinates:r.closedCoordinates}},line:(e,t,n)=>{const r=Hr(e,t);return{nativeEntity:n.entities.add(r.entity),coordinates:e.lineCoordinates??[]}},circle:(e,t,n)=>{const r=jr(e);return{nativeEntity:n.entities.add(r.entity),coordinates:{center:r.center,radius:r.radius}}},rectangle:(e,t,n)=>{const r=Yr(e,t),i=n.entities.add(r.fillEntity),a=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:i,stroke:a},coordinates:r.coordinates}},point:(e,t,n)=>{const r=qr(e);return{nativeEntity:n.entities.add(r.entity),coordinates:r.point}}};function jt(e,t,n){const r=Xr[e];if(!r)throw new Error(`不支持的实体类型: ${e}`);return r(t,!Kr(n),n)}function Me(e,t){try{e.type==="polygon"||e.type==="rectangle"?(e.nativeEntity?.fill&&t.entities.remove(e.nativeEntity.fill),e.nativeEntity?.stroke&&t.entities.remove(e.nativeEntity.stroke)):e.nativeEntity&&t.entities.remove(e.nativeEntity)}catch(n){w.warn(`移除原生实体失败 (${e.id}):`,n)}}function He(e,t,n,r){return{color:e.fillColor||t.options.fillColor||n,alpha:e.fillAlpha!==void 0?e.fillAlpha:t.options.fillAlpha??r}}function Ie(e,t,n,r){return{color:e.strokeColor||t.options.strokeColor||n,alpha:e.strokeAlpha!==void 0?e.strokeAlpha:r}}function Zr(e,t){const n=N(),{fill:r,stroke:i}=e.nativeEntity,a=$e(t.coordinates),l=a.map(s=>n.Cartesian3.fromDegrees(s.lng,s.lat));r.polygon.hierarchy=new n.PolygonHierarchy(l),i.polyline.positions=l,e.coordinates=a}function Jr(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:a}=He(t,e,"#ff0000",.1);n.polygon.material=B(i,a)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:a}=Ie(t,e,"#00ff00",1);r.polyline.material=B(i,a)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=3&&Zr(e,t)}function Qr(e,t){const n=N(),{fill:r,stroke:i}=e.nativeEntity,[a,l]=t.coordinates;r.rectangle.coordinates=n.Rectangle.fromDegrees(Math.min(a.lng,l.lng),Math.min(a.lat,l.lat),Math.max(a.lng,l.lng),Math.max(a.lat,l.lat));const s=We(a,l);i.polyline.positions=s.map(u=>n.Cartesian3.fromDegrees(u[0],u[1])),e.coordinates=s}function ei(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:a}=He(t,e,"#ff0000",.1);n.rectangle.material=B(i,a)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:a}=Ie(t,e,"#00ff00",1);r.polyline.material=B(i,a)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=2&&Qr(e,t)}function ti(e,t){const n=N(),i=e.nativeEntity.polyline;if(i){if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:a,alpha:l}=Ie(t,e,"#3366ff",1);i.material=B(a,l)}t.strokeWidth!==void 0&&(i.width=t.strokeWidth),t.lineCoordinates&&t.lineCoordinates.length>=4&&(i.positions=n.Cartesian3.fromDegreesArray(t.lineCoordinates),e.coordinates=t.lineCoordinates)}}function ni(e,t){const n=N(),r=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:a}=He(t,e,"#ff0000",.1);r.ellipse.material=B(i,a)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:a}=Ie(t,e,"#00ff00",1);r.ellipse.outlineColor=B(i,a)}if(t.strokeWidth!==void 0&&(r.ellipse.outlineWidth=t.strokeWidth),t.radius!==void 0&&(r.ellipse.semiMinorAxis=t.radius,r.ellipse.semiMajorAxis=t.radius),t.center){r.position=n.Cartesian3.fromDegrees(t.center.lng,t.center.lat);const i=e.coordinates,a=i&&!Array.isArray(i)?i.radius:void 0;e.coordinates={center:t.center,radius:t.radius||a||1e3}}}function ri(e,t){const n=N(),r=e.nativeEntity,i=r.point;i&&(t.pointColor!==void 0&&(i.color=B(t.pointColor,1)),t.pixelSize!==void 0&&(i.pixelSize=t.pixelSize),t.point&&(r.position=n.Cartesian3.fromDegrees(t.point.lng,t.point.lat),e.coordinates=[t.point.lng,t.point.lat]))}function ii(e,t){const n=e.nativeEntity;e.type==="polygon"||e.type==="rectangle"?(n.fill.show=t,n.stroke.show=t):n.show=t}function ai(e,t,n){e==="polygon"?Jr(t,n):e==="rectangle"?ei(t,n):e==="line"?ti(t,n):e==="circle"?ni(t,n):e==="point"&&ri(t,n)}function oi(e,t){const n=t.coordinates;n&&((e.type==="polygon"||e.type==="rectangle")&&!e.coordinates&&Array.isArray(n)&&(e.coordinates=n),e.type==="line"&&!e.lineCoordinates&&t.type==="line"&&Array.isArray(n)&&(e.lineCoordinates=n),e.type==="circle"&&!e.center&&t.type==="circle"&&!Array.isArray(n)&&(e.center=n.center,e.radius=n.radius||1e3),e.type==="point"&&!e.point&&t.type==="point"&&Array.isArray(n)&&(e.point=n))}async function li(e,t,n,r,i){Me(t,r);const a={...t.options,...n,id:e,type:n.type};return oi(a,t),await i(a)!==null}function Yt(e){const t=new Map;let n="";const r=()=>!e.value||!e.value.entities?(w.warn("地图实例未就绪"),!1):!0,i=async()=>{if(r())return!0;try{return await xt(),r()}catch{return!1}},a=async c=>{try{if(!await i())return null;const f=e.value;if(!f)return null;const h=c.id||`${c.type}-${Date.now()}`,{nativeEntity:p,coordinates:b}=jt(c.type,c,f),v={id:h,type:c.type,options:{...c,id:h,type:c.type,visible:c.visible!==!1},nativeEntity:p,coordinates:b};return t.set(h,v),n=h,h}catch(f){return w.error("绘制实体失败:",f),null}},l=c=>{try{if(!r())return!1;const f=e.value;if(!f)return!1;if(!c)return t.forEach(p=>Me(p,f)),t.clear(),n="",!0;const h=t.get(c);return h?(Me(h,f),t.delete(c),n===c&&(n=""),!0):(w.warn(`实体未找到: ${c}`),!1)}catch(f){return w.error("删除实体失败:",f),!1}},s=()=>n,u=async(c,f)=>{try{const h=t.get(c);if(!h)return w.warn(`实体未找到:${c}`),!1;if(!await i())return!1;const p=e.value;return p?f.type&&f.type!==h.type?await li(c,h,f,p,a):(ai(h.type,h,f),f.name!==void 0&&(h.options.name=f.name),f.visible!==void 0&&ii(h,f.visible),h.options={...h.options,...f},t.set(c,h),!0):!1}catch(h){return w.error(`修改实体失败 (${c}):`,h),!1}},d=()=>{if(!r())return;const c=e.value;if(c)for(const[f,h]of t)try{Me(h,c),h.nativeEntity=jt(h.type,h.options,c).nativeEntity}catch(p){w.warn(`重绘实体失败 (${f}):`,p)}};return o.onUnmounted(()=>{try{t.clear(),n=""}catch(c){w.warn("[useMapEntity] onUnmounted cleanup error:",c)}}),{drawEntity:a,updateEntity:u,deleteEntity:l,redrawAllEntities:d,getCurrentEntityId:s}}function si(){return{drawInstance:null,editInstance:null,currentDrawId:"",currentDrawType:null,isDrawing:!1,isEditing:!1,drawCallback:null,mapInstance:null,mapHandler:null,eventListeners:[],lastEditedEntity:null,drawEntityIds:new Set}}const ue={fillColor:"#369",fillAlpha:.6,borderColor:"#fff",borderAlpha:.8,lineWidth:2,labelFont:"14px arial",arrowWidth:20};function Ae(e,t,n,r){return typeof e!="number"||Number.isNaN(e)?r:Math.min(n,Math.max(t,e))}class ci{constructor(t){this.config={...ue,...t},this.config.fillAlpha=Ae(this.config.fillAlpha,0,1,ue.fillAlpha),this.config.borderAlpha=Ae(this.config.borderAlpha,0,1,ue.borderAlpha),this.config.lineWidth=Ae(this.config.lineWidth,1,50,ue.lineWidth),this.config.arrowWidth=Ae(this.config.arrowWidth,1,100,ue.arrowWidth)}materials(t){const{fillColor:n,fillAlpha:r,borderColor:i,borderAlpha:a}=this.config;return{fill:t.Color.fromCssColorString(n).withAlpha(r),border:t.Color.fromCssColorString(i).withAlpha(a)}}label(t){const{labelFont:n}=this.config;return{fillColor:t.Color.WHITE,font:n,verticalOrigin:t.VerticalOrigin.BOTTOM,pixelOffset:new t.Cartesian2(0,-20),disableDepthTestDistance:5e3}}getDrawConfig(){const t=N(),{fill:n,border:r}=this.materials(t),i=this.label(t),a=this.config.lineWidth,l={bmgl:t,config:this.config,shared:{fill:n,border:r,label:i,width:a}},s={repeat:!0};for(const u of gt())u.buildConfig&&(s[u.type]=u.buildConfig(l));return s}getEditConfig(){const t=N();return{axis:{scale:1},control:{tolerance:4,marker:{eyeOffset:new t.Cartesian3(0,0,-20),verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:5e3}}}}}function qt(e){return e.map(t=>De(t)).filter(t=>t!==null)}function ui(e){try{const t=e.polygon.hierarchy.getValue().positions||[],n=qt(t);return{type:"polygon",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return w.error("提取多边形数据失败:",t),null}}function di(e){const t=N();try{const n=e.rectangle.coordinates.getValue(),r=t.Math.toDegrees(n.west),i=t.Math.toDegrees(n.south),a=t.Math.toDegrees(n.east),l=t.Math.toDegrees(n.north);return{type:"rectangle",path:[[r,l],[a,l],[a,i],[r,i],[r,l]],rawPath:[{lng:r,lat:l},{lng:a,lat:l},{lng:a,lat:i},{lng:r,lat:i}],radius:void 0}}catch(n){return w.error("提取矩形数据失败:",n),null}}function fi(e){try{const t=e.polyline.positions.getValue(),n=qt(t);return{type:"polyline",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return w.error("提取折线数据失败:",t),null}}function hi(e){try{const t=De(e.position.getValue());if(!t)return null;const n=e.ellipse.semiMajorAxis?.getValue()||0,r=e.ellipse.semiMinorAxis?.getValue()||0;return{type:"circle",center:[t.lng,t.lat],radius:Math.max(n,r),rawPath:[t]}}catch(t){return w.error("提取圆形数据失败:",t),null}}function gi(e){try{const t=De(e.position.getValue());return t?{type:"circle",center:[t.lng,t.lat],radius:e.radius||0,rawPath:[t]}:null}catch{return null}}function Kt(e){return e?e.polygon?ui(e):e.rectangle?di(e):e.polyline?fi(e):e.position&&e.ellipse?hi(e):e.billboard&&e.position?gi(e):null:null}function pi(e){return $t(e)}function mi(e){return e.editInstance&&(e.editInstance.isEditing||e.editInstance._isEditing||e.editInstance.editing)||!1}function wi(e){typeof e.finish=="function"?e.finish():typeof e.stop=="function"?e.stop():typeof e.disable=="function"?e.disable():typeof e.end=="function"?e.end():e.isEditing=!1}function de(e,t=!1){if(e.editInstance){t&&e.currentDrawId&&(e.lastEditedEntity=e.mapInstance?.entities.getById(e.currentDrawId)??null);try{wi(e.editInstance)}catch(n){w.error("结束编辑状态失败:",n)}finally{e.isEditing=!1}t&&e.lastEditedEntity&&yi(e)}}function J(e,t){if(e.drawCallback)try{e.drawCallback(t)}catch(n){w.error("绘图回调执行失败:",n)}else w.warn("绘图回调函数未设置")}function yi(e){if(!(!e.lastEditedEntity||!e.currentDrawId))try{const t=Kt(e.lastEditedEntity);if(!t)return;const n={type:t.type,layer:{_id:e.currentDrawId},path:t.rawPath||[]};t.type==="circle"&&t.radius!==void 0&&(n.radius=t.radius),J(e,{type:t.type,operation:"edit",id:e.currentDrawId,data:t,rawData:n}),e.lastEditedEntity=null}catch(t){w.error("手动触发编辑完成事件失败:",t)}}function vi(e,t,n){try{if(e.drawInstance||n(),!e.drawInstance)throw new Error("绘图实例初始化失败");if(e.isEditing&&de(e,!1),e.isDrawing=!0,e.currentDrawType=t,typeof e.drawInstance.enable=="function")e.drawInstance.enable(t);else if(typeof e.drawInstance.start=="function")e.drawInstance.start(t);else throw new Error("绘图实例没有可用的启用方法")}catch(r){throw w.error(`开始绘制 ${t} 失败:`,r),e.isDrawing=!1,e.currentDrawType=null,r}}function Ci(e){const t=(n,...r)=>{if(n){for(const i of r)if(typeof n[i]=="function"){n[i]();return}}};t(e.drawInstance,"disable","stop"),t(e.editInstance,"disable","stop")}function bi(e){e.currentDrawId="",e.currentDrawType=null,e.isDrawing=!1,e.isEditing=!1,e.lastEditedEntity=null}function Q(e){e.isEditing&&de(e,!1),Ci(e),bi(e)}function Ei(e,t=""){if(!e.mapInstance)return;const n=t||e.currentDrawId;if(e.isEditing&&de(e,!1),!n){Q(e);return}const r=e.mapInstance.entities.getById(n);if(r){const i=Kt(r);if(e.mapInstance.entities.remove(r),e.drawEntityIds.delete(n),e.currentDrawId===n&&(e.currentDrawId=""),i){const a={type:i.type,layer:{_id:n},path:i.rawPath||[]};i.type==="circle"&&i.radius!==void 0&&(a.radius=i.radius),J(e,{type:i.type,operation:"delete",id:n,data:i,rawData:a})}}Q(e)}function Ti(e){if(!e.mapInstance)return;e.isEditing&&de(e,!1);let t=0;if(e.drawEntityIds.size>0){for(const r of e.drawEntityIds){const i=e.mapInstance.entities.getById(r);i&&(e.mapInstance.entities.remove(i),t++)}e.drawEntityIds.clear()}else{const r=e.mapInstance.entities?.values||[];r.some(a=>!e.drawEntityIds.has(a?._id))||(e.mapInstance.entities.removeAll(),t=r.length)}const n=e.currentDrawType||"polygon";J(e,{type:n,operation:"clear",data:null,rawData:null,count:t}),Q(e)}class j{static process(t){if(!t?.type)return null;try{const n=j.getProcessor(t.type);if(!n)return null;const r=n(t);return r?{...r,id:t.layer?._id||""}:null}catch(n){return w.error("数据处理失败:",n),null}}static getProcessor(t){return{rectangle:j.processRectangle,polygon:j.processPolygon,circle:j.processCircle,triangle:j.processTriangle,polyline:j.processPolyline}[t]}static processRectangle(t){const[n,r]=t.path||[];return!n||!r?null:{type:"rectangle",path:[[n.lng,n.lat],[r.lng,n.lat],[r.lng,r.lat],[n.lng,r.lat],[n.lng,n.lat]]}}static processPolygon(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polygon",path:[...n,n[0]]}}static processCircle(t){const n=t.path;return!n||n.lng===void 0?null:{type:"circle",center:[n.lng,n.lat],radius:t.radius||0}}static processTriangle(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"triangle",path:[...n,n[0]]}}static processPolyline(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polyline",path:n}}}function Si(e,t,n){J(e,{type:pi(n),operation:"select",id:t,data:{id:t},rawData:n})}function Di(e){if(mi(e)){de(e,!0);return}e.isDrawing&&e.currentDrawType&&J(e,{type:e.currentDrawType,operation:"cancel",id:e.currentDrawId,data:null,rawData:null}),Q(e)}function Mi(e,t){if(!e.mapInstance)return;const n=N(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const i=r?.id?._id;if(typeof i!="string"||!i)return;const a=e.mapInstance.entities.getById(i);if(!a||!e.editInstance)return;e.currentDrawId=i,e.lastEditedEntity=a;const l=e.editInstance;typeof l.edit=="function"?l.edit(a):typeof l.start=="function"?l.start(a):typeof l.enable=="function"&&l.enable(a),e.isEditing=!0}function Ii(e,t){if(!e.mapInstance||e.isDrawing)return;const n=N(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const i=r?.id?._id;if(typeof i!="string"||!i)return;const a=e.mapInstance.entities.getById(i);a&&(e.currentDrawId=i,Si(e,i,a))}function Ai(e,t){const n=j.process(t.detail);if(!n)return;n.id&&e.drawEntityIds.add(n.id);const r={type:n.type,operation:"draw",id:n.id,data:n,rawData:t.detail};J(e,r),Q(e)}function xi(e,t){e.isEditing=!1;const n=j.process(t.detail);if(!n){e.lastEditedEntity=null;return}const r={type:n.type,operation:"edit",id:n.id,data:n,rawData:t.detail};J(e,r),e.lastEditedEntity=null}function Xt(e){e.eventListeners.forEach(({type:t})=>{try{e.mapHandler?.removeInputAction(t)}catch(n){w.warn(`移除 ${t} 事件监听器失败:`,n)}}),e.eventListeners=[]}function Li(e){Xt(e);const t=e.mapHandler;if(!t)return;const n=N(),r=[n.ScreenSpaceEventType.RIGHT_CLICK,n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,n.ScreenSpaceEventType.LEFT_CLICK],i=[()=>Di(e),a=>Mi(e,a),a=>Ii(e,a)];r.forEach((a,l)=>{t.setInputAction(i[l],a),e.eventListeners.push({type:a})})}function Ni(e){e.drawInstance&&(e.drawInstance.on("bm_draw_end",t=>Ai(e,t)),e.editInstance&&e.editInstance.on("bm_edit_end",t=>xi(e,t)))}function ki(e,t,n){try{if(e.mapInstance=o.isRef(t)?t.value:t,!e.mapInstance)throw new Error("地图实例不可用");if(!D())throw new Error("BMGL 库未加载");if(e.mapHandler=e.mapInstance.screenSpaceEventHandler,!e.mapHandler)throw new Error("地图事件处理器不可用");const r=N(),i=new ci(n);e.drawInstance=new r.Plot.Draw(e.mapInstance,i.getDrawConfig()),e.editInstance=new r.Plot.Edit(e.mapInstance,i.getEditConfig()),Li(e),Ni(e)}catch(r){throw w.error("绘图工具初始化失败:",r),r}}function Zt(e){try{Q(e),Xt(e),e.drawInstance&&typeof e.drawInstance.destroy=="function"&&e.drawInstance.destroy(),e.editInstance&&typeof e.editInstance.destroy=="function"&&e.editInstance.destroy(),e.drawInstance=null,e.editInstance=null,e.drawCallback=null,e.mapHandler=null,e.lastEditedEntity=null}catch(t){w.error("清理绘图工具资源失败:",t)}}function Jt(e,t){const n=si(),r=()=>ki(n,e,t),i=s=>{n.drawCallback=s},a=()=>({isDrawing:n.isDrawing,isEditing:n.isEditing,currentDrawId:n.currentDrawId,currentDrawType:n.currentDrawType,drawInstance:!!n.drawInstance,editInstance:!!n.editInstance}),l=()=>n.isDrawing;if(e&&typeof e=="object"&&"value"in e)o.watch(e,s=>{if(s&&!n.drawInstance)try{r()}catch(u){w.warn("自动初始化失败,将在绘图时重试:",u)}},{immediate:!0});else if(e)try{r()}catch(s){w.warn("自动初始化失败,将在绘图时重试:",s)}return o.onUnmounted(()=>{Zt(n)}),{startDrawing:s=>vi(n,s,r),cancelDrawing:()=>Q(n),removeDrawing:(s="")=>Ei(n,s),clearAllDrawings:()=>Ti(n),setCallback:i,getDrawingStatus:a,getIsDrawing:l,initialize:r,cleanup:()=>Zt(n)}}function _i(){return{popupLayer:null,divLayerManager:null,mapInstance:null,currentPopupData:null,displayConfig:null,popupSeq:0}}function fe(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Vi(e){return e&&/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)?e:""}function re(e,t){return typeof e=="number"&&!Number.isNaN(e)?e.toFixed(t):"-"}function Pi(e){return R[e||"default"]||R.default}function Bi(e){return[`--status-color: ${e.color}`,`--status-bg: ${e.color}10`,`--status-border: ${e.color}30`,`--status-shadow: ${e.color}30`].join(";")}function Ri(e,t){const n=[e.lineCode,e.lineNo,e.pointNo].filter(i=>i!=null&&i!==""),r=n.length?`<div class="map-point-popup-subtitle"><span>${n.map(i=>fe(i)).join('<span class="map-point-popup-divider">|</span>')}</span></div>`:"";return`
1
+ (function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g.BigmapPlugin={},g.Vue))})(this,(function(g,l){"use strict";const Dt={debug:10,info:20,warn:30,error:40,silent:Number.POSITIVE_INFINITY},xe="[sems-map]";function vr(){try{const e=typeof process<"u"?process.env:void 0;if(e&&e.NODE_ENV==="production")return"warn"}catch{}return"debug"}let qe=vr();function Cr(e){qe=e}function br(){return qe}function Ne(e){return Dt[e]>=Dt[qe]}const y={debug(...e){Ne("debug")&&console.debug(xe,...e)},info(...e){Ne("info")&&console.info(xe,...e)},warn(...e){Ne("warn")&&console.warn(xe,...e)},error(...e){Ne("error")&&console.error(xe,...e)}},Mt=Symbol("originalHandler");class Xe{constructor(){this.events=new Map}on(t,n){return this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n),()=>this.off(t,n)}once(t,n){const r=i=>{n(i),this.off(t,r)};return r[Mt]=n,this.on(t,r)}off(t,n){if(!n){this.events.delete(t);return}const r=this.events.get(t);if(!r)return;const i=r.findIndex(o=>o===n||o[Mt]===n);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(t)}async emit(t,n){const r=this.events.get(t);if(!r||r.length===0)return;const i=r.slice(),o=[];for(const a of i)try{const s=a(n);s&&typeof s.then=="function"&&o.push(s.catch(c=>{y.error(`[EventBus] Error in async handler for event "${String(t)}":`,c)}))}catch(s){y.error(`[EventBus] Error in handler for event "${String(t)}":`,s)}o.length>0&&await Promise.all(o)}clear(){this.events.clear()}getStats(){return Array.from(this.events.entries()).map(([t,n])=>({event:String(t),handlerCount:n.length}))}}const Er=new Xe,ge=new Map;function J(e){ge.set(e.type,e)}J({type:"area",name:"测面积",defaultSize:15,icon:"area",toolbarOrder:4,buildConfig:({shared:e})=>({material:e.fill,labelOptions:e.label})}),J({type:"polygon",name:"绘制多边形",defaultSize:14,icon:"polygon",toolbarOrder:1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})}),J({type:"circle",name:"绘制圆形",defaultSize:17,icon:"circle",toolbarOrder:2,buildConfig:({bmgl:e,config:t,shared:n})=>({material:n.fill,width:n.width,controlLine:{permanent:!0,lineStyle:{width:n.width,clampToGround:!0,material:n.border},textStyle:{font:t.labelFont,disableDepthTestDistance:1/0,verticalOrigin:e.VerticalOrigin.BOTTOM}}})}),J({type:"azimuth",name:"测方位",defaultSize:15,icon:"azimuth",toolbarOrder:6,buildConfig:({bmgl:e,config:t})=>({clampToGround:!0,material:new e.PolylineArrowMaterialProperty(e.Color.fromCssColorString(t.fillColor)),width:t.arrowWidth,labelOptions:{fillColor:e.Color.YELLOW}})}),J({type:"ruler",name:"测距离",defaultSize:15,icon:"ruler",toolbarOrder:5,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill,labelOptions:t.label})}),J({type:"polyline",name:"绘制线",defaultSize:16,icon:"polyline",toolbarOrder:3,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill})}),J({type:"triangle",name:"绘制三角形",defaultSize:16,icon:"triangle",inDefaultToolbar:!1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:4,material:t.fill})}),J({type:"rectangle",name:"绘制矩形",defaultSize:16,icon:"rectangle",toolbarOrder:0,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})});function Tr(e){ge.set(e.type,e)}function It(e){return ge.get(e)}function Lt(){return[...ge.values()]}function At(){return[...ge.values()].filter(e=>e.inDefaultToolbar!==!1).sort((e,t)=>(e.toolbarOrder??Number.MAX_SAFE_INTEGER)-(t.toolbarOrder??Number.MAX_SAFE_INTEGER))}function xt(){return At().map(e=>({icon:e.type,name:e.name,size:e.defaultSize}))}const pe="/libs",se={lng:104.03770513,lat:30.48187111,height:2e4},_e={heading:6.267876539812834,pitch:-1.3962634015954636,roll:.00016118230151462853},ke={FLY_TO:2,MORPH:.8,WAVE:3e3},ce={BATCH_SIZE:200,YIELD_BUDGET_MS:8,DEBOUNCE_DELAY:300,GRID_SIZE:.1},Ze=xt(),Nt=["bigemap.dc-satellite","bigemap.dc-street"],_t={contourSpacing:150,contourWidth:2,outlineWidth:2,labelEvery:5,maxLabels:28,labelMinDistance:140,labelOutlineWidth:3,sampleStep:80,scanStep:120,viewportMargin:48,legendColorStep:500},kt={autoPlay:!1,speed:1,loop:!1,follow:!1,followHeight:2e3,trailTime:10,duration:0,interval:1,markerColor:"#ff3b30",markerSize:12,markerIcon:"",lineColor:"#0a84ff",lineWidth:4,maxPoints:2e4},Pt={fillColor:"#000000",fillAlpha:.8,outlineColor:"#44d5ff",outlineAlpha:1,outlineWidth:4,showOutline:!0},Vt={fillColor:"#3d8bff",fillAlpha:.35,strokeColor:"#ffffff",strokeAlpha:1,strokeWidth:2,pointColor:"#ff3b30",pointPixelSize:8,showLabel:!0,labelColor:"#ffffff",labelFontSize:13,labelOutlineColor:"#000000",fillPalette:[],useKmlStyle:!0,showFill:!0,showOutline:!0,extractProperties:!0,autoFlyTo:!0,timeout:15e3},Je={containerId:"bigmap-container",libsUrl:pe,mapType:"3d",position:se,mapId:"bigemap.cebjohn0",terrainId:"bigemap.dc-terrain",baseLayers:Nt,showSearch:!1,showControls:!0,showStatus:!1,showDeleteControls:!0,tools:Ze,searchDebounceTime:ce.DEBOUNCE_DELAY},q={METERS_PER_DEGREE_LAT:111320,METERS_PER_DEGREE_LAT_APPROX:111e3,CAMERA_FOV_DEGREES:60,MIN_CAMERA_HEIGHT:1e3},Rt=500,Bt=800,Sr=200,Dr=900,Ft=1e4,Mr=100,Ir=1e3,Ot={NEAR:3e3,NEAR_VALUE:1,FAR:1e5,FAR_VALUE:.1},Lr=6,Ar=1001,G={1:{color:"#9E9E9E",text:"未发布"},2:{color:"#2196F3",text:"已发布"},3:{color:"#FF9800",text:"未完成"},4:{color:"#4CAF50",text:"已完成"},5:{color:"#FF5722",text:"整改"},6:{color:"#E91E63",text:"整改中"},7:{color:"#8BC34A",text:"整改完成"},8:{color:"#009688",text:"合格"},9:{color:"#00BCD4",text:"整改合格"},10:{color:"#F44336",text:"不合格"},11:{color:"#9C27B0",text:"变观中"},12:{color:"#673AB7",text:"已变观"},13:{color:"#607D8B",text:"任务终止"},default:{color:"#2196F3",text:"未知状态"}},xr=e=>G[e]||G.default;function Nr(e){if(!e)return{};const t={};for(const n of Object.keys(e)){const r=e[n];r!==void 0&&(t[n]=r)}return t}function Qe(...e){const t={...Je};for(const n of e){const r=Nr(n);Object.assign(t,r),r.geoserver&&(t.geoserver={...t.geoserver||{},...r.geoserver})}return t}function _r(e,t){return Qe(e,t)}class zt{constructor(t){this.config=Qe(t)}get(t){return this.config[t]}set(t,n){this.config[t]=n}getAll(){return{...this.config}}update(t){this.config=Qe(this.config,t)}reset(){this.config={...Je}}}class Ut{constructor(){this.resources=new Set}register(t){this.resources.add(t)}unregister(t){this.resources.delete(t)}async cleanup(){const t=Array.from(this.resources);this.resources.clear(),await Promise.allSettled(t.map(async n=>{try{await n()}catch(r){y.error("[ResourceManager] Error during cleanup:",r)}}))}getResourceCount(){return this.resources.size}}function kr(e){return{isReady:!1,isLoading:!1,mapType:e==="2d"?"2d":"3d",cameraPosition:{lng:0,lat:0,height:0,altitude:0,heading:0,pitch:0,roll:0},bounds:null,error:null}}function Pr(e){return{configManager:new zt(e),eventBus:new Xe,resourceManager:new Ut,map:l.shallowRef(null),state:l.ref(kr(e.mapType||"3d")),cancelled:{value:!1},destroyed:{value:!1},initializing:{value:!1}}}const $t=pe,et={"bigemap-2d":{name:"BigMap 2D",path:"/libs/bigemap/bigemap.js",dependencies:["bigemap-2d-css"]},"bigemap-2d-css":{name:"BigMap 2D CSS",path:"/libs/bigemap/bigemap.css",isCss:!0},"bigemap-3d":{name:"BigMap 3D",path:"/bigemap-gl.js/v1.1.0/bigemap-gl.js",dependencies:["bigemap-3d-css"]},"bigemap-3d-css":{name:"BigMap 3D CSS",path:"/libs/bigemap/widgets.css",isCss:!0},"bmgl-plot":{name:"BigMap Plot",path:"/libs/bigemap/bmgl-plot.min.js",dependencies:["bigemap-3d"]},"circle-wave":{name:"Circle Wave",path:"/libs/bigemap/circleWave.js",dependencies:["bmgl-plot"]},"bm-geometry-util":{name:"BigMap Geometry Util",path:"/libs/bigemap/bm.geometryutil.js",dependencies:["bigemap-3d"]},"move-marker":{name:"BigMap Move Marker",path:"/libs/bigemap/moveMarker.js",dependencies:["bigemap-3d","bm-geometry-util"]},"bmgl-header":{name:"BMGL Sandcastle Header",path:"/libs/bigemap/bmgl-header.js",dependencies:["bigemap-3d"]},"elevation-contour":{name:"Bigemap Elevation Contour",path:"/libs/bigemap/BigemapElevationContourLayer.js",dependencies:["bigemap-3d"]}};function tt(e,t,n){if(e.path.startsWith("/libs/"))return n+e.path.slice(5);if(e.path.startsWith("/")){if(!t)throw new Error(`未配置 serverUrl,无法解析地图资源路径: ${e.path}`);return t.replace(/\/$/,"")+e.path}return e.path}const Pe=3e4;class Gt{constructor(){this.loaded=new Set,this.pending=new Map}loadJs(t){return new Promise((n,r)=>{if(document.querySelector(`script[src="${t}"]`)){n();return}const i=document.createElement("script");i.src=t,i.async=!0;let o=!1;const a=setTimeout(()=>{o||(o=!0,i.remove(),r(new Error(`脚本加载超时(${Pe/1e3}s): ${t}`)))},Pe);i.onload=()=>{o||(o=!0,clearTimeout(a),n())},i.onerror=()=>{o||(o=!0,clearTimeout(a),i.remove(),r(new Error(`脚本加载失败: ${t}`)))},document.head.appendChild(i)})}loadCss(t){return new Promise((n,r)=>{if(document.querySelector(`link[href="${t}"]`)){n();return}const i=document.createElement("link");i.rel="stylesheet",i.href=t;let o=!1;const a=setTimeout(()=>{o||(o=!0,i.remove(),r(new Error(`样式加载超时(${Pe/1e3}s): ${t}`)))},Pe);i.onload=()=>{o||(o=!0,clearTimeout(a),n())},i.onerror=()=>{o||(o=!0,clearTimeout(a),i.remove(),r(new Error(`样式加载失败: ${t}`)))},document.head.appendChild(i)})}loadResource(t,n,r){const i=tt(t,n,r);if(this.loaded.has(i))return Promise.resolve();if(this.pending.has(i))return this.pending.get(i);const o=t.isCss?this.loadCss(i):this.loadJs(i);return this.pending.set(i,o),o.then(()=>{this.loaded.add(i)}).finally(()=>{this.pending.delete(i)}),o}async loadWithDependencies(t,n,r,i){const a={...et,...i}[t];if(!a)throw new Error(`库配置未找到: ${t}`);for(const s of a.dependencies||[])await this.loadWithDependencies(s,n,r,i);await this.loadResource(a,n,r)}async loadScripts(t,n,r=$t,i){await Promise.all(t.map(o=>this.loadWithDependencies(o,n,r,i)))}isLoaded(t,n,r){const i=et[t];if(!i||i.path.startsWith("/")&&!i.path.startsWith("/libs/")&&!n)return!1;const o=tt(i,n||"",r||$t);return this.loaded.has(o)}clearLoaded(){this.loaded.clear(),this.pending.clear()}}const Ve=new Gt;let me=null;function Wt(e){me=e}function M(){return me||(typeof window<"u"&&window.bmgl?(me=window.bmgl,me):null)}function R(){const e=M();if(!e)throw new Error("bmgl 库未就绪:请确保地图初始化完成后再调用该能力");return e}async function Ht(e=3e3){const t=M();return t||new Promise((n,r)=>{const i=Date.now(),o=setInterval(()=>{const a=M();a?(clearInterval(o),n(a)):Date.now()-i>e&&(clearInterval(o),r(new Error("bmgl 加载超时")))},50)})}class ne{constructor(){this.entries=new Map}static getInstance(){return ne.instance||(ne.instance=new ne),ne.instance}register(t,n,r,i){this.entries.set(t,{map:n,eventBus:r,resourceManager:i})}get(t){return this.entries.get(t)?.map}has(t){return this.entries.has(t)}getEventBus(t){return this.entries.get(t)?.eventBus}getResourceManager(t){return this.entries.get(t)?.resourceManager}async unregister(t){const n=this.entries.get(t);if(n&&(this.entries.delete(t),await n.resourceManager.cleanup(),n.eventBus.clear(),!n.map.isDestroyed?.()))try{n.map.destroy()}catch(r){y.error("[MapManager] Error destroying map:",r)}}getAllMapIds(){return Array.from(this.entries.keys())}async cleanupAll(){const t=this.getAllMapIds();await Promise.all(t.map(n=>this.unregister(n)))}}const ye=ne.getInstance();function Vr(e,t=3e3){return new Promise((n,r)=>{const i=Date.now(),o=setInterval(()=>{document.getElementById(e)?(clearInterval(o),n()):Date.now()-i>t&&(clearInterval(o),r(new Error(`容器未找到: ${e}`)))},16)})}async function Rr(e){const t=e.configManager.get("containerId");if(!t)throw new Error("容器ID未定义");return await Vr(t),t}async function Br(e){const t=e.configManager.get("serverUrl"),n=e.configManager.get("accessToken"),r=e.configManager.get("libsUrl"),i=e.configManager.get("extraLibs");try{await Ve.loadScripts(["bigemap-3d","bmgl-plot","circle-wave"],t,r,i)}catch(a){throw y.error("[loadBmglScripts] 地图服务连接失败,请确认 serverUrl 可达且服务已启动:",a),new Error("地图服务连接失败,请确认服务器地址正确且服务已启动")}const o=M();if(!o)throw new Error("BMGL 库加载失败");Wt(o),o.Config.HTTP_URL=t,n&&(console.log("accessToken",n),o.Config.accessToken=n),Fr(o)}function Fr(e){e.RequestScheduler&&(e.RequestScheduler.maximumRequests=120,e.RequestScheduler.maximumRequestsPerServer=18)}function Or(e){const t=M(),n=e.configManager.get("containerId");if(!t||!n)throw new Error("地图实例创建失败:BMGL 库或容器 ID 未就绪");const r=new t.Viewer(n,{mapId:e.configManager.get("mapId"),terrainId:e.configManager.get("terrainId"),requestRenderMode:!1,selectionIndicator:!1,infoBox:!1});return zr(r,e.state.value.mapType),r}function zr(e,t){t==="3d"&&(e.scene.globe.depthTestAgainstTerrain=!0);const n=e.scene,r=e.scene.globe;n.preloadFlightDestinations=!0,r.tileCacheSize=1e3,r.preloadAncestors=!0,r.preloadSiblings=!0,r.maximumScreenSpaceError=1.5}async function Ur(e,t,n){if(ye.has(n))try{await ye.unregister(n)}catch(r){y.warn(`[registerMap] 清理残留地图实例失败 (${n}):`,r)}ye.register(n,t,e.eventBus,e.resourceManager)}function Kt(e){return typeof e=="number"&&!Number.isNaN(e)?e:1e4}function jt(e,t,n){const r=M();if(!r)throw new Error("BMGL 库未加载,无法构造相机目标位置");return r.Cartesian3.fromDegrees(e,t,n)}function Yt(){return{heading:_e.heading,pitch:_e.pitch,roll:_e.roll}}function $r(e){const t=e.configManager.get("position");t&&e.map.value?.camera.flyTo({destination:jt(t.lng,t.lat,Kt(t.height)),orientation:Yt(),duration:ke.FLY_TO})}function Gr(e,t,n,r){e.map.value&&e.map.value.camera.flyTo({destination:jt(t,n,Kt(r)),orientation:Yt(),duration:ke.FLY_TO})}function Wr(e){const t=M();if(!e.map.value||!t)return null;const n=e.map.value.camera.computeViewRectangle();return n?{minx:t.Math.toDegrees(n.west),maxx:t.Math.toDegrees(n.east),miny:t.Math.toDegrees(n.south),maxy:t.Math.toDegrees(n.north)}:Hr(e)}function Hr(e){const t=M();if(!t)return null;const n=e.map.value,r=n.scene.globe.ellipsoid;try{const i=n.camera.pickEllipsoid(new t.Cartesian2(0,0),r),o=n.camera.pickEllipsoid(new t.Cartesian2(n.scene.canvas.clientWidth,n.scene.canvas.clientHeight),r);if(!i||!o)return null;const a=r.cartesianToCartographic(i),s=r.cartesianToCartographic(o);return{minx:t.Math.toDegrees(a.longitude),maxx:t.Math.toDegrees(s.longitude),miny:t.Math.toDegrees(s.latitude),maxy:t.Math.toDegrees(a.latitude)}}catch{return null}}function Kr(e){return e.initializing.value||!!e.map.value||e.destroyed.value}async function jr(e){if(!Kr(e)){e.cancelled.value=!1,e.initializing.value=!0,e.state.value.isLoading=!0,e.state.value.error=null;try{await Yr(e)}catch(t){throw e.state.value.error=t instanceof Error?t:new Error(String(t)),await e.eventBus.emit("map:error",t),t}finally{e.initializing.value=!1,e.state.value.isLoading=!1}}}async function Yr(e){const t=await Rr(e);if(await Br(e),e.cancelled.value)return;const n=Or(e);if(e.cancelled.value){qr(n);return}e.map.value=n,await Ur(e,n,t),await $r(e),!e.cancelled.value&&(e.state.value.isReady=!0,await e.eventBus.emit("map:ready"))}function qr(e){try{e.destroy()}catch(t){y.error("[useMap] 销毁未注册的地图实例失败:",t)}}async function qt(e){if(e.cancelled.value=!0,e.destroyed.value=!0,!e.map.value)return;const t=e.configManager.get("containerId");if(e.map.value=null,e.state.value.isReady=!1,t)try{await ye.unregister(t)}catch(n){y.error("[useMap] 销毁地图失败:",n)}}function Xt(e,t,n){const r=M();if(!r)throw new Error("BMGL 库未加载,无法构造目标视角");return{destination:r.Cartesian3.fromDegrees(e,t,n),orientation:{heading:0,pitch:r.Math.toRadians(-90),roll:0}}}function Xr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="2d"))try{const n=M();if(!n)throw new Error("BMGL 库未加载,无法切换 2D 模式");const r=n.Cartographic.fromCartesian(t.camera.position);t.scene.morphTo2D?.(0),e.state.value.mapType="2d",e.eventBus.emit("map:mode-changed","2d"),t.camera.setView(Xt(n.Math.toDegrees(r.longitude),n.Math.toDegrees(r.latitude),r.height))}catch(n){y.error("切换到2D模式失败:",n)}}function Zr(e){const t=M();if(!t)throw new Error("BMGL 库未加载,无法计算 3D 目标视图");const n=t.Cartographic.fromCartesian(e.map.value.camera.position),r={lng:t.Math.toDegrees(n.longitude),lat:t.Math.toDegrees(n.latitude),height:Math.max(n.height,1e4)},i=Wr(e);if(!i)return r;const o=(i.minx+i.maxx)/2,a=(i.miny+i.maxy)/2,s=(i.maxx-i.minx)*Math.cos(a*Math.PI/180)*q.METERS_PER_DEGREE_LAT_APPROX,c=(i.maxy-i.miny)*q.METERS_PER_DEGREE_LAT_APPROX,d=Math.max(s,c),u=t.Math.toRadians(q.CAMERA_FOV_DEGREES),f=Math.max(d/(2*Math.tan(u/2)),q.MIN_CAMERA_HEIGHT);return{lng:o,lat:a,height:f}}function Jr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="3d"))try{const n=Zr(e);t.scene.morphTo3D?.(0),e.state.value.mapType="3d",e.eventBus.emit("map:mode-changed","3d"),setTimeout(()=>{e.map.value&&e.map.value.camera.setView(Xt(n.lng,n.lat,n.height))},Bt)}catch(n){y.error("切换到3D模式失败:",n)}}function Qr(e){e.state.value.mapType==="2d"?Jr(e):Xr(e)}function Zt(e){const t=Pr(e),n=(i,o,a)=>Gr(t,i,o,a),r=()=>Qr(t);return l.onBeforeUnmount(()=>{qt(t)}),{map:t.map,state:t.state,initMap:()=>jr(t),setView:n,toggleMapType:r,destroy:()=>qt(t),on:t.eventBus.on.bind(t.eventBus),once:t.eventBus.once.bind(t.eventBus),off:t.eventBus.off.bind(t.eventBus),emit:t.eventBus.emit.bind(t.eventBus)}}function ei(e){return{billboardCollection:null,billboardMap:new Map,pointDataCache:[],cacheIdIndex:new Map,gridIndex:null,gridSize:e,scaleByDistance:null}}function Jt(e,t,n){const r=Math.floor(t/e),i=Math.floor(n/e);return`${r},${i}`}function Qt(e,t){const n=Jt(e.gridSize,t.lng,t.lat),r=e.gridIndex?.get(n);r?r.push(t):e.gridIndex?.set(n,[t])}function en(e,t){if(!e.gridIndex)return;const n=Jt(e.gridSize,t.lng,t.lat),r=e.gridIndex.get(n);if(!r)return;const i=r.indexOf(t);i>-1&&r.splice(i,1),r.length===0&&e.gridIndex.delete(n)}const ti=1e5;function ni(e,t){const n=[];if(!e.gridIndex)return n;const r=Math.floor(t.west/e.gridSize),i=Math.floor(t.south/e.gridSize),o=Math.floor(t.east/e.gridSize),a=Math.floor(t.north/e.gridSize),s=(o-r+1)*(a-i+1),c=d=>d.lng>=t.west&&d.lng<=t.east&&d.lat>=t.south&&d.lat<=t.north;if(s>ti){for(const d of e.pointDataCache)c(d)&&n.push(d);return n}for(let d=r;d<=o;d++)for(let u=i;u<=a;u++){const f=e.gridIndex.get(`${d},${u}`)||[];for(const h of f)c(h)&&n.push(h)}return n}function ri(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const[o,a]of e)o<t&&(t=o),a<n&&(n=a),o>r&&(r=o),a>i&&(i=a);return{west:t,south:n,east:r,north:i}}function ii(e){const[t,n]=e.center,r=e.radius/(q.METERS_PER_DEGREE_LAT*Math.cos(n*Math.PI/180)),i=e.radius/q.METERS_PER_DEGREE_LAT;return{west:t-r,east:t+r,south:n-i,north:n+i}}function oi(e){return e.type==="circle"?ii(e):ri(e.coordinates)}function ai(e,t){const[n,r]=e;let i=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){const[s,c]=t[o],[d,u]=t[a];c>r!=u>r&&n<(d-s)*(r-c)/(u-c)+s&&(i=!i)}return i}function li(e,t){const[n,r]=t.center,i=t.radius*t.radius,o=(e.lng-n)*q.METERS_PER_DEGREE_LAT*Math.cos(r*Math.PI/180),a=(e.lat-r)*q.METERS_PER_DEGREE_LAT;return o*o+a*a<=i}function si(e,t){return t.type==="circle"?e.filter(n=>li(n,t)):t.type==="polygon"||t.type==="triangle"?e.filter(n=>ai([n.lng,n.lat],t.coordinates)):e}function ci(e,t){if(!e.gridIndex||e.pointDataCache.length===0)return[];const n=oi(t);let r=ni(e,n);return t.type!=="rectangle"&&(r=si(r,t)),r}function ui(e,t){const{field:n,keyword:r,limit:i=10,caseSensitive:o=!1}=t,a=o?r.trim():r.trim().toLowerCase(),s=Array.isArray(n)?n:[n],c=[];for(const d of e.pointDataCache)if(s.some(f=>{const h=d[f];return h==null?!1:(o?String(h):String(h).toLowerCase()).includes(a)})&&(c.push(d),c.length>=i))break;return c}const di={lng:"lng",lat:"lat",altitude:"altitude",id:"id"};let tn=0,nn=!1,rn=!1;function fi(){return nn||(nn=!0,y.warn("[useMapPoint] 检测到未提供 id 的点位,已启用自增 id 自动生成;建议通过 fieldMapping.id 提供稳定 id 以支持 updatePoints 精确定位")),tn+=1,`__auto_${tn}`}function hi(){return typeof MessageChannel<"u"?new Promise(e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(0)}):new Promise(e=>setTimeout(e,0))}function gi(e,t){if(!t.scaleByDistance){const n=Ot;t.scaleByDistance=new e.NearFarScalar(n.NEAR,n.NEAR_VALUE,n.FAR,n.FAR_VALUE)}return t.scaleByDistance}function on(e){const t=ei(ce.GRID_SIZE),n=async()=>{if(!t.billboardCollection&&e.value){const d=M();d&&(t.billboardCollection=e.value.scene.primitives.add(new d.BillboardCollection))}return t.billboardCollection},r=()=>{if(t.billboardCollection)try{t.billboardCollection.removeAll()}catch(d){y.warn("[useMapPoint] removeAll billboard 失败:",d)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null},i=d=>{const u=t.cacheIdIndex.get(d);if(u===void 0)return;const f=t.pointDataCache[u],h=t.billboardMap.get(d);if(h&&t.billboardCollection)try{t.billboardCollection.remove(h)}catch(p){y.warn("[useMapPoint] 移除旧 billboard 失败:",p)}return t.billboardMap.delete(d),en(t,f),u},o=(d,u,f,h)=>{const p=parseFloat(u[f.fieldMapping.lng])||0,b=parseFloat(u[f.fieldMapping.lat])||0,C=parseFloat(u[f.fieldMapping.altitude])||0,m=d.Cartesian3.fromDegrees(p,b,C),v=t.billboardCollection.add({position:m,image:u.icon,width:u.width||f.width,height:u.height||f.height,scaleByDistance:gi(d,t),id:h,disableDepthTestDistance:Ot.NEAR,verticalOrigin:d.VerticalOrigin.BOTTOM});return v.pointData=u,{billboard:v,position:m,lng:p,lat:b,altitude:C}},a=async(d,u,f,h="append")=>{try{if(h==="replace"&&r(),!await n())return;const b=M();if(!b)return;const C={width:u?.width||20,height:u?.height||20,fieldMapping:{...di,...u?.fieldMapping||{}}},m=performance.now();t.gridIndex||(t.gridIndex=new Map);const v=Array.isArray(d)?d:[],w=v.length,E=ce.BATCH_SIZE,V=ce.YIELD_BUDGET_MS;let S=performance.now(),N=0;for(let T=0;T<w;T+=E){const I=v.slice(T,T+E);for(const k of I){if(!k.icon){N+=1,rn||(rn=!0,y.warn("[useMapPoint] 检测到缺失 icon 的点位,已跳过渲染;请在数据层通过 iconManager 预生成 icon 后传入"));continue}const L=k[C.fieldMapping.id],A=L!=null&&L!==""?String(L):fi(),B=i(A),{billboard:x,position:Z,lng:ee,lat:Me,altitude:Ie}=o(b,k,C,A);t.billboardMap.set(A,x);const te={...k,id:A,lng:ee,lat:Me,altitude:Ie,icon:k.icon};B!==void 0?t.pointDataCache[B]=te:(t.cacheIdIndex.set(A,t.pointDataCache.length),t.pointDataCache.push(te)),Qt(t,te)}T+E<w&&performance.now()-S>=V&&(await hi(),S=performance.now())}N>0&&y.warn(`[useMapPoint] 本次加载跳过 ${N} 个缺失 icon 的点位`),console.log(`[useMapPoint] ${h} ${v.length} 个点位 billboard 渲染耗时:${(performance.now()-m).toFixed(0)}ms`)}catch(p){throw y.error("加载点位失败:",p),p}},s=async d=>{const u=M();for(const f of d){const h=String(f.id),p=t.billboardMap.get(h);if(p){if(f.icon&&(p.image=f.icon),f.width!==void 0&&(p.width=f.width),f.height!==void 0&&(p.height=f.height),u&&f.lng!==void 0&&f.lat!==void 0){const b=u.Cartesian3.fromDegrees(Number(f.lng),Number(f.lat),Number(f.altitude??0));p.position=b;const C=t.cacheIdIndex.get(h);if(C!==void 0){const m=t.pointDataCache[C];en(t,m),m.lng=Number(f.lng),m.lat=Number(f.lat),f.altitude!==void 0&&(m.altitude=Number(f.altitude)),Qt(t,m)}}if(f.name!==void 0){const b=t.cacheIdIndex.get(h);b!==void 0&&(t.pointDataCache[b].name=String(f.name))}}}},c=async()=>{r()};return l.onUnmounted(()=>{try{const d=e.value?.scene;if(d?.primitives&&t.billboardCollection)try{d.primitives.remove(t.billboardCollection)}catch(u){y.warn("[useMapPoint] remove billboardCollection error:",u)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null,t.billboardCollection=null}catch(d){y.warn("[useMapPoint] onUnmounted cleanup error:",d)}}),{loadPoints:a,searchByShape:d=>ci(t,d),searchByText:d=>ui(t,d),updatePoints:s,clearPoints:c}}function an(e){return e?.rectangle?"rectangle":e?.polygon?"polygon":e?.polyline?"polyline":e?.ellipse||e?.position&&e?.billboard?"circle":"polygon"}function nt(e){if(e.length===0)return e;const t=e[0],n=e[e.length-1];return(Array.isArray(t)?t[0]===n[0]&&t[1]===n[1]:t.lng===n.lng&&t.lat===n.lat)?[...e]:[...e,t]}function pi(e,t=0){const n=M();return n?n.Cartesian3.fromDegrees(e.lng,e.lat,t):null}function ln(e){const t=M();return t?{lng:t.Math.toDegrees(e.longitude),lat:t.Math.toDegrees(e.latitude)}:null}function Re(e){const t=M();if(!t)return null;const n=t.Cartographic.fromCartesian(e);return ln(n)}function rt(e,t){return[[e.lng,e.lat],[t.lng,e.lat],[t.lng,t.lat],[e.lng,t.lat],[e.lng,e.lat]]}const we={fillColor:"#ff0000",strokeColor:"#00ff00",lineColor:"#3366ff",strokeWidth:3,fillAlpha:.1,strokeAlpha:1,pointColor:"#ff0000",pixelSize:10,radius:1e3};function U(e,t){return R().Color.fromCssColorString(e).withAlpha(t)}function sn(e){const t=R();return e.map(n=>Array.isArray(n)?t.Cartesian3.fromDegrees(n[0],n[1]):t.Cartesian3.fromDegrees(n.lng,n.lat))}function mi(e,t=!0){const n=R(),r=we;if(!e.coordinates||e.coordinates.length<3)throw new Error("多边形需要至少3个坐标点");const i=nt(e.coordinates),o=sn(i),a=new n.Entity({polygon:{hierarchy:new n.PolygonHierarchy(o),material:U(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),s=new n.Entity({polyline:{positions:o,width:e.strokeWidth??r.strokeWidth,material:U(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:a,strokeEntity:s,positions:o,closedCoordinates:i}}function yi(e,t=!0){const n=R(),r=we;if(!e.lineCoordinates||e.lineCoordinates.length<4)throw new Error("线段需要至少2个点");return{entity:new n.Entity({polyline:{positions:n.Cartesian3.fromDegreesArray(e.lineCoordinates),width:e.strokeWidth??r.strokeWidth,material:U(e.strokeColor??r.lineColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}})}}function wi(e){const t=R(),n=we;if(!e.center)throw new Error("圆形需要中心点坐标");const r=e.radius??n.radius;return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.center.lng,e.center.lat),ellipse:{semiMinorAxis:r,semiMajorAxis:r,height:0,material:U(e.fillColor??n.fillColor,e.fillAlpha??n.fillAlpha),outline:!0,outlineColor:U(e.strokeColor??n.strokeColor,e.strokeAlpha??n.strokeAlpha),outlineWidth:e.strokeWidth??n.strokeWidth}}),center:e.center,radius:r}}function vi(e,t=!0){const n=R(),r=we;if(!e.coordinates||e.coordinates.length<2)throw new Error("矩形需要两个对角点坐标");const[i,o]=e.coordinates,a=n.Rectangle.fromDegrees(Math.min(i.lng,o.lng),Math.min(i.lat,o.lat),Math.max(i.lng,o.lng),Math.max(i.lat,o.lat)),s=new n.Entity({rectangle:{coordinates:a,material:U(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),c=rt(i,o),d=new n.Entity({polyline:{positions:sn(c),width:e.strokeWidth??r.strokeWidth,material:U(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:s,strokeEntity:d,coordinates:c}}function Ci(e){const t=R(),n=we;if(!e.point)throw new Error("点需要坐标");return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.point.lng,e.point.lat),point:{pixelSize:e.pixelSize??n.pixelSize,color:U(e.pointColor??n.pointColor,1),heightReference:t.HeightReference.CLAMP_TO_GROUND}}),point:[e.point.lng,e.point.lat]}}function bi(e){const t=R();return!!(t.SceneMode&&e.scene.mode===t.SceneMode.SCENE2D)}const Ei={polygon:(e,t,n)=>{const r=mi(e,t),i=n.entities.add(r.fillEntity),o=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:i,stroke:o},coordinates:r.closedCoordinates}},line:(e,t,n)=>{const r=yi(e,t);return{nativeEntity:n.entities.add(r.entity),coordinates:e.lineCoordinates??[]}},circle:(e,t,n)=>{const r=wi(e);return{nativeEntity:n.entities.add(r.entity),coordinates:{center:r.center,radius:r.radius}}},rectangle:(e,t,n)=>{const r=vi(e,t),i=n.entities.add(r.fillEntity),o=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:i,stroke:o},coordinates:r.coordinates}},point:(e,t,n)=>{const r=Ci(e);return{nativeEntity:n.entities.add(r.entity),coordinates:r.point}}};function cn(e,t,n){const r=Ei[e];if(!r)throw new Error(`不支持的实体类型: ${e}`);return r(t,!bi(n),n)}function Be(e,t){try{e.type==="polygon"||e.type==="rectangle"?(e.nativeEntity?.fill&&t.entities.remove(e.nativeEntity.fill),e.nativeEntity?.stroke&&t.entities.remove(e.nativeEntity.stroke)):e.nativeEntity&&t.entities.remove(e.nativeEntity)}catch(n){y.warn(`移除原生实体失败 (${e.id}):`,n)}}function it(e,t,n,r){return{color:e.fillColor||t.options.fillColor||n,alpha:e.fillAlpha!==void 0?e.fillAlpha:t.options.fillAlpha??r}}function Fe(e,t,n,r){return{color:e.strokeColor||t.options.strokeColor||n,alpha:e.strokeAlpha!==void 0?e.strokeAlpha:r}}function Ti(e,t){const n=R(),{fill:r,stroke:i}=e.nativeEntity,o=nt(t.coordinates),a=o.map(s=>n.Cartesian3.fromDegrees(s.lng,s.lat));r.polygon.hierarchy=new n.PolygonHierarchy(a),i.polyline.positions=a,e.coordinates=o}function Si(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:o}=it(t,e,"#ff0000",.1);n.polygon.material=U(i,o)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:o}=Fe(t,e,"#00ff00",1);r.polyline.material=U(i,o)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=3&&Ti(e,t)}function Di(e,t){const n=R(),{fill:r,stroke:i}=e.nativeEntity,[o,a]=t.coordinates;r.rectangle.coordinates=n.Rectangle.fromDegrees(Math.min(o.lng,a.lng),Math.min(o.lat,a.lat),Math.max(o.lng,a.lng),Math.max(o.lat,a.lat));const s=rt(o,a);i.polyline.positions=s.map(c=>n.Cartesian3.fromDegrees(c[0],c[1])),e.coordinates=s}function Mi(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:o}=it(t,e,"#ff0000",.1);n.rectangle.material=U(i,o)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:o}=Fe(t,e,"#00ff00",1);r.polyline.material=U(i,o)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=2&&Di(e,t)}function Ii(e,t){const n=R(),i=e.nativeEntity.polyline;if(i){if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:o,alpha:a}=Fe(t,e,"#3366ff",1);i.material=U(o,a)}t.strokeWidth!==void 0&&(i.width=t.strokeWidth),t.lineCoordinates&&t.lineCoordinates.length>=4&&(i.positions=n.Cartesian3.fromDegreesArray(t.lineCoordinates),e.coordinates=t.lineCoordinates)}}function Li(e,t){const n=R(),r=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:o}=it(t,e,"#ff0000",.1);r.ellipse.material=U(i,o)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:o}=Fe(t,e,"#00ff00",1);r.ellipse.outlineColor=U(i,o)}if(t.strokeWidth!==void 0&&(r.ellipse.outlineWidth=t.strokeWidth),t.radius!==void 0&&(r.ellipse.semiMinorAxis=t.radius,r.ellipse.semiMajorAxis=t.radius),t.center){r.position=n.Cartesian3.fromDegrees(t.center.lng,t.center.lat);const i=e.coordinates,o=i&&!Array.isArray(i)?i.radius:void 0;e.coordinates={center:t.center,radius:t.radius||o||1e3}}}function Ai(e,t){const n=R(),r=e.nativeEntity,i=r.point;i&&(t.pointColor!==void 0&&(i.color=U(t.pointColor,1)),t.pixelSize!==void 0&&(i.pixelSize=t.pixelSize),t.point&&(r.position=n.Cartesian3.fromDegrees(t.point.lng,t.point.lat),e.coordinates=[t.point.lng,t.point.lat]))}function xi(e,t){const n=e.nativeEntity;e.type==="polygon"||e.type==="rectangle"?(n.fill.show=t,n.stroke.show=t):n.show=t}function Ni(e,t,n){e==="polygon"?Si(t,n):e==="rectangle"?Mi(t,n):e==="line"?Ii(t,n):e==="circle"?Li(t,n):e==="point"&&Ai(t,n)}function _i(e,t){const n=t.coordinates;n&&((e.type==="polygon"||e.type==="rectangle")&&!e.coordinates&&Array.isArray(n)&&(e.coordinates=n),e.type==="line"&&!e.lineCoordinates&&t.type==="line"&&Array.isArray(n)&&(e.lineCoordinates=n),e.type==="circle"&&!e.center&&t.type==="circle"&&!Array.isArray(n)&&(e.center=n.center,e.radius=n.radius||1e3),e.type==="point"&&!e.point&&t.type==="point"&&Array.isArray(n)&&(e.point=n))}async function ki(e,t,n,r,i){Be(t,r);const o={...t.options,...n,id:e,type:n.type};return _i(o,t),await i(o)!==null}function un(e){const t=new Map;let n="";const r=()=>!e.value||!e.value.entities?(y.warn("地图实例未就绪"),!1):!0,i=async()=>{if(r())return!0;try{return await Ht(),r()}catch{return!1}},o=async u=>{try{if(!await i())return null;const f=e.value;if(!f)return null;const h=u.id||`${u.type}-${Date.now()}`,{nativeEntity:p,coordinates:b}=cn(u.type,u,f),C={id:h,type:u.type,options:{...u,id:h,type:u.type,visible:u.visible!==!1},nativeEntity:p,coordinates:b};return t.set(h,C),n=h,h}catch(f){return y.error("绘制实体失败:",f),null}},a=u=>{try{if(!r())return!1;const f=e.value;if(!f)return!1;if(!u)return t.forEach(p=>Be(p,f)),t.clear(),n="",!0;const h=t.get(u);return h?(Be(h,f),t.delete(u),n===u&&(n=""),!0):(y.warn(`实体未找到: ${u}`),!1)}catch(f){return y.error("删除实体失败:",f),!1}},s=()=>n,c=async(u,f)=>{try{const h=t.get(u);if(!h)return y.warn(`实体未找到:${u}`),!1;if(!await i())return!1;const p=e.value;return p?f.type&&f.type!==h.type?await ki(u,h,f,p,o):(Ni(h.type,h,f),f.name!==void 0&&(h.options.name=f.name),f.visible!==void 0&&xi(h,f.visible),h.options={...h.options,...f},t.set(u,h),!0):!1}catch(h){return y.error(`修改实体失败 (${u}):`,h),!1}},d=()=>{if(!r())return;const u=e.value;if(u)for(const[f,h]of t)try{Be(h,u),h.nativeEntity=cn(h.type,h.options,u).nativeEntity}catch(p){y.warn(`重绘实体失败 (${f}):`,p)}};return l.onUnmounted(()=>{try{t.clear(),n=""}catch(u){y.warn("[useMapEntity] onUnmounted cleanup error:",u)}}),{drawEntity:o,updateEntity:c,deleteEntity:a,redrawAllEntities:d,getCurrentEntityId:s}}function Pi(){return{drawInstance:null,editInstance:null,currentDrawId:"",currentDrawType:null,isDrawing:!1,isEditing:!1,drawCallback:null,mapInstance:null,mapHandler:null,eventListeners:[],lastEditedEntity:null,drawEntityIds:new Set}}const ve={fillColor:"#369",fillAlpha:.6,borderColor:"#fff",borderAlpha:.8,lineWidth:2,labelFont:"14px arial",arrowWidth:20};function Oe(e,t,n,r){return typeof e!="number"||Number.isNaN(e)?r:Math.min(n,Math.max(t,e))}class Vi{constructor(t){this.config={...ve,...t},this.config.fillAlpha=Oe(this.config.fillAlpha,0,1,ve.fillAlpha),this.config.borderAlpha=Oe(this.config.borderAlpha,0,1,ve.borderAlpha),this.config.lineWidth=Oe(this.config.lineWidth,1,50,ve.lineWidth),this.config.arrowWidth=Oe(this.config.arrowWidth,1,100,ve.arrowWidth)}materials(t){const{fillColor:n,fillAlpha:r,borderColor:i,borderAlpha:o}=this.config;return{fill:t.Color.fromCssColorString(n).withAlpha(r),border:t.Color.fromCssColorString(i).withAlpha(o)}}label(t){const{labelFont:n}=this.config;return{fillColor:t.Color.WHITE,font:n,verticalOrigin:t.VerticalOrigin.BOTTOM,pixelOffset:new t.Cartesian2(0,-20),disableDepthTestDistance:5e3}}getDrawConfig(){const t=R(),{fill:n,border:r}=this.materials(t),i=this.label(t),o=this.config.lineWidth,a={bmgl:t,config:this.config,shared:{fill:n,border:r,label:i,width:o}},s={repeat:!0};for(const c of Lt())c.buildConfig&&(s[c.type]=c.buildConfig(a));return s}getEditConfig(){const t=R();return{axis:{scale:1},control:{tolerance:4,marker:{eyeOffset:new t.Cartesian3(0,0,-20),verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:5e3}}}}}function dn(e){return e.map(t=>Re(t)).filter(t=>t!==null)}function Ri(e){try{const t=e.polygon.hierarchy.getValue().positions||[],n=dn(t);return{type:"polygon",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return y.error("提取多边形数据失败:",t),null}}function Bi(e){const t=R();try{const n=e.rectangle.coordinates.getValue(),r=t.Math.toDegrees(n.west),i=t.Math.toDegrees(n.south),o=t.Math.toDegrees(n.east),a=t.Math.toDegrees(n.north);return{type:"rectangle",path:[[r,a],[o,a],[o,i],[r,i],[r,a]],rawPath:[{lng:r,lat:a},{lng:o,lat:a},{lng:o,lat:i},{lng:r,lat:i}],radius:void 0}}catch(n){return y.error("提取矩形数据失败:",n),null}}function Fi(e){try{const t=e.polyline.positions.getValue(),n=dn(t);return{type:"polyline",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return y.error("提取折线数据失败:",t),null}}function Oi(e){try{const t=Re(e.position.getValue());if(!t)return null;const n=e.ellipse.semiMajorAxis?.getValue()||0,r=e.ellipse.semiMinorAxis?.getValue()||0;return{type:"circle",center:[t.lng,t.lat],radius:Math.max(n,r),rawPath:[t]}}catch(t){return y.error("提取圆形数据失败:",t),null}}function zi(e){try{const t=Re(e.position.getValue());return t?{type:"circle",center:[t.lng,t.lat],radius:e.radius||0,rawPath:[t]}:null}catch{return null}}function fn(e){return e?e.polygon?Ri(e):e.rectangle?Bi(e):e.polyline?Fi(e):e.position&&e.ellipse?Oi(e):e.billboard&&e.position?zi(e):null:null}function Ui(e){return an(e)}function $i(e){return e.editInstance&&(e.editInstance.isEditing||e.editInstance._isEditing||e.editInstance.editing)||!1}function Gi(e){typeof e.finish=="function"?e.finish():typeof e.stop=="function"?e.stop():typeof e.disable=="function"?e.disable():typeof e.end=="function"?e.end():e.isEditing=!1}function Ce(e,t=!1){if(e.editInstance){t&&e.currentDrawId&&(e.lastEditedEntity=e.mapInstance?.entities.getById(e.currentDrawId)??null);try{Gi(e.editInstance)}catch(n){y.error("结束编辑状态失败:",n)}finally{e.isEditing=!1}t&&e.lastEditedEntity&&Wi(e)}}function re(e,t){if(e.drawCallback)try{e.drawCallback(t)}catch(n){y.error("绘图回调执行失败:",n)}else y.warn("绘图回调函数未设置")}function Wi(e){if(!(!e.lastEditedEntity||!e.currentDrawId))try{const t=fn(e.lastEditedEntity);if(!t)return;const n={type:t.type,layer:{_id:e.currentDrawId},path:t.rawPath||[]};t.type==="circle"&&t.radius!==void 0&&(n.radius=t.radius),re(e,{type:t.type,operation:"edit",id:e.currentDrawId,data:t,rawData:n}),e.lastEditedEntity=null}catch(t){y.error("手动触发编辑完成事件失败:",t)}}function Hi(e,t,n){try{if(e.drawInstance||n(),!e.drawInstance)throw new Error("绘图实例初始化失败");if(e.isEditing&&Ce(e,!1),e.isDrawing=!0,e.currentDrawType=t,typeof e.drawInstance.enable=="function")e.drawInstance.enable(t);else if(typeof e.drawInstance.start=="function")e.drawInstance.start(t);else throw new Error("绘图实例没有可用的启用方法")}catch(r){throw y.error(`开始绘制 ${t} 失败:`,r),e.isDrawing=!1,e.currentDrawType=null,r}}function Ki(e){const t=(n,...r)=>{if(n){for(const i of r)if(typeof n[i]=="function"){n[i]();return}}};t(e.drawInstance,"disable","stop"),t(e.editInstance,"disable","stop")}function ji(e){e.currentDrawId="",e.currentDrawType=null,e.isDrawing=!1,e.isEditing=!1,e.lastEditedEntity=null}function ie(e){e.isEditing&&Ce(e,!1),Ki(e),ji(e)}function Yi(e,t=""){if(!e.mapInstance)return;const n=t||e.currentDrawId;if(e.isEditing&&Ce(e,!1),!n){ie(e);return}const r=e.mapInstance.entities.getById(n);if(r){const i=fn(r);if(e.mapInstance.entities.remove(r),e.drawEntityIds.delete(n),e.currentDrawId===n&&(e.currentDrawId=""),i){const o={type:i.type,layer:{_id:n},path:i.rawPath||[]};i.type==="circle"&&i.radius!==void 0&&(o.radius=i.radius),re(e,{type:i.type,operation:"delete",id:n,data:i,rawData:o})}}ie(e)}function qi(e){if(!e.mapInstance)return;e.isEditing&&Ce(e,!1);let t=0;if(e.drawEntityIds.size>0){for(const r of e.drawEntityIds){const i=e.mapInstance.entities.getById(r);i&&(e.mapInstance.entities.remove(i),t++)}e.drawEntityIds.clear()}else{const r=e.mapInstance.entities?.values||[];r.some(o=>!e.drawEntityIds.has(o?._id))||(e.mapInstance.entities.removeAll(),t=r.length)}const n=e.currentDrawType||"polygon";re(e,{type:n,operation:"clear",data:null,rawData:null,count:t}),ie(e)}class X{static process(t){if(!t?.type)return null;try{const n=X.getProcessor(t.type);if(!n)return null;const r=n(t);return r?{...r,id:t.layer?._id||""}:null}catch(n){return y.error("数据处理失败:",n),null}}static getProcessor(t){return{rectangle:X.processRectangle,polygon:X.processPolygon,circle:X.processCircle,triangle:X.processTriangle,polyline:X.processPolyline}[t]}static processRectangle(t){const[n,r]=t.path||[];return!n||!r?null:{type:"rectangle",path:[[n.lng,n.lat],[r.lng,n.lat],[r.lng,r.lat],[n.lng,r.lat],[n.lng,n.lat]]}}static processPolygon(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polygon",path:[...n,n[0]]}}static processCircle(t){const n=t.path;return!n||n.lng===void 0?null:{type:"circle",center:[n.lng,n.lat],radius:t.radius||0}}static processTriangle(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"triangle",path:[...n,n[0]]}}static processPolyline(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polyline",path:n}}}function Xi(e,t,n){re(e,{type:Ui(n),operation:"select",id:t,data:{id:t},rawData:n})}function Zi(e){if($i(e)){Ce(e,!0);return}e.isDrawing&&e.currentDrawType&&re(e,{type:e.currentDrawType,operation:"cancel",id:e.currentDrawId,data:null,rawData:null}),ie(e)}function Ji(e,t){if(!e.mapInstance)return;const n=R(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const i=r?.id?._id;if(typeof i!="string"||!i)return;const o=e.mapInstance.entities.getById(i);if(!o||!e.editInstance)return;e.currentDrawId=i,e.lastEditedEntity=o;const a=e.editInstance;typeof a.edit=="function"?a.edit(o):typeof a.start=="function"?a.start(o):typeof a.enable=="function"&&a.enable(o),e.isEditing=!0}function Qi(e,t){if(!e.mapInstance||e.isDrawing)return;const n=R(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const i=r?.id?._id;if(typeof i!="string"||!i)return;const o=e.mapInstance.entities.getById(i);o&&(e.currentDrawId=i,Xi(e,i,o))}function eo(e,t){const n=X.process(t.detail);if(!n)return;n.id&&e.drawEntityIds.add(n.id);const r={type:n.type,operation:"draw",id:n.id,data:n,rawData:t.detail};re(e,r),ie(e)}function to(e,t){e.isEditing=!1;const n=X.process(t.detail);if(!n){e.lastEditedEntity=null;return}const r={type:n.type,operation:"edit",id:n.id,data:n,rawData:t.detail};re(e,r),e.lastEditedEntity=null}function hn(e){e.eventListeners.forEach(({type:t})=>{try{e.mapHandler?.removeInputAction(t)}catch(n){y.warn(`移除 ${t} 事件监听器失败:`,n)}}),e.eventListeners=[]}function no(e){hn(e);const t=e.mapHandler;if(!t)return;const n=R(),r=[n.ScreenSpaceEventType.RIGHT_CLICK,n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,n.ScreenSpaceEventType.LEFT_CLICK],i=[()=>Zi(e),o=>Ji(e,o),o=>Qi(e,o)];r.forEach((o,a)=>{t.setInputAction(i[a],o),e.eventListeners.push({type:o})})}function ro(e){e.drawInstance&&(e.drawInstance.on("bm_draw_end",t=>eo(e,t)),e.editInstance&&e.editInstance.on("bm_edit_end",t=>to(e,t)))}function io(e,t,n){try{if(e.mapInstance=l.isRef(t)?t.value:t,!e.mapInstance)throw new Error("地图实例不可用");if(!M())throw new Error("BMGL 库未加载");if(e.mapHandler=e.mapInstance.screenSpaceEventHandler,!e.mapHandler)throw new Error("地图事件处理器不可用");const r=R(),i=new Vi(n);e.drawInstance=new r.Plot.Draw(e.mapInstance,i.getDrawConfig()),e.editInstance=new r.Plot.Edit(e.mapInstance,i.getEditConfig()),no(e),ro(e)}catch(r){throw y.error("绘图工具初始化失败:",r),r}}function gn(e){try{ie(e),hn(e),e.drawInstance&&typeof e.drawInstance.destroy=="function"&&e.drawInstance.destroy(),e.editInstance&&typeof e.editInstance.destroy=="function"&&e.editInstance.destroy(),e.drawInstance=null,e.editInstance=null,e.drawCallback=null,e.mapHandler=null,e.lastEditedEntity=null}catch(t){y.error("清理绘图工具资源失败:",t)}}function pn(e,t){const n=Pi(),r=()=>io(n,e,t),i=s=>{n.drawCallback=s},o=()=>({isDrawing:n.isDrawing,isEditing:n.isEditing,currentDrawId:n.currentDrawId,currentDrawType:n.currentDrawType,drawInstance:!!n.drawInstance,editInstance:!!n.editInstance}),a=()=>n.isDrawing;if(e&&typeof e=="object"&&"value"in e)l.watch(e,s=>{if(s&&!n.drawInstance)try{r()}catch(c){y.warn("自动初始化失败,将在绘图时重试:",c)}},{immediate:!0});else if(e)try{r()}catch(s){y.warn("自动初始化失败,将在绘图时重试:",s)}return l.onUnmounted(()=>{gn(n)}),{startDrawing:s=>Hi(n,s,r),cancelDrawing:()=>ie(n),removeDrawing:(s="")=>Yi(n,s),clearAllDrawings:()=>qi(n),setCallback:i,getDrawingStatus:o,getIsDrawing:a,initialize:r,cleanup:()=>gn(n)}}function oo(){return{popupLayer:null,divLayerManager:null,mapInstance:null,currentPopupData:null,displayConfig:null,popupSeq:0}}function be(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ao(e){return e&&/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)?e:""}function ue(e,t){return typeof e=="number"&&!Number.isNaN(e)?e.toFixed(t):"-"}function lo(e){return G[e||"default"]||G.default}function so(e){return[`--status-color: ${e.color}`,`--status-bg: ${e.color}10`,`--status-border: ${e.color}30`,`--status-shadow: ${e.color}30`].join(";")}function co(e,t){const n=[e.lineCode,e.lineNo,e.pointNo].filter(i=>i!=null&&i!==""),r=n.length?`<div class="map-point-popup-subtitle"><span>${n.map(i=>be(i)).join('<span class="map-point-popup-divider">|</span>')}</span></div>`:"";return`
2
2
  <div class="map-point-popup-title">
3
3
  <div class="map-point-popup-header">
4
- <h3>${fe(e.name||"点位信息")}</h3>
5
- <div class="map-point-popup-status">${fe(t.text)}</div>
4
+ <h3>${be(e.name||"点位信息")}</h3>
5
+ <div class="map-point-popup-status">${be(t.text)}</div>
6
6
  </div>
7
7
  ${r}
8
- </div>`}function Qt(e,t){return`
8
+ </div>`}function mn(e,t){return`
9
9
  <div class="map-point-popup-field">
10
- <div class="map-point-popup-field-label">${fe(e)}</div>
11
- <div class="map-point-popup-field-value">${fe(t)}</div>
12
- </div>`}function zi(e,t){const n=t[e.key];if(n==null||n==="")return"-";if(typeof e.format=="function")return e.format(n,t);switch(e.format){case"lng":return re(n,6);case"lat":return re(n,6);case"altitude":return`${re(n,2)} m`;default:return String(n)}}function Fi(e){return`<div class="map-point-popup-grid">${e.map(t=>Qt(t.label,t.value)).join("")}</div>`}function Oi(e){const t=re(e.lng,6),n=re(e.lat,6),r=re(e.altitude,2),i=e.teamName||"-",a=e.realName||"-";return Fi([{label:"经度",value:t},{label:"纬度",value:n},{label:"高程",value:`${r} m`},{label:"班组",value:i},{label:"人员",value:a}])}function Gi(e,t){return`<div class="map-point-popup-grid">${t.map(r=>Qt(r.label,zi(r,e))).join("")}</div>`}function Ui(e,t){const n=Pi(e.status),r=Bi(n),i=Vi(t?.themeColor),a=i?`--popup-accent: ${i};`:"",l=t?.fields?.length?Gi(e,t.fields):Oi(e);return`
13
- <div class="map-point-popup" style="${r};${a}">
14
- ${Ri(e,n)}
10
+ <div class="map-point-popup-field-label">${be(e)}</div>
11
+ <div class="map-point-popup-field-value">${be(t)}</div>
12
+ </div>`}function uo(e,t){const n=t[e.key];if(n==null||n==="")return"-";if(typeof e.format=="function")return e.format(n,t);switch(e.format){case"lng":return ue(n,6);case"lat":return ue(n,6);case"altitude":return`${ue(n,2)} m`;default:return String(n)}}function fo(e){return`<div class="map-point-popup-grid">${e.map(t=>mn(t.label,t.value)).join("")}</div>`}function ho(e){const t=ue(e.lng,6),n=ue(e.lat,6),r=ue(e.altitude,2),i=e.teamName||"-",o=e.realName||"-";return fo([{label:"经度",value:t},{label:"纬度",value:n},{label:"高程",value:`${r} m`},{label:"班组",value:i},{label:"人员",value:o}])}function go(e,t){return`<div class="map-point-popup-grid">${t.map(r=>mn(r.label,uo(r,e))).join("")}</div>`}function po(e,t){const n=lo(e.status),r=so(n),i=ao(t?.themeColor),o=i?`--popup-accent: ${i};`:"",a=t?.fields?.length?go(e,t.fields):ho(e);return`
13
+ <div class="map-point-popup" style="${r};${o}">
14
+ ${co(e,n)}
15
15
  <div class="map-point-popup-content">
16
- ${l}
16
+ ${a}
17
17
  </div>
18
- </div>`}function je(e){return typeof e=="number"&&!Number.isNaN(e)}function $i(e,t){return t&&(e.mapInstance=o.isRef(t)?t.value:t),!!e.mapInstance}async function Wi(e,t,n){if($i(e,t),!e.divLayerManager&&e.mapInstance){const r=D();if(!r)return null;e.divLayerManager=new r.div.DivLayerManager(e.mapInstance,{click:(i,a)=>{n&&n({position:a,detail:i})}})}return e.divLayerManager}function Hi(e){const t=D();if(!t)throw new Error("BMGL 库未加载,无法转换弹窗坐标");return t.Cartesian3.fromDegrees(e.lng,e.lat,e.altitude||0)}function en(e,t,n){const r=_i();r.displayConfig=n?.displayConfig||null;const i=()=>{if(r.popupLayer&&r.divLayerManager){try{r.divLayerManager.removeLayer(r.popupLayer)}catch(d){w.warn("移除弹窗时发生错误:",d)}r.popupLayer=null}r.currentPopupData=null},a=async(d,c={})=>{try{if(!d)throw new Error("点位数据不能为空");const f=++r.popupSeq,h={lng:je(d.lng)?d.lng:te.lng,lat:je(d.lat)?d.lat:te.lat,altitude:je(d.altitude)?d.altitude:0};i();const p=await Wi(r,e,t);if(!p)throw new Error("DivLayerManager 初始化失败");if(f!==r.popupSeq)return;r.currentPopupData={...d};const b={offsetX:0,offsetY:-20,className:"map-point-popup",...c},v=D();if(!v)throw new Error("BMGL 库未加载,无法创建弹窗");const m=new v.div.DivLayer(Ui(d,r.displayConfig||void 0),Hi(h),{offset:{x:b.offsetX,y:b.offsetY}});r.popupLayer=m,p.addLayer(m)}catch(f){w.error("显示点位弹窗失败:",f),i()}},l=()=>{i()},s=()=>r.popupLayer!==null,u=()=>r.currentPopupData;return o.onUnmounted(()=>{try{l()}catch(c){w.warn("[useMapPopup] onUnmounted removePopup error:",c)}const d=r.divLayerManager;if(d&&typeof d.destroy=="function")try{d.destroy()}catch(c){w.warn("[useMapPopup] onUnmounted destroy manager error:",c)}r.divLayerManager=null,r.mapInstance=null,r.currentPopupData=null}),{showPointPopup:a,removePopup:l,isPopupVisible:s,getCurrentPopupData:u}}function tn(e){let t=null;const n=()=>o.isRef(e)?e.value:e,r=new Set,i=new Map,a=s=>{try{if(t=n(),!t)throw new Error("地图实例不可用");const{position:u,config:d={}}=s,c=`circleWave_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,f=new CircleWave(t,c),{color:h="#0a84ff",radius:p=100,duration:b=3e3,ttl:v=0}=d;return f.add(u,h,p,b),r.add(c),v>0&&i.set(c,setTimeout(()=>{i.delete(c),l(c)},v)),c}catch(u){throw w.error("添加波动效果失败:",u),u}},l=s=>{try{if(t||(t=n()),!t||!t.entities)return w.warn("地图实例或 entities 不可用"),r.delete(s),!1;const u=t.entities.getById(s);if(!u)return w.warn(`未找到要删除的波动实体, ID: ${s}`),r.delete(s),!1;t.entities.remove(u),r.delete(s);const d=i.get(s);return d&&(clearTimeout(d),i.delete(s)),!0}catch(u){return w.error(`删除波动效果失败, ID: ${s}:`,u),r.delete(s),!1}};return o.onUnmounted(()=>{i.forEach(s=>clearTimeout(s)),i.clear();for(const s of Array.from(r))try{l(s)}catch(u){w.warn(`[useMapCircleWave] onUnmounted removeWave error (${s}):`,u)}r.clear()}),{addWave:a,removeWave:l}}function ji(){return{layers:new Map}}function nn(e){return e.value?e.value:(w.warn("[useMapLayers] 地图未初始化"),null)}function rn(e,t,n){const r=e.layers.get(n);if(r){try{t.value&&t.value.imageryLayers.remove(r,!1)}catch(i){w.warn(`移除同名旧图层失败 (${n}):`,i)}e.layers.delete(n)}}function Yi(e,t,n){const r=nn(t);if(!r)throw new Error("地图未初始化,无法添加影像图层");const i=N();rn(e,t,n);const a=new i.ImageryLayer(new i.BMImageryProvider({mapId:n}));return r.imageryLayers.add(a),e.layers.set(n,a),a}function qi(e,t,n,r="wmts-layer"){const i=nn(t);if(!i)throw new Error("地图未初始化,无法添加 WMTS 图层");const a=N();rn(e,t,r);const l=new a.WebMapTileServiceImageryProvider({url:n,layer:r,style:"default",format:"image/png",tileMatrixSetID:"EPSG:3857"}),s=i.imageryLayers.add(new a.ImageryLayer(l,{maximumTerrainLevel:21}));return e.layers.set(r,s),s}function Ki(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n?{layer:n,key:t}:(w.warn(`图层未找到: ${t}`),{layer:null,key:null})}return{layer:t,key:null}}function Xi(e,t,n){try{const{layer:r,key:i}=Ki(e,n);if(!r)return!1;if(t.value&&t.value.imageryLayers.remove(r,!1),i!==null)e.layers.delete(i);else for(const[a,l]of e.layers.entries())if(l===r){e.layers.delete(a);break}return!0}catch(r){return w.error("移除图层失败:",r),!1}}function Zi(e,t){const n=t.value;if(n)try{e.layers.forEach(r=>{n.imageryLayers.remove(r,!1)}),e.layers.clear()}catch(r){w.error("移除所有图层失败:",r)}}function an(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n||(w.warn(`图层未找到: ${t}`),null)}return t}function Ji(e,t,n){try{const r=an(e,t);return r?(r.show=n,!0):!1}catch(r){return w.error("设置图层可见性失败:",r),!1}}function Qi(e,t,n){try{if(typeof n!="number"||Number.isNaN(n)||n<0||n>1)return w.warn("透明度必须在 0-1 之间"),!1;const r=an(e,t);return r?(r.alpha=n,!0):!1}catch(r){return w.error("设置图层透明度失败:",r),!1}}function ea(e){const t=[];return e.layers.forEach((n,r)=>{t.push({name:r,layer:n})}),t}function on(e){const t=ji();return o.onUnmounted(()=>{try{t.layers.clear()}catch(n){w.warn("[useMapLayers] onUnmounted cleanup error:",n)}}),{addImageryLayer:n=>Yi(t,e,n),addWmtsLayer:(n,r)=>qi(t,e,n,r),removeLayer:n=>Xi(t,e,n),removeAllLayers:()=>Zi(t,e),setLayerVisible:(n,r)=>Ji(t,n,r),setLayerOpacity:(n,r)=>Qi(t,n,r),getAllLayers:()=>ea(t)}}function ta(e){return{...wt,...e}}function na(e,t){const n=e.Material.fromType("ElevationContour"),r=n.uniforms;return r.width=t.width,r.spacing=t.spacing,r.color=e.Color.RED.clone(),n}function ln(e,t){const n=o.ref(!1),r=s=>{const u=e.value;if(u?.scene?.globe)if(s){const d=D();if(!d)return;u.scene.globe.material=na(d,ta(t))}else u.scene.globe.material=void 0};return{contourVisible:n,setContourVisible:s=>{n.value=!!s,r(n.value)},reapply:()=>{n.value&&r(!0)},remove:()=>{r(!1)}}}const ra=2e4;function ia(e,t={}){if(!Array.isArray(e)||e.length<2)throw new Error("轨迹至少需要2个点");const n=t.interval&&t.interval>0?t.interval:1;e.some(h=>typeof h.time=="number"&&Number.isFinite(h.time));const r=e.map((h,p)=>({...h,time:typeof h.time=="number"&&Number.isFinite(h.time)?h.time:p*n}));r.sort((h,p)=>h.time-p.time);const i=[];let a=-1/0;for(const h of r)h.time>a&&(i.push(h),a=h.time);if(i.length<2)throw new Error("轨迹时间戳无效,无法构成回放时间表");const l=i.map(h=>h.time),s=l[0],u=l[l.length-1]-s,d=t.duration&&t.duration>0?t.duration:u,c=t.maxPoints&&t.maxPoints>=2?Math.floor(t.maxPoints):ra;let f=i;if(i.length>c){const h=Math.ceil(i.length/c);f=i.filter((b,v)=>v%h===0);const p=i[i.length-1];f[f.length-1]!==p&&f.push(p)}return{points:i,times:l,displayPoints:f,duration:d,minTime:s}}function he(e,t){const{points:n,times:r,duration:i,minTime:a}=e,l=n.length;if(t<=r[0]){const m=n[0];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:0,progress:0}}if(t>=r[l-1]){const m=n[l-1];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:l-1,progress:1}}let s=0,u=l-1;for(;s<u;){const m=s+u+1>>1;r[m]<=t?s=m:u=m-1}const d=s,c=r[d+1]-r[d],f=c>0?(t-r[d])/c:0,h=n[d],p=n[d+1],b=h.altitude??0,v=p.altitude??0;return{lng:h.lng+(p.lng-h.lng)*f,lat:h.lat+(p.lat-h.lat)*f,altitude:b+(v-b)*f,index:d,progress:i>0?(t-a)/i:0}}function aa(e,t={}){const n=e.duration,r=!!t.loop;let i=0,a=Math.max(0,t.speed??1),l=t.autoPlay?"playing":"idle";const s={status:l,currentTime:0,duration:n,progress:0,pointCount:e.points.length},u=m=>Math.max(0,Math.min(n,m)),d=()=>{s.status=l,s.currentTime=u(i),s.duration=n,s.progress=n>0?s.currentTime/n:0,s.pointCount=e.points.length},c=()=>{n<=0||(l==="ended"&&(i=0),l="playing",d())},f=()=>{l==="playing"&&(l="paused"),d()},h=()=>{i=0,l="idle",d()},p=m=>{a=Math.max(0,m),d()},b=m=>{i=u(m),l==="ended"&&(l="paused"),d()},v=m=>{l!=="playing"||n<=0||(i+=m*a,i>=n&&(r?i=i%n:(i=n,l="ended")),d())};return d(),{state:s,play:c,pause:f,stop:h,setSpeed:p,jumpTo:b,tick:v}}function oa(e){const t=D();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function Ye(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function la(e,t,n,r){const i=t.map(a=>e.Cartesian3.fromDegrees(a.lng,a.lat,a.altitude??0));return new e.Entity({polyline:{positions:i,width:n.lineWidth,material:Ye(e,n.lineColor,.9),clampToGround:r}})}function sa(e,t,n){return new e.Entity({polyline:{positions:[],width:t.lineWidth,material:Ye(e,t.markerColor,.9),clampToGround:n}})}function ca(e,t){if(!e?.billboard||!t.markerIcon||typeof Image>"u")return;const n=t.markerSize*2,r=new Image;r.onload=()=>{!e.billboard||!r.naturalWidth||!r.naturalHeight||(e.billboard.width=n,e.billboard.height=r.naturalHeight/r.naturalWidth*n)},r.src=t.markerIcon}function ua(e,t,n=!0){const r=new e.ConstantPositionProperty(e.Cartesian3.fromDegrees(0,0,0)),i=new e.Entity({position:r}),a=n?e.HeightReference.CLAMP_TO_GROUND:e.HeightReference.NONE;return t.markerIcon?i.billboard={image:t.markerIcon,width:t.markerSize*2,heightReference:a,verticalOrigin:e.VerticalOrigin.BOTTOM}:i.point={pixelSize:t.markerSize,color:Ye(e,t.markerColor,1),heightReference:a},ca(i,t),i}function da(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function qe(e){return{...yt,...e}}const fa=100,ha=.25;function sn(e,t,n){const r=o.ref({status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}),i=qe(t);let a=null,l=null,s=i,u=null,d=null,c=null,f=null,h=null,p=0,b=0;const v=()=>{const T=e.value;return T&&T.entities?T:null},m=()=>{h!==null&&(cancelAnimationFrame(h),h=null)},C=()=>{const T=v();T&&(u&&T.entities.remove(u),d&&T.entities.remove(d),c&&T.entities.remove(c)),u=null,d=null,c=null,f=null},y=()=>{l&&(r.value={...l.state})},E=T=>{if(!f)return;const L=D();L&&f.setValue(L.Cartesian3.fromDegrees(T.lng,T.lat,T.altitude))},_=T=>{if(!d||!a||!l)return;const L=D();if(!L)return;const P=l.state.currentTime,W=s.trailTime>0?Math.max(0,P-s.trailTime):0,ie=he(a,a.minTime+W),ee=a.points.slice(ie.index,T.index+1),O=da(L,ee);O.push(L.Cartesian3.fromDegrees(T.lng,T.lat,T.altitude)),d.polyline&&(d.polyline.positions=O)},S=T=>{const L=e.value;if(!L?.camera)return;const P=D();P&&L.camera.setView({destination:P.Cartesian3.fromDegrees(T.lng,T.lat,s.followHeight),orientation:{heading:0,pitch:P.Math.toRadians(-90),roll:0}})},A=T=>{if(!l||!a||l.state.status!=="playing"){m();return}h=requestAnimationFrame(A);const L=Math.min(Math.max((T-p)/1e3,0),ha);p=T,l.tick(L);const P=he(a,a.minTime+l.state.currentTime);E(P),T-b>=fa&&(_(P),b=T),s.follow&&S(P),y()},V=()=>{h===null&&(p=performance.now(),b=0,h=requestAnimationFrame(A))},U=(T,L)=>{if(!a)return;const P=!oa(T);u=la(L,a.displayPoints,s,P),d=sa(L,s,P),c=ua(L,s,P),f=c.position??null,T.entities.add(u),T.entities.add(d),T.entities.add(c);const W=he(a,a.minTime+(l?l.state.currentTime:0));E(W),_(W)},z=(T,L)=>{const P=v(),W=D();if(!P||!W)return;Ue.loadScripts(["move-marker","bmgl-header"],n?.serverUrl,n?.libsUrl||be).catch(ee=>w.warn("[useMapTrajectory] 轨迹辅助库加载失败:",ee)),s=qe({...i,...L});let ie;try{ie=ia(T,s)}catch(ee){w.warn("[useMapTrajectory] 轨迹数据无效:",ee);return}m(),C(),a=ie,l=aa(a,s),U(P,W),y(),s.autoPlay&&M()},M=()=>{l&&(l.play(),y(),l.state.status==="playing"&&V())},I=()=>{l&&(l.pause(),m(),y())},F=()=>{if(m(),!l||!a)return;l.stop();const T=he(a,a.minTime);E(T),_(T),y()},k=T=>{l&&(l.setSpeed(T),y())},Y=T=>{if(!l||!a)return;l.jumpTo(T);const L=he(a,a.minTime+l.state.currentTime);E(L),_(L),y()},K=()=>{m(),C(),a=null,l=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}},pe=()=>{const T=v(),L=D();!T||!L||!a||!l||(C(),U(T,L))},me=()=>{m(),C()},X=()=>{m(),C(),a=null,l=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}};return o.onUnmounted(()=>{X()}),{state:r,load:z,play:M,pause:I,stop:F,setSpeed:k,jumpTo:Y,clear:K,reapply:pe,remove:me,destroy:X}}function ga(e){const t=D();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function pa(e,t=30){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(const u of e)u.lng<n&&(n=u.lng),u.lng>r&&(r=u.lng),u.lat<i&&(i=u.lat),u.lat>a&&(a=u.lat);const l=Math.max(r-n,a-i)||1,s=Math.max(t,l*4);return[{lng:Math.max(-180,n-s),lat:Math.max(-85,i-s)},{lng:Math.min(180,r+s),lat:Math.max(-85,i-s)},{lng:Math.min(180,r+s),lat:Math.min(85,a+s)},{lng:Math.max(-180,n-s),lat:Math.min(85,a+s)}]}function cn(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function Ke(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function ma(e,t,n,r,i){const a={hierarchy:{positions:Ke(e,t),holes:[{positions:Ke(e,n)}]},material:cn(e,r.fillColor,r.fillAlpha)};return i||(a.height=0),new e.Entity({polygon:a})}function wa(e,t,n,r){return new e.Entity({polyline:{positions:Ke(e,t),width:n.outlineWidth,material:new e.PolylineGlowMaterialProperty({glowPower:.4,color:cn(e,n.outlineColor,n.outlineAlpha)}),clampToGround:r}})}function xe(e){return{...vt,...e}}function un(e,t){const n=o.ref({visible:!1,hasMask:!1,boundaryCount:0});let r=xe(t),i=null,a=null,l=null,s=null;const u=()=>{const y=e.value;return y&&y.entities?y:null},d=()=>{const y=u();y&&(a&&y.entities.remove(a),l&&y.entities.remove(l)),a=null,l=null},c=(y,E)=>{if(!i)return;const _=!ga(y),S=r.outerRing??pa(i);a=ma(E,S,i,r,_),l=r.showOutline?wa(E,i,r,_):null,y.entities.add(a),l&&y.entities.add(l)},f=()=>{const y=u(),E=D();!y||!E||!i||(d(),c(y,E))},h=()=>{const y=e.value?.scene;if(s||!y?.morphComplete)return;const E=()=>f();y.morphComplete.addEventListener(E),s=()=>y.morphComplete.removeEventListener(E)},p=(y,E)=>{const _=u(),S=D();!_||!S||!y||!y.length||(r=xe({...t,...E}),i=y,d(),c(_,S),n.value={visible:!0,hasMask:!0,boundaryCount:y.length},h())},b=y=>{a&&(a.show=!!y),l&&(l.show=!!y),n.value={...n.value,visible:!!y}},v=()=>{d()},m=()=>{s&&(s(),s=null),d(),i=null,r=xe(t),n.value={visible:!1,hasMask:!1,boundaryCount:0}},C=()=>{m()};return o.onUnmounted(()=>{C()}),{state:n,setMask:p,setVisible:b,clear:m,reapply:f,remove:v,destroy:C}}function ya(e=.5){return`
18
+ </div>`}function ot(e){return typeof e=="number"&&!Number.isNaN(e)}function mo(e,t){return t&&(e.mapInstance=l.isRef(t)?t.value:t),!!e.mapInstance}async function yo(e,t,n){if(mo(e,t),!e.divLayerManager&&e.mapInstance){const r=M();if(!r)return null;e.divLayerManager=new r.div.DivLayerManager(e.mapInstance,{click:(i,o)=>{n&&n({position:o,detail:i})}})}return e.divLayerManager}function wo(e){const t=M();if(!t)throw new Error("BMGL 库未加载,无法转换弹窗坐标");return t.Cartesian3.fromDegrees(e.lng,e.lat,e.altitude||0)}function yn(e,t,n){const r=oo();r.displayConfig=n?.displayConfig||null;const i=()=>{if(r.popupLayer&&r.divLayerManager){try{r.divLayerManager.removeLayer(r.popupLayer)}catch(d){y.warn("移除弹窗时发生错误:",d)}r.popupLayer=null}r.currentPopupData=null},o=async(d,u={})=>{try{if(!d)throw new Error("点位数据不能为空");const f=++r.popupSeq,h={lng:ot(d.lng)?d.lng:se.lng,lat:ot(d.lat)?d.lat:se.lat,altitude:ot(d.altitude)?d.altitude:0};i();const p=await yo(r,e,t);if(!p)throw new Error("DivLayerManager 初始化失败");if(f!==r.popupSeq)return;r.currentPopupData={...d};const b={offsetX:0,offsetY:-20,className:"map-point-popup",...u},C=M();if(!C)throw new Error("BMGL 库未加载,无法创建弹窗");const m=new C.div.DivLayer(po(d,r.displayConfig||void 0),wo(h),{offset:{x:b.offsetX,y:b.offsetY}});r.popupLayer=m,p.addLayer(m)}catch(f){y.error("显示点位弹窗失败:",f),i()}},a=()=>{i()},s=()=>r.popupLayer!==null,c=()=>r.currentPopupData;return l.onUnmounted(()=>{try{a()}catch(u){y.warn("[useMapPopup] onUnmounted removePopup error:",u)}const d=r.divLayerManager;if(d&&typeof d.destroy=="function")try{d.destroy()}catch(u){y.warn("[useMapPopup] onUnmounted destroy manager error:",u)}r.divLayerManager=null,r.mapInstance=null,r.currentPopupData=null}),{showPointPopup:o,removePopup:a,isPopupVisible:s,getCurrentPopupData:c}}function wn(e){let t=null;const n=()=>l.isRef(e)?e.value:e,r=new Set,i=new Map,o=s=>{try{if(t=n(),!t)throw new Error("地图实例不可用");const{position:c,config:d={}}=s,u=`circleWave_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,f=new CircleWave(t,u),{color:h="#0a84ff",radius:p=100,duration:b=3e3,ttl:C=0}=d;return f.add(c,h,p,b),r.add(u),C>0&&i.set(u,setTimeout(()=>{i.delete(u),a(u)},C)),u}catch(c){throw y.error("添加波动效果失败:",c),c}},a=s=>{try{if(t||(t=n()),!t||!t.entities)return y.warn("地图实例或 entities 不可用"),r.delete(s),!1;const c=t.entities.getById(s);if(!c)return y.warn(`未找到要删除的波动实体, ID: ${s}`),r.delete(s),!1;t.entities.remove(c),r.delete(s);const d=i.get(s);return d&&(clearTimeout(d),i.delete(s)),!0}catch(c){return y.error(`删除波动效果失败, ID: ${s}:`,c),r.delete(s),!1}};return l.onUnmounted(()=>{i.forEach(s=>clearTimeout(s)),i.clear();for(const s of Array.from(r))try{a(s)}catch(c){y.warn(`[useMapCircleWave] onUnmounted removeWave error (${s}):`,c)}r.clear()}),{addWave:o,removeWave:a}}function vo(){return{layers:new Map}}function vn(e){return e.value?e.value:(y.warn("[useMapLayers] 地图未初始化"),null)}function Cn(e,t,n){const r=e.layers.get(n);if(r){try{t.value&&t.value.imageryLayers.remove(r,!1)}catch(i){y.warn(`移除同名旧图层失败 (${n}):`,i)}e.layers.delete(n)}}function Co(e,t,n){const r=vn(t);if(!r)throw new Error("地图未初始化,无法添加影像图层");const i=R();Cn(e,t,n);const o=new i.ImageryLayer(new i.BMImageryProvider({mapId:n}));return r.imageryLayers.add(o),e.layers.set(n,o),o}function bo(e,t,n,r="wmts-layer"){const i=vn(t);if(!i)throw new Error("地图未初始化,无法添加 WMTS 图层");const o=R();Cn(e,t,r);const a=new o.WebMapTileServiceImageryProvider({url:n,layer:r,style:"default",format:"image/png",tileMatrixSetID:"EPSG:3857"}),s=i.imageryLayers.add(new o.ImageryLayer(a,{maximumTerrainLevel:21}));return e.layers.set(r,s),s}function Eo(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n?{layer:n,key:t}:(y.warn(`图层未找到: ${t}`),{layer:null,key:null})}return{layer:t,key:null}}function To(e,t,n){try{const{layer:r,key:i}=Eo(e,n);if(!r)return!1;if(t.value&&t.value.imageryLayers.remove(r,!1),i!==null)e.layers.delete(i);else for(const[o,a]of e.layers.entries())if(a===r){e.layers.delete(o);break}return!0}catch(r){return y.error("移除图层失败:",r),!1}}function So(e,t){const n=t.value;if(n)try{e.layers.forEach(r=>{n.imageryLayers.remove(r,!1)}),e.layers.clear()}catch(r){y.error("移除所有图层失败:",r)}}function bn(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n||(y.warn(`图层未找到: ${t}`),null)}return t}function Do(e,t,n){try{const r=bn(e,t);return r?(r.show=n,!0):!1}catch(r){return y.error("设置图层可见性失败:",r),!1}}function Mo(e,t,n){try{if(typeof n!="number"||Number.isNaN(n)||n<0||n>1)return y.warn("透明度必须在 0-1 之间"),!1;const r=bn(e,t);return r?(r.alpha=n,!0):!1}catch(r){return y.error("设置图层透明度失败:",r),!1}}function Io(e){const t=[];return e.layers.forEach((n,r)=>{t.push({name:r,layer:n})}),t}function En(e){const t=vo();return l.onUnmounted(()=>{try{t.layers.clear()}catch(n){y.warn("[useMapLayers] onUnmounted cleanup error:",n)}}),{addImageryLayer:n=>Co(t,e,n),addWmtsLayer:(n,r)=>bo(t,e,n,r),removeLayer:n=>To(t,e,n),removeAllLayers:()=>So(t,e),setLayerVisible:(n,r)=>Do(t,n,r),setLayerOpacity:(n,r)=>Mo(t,n,r),getAllLayers:()=>Io(t)}}function Tn(){return window.BigemapElevationContourLayer??null}async function Lo(e){const t=Tn();if(t)return t;await Ve.loadScripts(["elevation-contour"],e?.serverUrl,e?.libsUrl||pe);const n=Tn();if(!n)throw new Error("彩色等高线库加载失败:未找到 BigemapElevationContourLayer");return n}function Sn(e){return{..._t,...e}}function Ao(e){const t={};for(const[r,i]of Object.entries(e))i!==void 0&&(t[r]=i);const n=M();return n&&(t.bmgl=n),t}function Dn(e,t,n){const r=l.ref(!1),i=Sn(t),o=l.ref({enabled:!1,labelsLoading:!1,labelCount:0,contourSpacing:i.contourSpacing,labelSpacing:i.contourSpacing*i.labelEvery,contourWidth:i.contourWidth,outlineWidth:i.outlineWidth});let a=null,s=null,c=!1;const d=()=>{o.value=a?a.getState():{...o.value,enabled:r.value}},u=async()=>{if(a)return a;if(s)return s;const v=e.value;return v?.scene?.globe?(s=(async()=>{try{const w=await Lo(n);if(c)return null;const E=new w(v,Ao(i));return a=E,E.setVisible(r.value),E}catch(w){return y.error("[useMapContour] 彩色等高线库加载失败:",w),null}finally{s=null}})(),s):null},f=async v=>{if(r.value=!!v,!r.value){a?.hide(),d();return}await u()||(r.value=!1),d()},h=()=>{if(r.value){if(a){a.show(),d();return}f(!0)}},p=()=>{a?.hide(),d()},b=async()=>{if(!r.value)return{status:"hidden",labelCount:0};const v=await u();if(!v)return{status:"error",labelCount:0,error:new Error("彩色等高线库未就绪")};const w=await v.loadCurrentViewLabels();return d(),w},C=()=>{if(!a)return{status:"empty",labelCount:0};const v=a.clearLabels();return d(),v},m=()=>a?.getLegendData()??null;return l.onUnmounted(()=>{c=!0;try{a?.destroy()}catch(v){y.warn("[useMapContour] 释放等高线资源失败:",v)}a=null}),{contourVisible:r,contourState:o,setContourVisible:f,loadLabels:b,clearLabels:C,getLegendData:m,reapply:h,remove:p}}const xo=2e4;function No(e,t={}){if(!Array.isArray(e)||e.length<2)throw new Error("轨迹至少需要2个点");const n=t.interval&&t.interval>0?t.interval:1;e.some(h=>typeof h.time=="number"&&Number.isFinite(h.time));const r=e.map((h,p)=>({...h,time:typeof h.time=="number"&&Number.isFinite(h.time)?h.time:p*n}));r.sort((h,p)=>h.time-p.time);const i=[];let o=-1/0;for(const h of r)h.time>o&&(i.push(h),o=h.time);if(i.length<2)throw new Error("轨迹时间戳无效,无法构成回放时间表");const a=i.map(h=>h.time),s=a[0],c=a[a.length-1]-s,d=t.duration&&t.duration>0?t.duration:c,u=t.maxPoints&&t.maxPoints>=2?Math.floor(t.maxPoints):xo;let f=i;if(i.length>u){const h=Math.ceil(i.length/u);f=i.filter((b,C)=>C%h===0);const p=i[i.length-1];f[f.length-1]!==p&&f.push(p)}return{points:i,times:a,displayPoints:f,duration:d,minTime:s}}function Ee(e,t){const{points:n,times:r,duration:i,minTime:o}=e,a=n.length;if(t<=r[0]){const m=n[0];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:0,progress:0}}if(t>=r[a-1]){const m=n[a-1];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:a-1,progress:1}}let s=0,c=a-1;for(;s<c;){const m=s+c+1>>1;r[m]<=t?s=m:c=m-1}const d=s,u=r[d+1]-r[d],f=u>0?(t-r[d])/u:0,h=n[d],p=n[d+1],b=h.altitude??0,C=p.altitude??0;return{lng:h.lng+(p.lng-h.lng)*f,lat:h.lat+(p.lat-h.lat)*f,altitude:b+(C-b)*f,index:d,progress:i>0?(t-o)/i:0}}function _o(e,t={}){const n=e.duration,r=!!t.loop;let i=0,o=Math.max(0,t.speed??1),a=t.autoPlay?"playing":"idle";const s={status:a,currentTime:0,duration:n,progress:0,pointCount:e.points.length},c=m=>Math.max(0,Math.min(n,m)),d=()=>{s.status=a,s.currentTime=c(i),s.duration=n,s.progress=n>0?s.currentTime/n:0,s.pointCount=e.points.length},u=()=>{n<=0||(a==="ended"&&(i=0),a="playing",d())},f=()=>{a==="playing"&&(a="paused"),d()},h=()=>{i=0,a="idle",d()},p=m=>{o=Math.max(0,m),d()},b=m=>{i=c(m),a==="ended"&&(a="paused"),d()},C=m=>{a!=="playing"||n<=0||(i+=m*o,i>=n&&(r?i=i%n:(i=n,a="ended")),d())};return d(),{state:s,play:u,pause:f,stop:h,setSpeed:p,jumpTo:b,tick:C}}function ko(e){const t=M();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function at(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function Po(e,t,n,r){const i=t.map(o=>e.Cartesian3.fromDegrees(o.lng,o.lat,o.altitude??0));return new e.Entity({polyline:{positions:i,width:n.lineWidth,material:at(e,n.lineColor,.9),clampToGround:r}})}function Vo(e,t,n){return new e.Entity({polyline:{positions:[],width:t.lineWidth,material:at(e,t.markerColor,.9),clampToGround:n}})}function Ro(e,t){if(!e?.billboard||!t.markerIcon||typeof Image>"u")return;const n=t.markerSize*2,r=new Image;r.onload=()=>{!e.billboard||!r.naturalWidth||!r.naturalHeight||(e.billboard.width=n,e.billboard.height=r.naturalHeight/r.naturalWidth*n)},r.src=t.markerIcon}function Bo(e,t,n=!0){const r=new e.ConstantPositionProperty(e.Cartesian3.fromDegrees(0,0,0)),i=new e.Entity({position:r}),o=n?e.HeightReference.CLAMP_TO_GROUND:e.HeightReference.NONE;return t.markerIcon?i.billboard={image:t.markerIcon,width:t.markerSize*2,heightReference:o,verticalOrigin:e.VerticalOrigin.BOTTOM}:i.point={pixelSize:t.markerSize,color:at(e,t.markerColor,1),heightReference:o},Ro(i,t),i}function Fo(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function lt(e){return{...kt,...e}}const Oo=100,zo=.25;function Mn(e,t,n){const r=l.ref({status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}),i=lt(t);let o=null,a=null,s=i,c=null,d=null,u=null,f=null,h=null,p=0,b=0;const C=()=>{const D=e.value;return D&&D.entities?D:null},m=()=>{h!==null&&(cancelAnimationFrame(h),h=null)},v=()=>{const D=C();D&&(c&&D.entities.remove(c),d&&D.entities.remove(d),u&&D.entities.remove(u)),c=null,d=null,u=null,f=null},w=()=>{a&&(r.value={...a.state})},E=D=>{if(!f)return;const P=M();P&&f.setValue(P.Cartesian3.fromDegrees(D.lng,D.lat,D.altitude))},V=D=>{if(!d||!o||!a)return;const P=M();if(!P)return;const O=a.state.currentTime,j=s.trailTime>0?Math.max(0,O-s.trailTime):0,oe=Ee(o,o.minTime+j),ae=o.points.slice(oe.index,D.index+1),He=Fo(P,ae);He.push(P.Cartesian3.fromDegrees(D.lng,D.lat,D.altitude)),d.polyline&&(d.polyline.positions=He)},S=D=>{const P=e.value;if(!P?.camera)return;const O=M();O&&P.camera.setView({destination:O.Cartesian3.fromDegrees(D.lng,D.lat,s.followHeight),orientation:{heading:0,pitch:O.Math.toRadians(-90),roll:0}})},N=D=>{if(!a||!o||a.state.status!=="playing"){m();return}h=requestAnimationFrame(N);const P=Math.min(Math.max((D-p)/1e3,0),zo);p=D,a.tick(P);const O=Ee(o,o.minTime+a.state.currentTime);E(O),D-b>=Oo&&(V(O),b=D),s.follow&&S(O),w()},T=()=>{h===null&&(p=performance.now(),b=0,h=requestAnimationFrame(N))},I=(D,P)=>{if(!o)return;const O=!ko(D);c=Po(P,o.displayPoints,s,O),d=Vo(P,s,O),u=Bo(P,s,O),f=u.position??null,D.entities.add(c),D.entities.add(d),D.entities.add(u);const j=Ee(o,o.minTime+(a?a.state.currentTime:0));E(j),V(j)},k=(D,P)=>{const O=C(),j=M();if(!O||!j)return;Ve.loadScripts(["move-marker","bmgl-header"],n?.serverUrl,n?.libsUrl||pe).catch(ae=>y.warn("[useMapTrajectory] 轨迹辅助库加载失败:",ae)),s=lt({...i,...P});let oe;try{oe=No(D,s)}catch(ae){y.warn("[useMapTrajectory] 轨迹数据无效:",ae);return}m(),v(),o=oe,a=_o(o,s),I(O,j),w(),s.autoPlay&&L()},L=()=>{a&&(a.play(),w(),a.state.status==="playing"&&T())},A=()=>{a&&(a.pause(),m(),w())},B=()=>{if(m(),!a||!o)return;a.stop();const D=Ee(o,o.minTime);E(D),V(D),w()},x=D=>{a&&(a.setSpeed(D),w())},Z=D=>{if(!a||!o)return;a.jumpTo(D);const P=Ee(o,o.minTime+a.state.currentTime);E(P),V(P),w()},ee=()=>{m(),v(),o=null,a=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}},Me=()=>{const D=C(),P=M();!D||!P||!o||!a||(v(),I(D,P))},Ie=()=>{m(),v()},te=()=>{m(),v(),o=null,a=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}};return l.onUnmounted(()=>{te()}),{state:r,load:k,play:L,pause:A,stop:B,setSpeed:x,jumpTo:Z,clear:ee,reapply:Me,remove:Ie,destroy:te}}function Uo(e){const t=M();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function $o(e,t=30){let n=1/0,r=-1/0,i=1/0,o=-1/0;for(const c of e)c.lng<n&&(n=c.lng),c.lng>r&&(r=c.lng),c.lat<i&&(i=c.lat),c.lat>o&&(o=c.lat);const a=Math.max(r-n,o-i)||1,s=Math.max(t,a*4);return[{lng:Math.max(-180,n-s),lat:Math.max(-85,i-s)},{lng:Math.min(180,r+s),lat:Math.max(-85,i-s)},{lng:Math.min(180,r+s),lat:Math.min(85,o+s)},{lng:Math.max(-180,n-s),lat:Math.min(85,o+s)}]}function In(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function st(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function Go(e,t,n,r,i){const o={hierarchy:{positions:st(e,t),holes:[{positions:st(e,n)}]},material:In(e,r.fillColor,r.fillAlpha)};return i||(o.height=0),new e.Entity({polygon:o})}function Wo(e,t,n,r){return new e.Entity({polyline:{positions:st(e,t),width:n.outlineWidth,material:new e.PolylineGlowMaterialProperty({glowPower:.4,color:In(e,n.outlineColor,n.outlineAlpha)}),clampToGround:r}})}function ze(e){return{...Pt,...e}}function Ln(e,t){const n=l.ref({visible:!1,hasMask:!1,boundaryCount:0});let r=ze(t),i=null,o=null,a=null,s=null;const c=()=>{const w=e.value;return w&&w.entities?w:null},d=()=>{const w=c();w&&(o&&w.entities.remove(o),a&&w.entities.remove(a)),o=null,a=null},u=(w,E)=>{if(!i)return;const V=!Uo(w),S=r.outerRing??$o(i);o=Go(E,S,i,r,V),a=r.showOutline?Wo(E,i,r,V):null,w.entities.add(o),a&&w.entities.add(a)},f=()=>{const w=c(),E=M();!w||!E||!i||(d(),u(w,E))},h=()=>{const w=e.value?.scene;if(s||!w?.morphComplete)return;const E=()=>f();w.morphComplete.addEventListener(E),s=()=>w.morphComplete.removeEventListener(E)},p=(w,E)=>{const V=c(),S=M();!V||!S||!w||!w.length||(r=ze({...t,...E}),i=w,d(),u(V,S),n.value={visible:!0,hasMask:!0,boundaryCount:w.length},h())},b=w=>{o&&(o.show=!!w),a&&(a.show=!!w),n.value={...n.value,visible:!!w}},C=()=>{d()},m=()=>{s&&(s(),s=null),d(),i=null,r=ze(t),n.value={visible:!1,hasMask:!1,boundaryCount:0}},v=()=>{m()};return l.onUnmounted(()=>{v()}),{state:n,setMask:p,setVisible:b,clear:m,reapply:f,remove:C,destroy:v}}var z=(e=>(e.INVALID_URL="INVALID_URL",e.INVALID_TEXT="INVALID_TEXT",e.PARSE_FAILED="PARSE_FAILED",e.NO_FEATURES="NO_FEATURES",e.NETWORK_FAILED="NETWORK_FAILED",e.HTTP_ERROR="HTTP_ERROR",e.TIMEOUT="TIMEOUT",e.MAP_NOT_READY="MAP_NOT_READY",e.LOAD_FAILED="LOAD_FAILED",e))(z||{});class F extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="KmlError"}}function Ho(e){return e instanceof F||!!e&&typeof e=="object"&&e.name==="KmlError"&&typeof e.code=="string"}function Ko(e){if(Ho(e))return e;const t=e instanceof Error?e.message:String(e??"未知错误");return new F(`KML 加载失败:${t}`,"LOAD_FAILED",e)}function An(e,t){const n=[];for(let r=0;r<e.children.length;r++){const i=e.children[r];i.localName===t&&n.push(i)}return n}function $(e,t){for(let n=0;n<e.children.length;n++){const r=e.children[n];if(r.localName===t)return r}return null}function W(e,t){return $(e,t)?.textContent?.trim()??""}function Q(e){return e?.textContent?.trim()??""}function xn(e){if(e==null)return null;const t=String(e).trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function Te(e,t){const n=e.getElementsByTagName("*"),r=[];for(let i=0;i<n.length;i++){const o=n[i];o.localName===t&&r.push(o)}return r}function ct(e){const t=(e??"").trim().replace(/^#/,"");if(!/^[0-9a-fA-F]+$/.test(t))return null;if(t.length===8){const n=parseInt(t.slice(0,2),16)/255,r=t.slice(2,4),i=t.slice(4,6);return{css:`#${t.slice(6,8)}${i}${r}`.toLowerCase(),alpha:n}}return t.length===6?{css:`#${t}`.toLowerCase(),alpha:1}:null}function Nn(e){const t={},n=$(e,"LineStyle");if(n){const o=ct(W(n,"color"));o&&(t.lineColor=o.css,t.lineAlpha=o.alpha);const a=xn(W(n,"width"));a!==null&&(t.lineWidth=a)}const r=$(e,"PolyStyle");if(r){const o=ct(W(r,"color"));o&&(t.fillColor=o.css,t.fillAlpha=o.alpha);const a=Q($(r,"fill"));a==="0"?t.fill=!1:a==="1"&&(t.fill=!0);const s=Q($(r,"outline"));s==="0"?t.outline=!1:s==="1"&&(t.outline=!0)}const i=$(e,"IconStyle");if(i){const o=ct(W(i,"color"));o&&(t.iconColor=o.css);const a=xn(W(i,"scale"));a!==null&&(t.iconScale=a);const s=$(i,"Icon"),c=s?W(s,"href"):"";c&&(t.iconHref=c)}return t}function jo(e){const t=Te(e,"Pair");for(const n of t){const r=W(n,"key");if(r&&r!=="normal")continue;const i=W(n,"styleUrl");if(i)return _n(i)}return""}function _n(e){const t=e.indexOf("#");return t>=0?e.slice(t+1):e.trim()}function Yo(e){const t={styles:new Map,styleMaps:new Map};for(const n of Te(e,"Style")){const r=n.getAttribute("id");r&&t.styles.set(r,Nn(n))}for(const n of Te(e,"StyleMap")){const r=n.getAttribute("id");if(!r)continue;const i=jo(n);i&&t.styleMaps.set(r,i)}return t}function kn(e,t,n=0){if(!t||n>5)return null;const r=e.styles.get(t);if(r)return r;const i=e.styleMaps.get(t);return i?kn(e,i,n+1):null}function qo(e,t,n){return{...(e?kn(n,_n(e)):null)??{},...t??{}}}function Ue(e){const t=[];let n=0;const r=e.trim().split(/\s+/).filter(Boolean);for(const i of r){const o=i.split(","),a=Number(o[0]),s=Number(o[1]);if(!Number.isFinite(a)||!Number.isFinite(s)){n+=1;continue}const c=o.length>2?Number(o[2]):NaN;t.push(Number.isFinite(c)?{lng:a,lat:s,altitude:c}:{lng:a,lat:s})}return{coordinates:t,invalidCount:n}}function Xo(e){const t=$(e,"outerBoundaryIs"),n=t?$(t,"LinearRing"):null,r=n?Ue(Q($(n,"coordinates"))).coordinates:[];if(r.length<3)return null;const i=[];for(const o of An(e,"innerBoundaryIs")){const a=$(o,"LinearRing"),s=a?Ue(Q($(a,"coordinates"))).coordinates:[];s.length>=3&&i.push(s)}return{type:"Polygon",outer:r,holes:i}}function Pn(e,t){switch(e.localName){case"Point":{const n=Ue(Q($(e,"coordinates"))).coordinates[0];n&&t.push({type:"Point",coordinates:n});break}case"LineString":{const n=Ue(Q($(e,"coordinates"))).coordinates;n.length>=2&&t.push({type:"LineString",coordinates:n});break}case"Polygon":{const n=Xo(e);n&&t.push(n);break}case"MultiGeometry":{for(let n=0;n<e.children.length;n++)Pn(e.children[n],t);break}}}function Zo(e){const t=$(e,"ExtendedData");if(!t)return{};const n={};for(const r of Te(t,"SimpleData")){const i=r.getAttribute("name");i&&(n[i]=Q(r))}for(const r of An(t,"Data")){const i=r.getAttribute("name");i&&(n[i]=W(r,"value"))}return n}function Jo(e,t,n,r){const i=[];for(let s=0;s<e.children.length;s++)Pn(e.children[s],i);if(!i.length)return null;const o=e.getAttribute("id")||`kml-feature-${t+1}`,a=$(e,"Style");return{id:o,name:W(e,"name")||o,description:W(e,"description"),visible:W(e,"visibility")!=="0",properties:r?Zo(e):{},style:qo(W(e,"styleUrl"),a?Nn(a):null,n),geometries:i}}function Qo(e){const t=[],n=r=>{for(let i=0;i<r.children.length;i++){const o=r.children[i],a=o.localName;a==="Placemark"?t.push(o):(a==="Document"||a==="Folder")&&n(o)}};return n(e),t}function ea(e){for(const t of Te(e,"Document")){const n=W(t,"name");if(n)return n}return""}function ta(e){const t=e.replace(/\s+/g," ").trim();return t?`(${t.slice(0,200)})`:""}function Vn(e,t={}){if(typeof e!="string"||!e.trim())throw new F("KML 文本无效:内容不能为空",z.INVALID_TEXT);if(typeof DOMParser>"u")throw new F("KML 解析失败:当前环境不支持 XML 解析(DOMParser 不可用)",z.PARSE_FAILED);let n;try{n=new DOMParser().parseFromString(e,"text/xml")}catch(c){throw new F(`KML 解析失败:${c instanceof Error?c.message:String(c)}`,z.PARSE_FAILED,c)}const r=n.getElementsByTagName("parsererror")[0];if(r||n.documentElement?.localName==="parsererror")throw new F(`KML 解析失败:XML 格式错误${ta(Q(r??null))}`,z.PARSE_FAILED);const i=n.documentElement;if(!i||i.localName!=="kml")throw new F("KML 解析失败:根节点不是 <kml>,请确认传入的是 KML 格式数据",z.PARSE_FAILED);const o=Yo(i),a=t.extractProperties!==!1,s=Qo(i).map((c,d)=>Jo(c,d,o,a)).filter(c=>c!==null);if(!s.length)throw new F("KML 中未解析到任何可渲染的几何要素(支持 Point/LineString/Polygon/MultiGeometry)",z.NO_FEATURES);return{name:ea(i),features:s}}const na=["http:","https:","blob:","data:"];function ra(e){if(typeof e!="string"||!e.trim())throw new F("KML 地址无效:地址不能为空,请传入 KML 文件的 URL",z.INVALID_URL,e);const t=e.trim();let n;try{n=new URL(t,"http://localhost")}catch(r){throw new F(`KML 地址无效:无法解析地址 "${t}"`,z.INVALID_URL,r)}if(!na.includes(n.protocol))throw new F(`KML 地址无效:不支持的协议 "${n.protocol}",仅支持 http/https`,z.INVALID_URL,t);return t}async function ia(e,t=15e3){const n=ra(e),r=globalThis.fetch;if(typeof r!="function")throw new F("KML 请求失败:当前环境不支持 fetch,无法通过 URL 加载",z.NETWORK_FAILED);const i=new AbortController;let o=!1;const a=setTimeout(()=>{o=!0,i.abort()},t>0?t:15e3);let s;try{s=await r(n,{signal:i.signal})}catch(c){throw o?new F(`KML 请求超时:${t}ms 内未完成加载(${n})`,z.TIMEOUT,c):new F(`KML 请求失败:无法访问 ${n}(${c instanceof Error?c.message:String(c)})`,z.NETWORK_FAILED,c)}finally{clearTimeout(a)}if(!s.ok)throw new F(`KML 请求失败:服务器返回 HTTP ${s.status}${s.statusText?` ${s.statusText}`:""}(${n})`,z.HTTP_ERROR,s.status);try{return await s.text()}catch(c){throw new F(`KML 请求失败:读取响应内容失败(${n})`,z.NETWORK_FAILED,c)}}function oa(e){const t=M();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function de(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function fe(e,t,n){return e.Color.fromCssColorString(t).withAlpha(n)}function aa(e,t,n){const r=t.useKmlStyle;return{fillColor:n??(r?e.fillColor:void 0)??t.fillColor,fillAlpha:(r?e.fillAlpha:void 0)??t.fillAlpha,lineColor:n??(r?e.lineColor:void 0)??t.strokeColor,lineAlpha:(r?e.lineAlpha:void 0)??t.strokeAlpha,lineWidth:(r?e.lineWidth:void 0)??t.strokeWidth,pointColor:n??(r?e.iconColor:void 0)??t.pointColor,pointPixelSize:t.pointPixelSize,fill:t.showFill&&(r?e.fill!==!1:!0),outline:t.showOutline&&(r?e.outline!==!1:!0)}}function la(e,t){const n=e.fillPalette;if(!(!n||!n.length))return n[(t%n.length+n.length)%n.length]}function sa(e){if(!e.length)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0;for(const o of e)o.lng<t&&(t=o.lng),o.lng>n&&(n=o.lng),o.lat<r&&(r=o.lat),o.lat>i&&(i=o.lat);return{area:(n-t)*(i-r),center:{lng:(t+n)/2,lat:(r+i)/2}}}function ca(e){let t=null,n=null,r=null;for(const i of e.geometries)if(i.type==="Polygon"){const o=sa(i.outer);o&&(!t||o.area>t.area)&&(t=o)}else i.type==="LineString"?(!n||i.coordinates.length>n.length)&&(n=i.coordinates):r||(r=i.coordinates);return t?t.center:n&&n.length?n[Math.floor(n.length/2)]:r}function ua(e,t,n){const r=ca(t);return r?new e.Entity({name:t.name,position:de(e,[r])[0],label:{text:t.name,font:`${n.labelFontSize}px sans-serif`,fillColor:fe(e,n.labelColor,1),outlineColor:fe(e,n.labelOutlineColor,1),outlineWidth:2,style:e.LabelStyle?e.LabelStyle.FILL_AND_OUTLINE:void 0,verticalOrigin:e.VerticalOrigin?e.VerticalOrigin.CENTER:void 0,heightReference:e.HeightReference?e.HeightReference.CLAMP_TO_GROUND:void 0,disableDepthTestDistance:Number.POSITIVE_INFINITY}}):null}function da(e,t,n,r,i){const o=[];return n.fill&&o.push(new e.Entity({name:r.name,polygon:{hierarchy:{positions:de(e,t.outer),holes:t.holes.map(a=>({positions:de(e,a)}))},material:fe(e,n.fillColor,n.fillAlpha)}})),n.outline&&o.push(new e.Entity({name:r.name,polyline:{positions:de(e,t.outer),width:n.lineWidth,material:fe(e,n.lineColor,n.lineAlpha),clampToGround:i}})),o}function fa(e,t,n,r,i){return new e.Entity({name:r.name,polyline:{positions:de(e,t.coordinates),width:n.lineWidth,material:fe(e,n.lineColor,n.lineAlpha),clampToGround:i}})}function ha(e,t,n,r){return new e.Entity({name:r.name,position:de(e,[t.coordinates])[0],point:{pixelSize:n.pointPixelSize,color:fe(e,n.pointColor,1),heightReference:e.HeightReference?e.HeightReference.CLAMP_TO_GROUND:void 0}})}function ga(e,t,n,r,i=0){const o=aa(t.style,n,la(n,i)),a=[];for(const s of t.geometries)a.push(...pa(e,s,o,t,r));if(n.showLabel&&t.name){const s=ua(e,t,n);s&&a.push(s)}return a}function pa(e,t,n,r,i){switch(t.type){case"Polygon":return da(e,t,n,r,i);case"LineString":return[fa(e,t,n,r,i)];case"Point":return[ha(e,t,n,r)];default:return[]}}function $e(e){return{...Vt,...e}}function Se(){return{status:"idle",source:null,url:"",featureCount:0,polygonCount:0,lineCount:0,pointCount:0,visible:!1,error:null}}function ma(e){let t=0,n=0,r=0;for(const i of e)for(const o of i.geometries)o.type==="Polygon"?t+=1:o.type==="LineString"?n+=1:r+=1;return{polygonCount:t,lineCount:n,pointCount:r}}function Rn(e,t){const n=$e(t),r=l.ref(Se());let i=n,o=[],a=[],s=!0,c=null;const d=()=>{const T=e.value;return T&&T.entities?T:null},u=()=>{const T=d();if(T)for(const I of a)T.entities.remove(I.entity);a=[]},f=(T,I)=>{const k=!oa(T),L=[];o.forEach((A,B)=>{for(const x of ga(I,A,i,k,B))x.show=s&&A.visible,T.entities.add(x),L.push({entity:x,featureVisible:A.visible})}),a=L},h=()=>{const T=e.value?.scene;if(c||!T?.morphComplete)return;const I=()=>V();T.morphComplete.addEventListener(I),c=()=>T.morphComplete.removeEventListener(I)},p=()=>{const T=d();if(!T||!a.length)return;const I=a.map(k=>k.entity);try{T.flyTo?.(I.length===1?I[0]:I)}catch(k){y.warn("[useMapKml] 视角定位失败:",k)}},b=async(T,I,k)=>{const L=d(),A=M();if(!L||!A){const B=new F("地图尚未就绪:请在地图初始化完成后再加载 KML",z.MAP_NOT_READY);throw r.value={...Se(),status:"error",source:T,url:I,error:B.message},B}r.value={...Se(),status:"loading",source:T,url:I};try{o=await k(),s=!0,u(),f(L,A),h();const x=ma(o);return r.value={status:"success",source:T,url:I,featureCount:o.length,...x,visible:!0,error:null},i.autoFlyTo&&p(),{source:T,url:I,featureCount:o.length,...x,features:o}}catch(B){const x=Ko(B);throw u(),o=[],r.value={...Se(),status:"error",source:T,url:I,error:x.message},y.warn("[useMapKml] 加载失败:",x.message),x}},C=(T,I)=>{i=$e({...n,...I});const k=typeof T=="string"?T.trim():"";return b("url",k,async()=>Vn(await ia(T,i.timeout),{extractProperties:i.extractProperties}).features)},m=(T,I)=>(i=$e({...n,...I}),b("text","",async()=>Vn(T,{extractProperties:i.extractProperties}).features)),v=()=>o,w=T=>{s=!!T;for(const I of a)I.entity.show=s&&I.featureVisible;r.value={...r.value,visible:s}},E=()=>{u()},V=()=>{const T=d(),I=M();!T||!I||!o.length||(u(),f(T,I),s&&(r.value={...r.value,visible:!0}))},S=()=>{c&&(c(),c=null),u(),o=[],s=!0,i=n,r.value=Se()},N=()=>{S()};return l.onUnmounted(()=>{N()}),{state:r,loadFromUrl:C,loadFromText:m,getFeatures:v,setVisible:w,flyTo:p,remove:E,clear:S,reapply:V,destroy:N}}function ya(e=.5){return`
19
19
  uniform sampler2D colorTexture;
20
20
  varying vec2 v_textureCoordinates;
21
21
 
@@ -42,7 +42,7 @@ void main(void){
42
42
 
43
43
  gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(c,1), ${e});
44
44
  }
45
- `}function va(e=.3){return`
45
+ `}function wa(e=.3){return`
46
46
  uniform sampler2D colorTexture;
47
47
  varying vec2 v_textureCoordinates;
48
48
 
@@ -73,7 +73,7 @@ void main(void){
73
73
 
74
74
  gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(finalColor,1), ${e});
75
75
  }
76
- `}const dn={rain:.5,snow:.3};function fn(e,t){const n=o.ref({type:"clear",active:!1});let r=null;const i=()=>{const u=e.value;r&&u?.scene?.postProcessStages&&(u.scene.postProcessStages.remove(r),r=null)},a=(u,d)=>{const c=e.value,f=D();if(!c?.scene?.postProcessStages||!f)return;if(i(),u==="clear"||!dn[u]){n.value={type:"clear",active:!1};return}const h=d?.opacity??t?.opacity??dn[u],p=u==="rain"?ya(h):va(h);r=new f.PostProcessStage({name:`weather_${u}`,fragmentShader:p}),c.scene.postProcessStages.add(r),n.value={type:u,active:!0}},l=()=>{i(),r=null,n.value={type:"clear",active:!1}},s=()=>{l()};return o.onUnmounted(()=>{s()}),{state:n,setWeather:a,clear:l,destroy:s}}const Ca=6,ba=18,Ea=20;function Ta(e){return{day:e?.dayStartHour??Ca,dusk:e?.duskStartHour??ba,night:e?.nightStartHour??Ea}}function Sa(e,t){const{day:n,dusk:r,night:i}=Ta(t);return e>=n&&e<r?"day":e>=r&&e<i?"dusk":"night"}const Xe={x:.5781,y:-.5781,z:.5758};function Da(e,t){if(e==="day")return new t.SunLight;const n=e==="night";return new t.DirectionalLight({direction:new t.Cartesian3(Xe.x,Xe.y,Xe.z),color:n?new t.Color(.9,.925,1):t.Color.fromCssColorString("#deca7c"),intensity:n?.5:1})}function hn(e,t,n){const r=n?.is3D??o.ref(!0),i=o.ref(null),a=o.ref({enabled:!!t?.enabled,mode:"auto",period:"night",hour:0});let l,s,u;const d=()=>{const m=t?.now?.()??new Date;a.value.hour=m.getHours(),a.value.mode=i.value?"manual":"auto",a.value.period=i.value??Sa(a.value.hour,t)},c=()=>{const m=e.value;if(!m?.scene){u=void 0;return}const C=m.scene;(u!==void 0||l!==void 0)&&(C.light=l,s!==void 0&&(C.globe.enableLighting=s)),u=void 0},f=()=>{const m=e.value,C=D();if(!m?.scene||!C)return;const y=m.scene;s===void 0&&(l=y.light,s=!!y.globe.enableLighting),y.globe.enableLighting=!0;const E=Da(a.value.period,C);y.light=E,u=E},h=()=>{d(),a.value.enabled&&r.value?f():c()},p=m=>{a.value.enabled=!!m,h()},b=m=>{i.value=m==="auto"?null:m,h()},v=()=>{a.value.enabled=!1,c()};return o.onUnmounted(()=>v()),d(),{state:a,setEnabled:p,setPeriod:b,apply:h,destroy:v}}function gn(e,t){const n=e.layer||"PostGIS:dommap";return`${e.baseUrl.replace(/\/$/,"")}?layer=${n}&geo-token=${t}&style=&tilematrixset=EPSG%3A3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fvnd.jpeg-png&TileMatrix=EPSG%3A3857%3A{TileMatrix}&TileCol={TileCol}&TileRow={TileRow}`}function pn(e){return async()=>{const t=e.token;if(!t)throw new Error("未提供 GeoServer 令牌(geoserver.token),无法拼接 WMTS 地址");return gn(e,t)}}function Ma(){return{mapType:o.ref("3d"),mapBase:o.ref("bigemap"),currentDrawType:o.ref(null),loadingTitle:o.ref("地图加载中"),loadingSubtitle:o.ref("正在初始化地理数据..."),theme:o.ref("dark"),mapNameVisible:o.ref(!1)}}function Le(e){return typeof e=="number"&&!Number.isNaN(e)}function Ia(e){const t=o.ref(""),n=o.ref([]),r=o.ref(!1),i=o.ref(!1),a=o.ref(!1),l=o.ref(-1),s=o.ref(-1);let u,d,c=0;const f=o.computed(()=>t.value.trim()?n.value:[]),h=async S=>{const A=++c;try{const V=await e.searchByText({field:["name"],keyword:S,limit:10,caseSensitive:!1});if(A!==c)return;n.value=V||[],a.value=!1}catch(V){if(A!==c)return;w.error("搜索查询失败:",V),n.value=[],a.value=!0}finally{A===c&&(i.value=!1)}},p=S=>{if(t.value=S,u&&clearTimeout(u),!S.trim()){n.value=[],r.value=!1,a.value=!1;return}i.value=!0,r.value=!0,u=setTimeout(()=>{h(S.trim())},e.debounceTime)},b=S=>Le(S.altitude)?S.altitude+tr:e.position?.height??te.height,v=S=>{if(!Le(S.lng)||!Le(S.lat))return;e.setView(S.lng,S.lat,b(S));const A=e.addWave({position:[S.lng,S.lat,Le(S.altitude)?S.altitude:0],config:{color:"#0a84ff",radius:er,duration:Te.WAVE}});d&&clearTimeout(d),d=setTimeout(()=>e.removeWave(A),Et)},m=(S,A)=>{s.value=A,v(S),r.value=!1},C=S=>{const A=f.value.length;A!==0&&(l.value=(l.value+S+A)%A)},y=()=>{const S=l.value,A=f.value[S];A&&m(A,S)},E=()=>{r.value=!1},_=()=>{t.value="",n.value=[],r.value=!1,a.value=!1,s.value=-1,l.value=-1};return o.onUnmounted(()=>{u&&clearTimeout(u),d&&clearTimeout(d)}),{searchInput:t,searchList:n,showResults:r,isSearching:i,searchError:a,highlightIndex:l,selectedIndex:s,filteredList:f,handleInputSearch:p,handleResultClick:m,moveHighlight:C,selectHighlighted:y,closeResults:E,clearSearch:_}}function Aa(e){e.toggleMapTypeCore();const n=(e.mapType.value==="3d"?"2d":"3d")==="3d"?Qn:Jn;setTimeout(()=>e.redrawAllEntities(),n)}function xa(e){e.position&&e.setView(e.position.lng,e.position.lat,e.position.height)}async function Ze(e){e.loadingSubtitle.value="正在添加卫星影像图层...",await e.addImageryLayer("bigemap.dc-satellite"),e.loadingSubtitle.value="正在添加街道地名图层...",await e.addImageryLayer("bigemap.dc-street")}async function mn(e){if(!e.wmtsUrlProvider)throw new Error("未配置 wmtsUrlProvider,无法切换到生产底图");const t=await e.wmtsUrlProvider();if(!t)throw new Error("wmtsUrlProvider 未返回有效地址,无法切换到生产底图");await e.addWmtsLayer(t,"geoserver")}async function La(e){if(!e.map.value)return;const t=e.mapBase.value,n=t==="bigemap"?"geoserver":"bigemap";e.loadingSubtitle.value="正在切换地图底图...";try{await e.removeAllLayers(),n==="bigemap"?await Ze(e):await mn(e),e.mapBase.value=n}catch(r){w.error("切换地图底图失败:",r);try{await e.removeAllLayers(),t==="bigemap"?await Ze(e):await mn(e)}catch(i){w.error("恢复原底图失败:",i)}}finally{e.loadingSubtitle.value="正在初始化地理数据..."}}async function Na(e){if(e.map.value)try{await Ze(e)}catch(t){w.error("加载默认图层失败:",t)}}function ka(e){return t=>{if(e.getIsDrawing()||!e.map.value||!t.position)return;e.removePopup();const n=e.map.value.scene.pick(t.position);if(n&&n.primitive&&n.primitive.pointData){const r=n.primitive.pointData;e.onPointClick(r),e.showPointPopup(wn(r),{offsetX:0,offsetY:-25})}}}function _a(e,t){const n=document.querySelector(".map-point-popup");if(!n)return!1;const r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.left+e.x,l=r.top+e.y;return a>=i.left-8&&a<=i.right+8&&l>=i.top-8&&l<=i.bottom+8}function Va(e){let t=null;const n=r=>r?.id??r?.pointNo??r?.name??"";return r=>{if(e.getIsDrawing()||!e.map.value||!r.endPosition)return;const i=e.map.value.scene.canvas,a=e.map.value.scene.pick(r.endPosition);if(a&&a.primitive&&a.primitive.pointData){const l=a.primitive.pointData,s=n(l);s!==t&&(t=s,e.showPointPopup(wn(l),{offsetX:0,offsetY:-25}))}else _a(r.endPosition,i)||(t=null,e.removePopup())}}function wn(e){return{...e}}function Pa(e){if(!e.map.value)return null;const t=N(),n=new t.ScreenSpaceEventHandler(e.map.value.scene.canvas);return n.setInputAction(ka(e),t.ScreenSpaceEventType.LEFT_CLICK),n.setInputAction(Va(e),t.ScreenSpaceEventType.MOUSE_MOVE),n}function yn(e){if(e&&typeof e.destroy=="function")try{e.destroy()}catch(t){w.warn("[useMapView] destroy click listener error:",t)}}const vn=["containerId","position","serverUrl","accessToken","libsUrl","showSearch","showControls","showDeleteControls","showStatus","tools","searchDebounceTime","wmtsUrlProvider","geoserver","contourConfig","lightingConfig"],Ba={containerId:String,position:Object,serverUrl:String,accessToken:String,libsUrl:String,showSearch:Boolean,showControls:Boolean,showDeleteControls:Boolean,showStatus:Boolean,tools:Array,searchDebounceTime:Number,wmtsUrlProvider:Function,geoserver:Object,contourConfig:Object,lightingConfig:Boolean};function Ra(e,t){const n=e??{},r={};for(const i of vn)r[i]=n[i];return{...r,theme:t.theme,popupConfig:t.popupConfig}}function Cn(e,t){const n=Ma(),r=o.computed(()=>!!e.showSearch),i=o.computed(()=>e.showControls!==!1),a=o.computed(()=>e.showDeleteControls!==!1),l=o.computed(()=>!!e.showStatus),s=e.wmtsUrlProvider??(e.geoserver?pn(e.geoserver):void 0),u=o.computed(()=>!!s),d=o.computed(()=>({containerId:e.containerId,position:e.position||te,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl})),{map:c,state:f,initMap:h,setView:p,toggleMapType:b}=Pt(d.value),{loadPoints:v,searchByText:m,updatePoints:C,clearPoints:y,searchByShape:E}=Ut(c),{drawEntity:_,deleteEntity:S,redrawAllEntities:A}=Yt(c),{startDrawing:V,cancelDrawing:U,clearAllDrawings:z,removeDrawing:M,setCallback:I,getIsDrawing:F}=Jt(c),{showPointPopup:k,removePopup:Y}=en(c,void 0,{displayConfig:e.popupConfig}),{addWave:K,removeWave:pe}=tn(c),{addWmtsLayer:me,addImageryLayer:X,removeAllLayers:T,setLayerVisible:L}=on(c),{contourVisible:P,setContourVisible:W,reapply:ie,remove:ee}=ln(c,e.contourConfig),O=sn(c,void 0,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),we=un(c),ke=fn(c),ae=hn(c,{enabled:e.lightingConfig===!0},{is3D:o.computed(()=>f.value.mapType==="3d")});n.theme.value=e.theme||"dark";const uo=Ia({searchByText:m,setView:p,addWave:K,removeWave:pe,position:e.position,debounceTime:e.searchDebounceTime??ne.DEBOUNCE_DELAY});let ot=0;const lt=(x,ut)=>{ot+=1,n.loadingTitle.value=x,n.loadingSubtitle.value=ut,f.value.isLoading=!0},Wn=()=>{f.value.isLoading=!1},fo=(x,ut,Eo)=>{lt(x,ut);const To=ot;setTimeout(()=>{To===ot&&Wn()},Eo)},ho="bigemap.dc-street",st=()=>{L(ho,n.mapNameVisible.value)},Hn=x=>{n.mapNameVisible.value=!!x,st()},jn=x=>{n.theme.value=x},_e={map:c,mapType:n.mapType,mapBase:n.mapBase,loadingSubtitle:n.loadingSubtitle,position:e.position,wmtsUrlProvider:s,toggleMapTypeCore:b,redrawAllEntities:A,setView:p,removeAllLayers:T,addImageryLayer:X,addWmtsLayer:me},go={map:c,getIsDrawing:F,removePopup:Y,showPointPopup:k,onPointClick:t.onPointClick},po=()=>{z(),t.emit("clear-button-click"),t.emit("clear-draw")},mo=x=>{n.currentDrawType.value=x,V(x)},wo=()=>{n.currentDrawType.value=null},yo=()=>{I(x=>{wo(),x.operation==="draw"||x.operation==="edit"?t.emit("draw-end",x):x.operation==="delete"?t.emit("draw-delete",x):x.operation==="clear"&&t.emit("draw-clear",x)})};let ye;const vo=()=>{ye&&clearTimeout(ye),ye=setTimeout(()=>{f.value.isLoading=!1,t.emit("ready"),t.emit("init")},Ct)},Co=()=>{const x={map:c,state:f,setView:p,loadPoints:v,searchByText:m,searchByShape:E,updatePoints:C,clearPoints:y,startDrawing:V,stopDrawing:U,clearDrawings:z,removeDrawing:M,drawEntity:_,deleteEntity:S,setMapNameVisible:Hn,setContourVisible:W,trajectoryState:O.state,loadTrajectory:O.load,playTrajectory:O.play,pauseTrajectory:O.pause,stopTrajectory:O.stop,setTrajectorySpeed:O.setSpeed,jumpTrajectoryTo:O.jumpTo,clearTrajectory:O.clear,maskState:we.state,setMask:we.setMask,setMaskVisible:we.setVisible,clearMask:we.clear,weatherState:ke.state,setWeather:ke.setWeather,clearWeather:ke.clear,lightingState:ae.state,setLightingEnabled:ae.setEnabled,setLightingPeriod:ae.setPeriod,setTheme:jn};t.expose(x),t.emit("expose",x)};let Ve=null,ct=!1;o.onUnmounted(()=>{yn(Ve),Ve=null,ye&&clearTimeout(ye)});const bo=async()=>{try{lt("地图加载中","正在初始化地理数据..."),await h(),f.value.isLoading=!0,await Na(_e),st(),yn(Ve),Ve=Pa(go),yo(),ae.apply(),n.mapType.value=f.value.mapType,e.position&&await p(e.position.lng,e.position.lat,e.position.height),vo(),Co()}catch(x){throw f.value.isLoading=!1,f.value.error=x instanceof Error?x:new Error(String(x)),t.emit("error",x),x}};return{...n,state:f,map:c,showSearch:r,showControls:i,showDeleteControls:a,showStatus:l,wmtsEnabled:u,search:uo,onDelete:po,handleStartDrawing:mo,setMapNameVisible:Hn,setContourVisible:W,contourVisible:P,trajectoryState:O.state,maskState:we.state,weatherState:ke.state,lightingState:ae.state,setTheme:jn,toggleMapType:()=>{fo("视图切换中","正在切换 2D/3D 视图...",800),Aa(_e),n.mapType.value=f.value.mapType,f.value.mapType==="2d"?ee():ie(),O.reapply(),ae.apply()},resetView:()=>xa(_e),toggleMapBaseLayer:async()=>{if(!ct){ct=!0,lt("底图切换中","正在切换地图底图...");try{await La(_e),st()}finally{ct=!1,Wn()}}},init:bo}}const Je=o.defineComponent({name:"GameLoading",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载中"},subtitle:{type:String,default:"正在初始化地理数据..."}},setup(e){return()=>e.visible?o.createVNode("div",{class:"apple-loading-overlay"},[o.createVNode("div",{class:"apple-loading-content"},[o.createVNode("div",{class:"apple-spinner",role:"status","aria-label":"加载中"},null),o.createVNode("h2",{class:"apple-loading-title"},[e.title]),o.createVNode("p",{class:"apple-loading-subtitle"},[e.subtitle])])]):null}}),Qe={"2d":`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><!-- 2D 平面地图:2x2 坐标网格瓦片,表达俯视平面视角 -->\r
76
+ `}const Bn={rain:.5,snow:.3};function Fn(e,t){const n=l.ref({type:"clear",active:!1});let r=null;const i=()=>{const c=e.value;r&&c?.scene?.postProcessStages&&(c.scene.postProcessStages.remove(r),r=null)},o=(c,d)=>{const u=e.value,f=M();if(!u?.scene?.postProcessStages||!f)return;if(i(),c==="clear"||!Bn[c]){n.value={type:"clear",active:!1};return}const h=d?.opacity??t?.opacity??Bn[c],p=c==="rain"?ya(h):wa(h);r=new f.PostProcessStage({name:`weather_${c}`,fragmentShader:p}),u.scene.postProcessStages.add(r),n.value={type:c,active:!0}},a=()=>{i(),r=null,n.value={type:"clear",active:!1}},s=()=>{a()};return l.onUnmounted(()=>{s()}),{state:n,setWeather:o,clear:a,destroy:s}}const va=6,Ca=18,ba=20;function Ea(e){return{day:e?.dayStartHour??va,dusk:e?.duskStartHour??Ca,night:e?.nightStartHour??ba}}function Ta(e,t){const{day:n,dusk:r,night:i}=Ea(t);return e>=n&&e<r?"day":e>=r&&e<i?"dusk":"night"}const ut={x:.5781,y:-.5781,z:.5758};function Sa(e,t){if(e==="day")return new t.SunLight;const n=e==="night";return new t.DirectionalLight({direction:new t.Cartesian3(ut.x,ut.y,ut.z),color:n?new t.Color(.9,.925,1):t.Color.fromCssColorString("#deca7c"),intensity:n?.5:1})}function On(e,t,n){const r=n?.is3D??l.ref(!0),i=l.ref(null),o=l.ref({enabled:!!t?.enabled,mode:"auto",period:"night",hour:0});let a,s,c;const d=()=>{const m=t?.now?.()??new Date;o.value.hour=m.getHours(),o.value.mode=i.value?"manual":"auto",o.value.period=i.value??Ta(o.value.hour,t)},u=()=>{const m=e.value;if(!m?.scene){c=void 0;return}const v=m.scene;(c!==void 0||a!==void 0)&&(v.light=a,s!==void 0&&(v.globe.enableLighting=s)),c=void 0},f=()=>{const m=e.value,v=M();if(!m?.scene||!v)return;const w=m.scene;s===void 0&&(a=w.light,s=!!w.globe.enableLighting),w.globe.enableLighting=!0;const E=Sa(o.value.period,v);w.light=E,c=E},h=()=>{d(),o.value.enabled&&r.value?f():u()},p=m=>{o.value.enabled=!!m,h()},b=m=>{i.value=m==="auto"?null:m,h()},C=()=>{o.value.enabled=!1,u()};return l.onUnmounted(()=>C()),d(),{state:o,setEnabled:p,setPeriod:b,apply:h,destroy:C}}function zn(e,t){const n=e.layer||"PostGIS:dommap";return`${e.baseUrl.replace(/\/$/,"")}?layer=${n}&geo-token=${t}&style=&tilematrixset=EPSG%3A3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fvnd.jpeg-png&TileMatrix=EPSG%3A3857%3A{TileMatrix}&TileCol={TileCol}&TileRow={TileRow}`}function Un(e){return async()=>{const t=e.token;if(!t)throw new Error("未提供 GeoServer 令牌(geoserver.token),无法拼接 WMTS 地址");return zn(e,t)}}function Da(){return{mapType:l.ref("3d"),mapBase:l.ref("bigemap"),currentDrawType:l.ref(null),loadingTitle:l.ref("地图加载中"),loadingSubtitle:l.ref("正在初始化地理数据..."),theme:l.ref("dark"),mapNameVisible:l.ref(!1)}}function Ge(e){return typeof e=="number"&&!Number.isNaN(e)}function Ma(e){const t=l.ref(""),n=l.ref([]),r=l.ref(!1),i=l.ref(!1),o=l.ref(!1),a=l.ref(-1),s=l.ref(-1);let c,d,u=0;const f=l.computed(()=>t.value.trim()?n.value:[]),h=async S=>{const N=++u;try{const T=await e.searchByText({field:["name"],keyword:S,limit:10,caseSensitive:!1});if(N!==u)return;n.value=T||[],o.value=!1}catch(T){if(N!==u)return;y.error("搜索查询失败:",T),n.value=[],o.value=!0}finally{N===u&&(i.value=!1)}},p=S=>{if(t.value=S,c&&clearTimeout(c),!S.trim()){n.value=[],r.value=!1,o.value=!1;return}i.value=!0,r.value=!0,c=setTimeout(()=>{h(S.trim())},e.debounceTime)},b=S=>Ge(S.altitude)?S.altitude+Ir:e.position?.height??se.height,C=S=>{if(!Ge(S.lng)||!Ge(S.lat))return;e.setView(S.lng,S.lat,b(S));const N=e.addWave({position:[S.lng,S.lat,Ge(S.altitude)?S.altitude:0],config:{color:"#0a84ff",radius:Mr,duration:ke.WAVE}});d&&clearTimeout(d),d=setTimeout(()=>e.removeWave(N),Ft)},m=(S,N)=>{s.value=N,C(S),r.value=!1},v=S=>{const N=f.value.length;N!==0&&(a.value=(a.value+S+N)%N)},w=()=>{const S=a.value,N=f.value[S];N&&m(N,S)},E=()=>{r.value=!1},V=()=>{t.value="",n.value=[],r.value=!1,o.value=!1,s.value=-1,a.value=-1};return l.onUnmounted(()=>{c&&clearTimeout(c),d&&clearTimeout(d)}),{searchInput:t,searchList:n,showResults:r,isSearching:i,searchError:o,highlightIndex:a,selectedIndex:s,filteredList:f,handleInputSearch:p,handleResultClick:m,moveHighlight:v,selectHighlighted:w,closeResults:E,clearSearch:V}}function Ia(e){e.toggleMapTypeCore();const n=(e.mapType.value==="3d"?"2d":"3d")==="3d"?Dr:Sr;setTimeout(()=>e.redrawAllEntities(),n)}function La(e){e.position&&e.setView(e.position.lng,e.position.lat,e.position.height)}async function dt(e){for(const t of e.baseLayers)e.loadingSubtitle.value=`正在添加底图图层(${t})...`,await e.addImageryLayer(t)}async function $n(e){if(!e.wmtsUrlProvider)throw new Error("未配置 wmtsUrlProvider,无法切换到生产底图");const t=await e.wmtsUrlProvider();if(!t)throw new Error("wmtsUrlProvider 未返回有效地址,无法切换到生产底图");await e.addWmtsLayer(t,"geoserver")}async function Aa(e){if(!e.map.value)return;const t=e.mapBase.value,n=t==="bigemap"?"geoserver":"bigemap";e.loadingSubtitle.value="正在切换地图底图...";try{await e.removeAllLayers(),n==="bigemap"?await dt(e):await $n(e),e.mapBase.value=n}catch(r){y.error("切换地图底图失败:",r);try{await e.removeAllLayers(),t==="bigemap"?await dt(e):await $n(e)}catch(i){y.error("恢复原底图失败:",i)}}finally{e.loadingSubtitle.value="正在初始化地理数据..."}}async function xa(e){if(e.map.value)try{await dt(e)}catch(t){y.error("加载底图图层失败:",t)}}function Na(e){return t=>{if(e.getIsDrawing()||!e.map.value||!t.position)return;e.removePopup();const n=e.map.value.scene.pick(t.position);if(n&&n.primitive&&n.primitive.pointData){const r=n.primitive.pointData;e.onPointClick(r),e.showPointPopup(Gn(r),{offsetX:0,offsetY:-25})}}}function _a(e,t){const n=document.querySelector(".map-point-popup");if(!n)return!1;const r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),o=r.left+e.x,a=r.top+e.y;return o>=i.left-8&&o<=i.right+8&&a>=i.top-8&&a<=i.bottom+8}function ka(e){let t=null;const n=r=>r?.id??r?.pointNo??r?.name??"";return r=>{if(e.getIsDrawing()||!e.map.value||!r.endPosition)return;const i=e.map.value.scene.canvas,o=e.map.value.scene.pick(r.endPosition);if(o&&o.primitive&&o.primitive.pointData){const a=o.primitive.pointData,s=n(a);s!==t&&(t=s,e.showPointPopup(Gn(a),{offsetX:0,offsetY:-25}))}else _a(r.endPosition,i)||(t=null,e.removePopup())}}function Gn(e){return{...e}}function Pa(e){if(!e.map.value)return null;const t=R(),n=new t.ScreenSpaceEventHandler(e.map.value.scene.canvas);return n.setInputAction(Na(e),t.ScreenSpaceEventType.LEFT_CLICK),n.setInputAction(ka(e),t.ScreenSpaceEventType.MOUSE_MOVE),n}function Wn(e){if(e&&typeof e.destroy=="function")try{e.destroy()}catch(t){y.warn("[useMapView] destroy click listener error:",t)}}const Hn=["containerId","position","serverUrl","accessToken","libsUrl","mapId","terrainId","baseLayers","showSearch","showControls","showDeleteControls","showStatus","tools","searchDebounceTime","wmtsUrlProvider","geoserver","contourConfig","lightingConfig"],Va={containerId:String,position:Object,serverUrl:String,accessToken:String,libsUrl:String,mapId:String,terrainId:String,baseLayers:Array,showSearch:Boolean,showControls:Boolean,showDeleteControls:Boolean,showStatus:Boolean,tools:Array,searchDebounceTime:Number,wmtsUrlProvider:Function,geoserver:Object,contourConfig:Object,lightingConfig:Boolean};function Ra(e,t){const n=e??{},r={};for(const i of Hn)r[i]=n[i];return{...r,theme:t.theme,popupConfig:t.popupConfig}}function Kn(e,t){const n=Da(),r=l.computed(()=>!!e.showSearch),i=l.computed(()=>e.showControls!==!1),o=l.computed(()=>e.showDeleteControls!==!1),a=l.computed(()=>!!e.showStatus),s=e.wmtsUrlProvider??(e.geoserver?Un(e.geoserver):void 0),c=l.computed(()=>!!s),d=l.computed(()=>({containerId:e.containerId,position:e.position||se,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,mapId:e.mapId,terrainId:e.terrainId})),{map:u,state:f,initMap:h,setView:p,toggleMapType:b}=Zt(d.value),{loadPoints:C,searchByText:m,updatePoints:v,clearPoints:w,searchByShape:E}=on(u),{drawEntity:V,deleteEntity:S,redrawAllEntities:N}=un(u),{startDrawing:T,cancelDrawing:I,clearAllDrawings:k,removeDrawing:L,setCallback:A,getIsDrawing:B}=pn(u),{showPointPopup:x,removePopup:Z}=yn(u,void 0,{displayConfig:e.popupConfig}),{addWave:ee,removeWave:Me}=wn(u),{addWmtsLayer:Ie,addImageryLayer:te,removeAllLayers:D,setLayerVisible:P}=En(u),{contourVisible:O,contourState:j,setContourVisible:oe,loadLabels:ae,clearLabels:He,getLegendData:cl,reapply:ul,remove:dl}=Dn(u,e.contourConfig,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),Y=Mn(u,void 0,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),Le=Ln(u),le=Rn(u),Ke=Fn(u),he=On(u,{enabled:e.lightingConfig===!0},{is3D:l.computed(()=>f.value.mapType==="3d")});n.theme.value=e.theme||"dark";const fl=Ma({searchByText:m,setView:p,addWave:ee,removeWave:Me,position:e.position,debounceTime:e.searchDebounceTime??ce.DEBOUNCE_DELAY});let Ct=0;const bt=(_,St)=>{Ct+=1,n.loadingTitle.value=_,n.loadingSubtitle.value=St,f.value.isLoading=!0},mr=()=>{f.value.isLoading=!1},hl=(_,St,Tl)=>{bt(_,St);const Sl=Ct;setTimeout(()=>{Sl===Ct&&mr()},Tl)},gl="bigemap.dc-street",Et=()=>{P(gl,n.mapNameVisible.value)},yr=_=>{n.mapNameVisible.value=!!_,Et()},wr=_=>{n.theme.value=_},je={map:u,mapType:n.mapType,mapBase:n.mapBase,loadingSubtitle:n.loadingSubtitle,position:e.position,baseLayers:e.baseLayers??Nt,wmtsUrlProvider:s,toggleMapTypeCore:b,redrawAllEntities:N,setView:p,removeAllLayers:D,addImageryLayer:te,addWmtsLayer:Ie},pl={map:u,getIsDrawing:B,removePopup:Z,showPointPopup:x,onPointClick:t.onPointClick},ml=()=>{k(),t.emit("clear-button-click"),t.emit("clear-draw")},yl=_=>{n.currentDrawType.value=_,T(_)},wl=()=>{n.currentDrawType.value=null},vl=()=>{A(_=>{wl(),_.operation==="draw"||_.operation==="edit"?t.emit("draw-end",_):_.operation==="delete"?t.emit("draw-delete",_):_.operation==="clear"&&t.emit("draw-clear",_)})};let Ae;const Cl=()=>{Ae&&clearTimeout(Ae),Ae=setTimeout(()=>{f.value.isLoading=!1,t.emit("ready"),t.emit("init")},Rt)},bl=()=>{const _={map:u,state:f,setView:p,loadPoints:C,searchByText:m,searchByShape:E,updatePoints:v,clearPoints:w,startDrawing:T,stopDrawing:I,clearDrawings:k,removeDrawing:L,drawEntity:V,deleteEntity:S,setMapNameVisible:yr,setContourVisible:oe,contourState:j,loadContourLabels:ae,clearContourLabels:He,getContourLegend:cl,trajectoryState:Y.state,loadTrajectory:Y.load,playTrajectory:Y.play,pauseTrajectory:Y.pause,stopTrajectory:Y.stop,setTrajectorySpeed:Y.setSpeed,jumpTrajectoryTo:Y.jumpTo,clearTrajectory:Y.clear,maskState:Le.state,setMask:Le.setMask,setMaskVisible:Le.setVisible,clearMask:Le.clear,kmlState:le.state,loadKmlFromUrl:le.loadFromUrl,loadKmlFromText:le.loadFromText,setKmlVisible:le.setVisible,clearKml:le.clear,weatherState:Ke.state,setWeather:Ke.setWeather,clearWeather:Ke.clear,lightingState:he.state,setLightingEnabled:he.setEnabled,setLightingPeriod:he.setPeriod,setTheme:wr};t.expose(_),t.emit("expose",_)};let Ye=null,Tt=!1;l.onUnmounted(()=>{Wn(Ye),Ye=null,Ae&&clearTimeout(Ae)});const El=async()=>{try{bt("地图加载中","正在初始化地理数据..."),await h(),f.value.isLoading=!0,await xa(je),Et(),Wn(Ye),Ye=Pa(pl),vl(),he.apply(),n.mapType.value=f.value.mapType,e.position&&await p(e.position.lng,e.position.lat,e.position.height),Cl(),bl()}catch(_){throw f.value.isLoading=!1,f.value.error=_ instanceof Error?_:new Error(String(_)),t.emit("error",_),_}};return{...n,state:f,map:u,showSearch:r,showControls:i,showDeleteControls:o,showStatus:a,wmtsEnabled:c,search:fl,onDelete:ml,handleStartDrawing:yl,setMapNameVisible:yr,setContourVisible:oe,contourVisible:O,contourState:j,trajectoryState:Y.state,maskState:Le.state,kmlState:le.state,weatherState:Ke.state,lightingState:he.state,setTheme:wr,toggleMapType:()=>{hl("视图切换中","正在切换 2D/3D 视图...",800),Ia(je),n.mapType.value=f.value.mapType,f.value.mapType==="2d"?dl():ul(),Y.reapply(),le.reapply(),he.apply()},resetView:()=>La(je),toggleMapBaseLayer:async()=>{if(!Tt){Tt=!0,bt("底图切换中","正在切换地图底图...");try{await Aa(je),Et()}finally{Tt=!1,mr()}}},init:El}}const ft=l.defineComponent({name:"GameLoading",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载中"},subtitle:{type:String,default:"正在初始化地理数据..."}},setup(e){return()=>e.visible?l.createVNode("div",{class:"apple-loading-overlay"},[l.createVNode("div",{class:"apple-loading-content"},[l.createVNode("div",{class:"apple-spinner",role:"status","aria-label":"加载中"},null),l.createVNode("h2",{class:"apple-loading-title"},[e.title]),l.createVNode("p",{class:"apple-loading-subtitle"},[e.subtitle])])]):null}}),ht={"2d":`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><!-- 2D 平面地图:2x2 坐标网格瓦片,表达俯视平面视角 -->\r
77
77
  <path fill="#000000" d="M4 3.5h6.7a.5.5 0 0 1 .5.5v6.7a.5.5 0 0 1-.5.5H4a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5zm9.3 0H20a.5.5 0 0 1 .5.5v6.7a.5.5 0 0 1-.5.5h-6.7a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5zM4 12.8h6.7a.5.5 0 0 1 .5.5V20a.5.5 0 0 1-.5.5H4a.5.5 0 0 1-.5-.5v-6.7a.5.5 0 0 1 .5-.5zm9.3 0H20a.5.5 0 0 1 .5.5V20a.5.5 0 0 1-.5.5h-6.7a.5.5 0 0 1-.5-.5v-6.7a.5.5 0 0 1 .5-.5z"/></svg>\r
78
78
  `,"3d":`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><!-- 3D 立体:等轴测立方体(顶面 + 左右侧面),表达三维视角 -->\r
79
79
  <path fill="#000000" d="M12 2.6 20.6 7.1 12 11.6 3.4 7.1 12 2.6z"/>\r
@@ -104,4 +104,4 @@ void main(void){
104
104
  <circle cx="20" cy="8" r="1.6"></circle>\r
105
105
  <circle cx="12" cy="19" r="1.6"></circle>\r
106
106
  </svg>\r
107
- `,triangle:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755439485778" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35763" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M185.8 63.9c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM838.2 716.7c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM186.2 715.6c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7z" fill="#515151" p-id="35764"></path><path d="M287.2 818.1h447.6v37H287.2zM167.3 282h37v451h-37zM235.682 261.34l26.163-26.162L776.897 750.23l-26.163 26.162z" fill="#515151" p-id="35765"></path></svg>',view:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1767681773788" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6706" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M234.666667 224a10.666667 10.666667 0 0 0-10.666667 10.666667v149.333333a32 32 0 0 1-64 0v-149.333333A74.666667 74.666667 0 0 1 234.666667 160h149.333333a32 32 0 0 1 0 64h-149.333333zM597.333333 405.333333a21.333333 21.333333 0 0 1 21.333334 21.333334v170.666666a21.333333 21.333333 0 0 1-21.333334 21.333334h-170.666666a21.333333 21.333333 0 0 1-21.333334-21.333334v-170.666666a21.333333 21.333333 0 0 1 21.333334-21.333334h170.666666z m-170.666666-64a85.333333 85.333333 0 0 0-85.333334 85.333334v170.666666a85.333333 85.333333 0 0 0 85.333334 85.333334h170.666666a85.333333 85.333333 0 0 0 85.333334-85.333334v-170.666666a85.333333 85.333333 0 0 0-85.333334-85.333334h-170.666666z m-202.666667 448a10.666667 10.666667 0 0 0 10.666667 10.666667h149.333333a32 32 0 0 1 0 64h-149.333333A74.666667 74.666667 0 0 1 160 789.333333v-149.333333a32 32 0 0 1 64 0v149.333333z m565.333333 10.666667a10.666667 10.666667 0 0 0 10.666667-10.666667v-149.333333a32 32 0 0 1 64 0v149.333333a74.666667 74.666667 0 0 1-74.666667 74.666667h-149.333333a32 32 0 0 1 0-64h149.333333z m10.666667-565.333333a10.666667 10.666667 0 0 0-10.666667-10.666667h-149.333333a32 32 0 0 1 0-64h149.333333a74.666667 74.666667 0 0 1 74.666667 74.666667v149.333333a32 32 0 0 1-64 0v-149.333333z" fill="#000000" p-id="6707"></path></svg>',weather:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1766264800000" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8601" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><rect x="248" y="512" width="544" height="150" rx="72" fill="#272636" p-id="8602" /><circle cx="372" cy="504" r="120" fill="#272636" p-id="8603" /><circle cx="544" cy="452" r="150" fill="#272636" p-id="8604" /><circle cx="700" cy="504" r="118" fill="#272636" p-id="8605" /><path d="M366 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8606" /><path d="M492 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8607" /><path d="M618 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8608" /></svg>'};function bn(e){return Object.prototype.hasOwnProperty.call(Qe,e)}function za(e,t){return e.replace(/#[0-9a-fA-F]{6}/g,t).replace(/#[0-9a-fA-F]{3}/g,t).replace(/fill="(?!none")[^"]*"/g,`fill="${t}"`).replace(/stroke="(?!none")[^"]*"/g,`stroke="${t}"`)}function En(e,t){const n=Qe[e];return za(n,t||"currentColor")}const G=o.defineComponent({name:"AppIcon",inheritAttrs:!1,props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""}},setup(e){const t=o.computed(()=>bn(e.name)?En(e.name,e.color||void 0):""),n=o.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,...e.color?{color:e.color}:{}}));return()=>o.createVNode("span",{class:"app-icon iconfont-icon",style:n.value,role:"img","aria-hidden":"true"},[o.createVNode("span",{innerHTML:t.value},null)])}}),Tn=o.defineComponent({name:"MapError",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载失败"},message:{type:String,default:""}},emits:["retry"],setup(e,{emit:t}){return()=>e.visible?o.createVNode("div",{class:"map-error",role:"alert"},[o.createVNode("div",{class:"map-error__card"},[o.createVNode("div",{class:"map-error__icon"},[o.createVNode(G,{name:"view",size:28},null)]),o.createVNode("div",{class:"map-error__title"},[e.title]),o.createVNode("div",{class:"map-error__message"},[e.message||"初始化地理数据时出现异常,请检查网络连接后重试"]),o.createVNode("div",{class:"map-error__actions"},[o.createVNode("button",{type:"button",class:"map-error__retry",onClick:()=>t("retry")},[o.createTextVNode("重新加载")]),o.createVNode("span",{class:"map-error__hint"},[o.createTextVNode("若持续失败,请刷新页面")])])])]):null}}),Sn=o.defineComponent({name:"AppInput",inheritAttrs:!1,props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""},clearable:{type:Boolean,default:!1},prefixIcon:{type:String,default:""},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},ariaLabel:{type:String,default:""}},emits:["update:modelValue","input","clear","focus","blur","keydown"],setup(e,{emit:t,attrs:n}){const r=o.useSlots(),i=o.computed({get:()=>e.modelValue,set:d=>t("update:modelValue",d)}),a=o.computed(()=>e.clearable&&!e.disabled&&e.modelValue.length>0),l=d=>{const c=d.target.value;i.value=c,t("input",c)},s=()=>{i.value="",t("clear")},u=o.computed(()=>["app-input",{"app-input--disabled":e.disabled}]);return()=>{const d={},c={};for(const f of Object.keys(n))f.startsWith("on")&&f.length>2?c[f]=n[f]:d[f]=n[f];return o.createVNode("div",o.mergeProps({class:u.value},d),[e.prefixIcon?o.createVNode("span",{class:"app-input__prefix"},[o.createVNode(G,{name:e.prefixIcon,size:15},null)]):null,o.createVNode("input",o.mergeProps({class:"app-input__inner",type:"text",value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,autofocus:e.autofocus,"aria-label":e.ariaLabel||void 0,onInput:l,onFocus:f=>t("focus",f),onBlur:f=>t("blur",f),onKeydown:f=>t("keydown",f)},c),null),r.suffix?o.createVNode("span",{class:"app-input__suffix"},[r.suffix()]):null,a.value?o.createVNode("button",{type:"button",class:"app-input__clear","aria-label":"清除",onClick:s},[o.createVNode("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor"},[o.createVNode("path",{d:"M12 2a10 10 0 100 20 10 10 0 000-20zm4.24 12.83l-1.41 1.41L12 13.41l-2.83 2.83-1.41-1.41L10.59 12 7.76 9.17l1.41-1.41L12 10.59l2.83-2.83 1.41 1.41L13.41 12l2.83 2.83z"},null)])]):null])}}}),et=o.defineComponent({name:"AppSpinner",props:{size:{type:[Number,String],default:24},color:{type:String,default:""}},setup(e){const t=o.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,color:e.color||"currentColor"}));return()=>o.createVNode("span",{class:"app-spinner",style:t.value,role:"status","aria-label":"加载中"},[o.createVNode("span",{class:"app-spinner__circle"},null)])}}),Dn=o.defineComponent({name:"SearchResultsPanel",props:{list:{type:Array,default:()=>[]},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["result-click","result-hover","result-leave"],setup(e,{emit:t}){return()=>o.createVNode("div",{class:"search-results-panel"},[o.createVNode("div",{class:"results-header"},[o.createVNode("span",{class:"header-text"},[o.createTextVNode("搜索结果")])]),o.createVNode("div",{class:"results-content",role:"listbox","aria-label":"桩号搜索结果"},[e.list.map((n,r)=>o.createVNode("div",{key:n.id??r,class:["result-item",{highlight:e.highlightIndex===r,selected:e.selectedIndex===r}],role:"option","aria-selected":e.highlightIndex===r,onClick:()=>t("result-click",n,r),onMouseenter:()=>t("result-hover",r),onMouseleave:()=>t("result-leave")},[o.createVNode("div",{class:"result-icon"},[o.createVNode(G,{name:"location",size:16},null)]),o.createVNode("div",{class:"result-info"},[o.createVNode("div",{class:"result-name"},[n.name]),n.lng!==void 0&&n.lat!==void 0?o.createVNode("div",{class:"result-coordinates"},[n.lng.toFixed(6),o.createTextVNode(", "),n.lat.toFixed(6)]):null,n.altitude?o.createVNode("div",{class:"result-altitude"},[o.createTextVNode("海拔: "),n.altitude,o.createTextVNode("m")]):null]),o.createVNode("div",{class:"result-action"},[o.createVNode(G,{name:"aim",size:16},null)])]))]),o.createVNode("div",{class:"results-footer"},[o.createVNode("span",null,[o.createTextVNode("点击结果进行定位")])])])}}),tt=o.defineComponent({name:"NoResultsPanel",props:{keyword:{type:String,default:""},error:{type:Boolean,default:!1}},emits:["clear"],setup(e,{emit:t}){return()=>o.createVNode("div",{class:["no-results",{"no-results--error":e.error}]},[o.createVNode("div",{class:"no-results-content"},[o.createVNode(G,{name:e.error?"view":"search",size:32},null),o.createVNode("div",{class:"no-results-text"},[e.error?o.createVNode("p",null,[o.createTextVNode("查询失败,请检查网络后重试")]):o.createVNode("p",null,[o.createTextVNode('未找到"'),e.keyword,o.createTextVNode('"相关桩号'),o.createVNode("span",{class:"no-results-hint"},[o.createTextVNode(",请检查桩号格式后重新输入")])])]),e.error?o.createVNode("button",{type:"button",class:"no-results-retry",onClick:()=>t("clear")},[o.createTextVNode("清空重试")]):null])])}});function Fa(e){return{position:"fixed",top:`${e.bottom+nr}px`,left:`${e.left}px`,width:`${e.width}px`,zIndex:rr}}const Mn=o.defineComponent({name:"MapTools",inheritAttrs:!1,props:{showSearch:{type:Boolean,default:!1},theme:{type:String,default:"dark"},filteredList:{type:Array,default:()=>[]},showResults:{type:Boolean,default:!1},input:{type:String,default:""},isSearching:{type:Boolean,default:!1},searchError:{type:Boolean,default:!1},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["search-input","search-focus","search-clear","search-close","search-navigate","search-select","result-click","result-hover","result-leave"],setup(e,{emit:t,slots:n}){const r=o.ref(e.input),i=o.shallowRef(null),a=o.shallowRef(null),l=o.ref({}),s=o.computed(()=>e.showSearch);o.watch(()=>e.input,C=>{r.value=C});const u=()=>{i.value&&(l.value=Fa(i.value.getBoundingClientRect()))},d=C=>{r.value=C,t("search-input",C)},c=()=>{r.value="",t("search-clear","")},f=()=>{t("search-focus",r.value)},h=C=>{if(C.key==="Escape"){C.preventDefault(),t("search-close");return}if(C.key==="ArrowDown"){C.preventDefault(),t("search-navigate",1);return}if(C.key==="ArrowUp"){C.preventDefault(),t("search-navigate",-1);return}C.key==="Enter"&&(C.preventDefault(),t("search-select"))},p=C=>{if(!e.showResults)return;const y=C.target;a.value?.contains(y)||document.querySelector(".search-results-panel")?.contains(y)||document.querySelector(".no-results")?.contains(y)||t("search-close")};o.watch(()=>[e.showResults,e.filteredList.length],()=>{e.showResults&&u()}),o.onMounted(()=>{window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),document.addEventListener("mousedown",p)}),o.onUnmounted(()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),document.removeEventListener("mousedown",p)});const b=o.computed(()=>e.showResults&&e.filteredList.length>0),v=o.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&!e.searchError),m=o.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&e.searchError);return()=>o.createVNode("div",{class:"eapc-utils",ref:a},[s.value?o.createVNode("div",{class:"eapc-search"},[o.createVNode("div",{class:"search-container",ref:i},[o.createVNode(Sn,{class:"search-input",modelValue:r.value,placeholder:"请输入桩号进行搜索...",clearable:!0,prefixIcon:"search",ariaLabel:"桩号搜索","onUpdate:modelValue":d,onClear:c,onFocus:f,onKeydown:h},{suffix:()=>e.isSearching?o.createVNode(et,{size:14},null):r.value&&!e.searchError?o.createVNode("div",{class:"results-count"},[e.filteredList.length,o.createTextVNode("个结果")]):null})])]):null,o.createVNode(o.Teleport,{to:"body"},{default:()=>[b.value?o.createVNode(Dn,{class:"teleported","data-theme":e.theme,style:l.value,list:e.filteredList,highlightIndex:e.highlightIndex,selectedIndex:e.selectedIndex,"onResult-click":(C,y)=>t("result-click",C,y),"onResult-hover":C=>t("result-hover",C),"onResult-leave":()=>t("result-leave")},null):null,v.value?o.createVNode(tt,{class:"teleported","data-theme":e.theme,style:l.value,keyword:r.value},null):null,m.value?o.createVNode(tt,{class:"teleported","data-theme":e.theme,style:l.value,keyword:r.value,error:!0},null):null]}),o.createVNode("div",{class:"utils-right"},[n["utils-right"]?n["utils-right"]():null])])}}),In=o.defineComponent({name:"MapControls",inheritAttrs:!1,props:{showDeleteControls:{type:Boolean,default:!0},mapType:{type:String,default:"3d"},mapBase:{type:String,default:"bigemap"},currentDrawType:{type:String,default:null},mapNameVisible:{type:Boolean,default:!1},contourVisible:{type:Boolean,default:!1},tools:{type:Array,default:()=>Re},showBaseSwitch:{type:Boolean,default:!0}},emits:["delete","toggle-map-type","toggle-map-base","start-drawing","toggle-map-view","toggle-map-name","toggle-contour"],setup(e,{emit:t}){const n=o.computed(()=>e.currentDrawType!=null),r=l=>{n.value||t(l)},i=l=>{n.value&&e.currentDrawType!==l||t("start-drawing",l)},a=l=>{const s=ht(l);return s?s.icon:l};return()=>o.createVNode("div",{class:"eapc-control"},[e.showDeleteControls?o.createVNode("button",{type:"button",class:["item","delete-item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"清除绘制图形",onClick:()=>r("delete")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("清除绘制图形")]),o.createVNode(G,{name:"clear",size:18},null)]):null,o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapType==="3d"?"2D":"3D"}地图`,onClick:()=>r("toggle-map-type")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("切换"),e.mapType==="3d"?"2D":"3D",o.createTextVNode("地图")]),o.createVNode(G,{name:e.mapType,size:e.mapType==="3d"?24:22},null)]),o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"恢复视图",onClick:()=>r("toggle-map-view")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("恢复视图")]),o.createVNode(G,{name:"view",size:20},null)]),e.showBaseSwitch?o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapBase==="bigemap"?"物探地图":"生产地图"}底图`,onClick:()=>r("toggle-map-base")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("切换"),e.mapBase==="bigemap"?"物探地图":"生产地图"]),o.createVNode(G,{name:"base",size:20},null)]):null,o.createVNode("button",{type:"button",class:["item","label-switch-item","is-button",{"is-on":e.mapNameVisible}],role:"switch","aria-checked":e.mapNameVisible,"aria-label":e.mapNameVisible?"关闭地图名称注记":"加载地图名称注记",onClick:()=>t("toggle-map-name",!e.mapNameVisible)},[o.createVNode("span",{class:"txt"},[e.mapNameVisible?"关闭地图名称":"加载地图名称"]),o.createVNode("span",{class:"label-switch","aria-hidden":"true"},[o.createVNode("span",{class:"label-switch__track"},[o.createVNode("span",{class:"label-switch__thumb"},null)])])]),e.mapType==="3d"?o.createVNode("button",{type:"button",class:["item","is-button",{active:e.contourVisible}],"aria-pressed":e.contourVisible,"aria-label":e.contourVisible?"关闭等高线":"开启等高线",onClick:()=>t("toggle-contour")},[o.createVNode("span",{class:"txt"},[e.contourVisible?"关闭等高线":"开启等高线"]),o.createVNode(G,{name:"contour",size:18},null)]):null,o.createVNode("div",{class:"eapc-control__divider"},null),e.tools.map(l=>o.createVNode("button",{type:"button",key:l.icon,class:["item","tool-item","is-button",{active:e.currentDrawType===l.icon,"is-disabled":n.value&&e.currentDrawType!==l.icon}],disabled:n.value&&e.currentDrawType!==l.icon,"aria-pressed":e.currentDrawType===l.icon,"aria-label":l.name,onClick:()=>i(l.icon)},[o.createVNode("span",{class:"txt"},[l.name]),o.createVNode(G,{name:a(l.icon),size:l.size},null)]))])}}),Oa=500,An=1e3,Ga={bigemap:"生产地图",geoserver:"物探地图"};function Ne(e){return e&&typeof e.value=="object"?e.value:e}function Ua(e){return e>=1e3?`${(e/1e3).toFixed(2)} km`:`${Math.round(e)} m`}function xn(e){return e>=1024*1024*1024?`${(e/1024/1024/1024).toFixed(2)} GB`:`${(e/1024/1024).toFixed(1)} MB`}const Ln=o.defineComponent({name:"MapStatus",inheritAttrs:!1,props:{map:{type:Object,default:null},mapBase:{type:String,default:"bigemap"},visible:{type:Boolean,default:!1}},setup(e){const t=o.ref(!1),n=o.ref(0),r=o.ref("--"),i=o.ref({text:"--",detail:""}),a=o.ref("--"),l=o.ref("--"),s=o.shallowRef(null),u=o.shallowRef(null),d=o.ref(!1);let c=0,f=0,h=0,p=[],b=null,v=null,m=0;const C=()=>{f=0,h=performance.now();const M=()=>{f+=1;const I=performance.now();I-h>=Oa&&(n.value=Math.round(f*1e3/(I-h)),f=0,h=I),c=requestAnimationFrame(M)};c=requestAnimationFrame(M)},y=()=>{try{const M=performance.memory;if(!M){r.value="--";return}const I=M.usedJSHeapSize,F=M.jsHeapSizeLimit;r.value=`${xn(I)} / ${xn(F)}`}catch{r.value="--"}},E=()=>{const M=Ne(e.map);if(!M)return;const I=D();if(!I)return;if(!!(I.SceneMode&&M.scene.mode===I.SceneMode.SCENE2D)){i.value={text:"2D 视图",detail:Ga[e.mapBase]||e.mapBase};return}try{const k=I.Cartographic.fromCartesian(M.camera.position);i.value={text:"3D 视图",detail:`视距 ${Ua(k.height)}`}}catch{i.value={text:"3D 视图",detail:"--"}}},_=M=>{v=M,m===0&&(m=requestAnimationFrame(()=>{m=0;const I=v;if(v=null,!I)return;const F=Ne(e.map);if(!F)return;const k=D();if(!k)return;const Y=F.camera.pickEllipsoid(new k.Cartesian2(I.offsetX,I.offsetY),F.scene.globe.ellipsoid);if(!Y)return;const K=k.Cartographic.fromCartesian(Y);a.value=k.Math.toDegrees(K.longitude).toFixed(6),l.value=k.Math.toDegrees(K.latitude).toFixed(6)}))},S=()=>{!s.value||!u.value||(d.value=u.value.scrollWidth>s.value.clientWidth+1)},A=()=>{t.value=!t.value},V=M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),A())};o.onMounted(()=>{C(),y(),E(),S(),p.push(window.setInterval(y,An)),p.push(window.setInterval(E,An)),Ne(e.map)?.scene.canvas.addEventListener("mousemove",_),typeof ResizeObserver<"u"&&(b=new ResizeObserver(S),u.value&&b.observe(u.value),s.value&&b.observe(s.value))}),o.onUnmounted(()=>{cancelAnimationFrame(c),m!==0&&cancelAnimationFrame(m),v=null,b?.disconnect(),p.forEach(I=>window.clearInterval(I)),Ne(e.map)?.scene.canvas.removeEventListener("mousemove",_)});const U=()=>[o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("FPS")]),o.createVNode("b",{class:"map-status__value map-status__value--fps"},[n.value])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("内存")]),o.createVNode("span",{class:"map-status__value"},[r.value])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("层级")]),o.createVNode("span",{class:"map-status__value"},[i.value.text,i.value.detail?o.createVNode("em",{class:"map-status__detail"},[o.createTextVNode(" · "),i.value.detail]):null])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("坐标")]),o.createVNode("span",{class:"map-status__value map-status__value--coords"},[a.value,o.createTextVNode(", "),l.value])])],z=o.computed(()=>t.value&&d.value);return()=>e.visible?o.createVNode("div",{class:["map-status",t.value?"is-expanded":"is-collapsed"],role:"button",tabindex:0,title:t.value?"收起状态信息":"展开状态信息",onClick:A,onKeydown:V},[o.createVNode("span",{class:"map-status__badge","aria-hidden":t.value},[o.createVNode("b",{class:"map-status__badge-value"},[n.value])]),o.createVNode("span",{class:"map-status__expanded","aria-hidden":!t.value},[o.createVNode("span",{class:"map-status__row",ref:s},[o.createVNode("span",{class:["map-status__track",{"is-marquee":z.value}]},[o.createVNode("span",{class:"map-status__track-inner",ref:u},[U()]),z.value?o.createVNode("span",{class:"map-status__track-inner","aria-hidden":"true"},[U()]):null])])])]):null}}),Nn=o.defineComponent({name:"MapView",props:{config:{type:Object,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","error-retry","expose"],async setup(e,{emit:t,expose:n,slots:r}){const i=Ra(e.config,{theme:e.theme,popupConfig:e.popupConfig}),a=Cn(i,{emit:(k,...Y)=>t(k,...Y),expose:n,onPointClick:k=>t("point-click",k)});await a.init().catch(()=>{});const{mapType:l,mapBase:s,currentDrawType:u,loadingTitle:d,loadingSubtitle:c,theme:f,mapNameVisible:h,showControls:p,showDeleteControls:b,showStatus:v,wmtsEnabled:m}=a,{state:C,showSearch:y,search:E,onDelete:_,handleStartDrawing:S,toggleMapType:A,resetView:V,toggleMapBaseLayer:U,setMapNameVisible:z,setContourVisible:M,contourVisible:I,map:F}=a;return()=>o.createVNode(o.Fragment,null,[o.createVNode(Je,{visible:C.value.isLoading&&!C.value.error,title:d.value,subtitle:c.value},null),o.createVNode(Tn,{visible:!!C.value.error,message:C.value.error?.message,onRetry:()=>t("error-retry")},null),o.createVNode(Ln,{map:F,mapBase:s.value,visible:v.value},null),y.value?o.createVNode(Mn,{showSearch:!0,theme:f.value,filteredList:E.filteredList.value,showResults:E.showResults.value,input:E.searchInput.value,isSearching:E.isSearching.value,searchError:E.searchError.value,highlightIndex:E.highlightIndex.value,selectedIndex:E.selectedIndex.value,"onSearch-input":E.handleInputSearch,"onSearch-focus":()=>{E.showResults.value=!0},"onSearch-clear":E.clearSearch,"onSearch-close":()=>{E.showResults.value=!1},"onSearch-navigate":k=>E.moveHighlight(k),"onSearch-select":()=>E.selectHighlighted(),"onResult-click":E.handleResultClick,"onResult-hover":k=>{E.highlightIndex.value=k},"onResult-leave":()=>{E.highlightIndex.value=-1}},{"utils-right":()=>r["utils-right"]?r["utils-right"]():null}):null,p.value?o.createVNode(In,{showDeleteControls:b.value,mapType:l.value,mapBase:s.value,currentDrawType:u.value??void 0,mapNameVisible:h.value,contourVisible:I.value,tools:i.tools,showBaseSwitch:m.value,onDelete:_,"onToggle-map-type":A,"onToggle-map-base":U,"onToggle-map-view":V,"onToggle-map-name":k=>z(k),"onToggle-contour":()=>M(!I.value),"onStart-drawing":S},null):null,r.default?r.default():null])}}),$a=Object.fromEntries(vn.map(e=>[e,{type:Ba[e],default:void 0}])),Wa=o.defineComponent({name:"MapContainer",inheritAttrs:!1,props:{config:{type:Object,default:void 0},...$a,hideSearch:{type:Boolean,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","expose"],setup(e,{emit:t,slots:n,expose:r}){const i=o.ref(e.theme||"dark"),a=or(e.config,{containerId:e.containerId,position:e.position,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,showSearch:e.showSearch??e.hideSearch,showControls:e.showControls,showDeleteControls:e.showDeleteControls,showStatus:e.showStatus,tools:e.tools,searchDebounceTime:e.searchDebounceTime,wmtsUrlProvider:e.wmtsUrlProvider,geoserver:e.geoserver,contourConfig:e.contourConfig,lightingConfig:e.lightingConfig}),l=u=>{if(u&&typeof u.setTheme=="function"){const d=u.setTheme;u.setTheme=c=>{i.value=c,d(c)}}r(u),t("expose",u)},s=u=>(...d)=>{t(u,...d)};return()=>o.createVNode("div",{class:"map-container-wrapper","data-theme":i.value},[o.createVNode("div",{id:a.containerId,class:"map-container"},null),o.createVNode(o.Suspense,null,{default:()=>o.createVNode(Nn,{config:a,theme:i.value,popupConfig:e.popupConfig,onInit:s("init"),"onDraw-end":s("draw-end"),"onDraw-delete":s("draw-delete"),"onDraw-clear":s("draw-clear"),"onPoint-click":s("point-click"),"onClear-button-click":s("clear-button-click"),"onClear-draw":s("clear-draw"),onReady:s("ready"),onError:s("error"),onExpose:l},{default:u=>kn(n,"default",u),"utils-right":()=>kn(n,"utils-right",{})}),fallback:()=>o.createVNode(Je,{visible:!0},null)})])}});function kn(e,t,n){const r=e[t];return r?r(n):null}const Ha=o.defineComponent({name:"AppButton",inheritAttrs:!1,props:{type:{type:String,default:"primary"},size:{type:String,default:"medium"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},emits:["click"],setup(e,{slots:t,attrs:n,emit:r}){const i=o.computed(()=>["app-button",`app-button--${e.type}`,`app-button--${e.size}`,{"app-button--block":e.block},{"app-button--disabled":e.disabled||e.loading}]),a=l=>{e.disabled||e.loading||r("click",l)};return()=>o.createVNode("button",o.mergeProps({type:"button",class:i.value,disabled:e.disabled},n,{onClick:a}),[e.loading?o.createVNode(et,{size:14,class:"app-button__spinner"},null):null,t.default?o.createVNode("span",{class:"app-button__content"},[t.default()]):null])}});function _n(e,t){return/<svg\b[^>]*\sdata-keep-color\b/i.test(e)?e:e.replace(/#[0-9a-fA-F]{6}/g,t).replace(/#[0-9a-fA-F]{3}/g,t).replace(/fill="[^"]*"/g,`fill="${t}"`).replace(/stroke="[^"]*"/g,`stroke="${t}"`)}function Vn(e,t){const n=t/2;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"><circle cx="${n}" cy="${n}" r="${n}" fill="${e}"/></svg>`}function Pn(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)n+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(n)}`}const ja={fontSize:12,textColor:"#FFFFFF",textBgColor:"rgba(0, 0, 0, 0.6)",padding:4,rounded:!0,borderRadius:4};function Bn(e){return{...ja,...e}}let nt=null;function Rn(e,t){nt||(nt=document.createElement("canvas"));const n=nt.getContext("2d");return n.font=`${t}px Microsoft YaHei, sans-serif`,Math.ceil(n.measureText(e).width)}const Ya=3e3,ge=new Map,qa=100;function Ka(e){const t=ge.get(e);return t?Promise.resolve(t):new Promise(n=>{const r=new Image;let i=!1;const a=()=>{i||(i=!0,clearTimeout(l),n(r))};r.src=e,r.onload=()=>{if(r.naturalWidth>0&&r.naturalHeight>0)for(ge.set(e,r);ge.size>qa;){const s=ge.keys().next().value;if(s===void 0)break;ge.delete(s)}a()},r.onerror=a;const l=setTimeout(a,Ya)})}function Xa(e,t,n,r,i){e.fillStyle=t.textBgColor,t.rounded?(e.beginPath(),e.roundRect(n,0,r,i,t.borderRadius),e.fill()):e.fillRect(n,0,r,i)}function zn(e,t,n,r,i){e.font=`${t.fontSize}px Microsoft YaHei, sans-serif`,e.fillStyle=t.textColor,e.textAlign="center",e.textBaseline="middle",e.fillText(n,r/2,i/2)}async function Za(e,t,n,r,i){const a=await Ka(t.icon);return a.naturalWidth>0&&a.naturalHeight>0?(e.drawImage(a,r,i,n,n),!0):(e.fillStyle=t.color,e.fillRect(r,i,n,n),!1)}async function Fn(e,t,n,r){const i=n.iconSize||32,a=Bn(n.textConfig),l=Rn(t,a.fontSize)+a.padding*2,s=a.fontSize+a.padding*2,u=Math.max(i,l),d=s+i,c=document.createElement("canvas");c.width=u*r,c.height=d*r;const f=c.getContext("2d");f.scale(r,r);const h=(u-l)/2;Xa(f,a,h,l,s),zn(f,a,t,u,s);const p=await Za(f,e,i,(u-i)/2,s);return{icon:c,width:u,height:d,type:"text",text:t,status:e.status,color:e.color,degraded:!p}}function Ja(e,t,n){const r=n.iconSize||32,i=Bn(n.textConfig),a=Rn(t,i.fontSize)+i.padding*2,l=i.fontSize+i.padding*2,s=Math.max(r,a),u=l+r,d=document.createElement("canvas");d.width=s,d.height=u;const c=d.getContext("2d");return c.fillStyle=i.textBgColor,c.fillRect(0,0,s,l),zn(c,i,t,s,l),c.fillStyle=e.color,c.fillRect((s-r)/2,l,r,r),{icon:d,width:s,height:u,type:"text",text:t,status:e.status,color:e.color}}const Qa="color_svg";function On(e,t){return t===void 0?`${e}_no_text`:t===""?`${e}_empty_text`:`${e}_text_${t}`}function Gn(e){return`${Qa}_${e}`}function rt(e){return R[e]?.color||R.default.color}const it=25,eo=8;function to(){return typeof MessageChannel<"u"?new Promise(e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(0)}):new Promise(e=>setTimeout(e,0))}async function at(e){return performance.now()-e>=eo?(await to(),performance.now()):e}async function no(e,t){const n=new Map,r=new Map;t.forEach(i=>{const a=r.get(i.status)||[];a.push(i),r.set(i.status,a)});for(const[,i]of r){let a=performance.now();for(let l=0;l<i.length;l+=it){const s=i.slice(l,l+it);await Promise.all(s.map(async u=>{const d=u.id?.toString()??String(u.text??"");try{n.set(d,await e(u.status,u.text))}catch{n.set(d,await e(u.status))}})),l+it<i.length&&(a=await at(a))}}return n}async function ro(e,t){const n=Array.isArray(e)?e:[];if(n.length===0)return[];const r=new Array(n.length),i=new Map,a=new Map;for(let c=0;c<n.length;c++){const f=n[c],h=t.resolveColor(f),p=t.resolveBaseSvg(f),b=f.showName&&f.name?String(f.name).trim():"",v=`${p}${h}${b}`;r[c]=v,b?a.has(v)||a.set(v,{key:v,color:h,text:b,svg:p}):i.has(v)||i.set(v,{key:v,color:h,svg:p})}const l=new Map;let s=performance.now();for(const c of i.values()){const f=await t.createBaseIconBySvg(c.svg,c.color);f&&l.set(c.key,{icon:f.icon,width:f.width,height:f.height,type:f.type,text:f.text}),s=await at(s)}let u=0;const d=[];for(const c of a.values()){const f=t.peekTextIconBySvg(c.svg,c.color,c.text);f?(u++,l.set(c.key,f)):d.push(c)}t.onBatchStats?.({uniqueText:a.size,textHits:u,textGenerated:d.length}),s=performance.now();for(const c of d)l.set(c.key,await t.createTextIconBySvg(c.svg,c.color,c.text)),s=await at(s);for(let c=0;c<n.length;c++){const f=l.get(r[c]);if(!f)continue;const h=n[c];h.icon=f.icon,h.width=f.width,h.height=f.height}return n}function io(e,t){const n=JSON.stringify(R);for(const[r,i]of Object.entries(e))R[r]={color:i,text:R[r]?.text||R.default.text};n!==JSON.stringify(R)&&t()}function ao(){const e={default:R.default.color};for(const[t,n]of Object.entries(R))t!=="default"&&(e[t]=n.color);return e}const oo="color:";function Un(e){return`${oo}${e}`}class ${constructor(){this.maxIconCache=$.DEFAULT_MAX_ICON_CACHE,this.activeTasks=0,this.iconCache=new Map,this.colorCache=new Map,this.baseSvgCache=new Map,this.svgKeys=new Map,this.svgCount=0,this.compositeCache=new Map,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.rawSvg="",this.defaultConfig={iconSize:32}}static{this.DEFAULT_MAX_ICON_CACHE=8e3}static{this.TASK_MAX_ICON_CACHE=5e4}static{this.COMPOSITE_CACHE_CAP=2e4}get effectiveCacheLimit(){return this.activeTasks>0?$.TASK_MAX_ICON_CACHE:this.maxIconCache}touchCache(t){const n=this.iconCache.get(t);n&&(this.iconCache.delete(t),this.iconCache.set(t,n))}evictCacheIfNeeded(){for(;this.iconCache.size>this.effectiveCacheLimit;){const t=this.iconCache.keys().next().value;if(t===void 0)break;this.iconCache.delete(t)}}static getInstance(){return $.instance||($.instance=new $),$.instance}beginIconTask(){this.activeTasks++}endIconTask(){this.activeTasks>0&&this.activeTasks--,this.activeTasks===0&&(this.evictCacheIfNeeded(),this.evictCompositeCacheIfNeeded())}resolveSvgKey(t){const n=this.svgKeys.get(t);if(n)return n;const r=`svg#${this.svgCount++}`;return this.svgKeys.set(t,r),r}initialize(t,n){this.rawSvg=t,n&&(this.defaultConfig=n),n?.maxIconCache&&n.maxIconCache>0&&(this.maxIconCache=n.maxIconCache),this.preGenerateBaseColors()}preGenerateBaseColors(){if(this.colorCache.size>0||!this.rawSvg)return;new Set([...Object.keys(R),"default"]).forEach(n=>this.ensureColoredSvg(n,rt(n)))}ensureColoredSvg(t,n){const r=Gn(t);return this.colorCache.has(r)||this.colorCache.set(r,this.buildColoredSvg(n)),this.colorCache.get(r)}buildColoredSvg(t){const n=this.defaultConfig.iconSize||32;try{return _n(this.rawSvg,t)}catch{return Vn(t,n)}}normalizeText(t){const n=t?.trim();return n===""?"":n}buildBaseIcon(t,n){const i=`${this.resolveSvgKey(t||this.rawSvg)}${n}`,a=this.baseSvgCache.get(i);if(a)return a;const l=this.defaultConfig.iconSize||32,s=t||this.rawSvg;let u;try{u=Pn(_n(s,n))}catch{u=Pn(Vn(n,l))}const d={icon:u,width:l,height:l,type:"base",status:Un(n),color:n};return this.baseSvgCache.set(i,d),d}createBaseIconCore(t,n){return this.buildBaseIcon(this.rawSvg,n)}createBaseIconBySvg(t,n){return this.buildBaseIcon(t,n)}compositeKey(t,n,r){return`${this.resolveSvgKey(t||this.rawSvg)}${n}${r}`}peekTextIconBySvg(t,n,r){const i=this.compositeCache.get(this.compositeKey(t,n,r));if(i)return{icon:i.icon,width:i.width,height:i.height,type:i.type,text:i.text}}async createTextIconBySvg(t,n,r){const i=this.compositeKey(t,n,r),a=this.compositeCache.get(i);if(a)return{icon:a.icon,width:a.width,height:a.height,type:a.type,text:a.text};const l=this.buildBaseIcon(t,n),s=this.normalizeText(r)??"",u=await Fn(l,s,this.defaultConfig,this.dpr),d={icon:u.icon,width:u.width,height:u.height,type:u.type,text:u.text};return u.degraded||(this.compositeCache.set(i,{...u,text:s,status:l.status}),this.activeTasks===0&&this.evictCompositeCacheIfNeeded()),d}evictCompositeCacheIfNeeded(){for(;this.compositeCache.size>$.COMPOSITE_CACHE_CAP;){const t=this.compositeCache.keys().next().value;if(t===void 0)break;this.compositeCache.delete(t)}}matchCache(t,n,r){return t.status===n&&t.text===r}async createIcon(t,n){return this.createIconCore(t,rt(t),n)}async createIconByColor(t,n){return this.createIconCore(Un(t),t,n)}async createIconCore(t,n,r){const i=this.normalizeText(r),a=On(t,i),l=this.iconCache.get(a);if(l&&this.matchCache(l,t,i))return this.touchCache(a),{icon:l.icon,width:l.width,height:l.height,type:l.type,text:l.text};const s=await this.createBaseIconCore(t,n),u=i?await Fn(s,i,this.defaultConfig,this.dpr):s;return u.degraded||(this.iconCache.set(a,{...u,text:i,status:t}),this.evictCacheIfNeeded()),{icon:u.icon,width:u.width,height:u.height,type:u.type,text:u.text}}batchCreateIcons(t){return no(this.createIcon.bind(this),t)}batchCreatePointIcons(t){const n={resolveColor:r=>r.color||rt(r.status??"default"),resolveBaseSvg:r=>r.svg||this.rawSvg,createBaseIconBySvg:(r,i)=>Promise.resolve(this.buildBaseIcon(r,i)),createTextIconBySvg:(r,i,a)=>this.createTextIconBySvg(r,i,a),peekTextIconBySvg:(r,i,a)=>this.peekTextIconBySvg(r,i,a),iconSize:this.defaultConfig.iconSize||32,textConfig:this.defaultConfig.textConfig,dpr:this.dpr,onBatchStats:r=>{this.runtimeStats.textHits+=r.textHits,this.runtimeStats.textGenerated+=r.textGenerated,this.runtimeStats.uniqueText+=r.uniqueText}};return ro(t,n)}async createConditionalIcon(t,n){const r=n();return this.createIcon(t,r||void 0)}getIconHeightInfo(){const t=this.defaultConfig.iconSize||32,n=this.defaultConfig.textConfig||{},r=(n.fontSize??12)+(n.padding??0)*2;return{iconHeight:t,textHeight:r,totalHeight:t+r}}clearCache(){this.iconCache.clear(),this.colorCache.clear(),this.baseSvgCache.clear(),this.compositeCache.clear(),this.svgKeys.clear(),this.svgCount=0,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.preGenerateBaseColors()}clearCacheByStatus(t){for(const n of[...this.iconCache.keys()])n.startsWith(`${t}_`)&&this.iconCache.delete(n);this.colorCache.delete(Gn(t))}clearTextIconCache(t,n){this.iconCache.delete(On(t,n))}getCacheStats(){return{iconCache:this.iconCache.size,colorCache:this.colorCache.size,baseSvg:this.baseSvgCache.size,composite:this.compositeCache.size,total:this.iconCache.size+this.colorCache.size+this.baseSvgCache.size+this.compositeCache.size}}getRuntimeStats(){return{...this.runtimeStats}}getConfig(){return{...this.defaultConfig}}updateStatusColorMap(t){io(t,()=>this.clearCache())}getStatusColorMap(){return ao()}buildFallbackTextIcon(t,n){return Ja(t,n,this.defaultConfig)}}const lo=$.getInstance();function so(e){const t=e?.type,n=e?.data;if(t==="circle"&&Array.isArray(n?.center)&&n.center.length>=2)return{type:"circle",center:[n.center[0],n.center[1]],radius:Math.abs(Number(n.radius)||0)};if((t==="polygon"||t==="rectangle"||t==="triangle")&&Array.isArray(n?.path)&&n.path.length>=3){const r=n.path.map(i=>Array.isArray(i)&&i.length>=2?[Number(i[0]),Number(i[1])]:i&&typeof i.lng=="number"&&typeof i.lat=="number"?[i.lng,i.lat]:null).filter(i=>i!==null);if(r.length>=3)return{type:t,coordinates:r}}return null}var $n=(e=>(e.INIT_FAILED="INIT_FAILED",e.LOAD_SCRIPT_FAILED="LOAD_SCRIPT_FAILED",e.INVALID_PARAMS="INVALID_PARAMS",e.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",e.OPERATION_FAILED="OPERATION_FAILED",e))($n||{});class co extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="MapError"}}g.ANIMATION_DURATION=Te,g.AppButton=Ha,g.AppIcon=G,g.AppInput=Sn,g.AppSpinner=et,g.CAMERA_CONFIG=Ee,g.ConfigManager=St,g.DEFAULT_CONTOUR_CONFIG=wt,g.DEFAULT_LIBS_URL=be,g.DEFAULT_MAP_CONFIG=ze,g.DEFAULT_MASK_CONFIG=vt,g.DEFAULT_POSITION=te,g.DEFAULT_TOOLS=Re,g.DEFAULT_TRAJECTORY_CONFIG=yt,g.ErrorCode=$n,g.EventBus=Be,g.GEOMETRY_CONFIG=H,g.GameLoading=Je,g.ICON_MAP=Qe,g.IconManager=$,g.LIBRARIES=Oe,g.MORPH_3D_DELAY=bt,g.MapContainer=Wa,g.MapControls=In,g.MapError=Tn,g.MapErrorClass=co,g.MapManager=Z,g.MapStatus=Ln,g.MapTools=Mn,g.MapView=Nn,g.NoResultsPanel=tt,g.PERFORMANCE_CONFIG=ne,g.READY_DELAY=Ct,g.ResourceManager=Dt,g.STATUS_COLOR_MAP=R,g.ScriptLoader=It,g.SearchResultsPanel=Dn,g.WAVE_REMOVE_DELAY=Et,g.buildGeoServerWmtsUrl=gn,g.cartesianFromCoord=$r,g.cartesianToDegrees=De,g.cartographicToDegrees=Wt,g.closeCoordinates=$e,g.createGeoServerWmtsProvider=pn,g.createSearchShapeFromDrawEvent=so,g.eventBus=Xn,g.getBmgl=D,g.getDefaultToolbarEntries=pt,g.getDefaultTools=mt,g.getDrawToolEntries=gt,g.getDrawToolEntry=ht,g.getEntityType=$t,g.getLogLevel=Kn,g.getStatusInfo=ir,g.getSvg=En,g.iconManager=lo,g.isIconName=bn,g.logger=w,g.mapManager=se,g.normalizeMaskConfig=xe,g.normalizeTrajectoryConfig=qe,g.rectangleToPath=We,g.registerDrawTool=Zn,g.resolveUrl=Ge,g.scriptLoader=Ue,g.setBmgl=At,g.setLogLevel=qn,g.useMap=Pt,g.useMapCircleWave=tn,g.useMapContour=ln,g.useMapDraw=Jt,g.useMapEntity=Yt,g.useMapLayers=on,g.useMapLighting=hn,g.useMapMask=un,g.useMapPoint=Ut,g.useMapPopup=en,g.useMapTrajectory=sn,g.useMapView=Cn,g.useMapWeather=fn,g.waitForBmgl=xt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
107
+ `,triangle:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755439485778" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35763" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M185.8 63.9c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM838.2 716.7c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM186.2 715.6c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7z" fill="#515151" p-id="35764"></path><path d="M287.2 818.1h447.6v37H287.2zM167.3 282h37v451h-37zM235.682 261.34l26.163-26.162L776.897 750.23l-26.163 26.162z" fill="#515151" p-id="35765"></path></svg>',view:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1767681773788" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6706" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M234.666667 224a10.666667 10.666667 0 0 0-10.666667 10.666667v149.333333a32 32 0 0 1-64 0v-149.333333A74.666667 74.666667 0 0 1 234.666667 160h149.333333a32 32 0 0 1 0 64h-149.333333zM597.333333 405.333333a21.333333 21.333333 0 0 1 21.333334 21.333334v170.666666a21.333333 21.333333 0 0 1-21.333334 21.333334h-170.666666a21.333333 21.333333 0 0 1-21.333334-21.333334v-170.666666a21.333333 21.333333 0 0 1 21.333334-21.333334h170.666666z m-170.666666-64a85.333333 85.333333 0 0 0-85.333334 85.333334v170.666666a85.333333 85.333333 0 0 0 85.333334 85.333334h170.666666a85.333333 85.333333 0 0 0 85.333334-85.333334v-170.666666a85.333333 85.333333 0 0 0-85.333334-85.333334h-170.666666z m-202.666667 448a10.666667 10.666667 0 0 0 10.666667 10.666667h149.333333a32 32 0 0 1 0 64h-149.333333A74.666667 74.666667 0 0 1 160 789.333333v-149.333333a32 32 0 0 1 64 0v149.333333z m565.333333 10.666667a10.666667 10.666667 0 0 0 10.666667-10.666667v-149.333333a32 32 0 0 1 64 0v149.333333a74.666667 74.666667 0 0 1-74.666667 74.666667h-149.333333a32 32 0 0 1 0-64h149.333333z m10.666667-565.333333a10.666667 10.666667 0 0 0-10.666667-10.666667h-149.333333a32 32 0 0 1 0-64h149.333333a74.666667 74.666667 0 0 1 74.666667 74.666667v149.333333a32 32 0 0 1-64 0v-149.333333z" fill="#000000" p-id="6707"></path></svg>',weather:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1766264800000" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8601" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><rect x="248" y="512" width="544" height="150" rx="72" fill="#272636" p-id="8602" /><circle cx="372" cy="504" r="120" fill="#272636" p-id="8603" /><circle cx="544" cy="452" r="150" fill="#272636" p-id="8604" /><circle cx="700" cy="504" r="118" fill="#272636" p-id="8605" /><path d="M366 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8606" /><path d="M492 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8607" /><path d="M618 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8608" /></svg>'};function jn(e){return Object.prototype.hasOwnProperty.call(ht,e)}function Ba(e,t){return e.replace(/#[0-9a-fA-F]{6}/g,t).replace(/#[0-9a-fA-F]{3}/g,t).replace(/fill="(?!none")[^"]*"/g,`fill="${t}"`).replace(/stroke="(?!none")[^"]*"/g,`stroke="${t}"`)}function Yn(e,t){const n=ht[e];return Ba(n,t||"currentColor")}const H=l.defineComponent({name:"AppIcon",inheritAttrs:!1,props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""}},setup(e){const t=l.computed(()=>jn(e.name)?Yn(e.name,e.color||void 0):""),n=l.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,...e.color?{color:e.color}:{}}));return()=>l.createVNode("span",{class:"app-icon iconfont-icon",style:n.value,role:"img","aria-hidden":"true"},[l.createVNode("span",{innerHTML:t.value},null)])}}),qn=l.defineComponent({name:"MapError",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载失败"},message:{type:String,default:""}},emits:["retry"],setup(e,{emit:t}){return()=>e.visible?l.createVNode("div",{class:"map-error",role:"alert"},[l.createVNode("div",{class:"map-error__card"},[l.createVNode("div",{class:"map-error__icon"},[l.createVNode(H,{name:"view",size:28},null)]),l.createVNode("div",{class:"map-error__title"},[e.title]),l.createVNode("div",{class:"map-error__message"},[e.message||"初始化地理数据时出现异常,请检查网络连接后重试"]),l.createVNode("div",{class:"map-error__actions"},[l.createVNode("button",{type:"button",class:"map-error__retry",onClick:()=>t("retry")},[l.createTextVNode("重新加载")]),l.createVNode("span",{class:"map-error__hint"},[l.createTextVNode("若持续失败,请刷新页面")])])])]):null}}),Xn=l.defineComponent({name:"AppInput",inheritAttrs:!1,props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""},clearable:{type:Boolean,default:!1},prefixIcon:{type:String,default:""},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},ariaLabel:{type:String,default:""}},emits:["update:modelValue","input","clear","focus","blur","keydown"],setup(e,{emit:t,attrs:n}){const r=l.useSlots(),i=l.computed({get:()=>e.modelValue,set:d=>t("update:modelValue",d)}),o=l.computed(()=>e.clearable&&!e.disabled&&e.modelValue.length>0),a=d=>{const u=d.target.value;i.value=u,t("input",u)},s=()=>{i.value="",t("clear")},c=l.computed(()=>["app-input",{"app-input--disabled":e.disabled}]);return()=>{const d={},u={};for(const f of Object.keys(n))f.startsWith("on")&&f.length>2?u[f]=n[f]:d[f]=n[f];return l.createVNode("div",l.mergeProps({class:c.value},d),[e.prefixIcon?l.createVNode("span",{class:"app-input__prefix"},[l.createVNode(H,{name:e.prefixIcon,size:15},null)]):null,l.createVNode("input",l.mergeProps({class:"app-input__inner",type:"text",value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,autofocus:e.autofocus,"aria-label":e.ariaLabel||void 0,onInput:a,onFocus:f=>t("focus",f),onBlur:f=>t("blur",f),onKeydown:f=>t("keydown",f)},u),null),r.suffix?l.createVNode("span",{class:"app-input__suffix"},[r.suffix()]):null,o.value?l.createVNode("button",{type:"button",class:"app-input__clear","aria-label":"清除",onClick:s},[l.createVNode("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor"},[l.createVNode("path",{d:"M12 2a10 10 0 100 20 10 10 0 000-20zm4.24 12.83l-1.41 1.41L12 13.41l-2.83 2.83-1.41-1.41L10.59 12 7.76 9.17l1.41-1.41L12 10.59l2.83-2.83 1.41 1.41L13.41 12l2.83 2.83z"},null)])]):null])}}}),gt=l.defineComponent({name:"AppSpinner",props:{size:{type:[Number,String],default:24},color:{type:String,default:""}},setup(e){const t=l.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,color:e.color||"currentColor"}));return()=>l.createVNode("span",{class:"app-spinner",style:t.value,role:"status","aria-label":"加载中"},[l.createVNode("span",{class:"app-spinner__circle"},null)])}}),Zn=l.defineComponent({name:"SearchResultsPanel",props:{list:{type:Array,default:()=>[]},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["result-click","result-hover","result-leave"],setup(e,{emit:t}){return()=>l.createVNode("div",{class:"search-results-panel"},[l.createVNode("div",{class:"results-header"},[l.createVNode("span",{class:"header-text"},[l.createTextVNode("搜索结果")])]),l.createVNode("div",{class:"results-content",role:"listbox","aria-label":"桩号搜索结果"},[e.list.map((n,r)=>l.createVNode("div",{key:n.id??r,class:["result-item",{highlight:e.highlightIndex===r,selected:e.selectedIndex===r}],role:"option","aria-selected":e.highlightIndex===r,onClick:()=>t("result-click",n,r),onMouseenter:()=>t("result-hover",r),onMouseleave:()=>t("result-leave")},[l.createVNode("div",{class:"result-icon"},[l.createVNode(H,{name:"location",size:16},null)]),l.createVNode("div",{class:"result-info"},[l.createVNode("div",{class:"result-name"},[n.name]),n.lng!==void 0&&n.lat!==void 0?l.createVNode("div",{class:"result-coordinates"},[n.lng.toFixed(6),l.createTextVNode(", "),n.lat.toFixed(6)]):null,n.altitude?l.createVNode("div",{class:"result-altitude"},[l.createTextVNode("海拔: "),n.altitude,l.createTextVNode("m")]):null]),l.createVNode("div",{class:"result-action"},[l.createVNode(H,{name:"aim",size:16},null)])]))]),l.createVNode("div",{class:"results-footer"},[l.createVNode("span",null,[l.createTextVNode("点击结果进行定位")])])])}}),pt=l.defineComponent({name:"NoResultsPanel",props:{keyword:{type:String,default:""},error:{type:Boolean,default:!1}},emits:["clear"],setup(e,{emit:t}){return()=>l.createVNode("div",{class:["no-results",{"no-results--error":e.error}]},[l.createVNode("div",{class:"no-results-content"},[l.createVNode(H,{name:e.error?"view":"search",size:32},null),l.createVNode("div",{class:"no-results-text"},[e.error?l.createVNode("p",null,[l.createTextVNode("查询失败,请检查网络后重试")]):l.createVNode("p",null,[l.createTextVNode('未找到"'),e.keyword,l.createTextVNode('"相关桩号'),l.createVNode("span",{class:"no-results-hint"},[l.createTextVNode(",请检查桩号格式后重新输入")])])]),e.error?l.createVNode("button",{type:"button",class:"no-results-retry",onClick:()=>t("clear")},[l.createTextVNode("清空重试")]):null])])}});function Fa(e){return{position:"fixed",top:`${e.bottom+Lr}px`,left:`${e.left}px`,width:`${e.width}px`,zIndex:Ar}}const Jn=l.defineComponent({name:"MapTools",inheritAttrs:!1,props:{showSearch:{type:Boolean,default:!1},theme:{type:String,default:"dark"},filteredList:{type:Array,default:()=>[]},showResults:{type:Boolean,default:!1},input:{type:String,default:""},isSearching:{type:Boolean,default:!1},searchError:{type:Boolean,default:!1},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["search-input","search-focus","search-clear","search-close","search-navigate","search-select","result-click","result-hover","result-leave"],setup(e,{emit:t,slots:n}){const r=l.ref(e.input),i=l.shallowRef(null),o=l.shallowRef(null),a=l.ref({}),s=l.computed(()=>e.showSearch);l.watch(()=>e.input,v=>{r.value=v});const c=()=>{i.value&&(a.value=Fa(i.value.getBoundingClientRect()))},d=v=>{r.value=v,t("search-input",v)},u=()=>{r.value="",t("search-clear","")},f=()=>{t("search-focus",r.value)},h=v=>{if(v.key==="Escape"){v.preventDefault(),t("search-close");return}if(v.key==="ArrowDown"){v.preventDefault(),t("search-navigate",1);return}if(v.key==="ArrowUp"){v.preventDefault(),t("search-navigate",-1);return}v.key==="Enter"&&(v.preventDefault(),t("search-select"))},p=v=>{if(!e.showResults)return;const w=v.target;o.value?.contains(w)||document.querySelector(".search-results-panel")?.contains(w)||document.querySelector(".no-results")?.contains(w)||t("search-close")};l.watch(()=>[e.showResults,e.filteredList.length],()=>{e.showResults&&c()}),l.onMounted(()=>{window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),document.addEventListener("mousedown",p)}),l.onUnmounted(()=>{window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),document.removeEventListener("mousedown",p)});const b=l.computed(()=>e.showResults&&e.filteredList.length>0),C=l.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&!e.searchError),m=l.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&e.searchError);return()=>l.createVNode("div",{class:"eapc-utils",ref:o},[s.value?l.createVNode("div",{class:"eapc-search"},[l.createVNode("div",{class:"search-container",ref:i},[l.createVNode(Xn,{class:"search-input",modelValue:r.value,placeholder:"请输入桩号进行搜索...",clearable:!0,prefixIcon:"search",ariaLabel:"桩号搜索","onUpdate:modelValue":d,onClear:u,onFocus:f,onKeydown:h},{suffix:()=>e.isSearching?l.createVNode(gt,{size:14},null):r.value&&!e.searchError?l.createVNode("div",{class:"results-count"},[e.filteredList.length,l.createTextVNode("个结果")]):null})])]):null,l.createVNode(l.Teleport,{to:"body"},{default:()=>[b.value?l.createVNode(Zn,{class:"teleported","data-theme":e.theme,style:a.value,list:e.filteredList,highlightIndex:e.highlightIndex,selectedIndex:e.selectedIndex,"onResult-click":(v,w)=>t("result-click",v,w),"onResult-hover":v=>t("result-hover",v),"onResult-leave":()=>t("result-leave")},null):null,C.value?l.createVNode(pt,{class:"teleported","data-theme":e.theme,style:a.value,keyword:r.value},null):null,m.value?l.createVNode(pt,{class:"teleported","data-theme":e.theme,style:a.value,keyword:r.value,error:!0},null):null]}),l.createVNode("div",{class:"utils-right"},[n["utils-right"]?n["utils-right"]():null])])}}),Qn=l.defineComponent({name:"MapControls",inheritAttrs:!1,props:{showDeleteControls:{type:Boolean,default:!0},mapType:{type:String,default:"3d"},mapBase:{type:String,default:"bigemap"},currentDrawType:{type:String,default:null},mapNameVisible:{type:Boolean,default:!1},contourVisible:{type:Boolean,default:!1},tools:{type:Array,default:()=>Ze},showBaseSwitch:{type:Boolean,default:!0}},emits:["delete","toggle-map-type","toggle-map-base","start-drawing","toggle-map-view","toggle-map-name","toggle-contour"],setup(e,{emit:t}){const n=l.computed(()=>e.currentDrawType!=null),r=a=>{n.value||t(a)},i=a=>{n.value&&e.currentDrawType!==a||t("start-drawing",a)},o=a=>{const s=It(a);return s?s.icon:a};return()=>l.createVNode("div",{class:"eapc-control"},[e.showDeleteControls?l.createVNode("button",{type:"button",class:["item","delete-item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"清除绘制图形",onClick:()=>r("delete")},[l.createVNode("span",{class:"txt"},[l.createTextVNode("清除绘制图形")]),l.createVNode(H,{name:"clear",size:18},null)]):null,l.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapType==="3d"?"2D":"3D"}地图`,onClick:()=>r("toggle-map-type")},[l.createVNode("span",{class:"txt"},[l.createTextVNode("切换"),e.mapType==="3d"?"2D":"3D",l.createTextVNode("地图")]),l.createVNode(H,{name:e.mapType,size:e.mapType==="3d"?24:22},null)]),l.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"恢复视图",onClick:()=>r("toggle-map-view")},[l.createVNode("span",{class:"txt"},[l.createTextVNode("恢复视图")]),l.createVNode(H,{name:"view",size:20},null)]),e.showBaseSwitch?l.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapBase==="bigemap"?"物探地图":"生产地图"}底图`,onClick:()=>r("toggle-map-base")},[l.createVNode("span",{class:"txt"},[l.createTextVNode("切换"),e.mapBase==="bigemap"?"物探地图":"生产地图"]),l.createVNode(H,{name:"base",size:20},null)]):null,l.createVNode("button",{type:"button",class:["item","label-switch-item","is-button",{"is-on":e.mapNameVisible}],role:"switch","aria-checked":e.mapNameVisible,"aria-label":e.mapNameVisible?"关闭地图名称注记":"加载地图名称注记",onClick:()=>t("toggle-map-name",!e.mapNameVisible)},[l.createVNode("span",{class:"txt"},[e.mapNameVisible?"关闭地图名称":"加载地图名称"]),l.createVNode("span",{class:"label-switch","aria-hidden":"true"},[l.createVNode("span",{class:"label-switch__track"},[l.createVNode("span",{class:"label-switch__thumb"},null)])])]),e.mapType==="3d"?l.createVNode("button",{type:"button",class:["item","is-button",{active:e.contourVisible}],"aria-pressed":e.contourVisible,"aria-label":e.contourVisible?"关闭等高线":"开启等高线",onClick:()=>t("toggle-contour")},[l.createVNode("span",{class:"txt"},[e.contourVisible?"关闭等高线":"开启等高线"]),l.createVNode(H,{name:"contour",size:18},null)]):null,l.createVNode("div",{class:"eapc-control__divider"},null),e.tools.map(a=>l.createVNode("button",{type:"button",key:a.icon,class:["item","tool-item","is-button",{active:e.currentDrawType===a.icon,"is-disabled":n.value&&e.currentDrawType!==a.icon}],disabled:n.value&&e.currentDrawType!==a.icon,"aria-pressed":e.currentDrawType===a.icon,"aria-label":a.name,onClick:()=>i(a.icon)},[l.createVNode("span",{class:"txt"},[a.name]),l.createVNode(H,{name:o(a.icon),size:a.size},null)]))])}}),Oa=500,er=1e3,za={bigemap:"生产地图",geoserver:"物探地图"};function We(e){return e&&typeof e.value=="object"?e.value:e}function Ua(e){return e>=1e3?`${(e/1e3).toFixed(2)} km`:`${Math.round(e)} m`}function tr(e){return e>=1024*1024*1024?`${(e/1024/1024/1024).toFixed(2)} GB`:`${(e/1024/1024).toFixed(1)} MB`}const nr=l.defineComponent({name:"MapStatus",inheritAttrs:!1,props:{map:{type:Object,default:null},mapBase:{type:String,default:"bigemap"},visible:{type:Boolean,default:!1}},setup(e){const t=l.ref(!1),n=l.ref(0),r=l.ref("--"),i=l.ref({text:"--",detail:""}),o=l.ref("--"),a=l.ref("--"),s=l.shallowRef(null),c=l.shallowRef(null),d=l.ref(!1);let u=0,f=0,h=0,p=[],b=null,C=null,m=0;const v=()=>{f=0,h=performance.now();const L=()=>{f+=1;const A=performance.now();A-h>=Oa&&(n.value=Math.round(f*1e3/(A-h)),f=0,h=A),u=requestAnimationFrame(L)};u=requestAnimationFrame(L)},w=()=>{try{const L=performance.memory;if(!L){r.value="--";return}const A=L.usedJSHeapSize,B=L.jsHeapSizeLimit;r.value=`${tr(A)} / ${tr(B)}`}catch{r.value="--"}},E=()=>{const L=We(e.map);if(!L)return;const A=M();if(!A)return;if(!!(A.SceneMode&&L.scene.mode===A.SceneMode.SCENE2D)){i.value={text:"2D 视图",detail:za[e.mapBase]||e.mapBase};return}try{const x=A.Cartographic.fromCartesian(L.camera.position);i.value={text:"3D 视图",detail:`视距 ${Ua(x.height)}`}}catch{i.value={text:"3D 视图",detail:"--"}}},V=L=>{C=L,m===0&&(m=requestAnimationFrame(()=>{m=0;const A=C;if(C=null,!A)return;const B=We(e.map);if(!B)return;const x=M();if(!x)return;const Z=B.camera.pickEllipsoid(new x.Cartesian2(A.offsetX,A.offsetY),B.scene.globe.ellipsoid);if(!Z)return;const ee=x.Cartographic.fromCartesian(Z);o.value=x.Math.toDegrees(ee.longitude).toFixed(6),a.value=x.Math.toDegrees(ee.latitude).toFixed(6)}))},S=()=>{!s.value||!c.value||(d.value=c.value.scrollWidth>s.value.clientWidth+1)},N=()=>{t.value=!t.value},T=L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),N())};l.onMounted(()=>{v(),w(),E(),S(),p.push(window.setInterval(w,er)),p.push(window.setInterval(E,er)),We(e.map)?.scene.canvas.addEventListener("mousemove",V),typeof ResizeObserver<"u"&&(b=new ResizeObserver(S),c.value&&b.observe(c.value),s.value&&b.observe(s.value))}),l.onUnmounted(()=>{cancelAnimationFrame(u),m!==0&&cancelAnimationFrame(m),C=null,b?.disconnect(),p.forEach(A=>window.clearInterval(A)),We(e.map)?.scene.canvas.removeEventListener("mousemove",V)});const I=()=>[l.createVNode("span",{class:"map-status__item"},[l.createVNode("span",{class:"map-status__label"},[l.createTextVNode("FPS")]),l.createVNode("b",{class:"map-status__value map-status__value--fps"},[n.value])]),l.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[l.createTextVNode("·")]),l.createVNode("span",{class:"map-status__item"},[l.createVNode("span",{class:"map-status__label"},[l.createTextVNode("内存")]),l.createVNode("span",{class:"map-status__value"},[r.value])]),l.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[l.createTextVNode("·")]),l.createVNode("span",{class:"map-status__item"},[l.createVNode("span",{class:"map-status__label"},[l.createTextVNode("层级")]),l.createVNode("span",{class:"map-status__value"},[i.value.text,i.value.detail?l.createVNode("em",{class:"map-status__detail"},[l.createTextVNode(" · "),i.value.detail]):null])]),l.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[l.createTextVNode("·")]),l.createVNode("span",{class:"map-status__item"},[l.createVNode("span",{class:"map-status__label"},[l.createTextVNode("坐标")]),l.createVNode("span",{class:"map-status__value map-status__value--coords"},[o.value,l.createTextVNode(", "),a.value])])],k=l.computed(()=>t.value&&d.value);return()=>e.visible?l.createVNode("div",{class:["map-status",t.value?"is-expanded":"is-collapsed"],role:"button",tabindex:0,title:t.value?"收起状态信息":"展开状态信息",onClick:N,onKeydown:T},[l.createVNode("span",{class:"map-status__badge","aria-hidden":t.value},[l.createVNode("b",{class:"map-status__badge-value"},[n.value])]),l.createVNode("span",{class:"map-status__expanded","aria-hidden":!t.value},[l.createVNode("span",{class:"map-status__row",ref:s},[l.createVNode("span",{class:["map-status__track",{"is-marquee":k.value}]},[l.createVNode("span",{class:"map-status__track-inner",ref:c},[I()]),k.value?l.createVNode("span",{class:"map-status__track-inner","aria-hidden":"true"},[I()]):null])])])]):null}}),rr=l.defineComponent({name:"MapView",props:{config:{type:Object,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","error-retry","expose"],async setup(e,{emit:t,expose:n,slots:r}){const i=Ra(e.config,{theme:e.theme,popupConfig:e.popupConfig}),o=Kn(i,{emit:(x,...Z)=>t(x,...Z),expose:n,onPointClick:x=>t("point-click",x)});await o.init().catch(()=>{});const{mapType:a,mapBase:s,currentDrawType:c,loadingTitle:d,loadingSubtitle:u,theme:f,mapNameVisible:h,showControls:p,showDeleteControls:b,showStatus:C,wmtsEnabled:m}=o,{state:v,showSearch:w,search:E,onDelete:V,handleStartDrawing:S,toggleMapType:N,resetView:T,toggleMapBaseLayer:I,setMapNameVisible:k,setContourVisible:L,contourVisible:A,map:B}=o;return()=>l.createVNode(l.Fragment,null,[l.createVNode(ft,{visible:v.value.isLoading&&!v.value.error,title:d.value,subtitle:u.value},null),l.createVNode(qn,{visible:!!v.value.error,message:v.value.error?.message,onRetry:()=>t("error-retry")},null),l.createVNode(nr,{map:B,mapBase:s.value,visible:C.value},null),w.value?l.createVNode(Jn,{showSearch:!0,theme:f.value,filteredList:E.filteredList.value,showResults:E.showResults.value,input:E.searchInput.value,isSearching:E.isSearching.value,searchError:E.searchError.value,highlightIndex:E.highlightIndex.value,selectedIndex:E.selectedIndex.value,"onSearch-input":E.handleInputSearch,"onSearch-focus":()=>{E.showResults.value=!0},"onSearch-clear":E.clearSearch,"onSearch-close":()=>{E.showResults.value=!1},"onSearch-navigate":x=>E.moveHighlight(x),"onSearch-select":()=>E.selectHighlighted(),"onResult-click":E.handleResultClick,"onResult-hover":x=>{E.highlightIndex.value=x},"onResult-leave":()=>{E.highlightIndex.value=-1}},{"utils-right":()=>r["utils-right"]?r["utils-right"]():null}):null,p.value?l.createVNode(Qn,{showDeleteControls:b.value,mapType:a.value,mapBase:s.value,currentDrawType:c.value??void 0,mapNameVisible:h.value,contourVisible:A.value,tools:i.tools,showBaseSwitch:m.value,onDelete:V,"onToggle-map-type":N,"onToggle-map-base":I,"onToggle-map-view":T,"onToggle-map-name":x=>k(x),"onToggle-contour":()=>L(!A.value),"onStart-drawing":S},null):null,r.default?r.default():null])}}),$a=Object.fromEntries(Hn.map(e=>[e,{type:Va[e],default:void 0}])),Ga=l.defineComponent({name:"MapContainer",inheritAttrs:!1,props:{config:{type:Object,default:void 0},...$a,hideSearch:{type:Boolean,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","expose"],setup(e,{emit:t,slots:n,expose:r}){const i=l.ref(e.theme||"dark"),o=_r(e.config,{containerId:e.containerId,position:e.position,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,mapId:e.mapId,terrainId:e.terrainId,baseLayers:e.baseLayers,showSearch:e.showSearch??e.hideSearch,showControls:e.showControls,showDeleteControls:e.showDeleteControls,showStatus:e.showStatus,tools:e.tools,searchDebounceTime:e.searchDebounceTime,wmtsUrlProvider:e.wmtsUrlProvider,geoserver:e.geoserver,contourConfig:e.contourConfig,lightingConfig:e.lightingConfig}),a=c=>{if(c&&typeof c.setTheme=="function"){const d=c.setTheme;c.setTheme=u=>{i.value=u,d(u)}}r(c),t("expose",c)},s=c=>(...d)=>{t(c,...d)};return()=>l.createVNode("div",{class:"map-container-wrapper","data-theme":i.value},[l.createVNode("div",{id:o.containerId,class:"map-container"},null),l.createVNode(l.Suspense,null,{default:()=>l.createVNode(rr,{config:o,theme:i.value,popupConfig:e.popupConfig,onInit:s("init"),"onDraw-end":s("draw-end"),"onDraw-delete":s("draw-delete"),"onDraw-clear":s("draw-clear"),"onPoint-click":s("point-click"),"onClear-button-click":s("clear-button-click"),"onClear-draw":s("clear-draw"),onReady:s("ready"),onError:s("error"),onExpose:a},{default:c=>ir(n,"default",c),"utils-right":()=>ir(n,"utils-right",{})}),fallback:()=>l.createVNode(ft,{visible:!0},null)})])}});function ir(e,t,n){const r=e[t];return r?r(n):null}const Wa=l.defineComponent({name:"AppButton",inheritAttrs:!1,props:{type:{type:String,default:"primary"},size:{type:String,default:"medium"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},emits:["click"],setup(e,{slots:t,attrs:n,emit:r}){const i=l.computed(()=>["app-button",`app-button--${e.type}`,`app-button--${e.size}`,{"app-button--block":e.block},{"app-button--disabled":e.disabled||e.loading}]),o=a=>{e.disabled||e.loading||r("click",a)};return()=>l.createVNode("button",l.mergeProps({type:"button",class:i.value,disabled:e.disabled},n,{onClick:o}),[e.loading?l.createVNode(gt,{size:14,class:"app-button__spinner"},null):null,t.default?l.createVNode("span",{class:"app-button__content"},[t.default()]):null])}});function or(e,t){return/<svg\b[^>]*\sdata-keep-color\b/i.test(e)?e:e.replace(/#[0-9a-fA-F]{6}/g,t).replace(/#[0-9a-fA-F]{3}/g,t).replace(/fill="[^"]*"/g,`fill="${t}"`).replace(/stroke="[^"]*"/g,`stroke="${t}"`)}function ar(e,t){const n=t/2;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"><circle cx="${n}" cy="${n}" r="${n}" fill="${e}"/></svg>`}function lr(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)n+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(n)}`}const Ha={fontSize:12,textColor:"#FFFFFF",textBgColor:"rgba(0, 0, 0, 0.6)",padding:4,rounded:!0,borderRadius:4};function sr(e){return{...Ha,...e}}let mt=null;function cr(e,t){mt||(mt=document.createElement("canvas"));const n=mt.getContext("2d");return n.font=`${t}px Microsoft YaHei, sans-serif`,Math.ceil(n.measureText(e).width)}const Ka=3e3,De=new Map,ja=100;function Ya(e){const t=De.get(e);return t?Promise.resolve(t):new Promise(n=>{const r=new Image;let i=!1;const o=()=>{i||(i=!0,clearTimeout(a),n(r))};r.src=e,r.onload=()=>{if(r.naturalWidth>0&&r.naturalHeight>0)for(De.set(e,r);De.size>ja;){const s=De.keys().next().value;if(s===void 0)break;De.delete(s)}o()},r.onerror=o;const a=setTimeout(o,Ka)})}function qa(e,t,n,r,i){e.fillStyle=t.textBgColor,t.rounded?(e.beginPath(),e.roundRect(n,0,r,i,t.borderRadius),e.fill()):e.fillRect(n,0,r,i)}function ur(e,t,n,r,i){e.font=`${t.fontSize}px Microsoft YaHei, sans-serif`,e.fillStyle=t.textColor,e.textAlign="center",e.textBaseline="middle",e.fillText(n,r/2,i/2)}async function Xa(e,t,n,r,i){const o=await Ya(t.icon);return o.naturalWidth>0&&o.naturalHeight>0?(e.drawImage(o,r,i,n,n),!0):(e.fillStyle=t.color,e.fillRect(r,i,n,n),!1)}async function dr(e,t,n,r){const i=n.iconSize||32,o=sr(n.textConfig),a=cr(t,o.fontSize)+o.padding*2,s=o.fontSize+o.padding*2,c=Math.max(i,a),d=s+i,u=document.createElement("canvas");u.width=c*r,u.height=d*r;const f=u.getContext("2d");f.scale(r,r);const h=(c-a)/2;qa(f,o,h,a,s),ur(f,o,t,c,s);const p=await Xa(f,e,i,(c-i)/2,s);return{icon:u,width:c,height:d,type:"text",text:t,status:e.status,color:e.color,degraded:!p}}function Za(e,t,n){const r=n.iconSize||32,i=sr(n.textConfig),o=cr(t,i.fontSize)+i.padding*2,a=i.fontSize+i.padding*2,s=Math.max(r,o),c=a+r,d=document.createElement("canvas");d.width=s,d.height=c;const u=d.getContext("2d");return u.fillStyle=i.textBgColor,u.fillRect(0,0,s,a),ur(u,i,t,s,a),u.fillStyle=e.color,u.fillRect((s-r)/2,a,r,r),{icon:d,width:s,height:c,type:"text",text:t,status:e.status,color:e.color}}const Ja="color_svg";function fr(e,t){return t===void 0?`${e}_no_text`:t===""?`${e}_empty_text`:`${e}_text_${t}`}function hr(e){return`${Ja}_${e}`}function yt(e){return G[e]?.color||G.default.color}const wt=25,Qa=8;function el(){return typeof MessageChannel<"u"?new Promise(e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(0)}):new Promise(e=>setTimeout(e,0))}async function vt(e){return performance.now()-e>=Qa?(await el(),performance.now()):e}async function tl(e,t){const n=new Map,r=new Map;t.forEach(i=>{const o=r.get(i.status)||[];o.push(i),r.set(i.status,o)});for(const[,i]of r){let o=performance.now();for(let a=0;a<i.length;a+=wt){const s=i.slice(a,a+wt);await Promise.all(s.map(async c=>{const d=c.id?.toString()??String(c.text??"");try{n.set(d,await e(c.status,c.text))}catch{n.set(d,await e(c.status))}})),a+wt<i.length&&(o=await vt(o))}}return n}async function nl(e,t){const n=Array.isArray(e)?e:[];if(n.length===0)return[];const r=new Array(n.length),i=new Map,o=new Map;for(let u=0;u<n.length;u++){const f=n[u],h=t.resolveColor(f),p=t.resolveBaseSvg(f),b=f.showName&&f.name?String(f.name).trim():"",C=`${p}${h}${b}`;r[u]=C,b?o.has(C)||o.set(C,{key:C,color:h,text:b,svg:p}):i.has(C)||i.set(C,{key:C,color:h,svg:p})}const a=new Map;let s=performance.now();for(const u of i.values()){const f=await t.createBaseIconBySvg(u.svg,u.color);f&&a.set(u.key,{icon:f.icon,width:f.width,height:f.height,type:f.type,text:f.text}),s=await vt(s)}let c=0;const d=[];for(const u of o.values()){const f=t.peekTextIconBySvg(u.svg,u.color,u.text);f?(c++,a.set(u.key,f)):d.push(u)}t.onBatchStats?.({uniqueText:o.size,textHits:c,textGenerated:d.length}),s=performance.now();for(const u of d)a.set(u.key,await t.createTextIconBySvg(u.svg,u.color,u.text)),s=await vt(s);for(let u=0;u<n.length;u++){const f=a.get(r[u]);if(!f)continue;const h=n[u];h.icon=f.icon,h.width=f.width,h.height=f.height}return n}function rl(e,t){const n=JSON.stringify(G);for(const[r,i]of Object.entries(e))G[r]={color:i,text:G[r]?.text||G.default.text};n!==JSON.stringify(G)&&t()}function il(){const e={default:G.default.color};for(const[t,n]of Object.entries(G))t!=="default"&&(e[t]=n.color);return e}const ol="color:";function gr(e){return`${ol}${e}`}class K{constructor(){this.maxIconCache=K.DEFAULT_MAX_ICON_CACHE,this.activeTasks=0,this.iconCache=new Map,this.colorCache=new Map,this.baseSvgCache=new Map,this.svgKeys=new Map,this.svgCount=0,this.compositeCache=new Map,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.rawSvg="",this.defaultConfig={iconSize:32}}static{this.DEFAULT_MAX_ICON_CACHE=8e3}static{this.TASK_MAX_ICON_CACHE=5e4}static{this.COMPOSITE_CACHE_CAP=2e4}get effectiveCacheLimit(){return this.activeTasks>0?K.TASK_MAX_ICON_CACHE:this.maxIconCache}touchCache(t){const n=this.iconCache.get(t);n&&(this.iconCache.delete(t),this.iconCache.set(t,n))}evictCacheIfNeeded(){for(;this.iconCache.size>this.effectiveCacheLimit;){const t=this.iconCache.keys().next().value;if(t===void 0)break;this.iconCache.delete(t)}}static getInstance(){return K.instance||(K.instance=new K),K.instance}beginIconTask(){this.activeTasks++}endIconTask(){this.activeTasks>0&&this.activeTasks--,this.activeTasks===0&&(this.evictCacheIfNeeded(),this.evictCompositeCacheIfNeeded())}resolveSvgKey(t){const n=this.svgKeys.get(t);if(n)return n;const r=`svg#${this.svgCount++}`;return this.svgKeys.set(t,r),r}initialize(t,n){this.rawSvg=t,n&&(this.defaultConfig=n),n?.maxIconCache&&n.maxIconCache>0&&(this.maxIconCache=n.maxIconCache),this.preGenerateBaseColors()}preGenerateBaseColors(){if(this.colorCache.size>0||!this.rawSvg)return;new Set([...Object.keys(G),"default"]).forEach(n=>this.ensureColoredSvg(n,yt(n)))}ensureColoredSvg(t,n){const r=hr(t);return this.colorCache.has(r)||this.colorCache.set(r,this.buildColoredSvg(n)),this.colorCache.get(r)}buildColoredSvg(t){const n=this.defaultConfig.iconSize||32;try{return or(this.rawSvg,t)}catch{return ar(t,n)}}normalizeText(t){const n=t?.trim();return n===""?"":n}buildBaseIcon(t,n){const i=`${this.resolveSvgKey(t||this.rawSvg)}${n}`,o=this.baseSvgCache.get(i);if(o)return o;const a=this.defaultConfig.iconSize||32,s=t||this.rawSvg;let c;try{c=lr(or(s,n))}catch{c=lr(ar(n,a))}const d={icon:c,width:a,height:a,type:"base",status:gr(n),color:n};return this.baseSvgCache.set(i,d),d}createBaseIconCore(t,n){return this.buildBaseIcon(this.rawSvg,n)}createBaseIconBySvg(t,n){return this.buildBaseIcon(t,n)}compositeKey(t,n,r){return`${this.resolveSvgKey(t||this.rawSvg)}${n}${r}`}peekTextIconBySvg(t,n,r){const i=this.compositeCache.get(this.compositeKey(t,n,r));if(i)return{icon:i.icon,width:i.width,height:i.height,type:i.type,text:i.text}}async createTextIconBySvg(t,n,r){const i=this.compositeKey(t,n,r),o=this.compositeCache.get(i);if(o)return{icon:o.icon,width:o.width,height:o.height,type:o.type,text:o.text};const a=this.buildBaseIcon(t,n),s=this.normalizeText(r)??"",c=await dr(a,s,this.defaultConfig,this.dpr),d={icon:c.icon,width:c.width,height:c.height,type:c.type,text:c.text};return c.degraded||(this.compositeCache.set(i,{...c,text:s,status:a.status}),this.activeTasks===0&&this.evictCompositeCacheIfNeeded()),d}evictCompositeCacheIfNeeded(){for(;this.compositeCache.size>K.COMPOSITE_CACHE_CAP;){const t=this.compositeCache.keys().next().value;if(t===void 0)break;this.compositeCache.delete(t)}}matchCache(t,n,r){return t.status===n&&t.text===r}async createIcon(t,n){return this.createIconCore(t,yt(t),n)}async createIconByColor(t,n){return this.createIconCore(gr(t),t,n)}async createIconCore(t,n,r){const i=this.normalizeText(r),o=fr(t,i),a=this.iconCache.get(o);if(a&&this.matchCache(a,t,i))return this.touchCache(o),{icon:a.icon,width:a.width,height:a.height,type:a.type,text:a.text};const s=await this.createBaseIconCore(t,n),c=i?await dr(s,i,this.defaultConfig,this.dpr):s;return c.degraded||(this.iconCache.set(o,{...c,text:i,status:t}),this.evictCacheIfNeeded()),{icon:c.icon,width:c.width,height:c.height,type:c.type,text:c.text}}batchCreateIcons(t){return tl(this.createIcon.bind(this),t)}batchCreatePointIcons(t){const n={resolveColor:r=>r.color||yt(r.status??"default"),resolveBaseSvg:r=>r.svg||this.rawSvg,createBaseIconBySvg:(r,i)=>Promise.resolve(this.buildBaseIcon(r,i)),createTextIconBySvg:(r,i,o)=>this.createTextIconBySvg(r,i,o),peekTextIconBySvg:(r,i,o)=>this.peekTextIconBySvg(r,i,o),iconSize:this.defaultConfig.iconSize||32,textConfig:this.defaultConfig.textConfig,dpr:this.dpr,onBatchStats:r=>{this.runtimeStats.textHits+=r.textHits,this.runtimeStats.textGenerated+=r.textGenerated,this.runtimeStats.uniqueText+=r.uniqueText}};return nl(t,n)}async createConditionalIcon(t,n){const r=n();return this.createIcon(t,r||void 0)}getIconHeightInfo(){const t=this.defaultConfig.iconSize||32,n=this.defaultConfig.textConfig||{},r=(n.fontSize??12)+(n.padding??0)*2;return{iconHeight:t,textHeight:r,totalHeight:t+r}}clearCache(){this.iconCache.clear(),this.colorCache.clear(),this.baseSvgCache.clear(),this.compositeCache.clear(),this.svgKeys.clear(),this.svgCount=0,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.preGenerateBaseColors()}clearCacheByStatus(t){for(const n of[...this.iconCache.keys()])n.startsWith(`${t}_`)&&this.iconCache.delete(n);this.colorCache.delete(hr(t))}clearTextIconCache(t,n){this.iconCache.delete(fr(t,n))}getCacheStats(){return{iconCache:this.iconCache.size,colorCache:this.colorCache.size,baseSvg:this.baseSvgCache.size,composite:this.compositeCache.size,total:this.iconCache.size+this.colorCache.size+this.baseSvgCache.size+this.compositeCache.size}}getRuntimeStats(){return{...this.runtimeStats}}getConfig(){return{...this.defaultConfig}}updateStatusColorMap(t){rl(t,()=>this.clearCache())}getStatusColorMap(){return il()}buildFallbackTextIcon(t,n){return Za(t,n,this.defaultConfig)}}const al=K.getInstance();function ll(e){const t=e?.type,n=e?.data;if(t==="circle"&&Array.isArray(n?.center)&&n.center.length>=2)return{type:"circle",center:[n.center[0],n.center[1]],radius:Math.abs(Number(n.radius)||0)};if((t==="polygon"||t==="rectangle"||t==="triangle")&&Array.isArray(n?.path)&&n.path.length>=3){const r=n.path.map(i=>Array.isArray(i)&&i.length>=2?[Number(i[0]),Number(i[1])]:i&&typeof i.lng=="number"&&typeof i.lat=="number"?[i.lng,i.lat]:null).filter(i=>i!==null);if(r.length>=3)return{type:t,coordinates:r}}return null}var pr=(e=>(e.INIT_FAILED="INIT_FAILED",e.LOAD_SCRIPT_FAILED="LOAD_SCRIPT_FAILED",e.INVALID_PARAMS="INVALID_PARAMS",e.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",e.OPERATION_FAILED="OPERATION_FAILED",e))(pr||{});class sl extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="MapError"}}g.ANIMATION_DURATION=ke,g.AppButton=Wa,g.AppIcon=H,g.AppInput=Xn,g.AppSpinner=gt,g.CAMERA_CONFIG=_e,g.ConfigManager=zt,g.DEFAULT_CONTOUR_CONFIG=_t,g.DEFAULT_KML_CONFIG=Vt,g.DEFAULT_LIBS_URL=pe,g.DEFAULT_MAP_CONFIG=Je,g.DEFAULT_MASK_CONFIG=Pt,g.DEFAULT_POSITION=se,g.DEFAULT_TOOLS=Ze,g.DEFAULT_TRAJECTORY_CONFIG=kt,g.ErrorCode=pr,g.EventBus=Xe,g.GEOMETRY_CONFIG=q,g.GameLoading=ft,g.ICON_MAP=ht,g.IconManager=K,g.KmlError=F,g.KmlErrorCode=z,g.LIBRARIES=et,g.MORPH_3D_DELAY=Bt,g.MapContainer=Ga,g.MapControls=Qn,g.MapError=qn,g.MapErrorClass=sl,g.MapManager=ne,g.MapStatus=nr,g.MapTools=Jn,g.MapView=rr,g.NoResultsPanel=pt,g.PERFORMANCE_CONFIG=ce,g.READY_DELAY=Rt,g.ResourceManager=Ut,g.STATUS_COLOR_MAP=G,g.ScriptLoader=Gt,g.SearchResultsPanel=Zn,g.WAVE_REMOVE_DELAY=Ft,g.buildGeoServerWmtsUrl=zn,g.cartesianFromCoord=pi,g.cartesianToDegrees=Re,g.cartographicToDegrees=ln,g.closeCoordinates=nt,g.createGeoServerWmtsProvider=Un,g.createSearchShapeFromDrawEvent=ll,g.eventBus=Er,g.getBmgl=M,g.getDefaultToolbarEntries=At,g.getDefaultTools=xt,g.getDrawToolEntries=Lt,g.getDrawToolEntry=It,g.getEntityType=an,g.getLogLevel=br,g.getStatusInfo=xr,g.getSvg=Yn,g.iconManager=al,g.isIconName=jn,g.logger=y,g.mapManager=ye,g.normalizeContourConfig=Sn,g.normalizeKmlConfig=$e,g.normalizeMaskConfig=ze,g.normalizeTrajectoryConfig=lt,g.rectangleToPath=rt,g.registerDrawTool=Tr,g.resolveUrl=tt,g.scriptLoader=Ve,g.setBmgl=Wt,g.setLogLevel=Cr,g.useMap=Zt,g.useMapCircleWave=wn,g.useMapContour=Dn,g.useMapDraw=pn,g.useMapEntity=un,g.useMapKml=Rn,g.useMapLayers=En,g.useMapLighting=On,g.useMapMask=Ln,g.useMapPoint=on,g.useMapPopup=yn,g.useMapTrajectory=Mn,g.useMapView=Kn,g.useMapWeather=Fn,g.waitForBmgl=Ht,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));