bigmap-plugin 1.0.7 → 1.0.8

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,4 +1,4 @@
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,me=new Map;function ee(e){me.set(e.type,e)}ee({type:"area",name:"测面积",defaultSize:15,icon:"area",toolbarOrder:4,buildConfig:({shared:e})=>({material:e.fill,labelOptions:e.label})}),ee({type:"polygon",name:"绘制多边形",defaultSize:14,icon:"polygon",toolbarOrder:1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})}),ee({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}}})}),ee({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}})}),ee({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})}),ee({type:"polyline",name:"绘制线",defaultSize:16,icon:"polyline",toolbarOrder:3,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill})}),ee({type:"triangle",name:"绘制三角形",defaultSize:16,icon:"triangle",inDefaultToolbar:!1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:4,material:t.fill})}),ee({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){me.set(e.type,e)}function It(e){return me.get(e)}function Lt(){return[...me.values()]}function At(){return[...me.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 ye="/libs",ue={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},de={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:1,maxLabels:50,labelMinDistance:140,labelOutlineWidth:3,sampleStep:80,scanStep:120,viewportMargin:48,legendColorStep:500,refreshOnMove:!0},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:ye,mapType:"3d",position:ue,mapId:"bigemap.cebjohn0",terrainId:"bigemap.dc-terrain",baseLayers:Nt,showSearch:!1,showControls:!0,showStatus:!1,showDeleteControls:!0,tools:Ze,searchDebounceTime:de.DEBOUNCE_DELAY},J={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,W={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=>W[e]||W.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=ye,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 we=null;function Wt(e){we=e}function A(){return we||(typeof window<"u"&&window.bmgl?(we=window.bmgl,we):null)}function B(){const e=A();if(!e)throw new Error("bmgl 库未就绪:请确保地图初始化完成后再调用该能力");return e}async function Ht(e=3e3){const t=A();return t||new Promise((n,r)=>{const i=Date.now(),o=setInterval(()=>{const a=A();a?(clearInterval(o),n(a)):Date.now()-i>e&&(clearInterval(o),r(new Error("bmgl 加载超时")))},50)})}class re{constructor(){this.entries=new Map}static getInstance(){return re.instance||(re.instance=new re),re.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 ve=re.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=A();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=A(),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(ve.has(n))try{await ve.unregister(n)}catch(r){y.warn(`[registerMap] 清理残留地图实例失败 (${n}):`,r)}ve.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=A();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=A();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=A();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 ve.unregister(t)}catch(n){y.error("[useMap] 销毁地图失败:",n)}}function Xt(e,t,n){const r=A();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=A();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=A();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)*J.METERS_PER_DEGREE_LAT_APPROX,c=(i.maxy-i.miny)*J.METERS_PER_DEGREE_LAT_APPROX,d=Math.max(s,c),u=t.Math.toRadians(J.CAMERA_FOV_DEGREES),f=Math.max(d/(2*Math.tan(u/2)),J.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/(J.METERS_PER_DEGREE_LAT*Math.cos(n*Math.PI/180)),i=e.radius/J.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)*J.METERS_PER_DEGREE_LAT*Math.cos(r*Math.PI/180),a=(e.lat-r)*J.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(de.GRID_SIZE),n=async()=>{if(!t.billboardCollection&&e.value){const d=A();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(m){y.warn("[useMapPoint] 移除旧 billboard 失败:",m)}return t.billboardMap.delete(d),en(t,f),u},o=(d,u,f,h)=>{const m=parseFloat(u[f.fieldMapping.lng])||0,E=parseFloat(u[f.fieldMapping.lat])||0,v=parseFloat(u[f.fieldMapping.altitude])||0,p=d.Cartesian3.fromDegrees(m,E,v),b=t.billboardCollection.add({position:p,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 b.pointData=u,{billboard:b,position:p,lng:m,lat:E,altitude:v}},a=async(d,u,f,h="append")=>{try{if(h==="replace"&&r(),!await n())return;const E=A();if(!E)return;const v={width:u?.width||20,height:u?.height||20,fieldMapping:{...di,...u?.fieldMapping||{}}},p=performance.now();t.gridIndex||(t.gridIndex=new Map);const b=Array.isArray(d)?d:[],w=b.length,S=de.BATCH_SIZE,k=de.YIELD_BUDGET_MS;let D=performance.now(),_=0;for(let T=0;T<w;T+=S){const L=b.slice(T,T+S);for(const P of L){if(!P.icon){_+=1,rn||(rn=!0,y.warn("[useMapPoint] 检测到缺失 icon 的点位,已跳过渲染;请在数据层通过 iconManager 预生成 icon 后传入"));continue}const N=P[v.fieldMapping.id],C=N!=null&&N!==""?String(N):fi(),x=i(C),{billboard:M,position:H,lng:G,lat:j,altitude:ae}=o(E,P,v,C);t.billboardMap.set(C,M);const ne={...P,id:C,lng:G,lat:j,altitude:ae,icon:P.icon};x!==void 0?t.pointDataCache[x]=ne:(t.cacheIdIndex.set(C,t.pointDataCache.length),t.pointDataCache.push(ne)),Qt(t,ne)}T+S<w&&performance.now()-D>=k&&(await hi(),D=performance.now())}_>0&&y.warn(`[useMapPoint] 本次加载跳过 ${_} 个缺失 icon 的点位`),console.log(`[useMapPoint] ${h} ${b.length} 个点位 billboard 渲染耗时:${(performance.now()-p).toFixed(0)}ms`)}catch(m){throw y.error("加载点位失败:",m),m}},s=async d=>{const u=A();for(const f of d){const h=String(f.id),m=t.billboardMap.get(h);if(m){if(f.icon&&(m.image=f.icon),f.width!==void 0&&(m.width=f.width),f.height!==void 0&&(m.height=f.height),u&&f.lng!==void 0&&f.lat!==void 0){const E=u.Cartesian3.fromDegrees(Number(f.lng),Number(f.lat),Number(f.altitude??0));m.position=E;const v=t.cacheIdIndex.get(h);if(v!==void 0){const p=t.pointDataCache[v];en(t,p),p.lng=Number(f.lng),p.lat=Number(f.lat),f.altitude!==void 0&&(p.altitude=Number(f.altitude)),Qt(t,p)}}if(f.name!==void 0){const E=t.cacheIdIndex.get(h);E!==void 0&&(t.pointDataCache[E].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=A();return n?n.Cartesian3.fromDegrees(e.lng,e.lat,t):null}function ln(e){const t=A();return t?{lng:t.Math.toDegrees(e.longitude),lat:t.Math.toDegrees(e.latitude)}:null}function Re(e){const t=A();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 Ce={fillColor:"#ff0000",strokeColor:"#00ff00",lineColor:"#3366ff",strokeWidth:3,fillAlpha:.1,strokeAlpha:1,pointColor:"#ff0000",pixelSize:10,radius:1e3};function U(e,t){return B().Color.fromCssColorString(e).withAlpha(t)}function sn(e){const t=B();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=B(),r=Ce;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=B(),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:U(e.strokeColor??r.lineColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}})}}function wi(e){const t=B(),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: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=B(),r=Ce;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=B(),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:U(e.pointColor??n.pointColor,1),heightReference:t.HeightReference.CLAMP_TO_GROUND}}),point:[e.point.lng,e.point.lat]}}function bi(e){const t=B();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=B(),{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=B(),{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=B(),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=B(),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=B(),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:m,coordinates:E}=cn(u.type,u,f),v={id:h,type:u.type,options:{...u,id:h,type:u.type,visible:u.visible!==!1},nativeEntity:m,coordinates:E};return t.set(h,v),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(m=>Be(m,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 m=e.value;return m?f.type&&f.type!==h.type?await ki(u,h,f,m,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(m){y.warn(`重绘实体失败 (${f}):`,m)}};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 be={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={...be,...t},this.config.fillAlpha=Oe(this.config.fillAlpha,0,1,be.fillAlpha),this.config.borderAlpha=Oe(this.config.borderAlpha,0,1,be.borderAlpha),this.config.lineWidth=Oe(this.config.lineWidth,1,50,be.lineWidth),this.config.arrowWidth=Oe(this.config.arrowWidth,1,100,be.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=B(),{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=B();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=B();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 Ee(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 ie(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),ie(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&&Ee(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 oe(e){e.isEditing&&Ee(e,!1),Ki(e),ji(e)}function Yi(e,t=""){if(!e.mapInstance)return;const n=t||e.currentDrawId;if(e.isEditing&&Ee(e,!1),!n){oe(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),ie(e,{type:i.type,operation:"delete",id:n,data:i,rawData:o})}}oe(e)}function qi(e){if(!e.mapInstance)return;e.isEditing&&Ee(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";ie(e,{type:n,operation:"clear",data:null,rawData:null,count:t}),oe(e)}class Q{static process(t){if(!t?.type)return null;try{const n=Q.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:Q.processRectangle,polygon:Q.processPolygon,circle:Q.processCircle,triangle:Q.processTriangle,polyline:Q.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){ie(e,{type:Ui(n),operation:"select",id:t,data:{id:t},rawData:n})}function Zi(e){if($i(e)){Ee(e,!0);return}e.isDrawing&&e.currentDrawType&&ie(e,{type:e.currentDrawType,operation:"cancel",id:e.currentDrawId,data:null,rawData:null}),oe(e)}function Ji(e,t){if(!e.mapInstance)return;const n=B(),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=B(),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=Q.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};ie(e,r),oe(e)}function to(e,t){e.isEditing=!1;const n=Q.process(t.detail);if(!n){e.lastEditedEntity=null;return}const r={type:n.type,operation:"edit",id:n.id,data:n,rawData:t.detail};ie(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=B(),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(!A())throw new Error("BMGL 库未加载");if(e.mapHandler=e.mapInstance.screenSpaceEventHandler,!e.mapHandler)throw new Error("地图事件处理器不可用");const r=B(),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{oe(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:()=>oe(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 Te(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 fe(e,t){return typeof e=="number"&&!Number.isNaN(e)?e.toFixed(t):"-"}function lo(e){return W[e||"default"]||W.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=>Te(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,me=new Map;function ee(e){me.set(e.type,e)}ee({type:"area",name:"测面积",defaultSize:15,icon:"area",toolbarOrder:4,buildConfig:({shared:e})=>({material:e.fill,labelOptions:e.label})}),ee({type:"polygon",name:"绘制多边形",defaultSize:14,icon:"polygon",toolbarOrder:1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})}),ee({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}}})}),ee({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}})}),ee({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})}),ee({type:"polyline",name:"绘制线",defaultSize:16,icon:"polyline",toolbarOrder:3,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill})}),ee({type:"triangle",name:"绘制三角形",defaultSize:16,icon:"triangle",inDefaultToolbar:!1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:4,material:t.fill})}),ee({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){me.set(e.type,e)}function It(e){return me.get(e)}function Lt(){return[...me.values()]}function At(){return[...me.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 ye="/libs",ue={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},de={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:1,maxLabels:50,labelMinDistance:140,labelOutlineWidth:3,sampleStep:80,scanStep:120,viewportMargin:48,legendColorStep:500,refreshOnMove:!0},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:ye,mapType:"3d",position:ue,mapId:"bigemap.cebjohn0",terrainId:"bigemap.dc-terrain",baseLayers:Nt,showSearch:!1,showControls:!0,showStatus:!1,showDeleteControls:!0,tools:Ze,searchDebounceTime:de.DEBOUNCE_DELAY},J={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,W={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=>W[e]||W.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=ye,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 we=null;function Wt(e){we=e}function x(){return we||(typeof window<"u"&&window.bmgl?(we=window.bmgl,we):null)}function B(){const e=x();if(!e)throw new Error("bmgl 库未就绪:请确保地图初始化完成后再调用该能力");return e}async function Ht(e=3e3){const t=x();return t||new Promise((n,r)=>{const i=Date.now(),o=setInterval(()=>{const a=x();a?(clearInterval(o),n(a)):Date.now()-i>e&&(clearInterval(o),r(new Error("bmgl 加载超时")))},50)})}class re{constructor(){this.entries=new Map}static getInstance(){return re.instance||(re.instance=new re),re.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 ve=re.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=x();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=x(),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(ve.has(n))try{await ve.unregister(n)}catch(r){y.warn(`[registerMap] 清理残留地图实例失败 (${n}):`,r)}ve.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=x();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=x();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=x();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 ve.unregister(t)}catch(n){y.error("[useMap] 销毁地图失败:",n)}}function Xt(e,t,n){const r=x();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=x();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=x();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)*J.METERS_PER_DEGREE_LAT_APPROX,c=(i.maxy-i.miny)*J.METERS_PER_DEGREE_LAT_APPROX,d=Math.max(s,c),u=t.Math.toRadians(J.CAMERA_FOV_DEGREES),f=Math.max(d/(2*Math.tan(u/2)),J.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/(J.METERS_PER_DEGREE_LAT*Math.cos(n*Math.PI/180)),i=e.radius/J.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)*J.METERS_PER_DEGREE_LAT*Math.cos(r*Math.PI/180),a=(e.lat-r)*J.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(de.GRID_SIZE),n=async()=>{if(!t.billboardCollection&&e.value){const d=x();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(m){y.warn("[useMapPoint] 移除旧 billboard 失败:",m)}return t.billboardMap.delete(d),en(t,f),u},o=(d,u,f,h)=>{const m=parseFloat(u[f.fieldMapping.lng])||0,E=parseFloat(u[f.fieldMapping.lat])||0,v=parseFloat(u[f.fieldMapping.altitude])||0,p=d.Cartesian3.fromDegrees(m,E,v),C=t.billboardCollection.add({position:p,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 C.pointData=u,{billboard:C,position:p,lng:m,lat:E,altitude:v}},a=async(d,u,f,h="append")=>{try{if(h==="replace"&&r(),!await n())return;const E=x();if(!E)return;const v={width:u?.width||20,height:u?.height||20,fieldMapping:{...di,...u?.fieldMapping||{}}},p=performance.now();t.gridIndex||(t.gridIndex=new Map);const C=Array.isArray(d)?d:[],w=C.length,S=de.BATCH_SIZE,k=de.YIELD_BUDGET_MS;let D=performance.now(),_=0;for(let T=0;T<w;T+=S){const L=C.slice(T,T+S);for(const P of L){if(!P.icon){_+=1,rn||(rn=!0,y.warn("[useMapPoint] 检测到缺失 icon 的点位,已跳过渲染;请在数据层通过 iconManager 预生成 icon 后传入"));continue}const N=P[v.fieldMapping.id],b=N!=null&&N!==""?String(N):fi(),A=i(b),{billboard:M,position:H,lng:G,lat:K,altitude:ae}=o(E,P,v,b);t.billboardMap.set(b,M);const ne={...P,id:b,lng:G,lat:K,altitude:ae,icon:P.icon};A!==void 0?t.pointDataCache[A]=ne:(t.cacheIdIndex.set(b,t.pointDataCache.length),t.pointDataCache.push(ne)),Qt(t,ne)}T+S<w&&performance.now()-D>=k&&(await hi(),D=performance.now())}_>0&&y.warn(`[useMapPoint] 本次加载跳过 ${_} 个缺失 icon 的点位`),console.log(`[useMapPoint] ${h} ${C.length} 个点位 billboard 渲染耗时:${(performance.now()-p).toFixed(0)}ms`)}catch(m){throw y.error("加载点位失败:",m),m}},s=async d=>{const u=x();for(const f of d){const h=String(f.id),m=t.billboardMap.get(h);if(m){if(f.icon&&(m.image=f.icon),f.width!==void 0&&(m.width=f.width),f.height!==void 0&&(m.height=f.height),u&&f.lng!==void 0&&f.lat!==void 0){const E=u.Cartesian3.fromDegrees(Number(f.lng),Number(f.lat),Number(f.altitude??0));m.position=E;const v=t.cacheIdIndex.get(h);if(v!==void 0){const p=t.pointDataCache[v];en(t,p),p.lng=Number(f.lng),p.lat=Number(f.lat),f.altitude!==void 0&&(p.altitude=Number(f.altitude)),Qt(t,p)}}if(f.name!==void 0){const E=t.cacheIdIndex.get(h);E!==void 0&&(t.pointDataCache[E].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=x();return n?n.Cartesian3.fromDegrees(e.lng,e.lat,t):null}function ln(e){const t=x();return t?{lng:t.Math.toDegrees(e.longitude),lat:t.Math.toDegrees(e.latitude)}:null}function Re(e){const t=x();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 Ce={fillColor:"#ff0000",strokeColor:"#00ff00",lineColor:"#3366ff",strokeWidth:3,fillAlpha:.1,strokeAlpha:1,pointColor:"#ff0000",pixelSize:10,radius:1e3};function U(e,t){return B().Color.fromCssColorString(e).withAlpha(t)}function sn(e){const t=B();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=B(),r=Ce;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=B(),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:U(e.strokeColor??r.lineColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}})}}function wi(e){const t=B(),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: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=B(),r=Ce;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=B(),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:U(e.pointColor??n.pointColor,1),heightReference:t.HeightReference.CLAMP_TO_GROUND}}),point:[e.point.lng,e.point.lat]}}function bi(e){const t=B();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=B(),{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=B(),{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=B(),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=B(),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=B(),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:m,coordinates:E}=cn(u.type,u,f),v={id:h,type:u.type,options:{...u,id:h,type:u.type,visible:u.visible!==!1},nativeEntity:m,coordinates:E};return t.set(h,v),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(m=>Be(m,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 m=e.value;return m?f.type&&f.type!==h.type?await ki(u,h,f,m,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(m){y.warn(`重绘实体失败 (${f}):`,m)}};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 be={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={...be,...t},this.config.fillAlpha=Oe(this.config.fillAlpha,0,1,be.fillAlpha),this.config.borderAlpha=Oe(this.config.borderAlpha,0,1,be.borderAlpha),this.config.lineWidth=Oe(this.config.lineWidth,1,50,be.lineWidth),this.config.arrowWidth=Oe(this.config.arrowWidth,1,100,be.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=B(),{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=B();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=B();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 Ee(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 ie(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),ie(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&&Ee(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 oe(e){e.isEditing&&Ee(e,!1),Ki(e),ji(e)}function Yi(e,t=""){if(!e.mapInstance)return;const n=t||e.currentDrawId;if(e.isEditing&&Ee(e,!1),!n){oe(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),ie(e,{type:i.type,operation:"delete",id:n,data:i,rawData:o})}}oe(e)}function qi(e){if(!e.mapInstance)return;e.isEditing&&Ee(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";ie(e,{type:n,operation:"clear",data:null,rawData:null,count:t}),oe(e)}class Q{static process(t){if(!t?.type)return null;try{const n=Q.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:Q.processRectangle,polygon:Q.processPolygon,circle:Q.processCircle,triangle:Q.processTriangle,polyline:Q.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){ie(e,{type:Ui(n),operation:"select",id:t,data:{id:t},rawData:n})}function Zi(e){if($i(e)){Ee(e,!0);return}e.isDrawing&&e.currentDrawType&&ie(e,{type:e.currentDrawType,operation:"cancel",id:e.currentDrawId,data:null,rawData:null}),oe(e)}function Ji(e,t){if(!e.mapInstance)return;const n=B(),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=B(),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=Q.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};ie(e,r),oe(e)}function to(e,t){e.isEditing=!1;const n=Q.process(t.detail);if(!n){e.lastEditedEntity=null;return}const r={type:n.type,operation:"edit",id:n.id,data:n,rawData:t.detail};ie(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=B(),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(!x())throw new Error("BMGL 库未加载");if(e.mapHandler=e.mapInstance.screenSpaceEventHandler,!e.mapHandler)throw new Error("地图事件处理器不可用");const r=B(),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{oe(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:()=>oe(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 Te(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 fe(e,t){return typeof e=="number"&&!Number.isNaN(e)?e.toFixed(t):"-"}function lo(e){return W[e||"default"]||W.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=>Te(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
4
  <h3>${Te(e.name||"点位信息")}</h3>
@@ -15,7 +15,7 @@
15
15
  <div class="map-point-popup-content">
16
16
  ${a}
17
17
  </div>
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=A();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=A();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:ue.lng,lat:ot(d.lat)?d.lat:ue.lat,altitude:ot(d.altitude)?d.altitude:0};i();const m=await yo(r,e,t);if(!m)throw new Error("DivLayerManager 初始化失败");if(f!==r.popupSeq)return;r.currentPopupData={...d};const E={offsetX:0,offsetY:-20,className:"map-point-popup",...u},v=A();if(!v)throw new Error("BMGL 库未加载,无法创建弹窗");const p=new v.div.DivLayer(po(d,r.displayConfig||void 0),wo(h),{offset:{x:E.offsetX,y:E.offsetY}});r.popupLayer=p,m.addLayer(p)}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:m=100,duration:E=3e3,ttl:v=0}=d;return f.add(c,h,m,E),r.add(u),v>0&&i.set(u,setTimeout(()=>{i.delete(u),a(u)},v)),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=B();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=B();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||ye);const n=Tn();if(!n)throw new Error("彩色等高线库加载失败:未找到 BigemapElevationContourLayer");return n}function Sn(e){return{..._t,...e}}const Ao=500,xo=20,No=400,_o=1200;function ko(e){const t={};for(const[r,i]of Object.entries(e))r!=="refreshOnMove"&&i!==void 0&&(t[r]=i);const n=A();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=null,d=null,u=0,f=0,h=!1,m=!1,E=!1,v=!1;const p=()=>{o.value=a?a.getState():{...o.value,enabled:r.value}},b=async(C,x)=>{if(m)return E=!0,null;m=!0;const M=++f;try{const H=x?xo:1;for(let G=0;G<H;G++){if(v||!h||a!==C||M!==f)return null;C.clearLabels();const j=await C.loadCurrentViewLabels();if(M!==f)return null;if(p(),j.status==="terrain-loading"){await new Promise(ae=>setTimeout(ae,Ao));continue}return j.status==="success"?y.debug(`[useMapContour] 已标注 ${j.labelCount} 个高程数字`):j.status==="no-results"?y.warn("[useMapContour] 当前视区未找到可标注的等高线:请确认已开启地形,或调小 contourConfig.contourSpacing / labelEvery 以加密标注间隔"):y.warn(`[useMapContour] 高程数字未加载(${j.status})`),j}return y.warn("[useMapContour] 地形长时间未就绪,已放弃自动标注高程数字"),null}finally{m=!1,E&&(E=!1,!v&&h&&a&&w())}},w=()=>{v||!i.refreshOnMove||!h||!a||(d&&clearTimeout(d),d=setTimeout(()=>{if(d=null,v||!h||!a)return;const C=_o-(Date.now()-u);if(C>0){d=setTimeout(()=>{d=null,!(v||!h||!a)&&(u=Date.now(),b(a,!0))},C);return}u=Date.now(),b(a,!0)},No))},S=C=>{if(c)return;const x=C.camera,M=C.scene?.globe,H=[];if(typeof x?.moveEnd?.addEventListener=="function"&&(x.moveEnd.addEventListener(w),H.push(()=>x.moveEnd.removeEventListener(w))),typeof M?.tileLoadProgressEvent?.addEventListener=="function"){const G=j=>{j===0&&w()};M.tileLoadProgressEvent.addEventListener(G),H.push(()=>M.tileLoadProgressEvent.removeEventListener(G))}c=()=>H.forEach(G=>G())},k=async()=>{if(a)return a;if(s)return s;const C=e.value;return C?.scene?.globe?(s=(async()=>{try{const x=await Lo(n);if(v)return null;const M=new x(C,ko(i));return a=M,M.setVisible(r.value),h=r.value,S(C),M}catch(x){return y.error("[useMapContour] 彩色等高线库加载失败:",x),null}finally{s=null}})(),s):null},D=async C=>{if(r.value=!!C,!r.value){h=!1,a?.hide(),p();return}const x=await k();if(!x){r.value=!1,h=!1,p();return}h=!0,p(),b(x,!0)},_=()=>{if(r.value){if(a){h=!0,a.show(),p(),w();return}D(!0)}},T=()=>{h=!1,a?.hide(),p()},L=async()=>{if(!r.value)return{status:"hidden",labelCount:0};const C=await k();if(!C)return{status:"error",labelCount:0,error:new Error("彩色等高线库未就绪")};const x=await b(C,!1);return x||{status:"busy",labelCount:C.getState().labelCount}},P=()=>{if(!a)return{status:"empty",labelCount:0};const C=a.clearLabels();return p(),C},N=()=>a?.getLegendData()??null;return l.onUnmounted(()=>{v=!0,d&&(clearTimeout(d),d=null),c?.(),c=null;try{a?.destroy()}catch(C){y.warn("[useMapContour] 释放等高线资源失败:",C)}a=null}),{contourVisible:r,contourState:o,setContourVisible:D,loadLabels:L,clearLabels:P,getLegendData:N,reapply:_,remove:T}}const Po=2e4;function Vo(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,m)=>({...h,time:typeof h.time=="number"&&Number.isFinite(h.time)?h.time:m*n}));r.sort((h,m)=>h.time-m.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):Po;let f=i;if(i.length>u){const h=Math.ceil(i.length/u);f=i.filter((E,v)=>v%h===0);const m=i[i.length-1];f[f.length-1]!==m&&f.push(m)}return{points:i,times:a,displayPoints:f,duration:d,minTime:s}}function Se(e,t){const{points:n,times:r,duration:i,minTime:o}=e,a=n.length;if(t<=r[0]){const p=n[0];return{lng:p.lng,lat:p.lat,altitude:p.altitude??0,index:0,progress:0}}if(t>=r[a-1]){const p=n[a-1];return{lng:p.lng,lat:p.lat,altitude:p.altitude??0,index:a-1,progress:1}}let s=0,c=a-1;for(;s<c;){const p=s+c+1>>1;r[p]<=t?s=p:c=p-1}const d=s,u=r[d+1]-r[d],f=u>0?(t-r[d])/u:0,h=n[d],m=n[d+1],E=h.altitude??0,v=m.altitude??0;return{lng:h.lng+(m.lng-h.lng)*f,lat:h.lat+(m.lat-h.lat)*f,altitude:E+(v-E)*f,index:d,progress:i>0?(t-o)/i:0}}function Ro(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=p=>Math.max(0,Math.min(n,p)),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()},m=p=>{o=Math.max(0,p),d()},E=p=>{i=c(p),a==="ended"&&(a="paused"),d()},v=p=>{a!=="playing"||n<=0||(i+=p*o,i>=n&&(r?i=i%n:(i=n,a="ended")),d())};return d(),{state:s,play:u,pause:f,stop:h,setSpeed:m,jumpTo:E,tick:v}}function Bo(e){const t=A();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function at(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function Fo(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 Oo(e,t,n){return new e.Entity({polyline:{positions:[],width:t.lineWidth,material:at(e,t.markerColor,.9),clampToGround:n}})}function zo(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 Uo(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},zo(i,t),i}function $o(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function lt(e){return{...kt,...e}}const Go=100,Wo=.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,m=0,E=0;const v=()=>{const I=e.value;return I&&I.entities?I:null},p=()=>{h!==null&&(cancelAnimationFrame(h),h=null)},b=()=>{const I=v();I&&(c&&I.entities.remove(c),d&&I.entities.remove(d),u&&I.entities.remove(u)),c=null,d=null,u=null,f=null},w=()=>{a&&(r.value={...a.state})},S=I=>{if(!f)return;const R=A();R&&f.setValue(R.Cartesian3.fromDegrees(I.lng,I.lat,I.altitude))},k=I=>{if(!d||!o||!a)return;const R=A();if(!R)return;const O=a.state.currentTime,X=s.trailTime>0?Math.max(0,O-s.trailTime):0,le=Se(o,o.minTime+X),se=o.points.slice(le.index,I.index+1),He=$o(R,se);He.push(R.Cartesian3.fromDegrees(I.lng,I.lat,I.altitude)),d.polyline&&(d.polyline.positions=He)},D=I=>{const R=e.value;if(!R?.camera)return;const O=A();O&&R.camera.setView({destination:O.Cartesian3.fromDegrees(I.lng,I.lat,s.followHeight),orientation:{heading:0,pitch:O.Math.toRadians(-90),roll:0}})},_=I=>{if(!a||!o||a.state.status!=="playing"){p();return}h=requestAnimationFrame(_);const R=Math.min(Math.max((I-m)/1e3,0),Wo);m=I,a.tick(R);const O=Se(o,o.minTime+a.state.currentTime);S(O),I-E>=Go&&(k(O),E=I),s.follow&&D(O),w()},T=()=>{h===null&&(m=performance.now(),E=0,h=requestAnimationFrame(_))},L=(I,R)=>{if(!o)return;const O=!Bo(I);c=Fo(R,o.displayPoints,s,O),d=Oo(R,s,O),u=Uo(R,s,O),f=u.position??null,I.entities.add(c),I.entities.add(d),I.entities.add(u);const X=Se(o,o.minTime+(a?a.state.currentTime:0));S(X),k(X)},P=(I,R)=>{const O=v(),X=A();if(!O||!X)return;Ve.loadScripts(["move-marker","bmgl-header"],n?.serverUrl,n?.libsUrl||ye).catch(se=>y.warn("[useMapTrajectory] 轨迹辅助库加载失败:",se)),s=lt({...i,...R});let le;try{le=Vo(I,s)}catch(se){y.warn("[useMapTrajectory] 轨迹数据无效:",se);return}p(),b(),o=le,a=Ro(o,s),L(O,X),w(),s.autoPlay&&N()},N=()=>{a&&(a.play(),w(),a.state.status==="playing"&&T())},C=()=>{a&&(a.pause(),p(),w())},x=()=>{if(p(),!a||!o)return;a.stop();const I=Se(o,o.minTime);S(I),k(I),w()},M=I=>{a&&(a.setSpeed(I),w())},H=I=>{if(!a||!o)return;a.jumpTo(I);const R=Se(o,o.minTime+a.state.currentTime);S(R),k(R),w()},G=()=>{p(),b(),o=null,a=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}},j=()=>{const I=v(),R=A();!I||!R||!o||!a||(b(),L(I,R))},ae=()=>{p(),b()},ne=()=>{p(),b(),o=null,a=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}};return l.onUnmounted(()=>{ne()}),{state:r,load:P,play:N,pause:C,stop:x,setSpeed:M,jumpTo:H,clear:G,reapply:j,remove:ae,destroy:ne}}function Ho(e){const t=A();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function Ko(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 jo(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 Yo(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,S)=>{if(!i)return;const k=!Ho(w),D=r.outerRing??Ko(i);o=jo(S,D,i,r,k),a=r.showOutline?Yo(S,i,r,k):null,w.entities.add(o),a&&w.entities.add(a)},f=()=>{const w=c(),S=A();!w||!S||!i||(d(),u(w,S))},h=()=>{const w=e.value?.scene;if(s||!w?.morphComplete)return;const S=()=>f();w.morphComplete.addEventListener(S),s=()=>w.morphComplete.removeEventListener(S)},m=(w,S)=>{const k=c(),D=A();!k||!D||!w||!w.length||(r=ze({...t,...S}),i=w,d(),u(k,D),n.value={visible:!0,hasMask:!0,boundaryCount:w.length},h())},E=w=>{o&&(o.show=!!w),a&&(a.show=!!w),n.value={...n.value,visible:!!w}},v=()=>{d()},p=()=>{s&&(s(),s=null),d(),i=null,r=ze(t),n.value={visible:!1,hasMask:!1,boundaryCount:0}},b=()=>{p()};return l.onUnmounted(()=>{b()}),{state:n,setMask:m,setVisible:E,clear:p,reapply:f,remove:v,destroy:b}}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 qo(e){return e instanceof F||!!e&&typeof e=="object"&&e.name==="KmlError"&&typeof e.code=="string"}function Xo(e){if(qo(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 K(e,t){return $(e,t)?.textContent?.trim()??""}function te(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 De(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(K(n,"color"));o&&(t.lineColor=o.css,t.lineAlpha=o.alpha);const a=xn(K(n,"width"));a!==null&&(t.lineWidth=a)}const r=$(e,"PolyStyle");if(r){const o=ct(K(r,"color"));o&&(t.fillColor=o.css,t.fillAlpha=o.alpha);const a=te($(r,"fill"));a==="0"?t.fill=!1:a==="1"&&(t.fill=!0);const s=te($(r,"outline"));s==="0"?t.outline=!1:s==="1"&&(t.outline=!0)}const i=$(e,"IconStyle");if(i){const o=ct(K(i,"color"));o&&(t.iconColor=o.css);const a=xn(K(i,"scale"));a!==null&&(t.iconScale=a);const s=$(i,"Icon"),c=s?K(s,"href"):"";c&&(t.iconHref=c)}return t}function Zo(e){const t=De(e,"Pair");for(const n of t){const r=K(n,"key");if(r&&r!=="normal")continue;const i=K(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 Jo(e){const t={styles:new Map,styleMaps:new Map};for(const n of De(e,"Style")){const r=n.getAttribute("id");r&&t.styles.set(r,Nn(n))}for(const n of De(e,"StyleMap")){const r=n.getAttribute("id");if(!r)continue;const i=Zo(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 ea(e){const t=$(e,"outerBoundaryIs"),n=t?$(t,"LinearRing"):null,r=n?Ue(te($(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(te($(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(te($(e,"coordinates"))).coordinates[0];n&&t.push({type:"Point",coordinates:n});break}case"LineString":{const n=Ue(te($(e,"coordinates"))).coordinates;n.length>=2&&t.push({type:"LineString",coordinates:n});break}case"Polygon":{const n=ea(e);n&&t.push(n);break}case"MultiGeometry":{for(let n=0;n<e.children.length;n++)Pn(e.children[n],t);break}}}function ta(e){const t=$(e,"ExtendedData");if(!t)return{};const n={};for(const r of De(t,"SimpleData")){const i=r.getAttribute("name");i&&(n[i]=te(r))}for(const r of An(t,"Data")){const i=r.getAttribute("name");i&&(n[i]=K(r,"value"))}return n}function na(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:K(e,"name")||o,description:K(e,"description"),visible:K(e,"visibility")!=="0",properties:r?ta(e):{},style:Qo(K(e,"styleUrl"),a?Nn(a):null,n),geometries:i}}function ra(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 ia(e){for(const t of De(e,"Document")){const n=K(t,"name");if(n)return n}return""}function oa(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 格式错误${oa(te(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=Jo(i),a=t.extractProperties!==!1,s=ra(i).map((c,d)=>na(c,d,o,a)).filter(c=>c!==null);if(!s.length)throw new F("KML 中未解析到任何可渲染的几何要素(支持 Point/LineString/Polygon/MultiGeometry)",z.NO_FEATURES);return{name:ia(i),features:s}}const aa=["http:","https:","blob:","data:"];function la(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(!aa.includes(n.protocol))throw new F(`KML 地址无效:不支持的协议 "${n.protocol}",仅支持 http/https`,z.INVALID_URL,t);return t}async function sa(e,t=15e3){const n=la(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 ca(e){const t=A();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function he(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function ge(e,t,n){return e.Color.fromCssColorString(t).withAlpha(n)}function ua(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 da(e,t){const n=e.fillPalette;if(!(!n||!n.length))return n[(t%n.length+n.length)%n.length]}function fa(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 ha(e){let t=null,n=null,r=null;for(const i of e.geometries)if(i.type==="Polygon"){const o=fa(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 ga(e,t,n){const r=ha(t);return r?new e.Entity({name:t.name,position:he(e,[r])[0],label:{text:t.name,font:`${n.labelFontSize}px sans-serif`,fillColor:ge(e,n.labelColor,1),outlineColor:ge(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 pa(e,t,n,r,i){const o=[];return n.fill&&o.push(new e.Entity({name:r.name,polygon:{hierarchy:{positions:he(e,t.outer),holes:t.holes.map(a=>({positions:he(e,a)}))},material:ge(e,n.fillColor,n.fillAlpha)}})),n.outline&&o.push(new e.Entity({name:r.name,polyline:{positions:he(e,t.outer),width:n.lineWidth,material:ge(e,n.lineColor,n.lineAlpha),clampToGround:i}})),o}function ma(e,t,n,r,i){return new e.Entity({name:r.name,polyline:{positions:he(e,t.coordinates),width:n.lineWidth,material:ge(e,n.lineColor,n.lineAlpha),clampToGround:i}})}function ya(e,t,n,r){return new e.Entity({name:r.name,position:he(e,[t.coordinates])[0],point:{pixelSize:n.pointPixelSize,color:ge(e,n.pointColor,1),heightReference:e.HeightReference?e.HeightReference.CLAMP_TO_GROUND:void 0}})}function wa(e,t,n,r,i=0){const o=ua(t.style,n,da(n,i)),a=[];for(const s of t.geometries)a.push(...va(e,s,o,t,r));if(n.showLabel&&t.name){const s=ga(e,t,n);s&&a.push(s)}return a}function va(e,t,n,r,i){switch(t.type){case"Polygon":return pa(e,t,n,r,i);case"LineString":return[ma(e,t,n,r,i)];case"Point":return[ya(e,t,n,r)];default:return[]}}function $e(e){return{...Vt,...e}}function Me(){return{status:"idle",source:null,url:"",featureCount:0,polygonCount:0,lineCount:0,pointCount:0,visible:!1,error:null}}function Ca(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(Me());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 L of a)T.entities.remove(L.entity);a=[]},f=(T,L)=>{const P=!ca(T),N=[];o.forEach((C,x)=>{for(const M of wa(L,C,i,P,x))M.show=s&&C.visible,T.entities.add(M),N.push({entity:M,featureVisible:C.visible})}),a=N},h=()=>{const T=e.value?.scene;if(c||!T?.morphComplete)return;const L=()=>k();T.morphComplete.addEventListener(L),c=()=>T.morphComplete.removeEventListener(L)},m=()=>{const T=d();if(!T||!a.length)return;const L=a.map(P=>P.entity);try{T.flyTo?.(L.length===1?L[0]:L)}catch(P){y.warn("[useMapKml] 视角定位失败:",P)}},E=async(T,L,P)=>{const N=d(),C=A();if(!N||!C){const x=new F("地图尚未就绪:请在地图初始化完成后再加载 KML",z.MAP_NOT_READY);throw r.value={...Me(),status:"error",source:T,url:L,error:x.message},x}r.value={...Me(),status:"loading",source:T,url:L};try{o=await P(),s=!0,u(),f(N,C),h();const M=Ca(o);return r.value={status:"success",source:T,url:L,featureCount:o.length,...M,visible:!0,error:null},i.autoFlyTo&&m(),{source:T,url:L,featureCount:o.length,...M,features:o}}catch(x){const M=Xo(x);throw u(),o=[],r.value={...Me(),status:"error",source:T,url:L,error:M.message},y.warn("[useMapKml] 加载失败:",M.message),M}},v=(T,L)=>{i=$e({...n,...L});const P=typeof T=="string"?T.trim():"";return E("url",P,async()=>Vn(await sa(T,i.timeout),{extractProperties:i.extractProperties}).features)},p=(T,L)=>(i=$e({...n,...L}),E("text","",async()=>Vn(T,{extractProperties:i.extractProperties}).features)),b=()=>o,w=T=>{s=!!T;for(const L of a)L.entity.show=s&&L.featureVisible;r.value={...r.value,visible:s}},S=()=>{u()},k=()=>{const T=d(),L=A();!T||!L||!o.length||(u(),f(T,L),s&&(r.value={...r.value,visible:!0}))},D=()=>{c&&(c(),c=null),u(),o=[],s=!0,i=n,r.value=Me()},_=()=>{D()};return l.onUnmounted(()=>{_()}),{state:r,loadFromUrl:v,loadFromText:p,getFeatures:b,setVisible:w,flyTo:m,remove:S,clear:D,reapply:k,destroy:_}}function ba(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=x();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=x();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:ue.lng,lat:ot(d.lat)?d.lat:ue.lat,altitude:ot(d.altitude)?d.altitude:0};i();const m=await yo(r,e,t);if(!m)throw new Error("DivLayerManager 初始化失败");if(f!==r.popupSeq)return;r.currentPopupData={...d};const E={offsetX:0,offsetY:-20,className:"map-point-popup",...u},v=x();if(!v)throw new Error("BMGL 库未加载,无法创建弹窗");const p=new v.div.DivLayer(po(d,r.displayConfig||void 0),wo(h),{offset:{x:E.offsetX,y:E.offsetY}});r.popupLayer=p,m.addLayer(p)}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:m=100,duration:E=3e3,ttl:v=0}=d;return f.add(c,h,m,E),r.add(u),v>0&&i.set(u,setTimeout(()=>{i.delete(u),a(u)},v)),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=B();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=B();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||ye);const n=Tn();if(!n)throw new Error("彩色等高线库加载失败:未找到 BigemapElevationContourLayer");return n}function Sn(e){return{..._t,...e}}const Ao=500,xo=20,No=400,_o=1200;function ko(e){const t={};for(const[r,i]of Object.entries(e))r!=="refreshOnMove"&&i!==void 0&&(t[r]=i);const n=x();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=null,d=null,u=0,f=0,h=!1,m=!1,E=!1,v=!1;const p=()=>{o.value=a?a.getState():{...o.value,enabled:r.value}},C=async(b,A)=>{if(m)return E=!0,null;m=!0;const M=++f;try{const H=A?xo:1;for(let G=0;G<H;G++){if(v||!h||a!==b||M!==f)return null;b.clearLabels();const K=await b.loadCurrentViewLabels();if(M!==f)return null;if(p(),K.status==="terrain-loading"){await new Promise(ae=>setTimeout(ae,Ao));continue}return K.status==="success"?y.debug(`[useMapContour] 已标注 ${K.labelCount} 个高程数字`):K.status==="hidden"||(K.status==="no-results"?y.warn("[useMapContour] 当前视区未找到可标注的等高线:请确认已开启地形,或调小 contourConfig.contourSpacing / labelEvery 以加密标注间隔"):y.warn(`[useMapContour] 高程数字未加载(${K.status})`)),K}return y.warn("[useMapContour] 地形长时间未就绪,已放弃自动标注高程数字"),null}finally{m=!1,E&&(E=!1,!v&&h&&a&&w())}},w=()=>{v||!i.refreshOnMove||!h||!a||(d&&clearTimeout(d),d=setTimeout(()=>{if(d=null,v||!h||!a)return;const b=_o-(Date.now()-u);if(b>0){d=setTimeout(()=>{d=null,!(v||!h||!a)&&(u=Date.now(),C(a,!0))},b);return}u=Date.now(),C(a,!0)},No))},S=b=>{if(c)return;const A=b.camera,M=b.scene?.globe,H=[];if(typeof A?.moveEnd?.addEventListener=="function"&&(A.moveEnd.addEventListener(w),H.push(()=>A.moveEnd.removeEventListener(w))),typeof M?.tileLoadProgressEvent?.addEventListener=="function"){const G=K=>{K===0&&w()};M.tileLoadProgressEvent.addEventListener(G),H.push(()=>M.tileLoadProgressEvent.removeEventListener(G))}c=()=>H.forEach(G=>G())},k=async()=>{if(a)return a;if(s)return s;const b=e.value;return b?.scene?.globe?(s=(async()=>{try{const A=await Lo(n);if(v)return null;const M=new A(b,ko(i));return a=M,M.setVisible(r.value),h=r.value,S(b),M}catch(A){return y.error("[useMapContour] 彩色等高线库加载失败:",A),null}finally{s=null}})(),s):null},D=async b=>{if(r.value=!!b,!r.value){h=!1,a?.hide(),a?.clearLabels(),p();return}const A=await k();if(!A){r.value=!1,h=!1,p();return}h=!0,A.show(),p(),C(A,!0)},_=()=>{if(r.value){if(a){h=!0,a.show(),p(),C(a,!0);return}D(!0)}},T=()=>{h=!1,a?.hide(),a?.clearLabels(),p()},L=async()=>{if(!r.value)return{status:"hidden",labelCount:0};const b=await k();if(!b)return{status:"error",labelCount:0,error:new Error("彩色等高线库未就绪")};const A=await C(b,!1);return A||{status:"busy",labelCount:b.getState().labelCount}},P=()=>{if(!a)return{status:"empty",labelCount:0};const b=a.clearLabels();return p(),b},N=()=>a?.getLegendData()??null;return l.onUnmounted(()=>{v=!0,d&&(clearTimeout(d),d=null),c?.(),c=null;try{a?.destroy()}catch(b){y.warn("[useMapContour] 释放等高线资源失败:",b)}a=null}),{contourVisible:r,contourState:o,setContourVisible:D,loadLabels:L,clearLabels:P,getLegendData:N,reapply:_,remove:T}}const Po=2e4;function Vo(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,m)=>({...h,time:typeof h.time=="number"&&Number.isFinite(h.time)?h.time:m*n}));r.sort((h,m)=>h.time-m.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):Po;let f=i;if(i.length>u){const h=Math.ceil(i.length/u);f=i.filter((E,v)=>v%h===0);const m=i[i.length-1];f[f.length-1]!==m&&f.push(m)}return{points:i,times:a,displayPoints:f,duration:d,minTime:s}}function Se(e,t){const{points:n,times:r,duration:i,minTime:o}=e,a=n.length;if(t<=r[0]){const p=n[0];return{lng:p.lng,lat:p.lat,altitude:p.altitude??0,index:0,progress:0}}if(t>=r[a-1]){const p=n[a-1];return{lng:p.lng,lat:p.lat,altitude:p.altitude??0,index:a-1,progress:1}}let s=0,c=a-1;for(;s<c;){const p=s+c+1>>1;r[p]<=t?s=p:c=p-1}const d=s,u=r[d+1]-r[d],f=u>0?(t-r[d])/u:0,h=n[d],m=n[d+1],E=h.altitude??0,v=m.altitude??0;return{lng:h.lng+(m.lng-h.lng)*f,lat:h.lat+(m.lat-h.lat)*f,altitude:E+(v-E)*f,index:d,progress:i>0?(t-o)/i:0}}function Ro(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=p=>Math.max(0,Math.min(n,p)),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()},m=p=>{o=Math.max(0,p),d()},E=p=>{i=c(p),a==="ended"&&(a="paused"),d()},v=p=>{a!=="playing"||n<=0||(i+=p*o,i>=n&&(r?i=i%n:(i=n,a="ended")),d())};return d(),{state:s,play:u,pause:f,stop:h,setSpeed:m,jumpTo:E,tick:v}}function Bo(e){const t=x();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function at(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function Fo(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 Oo(e,t,n){return new e.Entity({polyline:{positions:[],width:t.lineWidth,material:at(e,t.markerColor,.9),clampToGround:n}})}function zo(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 Uo(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},zo(i,t),i}function $o(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function lt(e){return{...kt,...e}}const Go=100,Wo=.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,m=0,E=0;const v=()=>{const I=e.value;return I&&I.entities?I:null},p=()=>{h!==null&&(cancelAnimationFrame(h),h=null)},C=()=>{const I=v();I&&(c&&I.entities.remove(c),d&&I.entities.remove(d),u&&I.entities.remove(u)),c=null,d=null,u=null,f=null},w=()=>{a&&(r.value={...a.state})},S=I=>{if(!f)return;const R=x();R&&f.setValue(R.Cartesian3.fromDegrees(I.lng,I.lat,I.altitude))},k=I=>{if(!d||!o||!a)return;const R=x();if(!R)return;const O=a.state.currentTime,X=s.trailTime>0?Math.max(0,O-s.trailTime):0,le=Se(o,o.minTime+X),se=o.points.slice(le.index,I.index+1),He=$o(R,se);He.push(R.Cartesian3.fromDegrees(I.lng,I.lat,I.altitude)),d.polyline&&(d.polyline.positions=He)},D=I=>{const R=e.value;if(!R?.camera)return;const O=x();O&&R.camera.setView({destination:O.Cartesian3.fromDegrees(I.lng,I.lat,s.followHeight),orientation:{heading:0,pitch:O.Math.toRadians(-90),roll:0}})},_=I=>{if(!a||!o||a.state.status!=="playing"){p();return}h=requestAnimationFrame(_);const R=Math.min(Math.max((I-m)/1e3,0),Wo);m=I,a.tick(R);const O=Se(o,o.minTime+a.state.currentTime);S(O),I-E>=Go&&(k(O),E=I),s.follow&&D(O),w()},T=()=>{h===null&&(m=performance.now(),E=0,h=requestAnimationFrame(_))},L=(I,R)=>{if(!o)return;const O=!Bo(I);c=Fo(R,o.displayPoints,s,O),d=Oo(R,s,O),u=Uo(R,s,O),f=u.position??null,I.entities.add(c),I.entities.add(d),I.entities.add(u);const X=Se(o,o.minTime+(a?a.state.currentTime:0));S(X),k(X)},P=(I,R)=>{const O=v(),X=x();if(!O||!X)return;Ve.loadScripts(["move-marker","bmgl-header"],n?.serverUrl,n?.libsUrl||ye).catch(se=>y.warn("[useMapTrajectory] 轨迹辅助库加载失败:",se)),s=lt({...i,...R});let le;try{le=Vo(I,s)}catch(se){y.warn("[useMapTrajectory] 轨迹数据无效:",se);return}p(),C(),o=le,a=Ro(o,s),L(O,X),w(),s.autoPlay&&N()},N=()=>{a&&(a.play(),w(),a.state.status==="playing"&&T())},b=()=>{a&&(a.pause(),p(),w())},A=()=>{if(p(),!a||!o)return;a.stop();const I=Se(o,o.minTime);S(I),k(I),w()},M=I=>{a&&(a.setSpeed(I),w())},H=I=>{if(!a||!o)return;a.jumpTo(I);const R=Se(o,o.minTime+a.state.currentTime);S(R),k(R),w()},G=()=>{p(),C(),o=null,a=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}},K=()=>{const I=v(),R=x();!I||!R||!o||!a||(C(),L(I,R))},ae=()=>{p(),C()},ne=()=>{p(),C(),o=null,a=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}};return l.onUnmounted(()=>{ne()}),{state:r,load:P,play:N,pause:b,stop:A,setSpeed:M,jumpTo:H,clear:G,reapply:K,remove:ae,destroy:ne}}function Ho(e){const t=x();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function Ko(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 jo(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 Yo(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,S)=>{if(!i)return;const k=!Ho(w),D=r.outerRing??Ko(i);o=jo(S,D,i,r,k),a=r.showOutline?Yo(S,i,r,k):null,w.entities.add(o),a&&w.entities.add(a)},f=()=>{const w=c(),S=x();!w||!S||!i||(d(),u(w,S))},h=()=>{const w=e.value?.scene;if(s||!w?.morphComplete)return;const S=()=>f();w.morphComplete.addEventListener(S),s=()=>w.morphComplete.removeEventListener(S)},m=(w,S)=>{const k=c(),D=x();!k||!D||!w||!w.length||(r=ze({...t,...S}),i=w,d(),u(k,D),n.value={visible:!0,hasMask:!0,boundaryCount:w.length},h())},E=w=>{o&&(o.show=!!w),a&&(a.show=!!w),n.value={...n.value,visible:!!w}},v=()=>{d()},p=()=>{s&&(s(),s=null),d(),i=null,r=ze(t),n.value={visible:!1,hasMask:!1,boundaryCount:0}},C=()=>{p()};return l.onUnmounted(()=>{C()}),{state:n,setMask:m,setVisible:E,clear:p,reapply:f,remove:v,destroy:C}}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 qo(e){return e instanceof F||!!e&&typeof e=="object"&&e.name==="KmlError"&&typeof e.code=="string"}function Xo(e){if(qo(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 j(e,t){return $(e,t)?.textContent?.trim()??""}function te(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 De(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(j(n,"color"));o&&(t.lineColor=o.css,t.lineAlpha=o.alpha);const a=xn(j(n,"width"));a!==null&&(t.lineWidth=a)}const r=$(e,"PolyStyle");if(r){const o=ct(j(r,"color"));o&&(t.fillColor=o.css,t.fillAlpha=o.alpha);const a=te($(r,"fill"));a==="0"?t.fill=!1:a==="1"&&(t.fill=!0);const s=te($(r,"outline"));s==="0"?t.outline=!1:s==="1"&&(t.outline=!0)}const i=$(e,"IconStyle");if(i){const o=ct(j(i,"color"));o&&(t.iconColor=o.css);const a=xn(j(i,"scale"));a!==null&&(t.iconScale=a);const s=$(i,"Icon"),c=s?j(s,"href"):"";c&&(t.iconHref=c)}return t}function Zo(e){const t=De(e,"Pair");for(const n of t){const r=j(n,"key");if(r&&r!=="normal")continue;const i=j(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 Jo(e){const t={styles:new Map,styleMaps:new Map};for(const n of De(e,"Style")){const r=n.getAttribute("id");r&&t.styles.set(r,Nn(n))}for(const n of De(e,"StyleMap")){const r=n.getAttribute("id");if(!r)continue;const i=Zo(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 ea(e){const t=$(e,"outerBoundaryIs"),n=t?$(t,"LinearRing"):null,r=n?Ue(te($(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(te($(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(te($(e,"coordinates"))).coordinates[0];n&&t.push({type:"Point",coordinates:n});break}case"LineString":{const n=Ue(te($(e,"coordinates"))).coordinates;n.length>=2&&t.push({type:"LineString",coordinates:n});break}case"Polygon":{const n=ea(e);n&&t.push(n);break}case"MultiGeometry":{for(let n=0;n<e.children.length;n++)Pn(e.children[n],t);break}}}function ta(e){const t=$(e,"ExtendedData");if(!t)return{};const n={};for(const r of De(t,"SimpleData")){const i=r.getAttribute("name");i&&(n[i]=te(r))}for(const r of An(t,"Data")){const i=r.getAttribute("name");i&&(n[i]=j(r,"value"))}return n}function na(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:j(e,"name")||o,description:j(e,"description"),visible:j(e,"visibility")!=="0",properties:r?ta(e):{},style:Qo(j(e,"styleUrl"),a?Nn(a):null,n),geometries:i}}function ra(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 ia(e){for(const t of De(e,"Document")){const n=j(t,"name");if(n)return n}return""}function oa(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 格式错误${oa(te(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=Jo(i),a=t.extractProperties!==!1,s=ra(i).map((c,d)=>na(c,d,o,a)).filter(c=>c!==null);if(!s.length)throw new F("KML 中未解析到任何可渲染的几何要素(支持 Point/LineString/Polygon/MultiGeometry)",z.NO_FEATURES);return{name:ia(i),features:s}}const aa=["http:","https:","blob:","data:"];function la(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(!aa.includes(n.protocol))throw new F(`KML 地址无效:不支持的协议 "${n.protocol}",仅支持 http/https`,z.INVALID_URL,t);return t}async function sa(e,t=15e3){const n=la(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 ca(e){const t=x();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function he(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function ge(e,t,n){return e.Color.fromCssColorString(t).withAlpha(n)}function ua(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 da(e,t){const n=e.fillPalette;if(!(!n||!n.length))return n[(t%n.length+n.length)%n.length]}function fa(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 ha(e){let t=null,n=null,r=null;for(const i of e.geometries)if(i.type==="Polygon"){const o=fa(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 ga(e,t,n){const r=ha(t);return r?new e.Entity({name:t.name,position:he(e,[r])[0],label:{text:t.name,font:`${n.labelFontSize}px sans-serif`,fillColor:ge(e,n.labelColor,1),outlineColor:ge(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 pa(e,t,n,r,i){const o=[];return n.fill&&o.push(new e.Entity({name:r.name,polygon:{hierarchy:{positions:he(e,t.outer),holes:t.holes.map(a=>({positions:he(e,a)}))},material:ge(e,n.fillColor,n.fillAlpha)}})),n.outline&&o.push(new e.Entity({name:r.name,polyline:{positions:he(e,t.outer),width:n.lineWidth,material:ge(e,n.lineColor,n.lineAlpha),clampToGround:i}})),o}function ma(e,t,n,r,i){return new e.Entity({name:r.name,polyline:{positions:he(e,t.coordinates),width:n.lineWidth,material:ge(e,n.lineColor,n.lineAlpha),clampToGround:i}})}function ya(e,t,n,r){return new e.Entity({name:r.name,position:he(e,[t.coordinates])[0],point:{pixelSize:n.pointPixelSize,color:ge(e,n.pointColor,1),heightReference:e.HeightReference?e.HeightReference.CLAMP_TO_GROUND:void 0}})}function wa(e,t,n,r,i=0){const o=ua(t.style,n,da(n,i)),a=[];for(const s of t.geometries)a.push(...va(e,s,o,t,r));if(n.showLabel&&t.name){const s=ga(e,t,n);s&&a.push(s)}return a}function va(e,t,n,r,i){switch(t.type){case"Polygon":return pa(e,t,n,r,i);case"LineString":return[ma(e,t,n,r,i)];case"Point":return[ya(e,t,n,r)];default:return[]}}function $e(e){return{...Vt,...e}}function Me(){return{status:"idle",source:null,url:"",featureCount:0,polygonCount:0,lineCount:0,pointCount:0,visible:!1,error:null}}function Ca(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(Me());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 L of a)T.entities.remove(L.entity);a=[]},f=(T,L)=>{const P=!ca(T),N=[];o.forEach((b,A)=>{for(const M of wa(L,b,i,P,A))M.show=s&&b.visible,T.entities.add(M),N.push({entity:M,featureVisible:b.visible})}),a=N},h=()=>{const T=e.value?.scene;if(c||!T?.morphComplete)return;const L=()=>k();T.morphComplete.addEventListener(L),c=()=>T.morphComplete.removeEventListener(L)},m=()=>{const T=d();if(!T||!a.length)return;const L=a.map(P=>P.entity);try{T.flyTo?.(L.length===1?L[0]:L)}catch(P){y.warn("[useMapKml] 视角定位失败:",P)}},E=async(T,L,P)=>{const N=d(),b=x();if(!N||!b){const A=new F("地图尚未就绪:请在地图初始化完成后再加载 KML",z.MAP_NOT_READY);throw r.value={...Me(),status:"error",source:T,url:L,error:A.message},A}r.value={...Me(),status:"loading",source:T,url:L};try{o=await P(),s=!0,u(),f(N,b),h();const M=Ca(o);return r.value={status:"success",source:T,url:L,featureCount:o.length,...M,visible:!0,error:null},i.autoFlyTo&&m(),{source:T,url:L,featureCount:o.length,...M,features:o}}catch(A){const M=Xo(A);throw u(),o=[],r.value={...Me(),status:"error",source:T,url:L,error:M.message},y.warn("[useMapKml] 加载失败:",M.message),M}},v=(T,L)=>{i=$e({...n,...L});const P=typeof T=="string"?T.trim():"";return E("url",P,async()=>Vn(await sa(T,i.timeout),{extractProperties:i.extractProperties}).features)},p=(T,L)=>(i=$e({...n,...L}),E("text","",async()=>Vn(T,{extractProperties:i.extractProperties}).features)),C=()=>o,w=T=>{s=!!T;for(const L of a)L.entity.show=s&&L.featureVisible;r.value={...r.value,visible:s}},S=()=>{u()},k=()=>{const T=d(),L=x();!T||!L||!o.length||(u(),f(T,L),s&&(r.value={...r.value,visible:!0}))},D=()=>{c&&(c(),c=null),u(),o=[],s=!0,i=n,r.value=Me()},_=()=>{D()};return l.onUnmounted(()=>{_()}),{state:r,loadFromUrl:v,loadFromText:p,getFeatures:C,setVisible:w,flyTo:m,remove:S,clear:D,reapply:k,destroy:_}}function ba(e=.5){return`
19
19
  uniform sampler2D colorTexture;
20
20
  varying vec2 v_textureCoordinates;
21
21
 
@@ -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 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=A();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],m=c==="rain"?ba(h):Ea(h);r=new f.PostProcessStage({name:`weather_${c}`,fragmentShader:m}),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 Ta=6,Sa=18,Da=20;function Ma(e){return{day:e?.dayStartHour??Ta,dusk:e?.duskStartHour??Sa,night:e?.nightStartHour??Da}}function Ia(e,t){const{day:n,dusk:r,night:i}=Ma(t);return e>=n&&e<r?"day":e>=r&&e<i?"dusk":"night"}const ut={x:.5781,y:-.5781,z:.5758};function La(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 p=t?.now?.()??new Date;o.value.hour=p.getHours(),o.value.mode=i.value?"manual":"auto",o.value.period=i.value??Ia(o.value.hour,t)},u=()=>{const p=e.value;if(!p?.scene){c=void 0;return}const b=p.scene;(c!==void 0||a!==void 0)&&(b.light=a,s!==void 0&&(b.globe.enableLighting=s)),c=void 0},f=()=>{const p=e.value,b=A();if(!p?.scene||!b)return;const w=p.scene;s===void 0&&(a=w.light,s=!!w.globe.enableLighting),w.globe.enableLighting=!0;const S=La(o.value.period,b);w.light=S,c=S},h=()=>{d(),o.value.enabled&&r.value?f():u()},m=p=>{o.value.enabled=!!p,h()},E=p=>{i.value=p==="auto"?null:p,h()},v=()=>{o.value.enabled=!1,u()};return l.onUnmounted(()=>v()),d(),{state:o,setEnabled:m,setPeriod:E,apply:h,destroy:v}}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 Aa(){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 xa(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 D=>{const _=++u;try{const T=await e.searchByText({field:["name"],keyword:D,limit:10,caseSensitive:!1});if(_!==u)return;n.value=T||[],o.value=!1}catch(T){if(_!==u)return;y.error("搜索查询失败:",T),n.value=[],o.value=!0}finally{_===u&&(i.value=!1)}},m=D=>{if(t.value=D,c&&clearTimeout(c),!D.trim()){n.value=[],r.value=!1,o.value=!1;return}i.value=!0,r.value=!0,c=setTimeout(()=>{h(D.trim())},e.debounceTime)},E=D=>Ge(D.altitude)?D.altitude+Ir:e.position?.height??ue.height,v=D=>{if(!Ge(D.lng)||!Ge(D.lat))return;e.setView(D.lng,D.lat,E(D));const _=e.addWave({position:[D.lng,D.lat,Ge(D.altitude)?D.altitude:0],config:{color:"#0a84ff",radius:Mr,duration:ke.WAVE}});d&&clearTimeout(d),d=setTimeout(()=>e.removeWave(_),Ft)},p=(D,_)=>{s.value=_,v(D),r.value=!1},b=D=>{const _=f.value.length;_!==0&&(a.value=(a.value+D+_)%_)},w=()=>{const D=a.value,_=f.value[D];_&&p(_,D)},S=()=>{r.value=!1},k=()=>{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:m,handleResultClick:p,moveHighlight:b,selectHighlighted:w,closeResults:S,clearSearch:k}}function Na(e){e.toggleMapTypeCore();const n=(e.mapType.value==="3d"?"2d":"3d")==="3d"?Dr:Sr;setTimeout(()=>e.redrawAllEntities(),n)}function _a(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 ka(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 Pa(e){if(e.map.value)try{await dt(e)}catch(t){y.error("加载底图图层失败:",t)}}function Va(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 Ra(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 Ba(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 Ra(r.endPosition,i)||(t=null,e.removePopup())}}function Gn(e){return{...e}}function Fa(e){if(!e.map.value)return null;const t=B(),n=new t.ScreenSpaceEventHandler(e.map.value.scene.canvas);return n.setInputAction(Va(e),t.ScreenSpaceEventType.LEFT_CLICK),n.setInputAction(Ba(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"],Oa={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 za(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=Aa(),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||ue,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,mapId:e.mapId,terrainId:e.terrainId})),{map:u,state:f,initMap:h,setView:m,toggleMapType:E}=Zt(d.value),{loadPoints:v,searchByText:p,updatePoints:b,clearPoints:w,searchByShape:S}=on(u),{drawEntity:k,deleteEntity:D,redrawAllEntities:_}=un(u),{startDrawing:T,cancelDrawing:L,clearAllDrawings:P,removeDrawing:N,setCallback:C,getIsDrawing:x}=pn(u),{showPointPopup:M,removePopup:H}=yn(u,void 0,{displayConfig:e.popupConfig}),{addWave:G,removeWave:j}=wn(u),{addWmtsLayer:ae,addImageryLayer:ne,removeAllLayers:I,setLayerVisible:R}=En(u),{contourVisible:O,contourState:X,setContourVisible:le,loadLabels:se,clearLabels:He,getLegendData:hl,reapply:gl,remove:pl}=Dn(u,e.contourConfig,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),Z=Mn(u,void 0,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),Le=Ln(u),ce=Rn(u),Ke=Fn(u),pe=On(u,{enabled:e.lightingConfig===!0},{is3D:l.computed(()=>f.value.mapType==="3d")});n.theme.value=e.theme||"dark";const ml=xa({searchByText:p,setView:m,addWave:G,removeWave:j,position:e.position,debounceTime:e.searchDebounceTime??de.DEBOUNCE_DELAY});let Ct=0;const bt=(V,St)=>{Ct+=1,n.loadingTitle.value=V,n.loadingSubtitle.value=St,f.value.isLoading=!0},mr=()=>{f.value.isLoading=!1},yl=(V,St,Il)=>{bt(V,St);const Ll=Ct;setTimeout(()=>{Ll===Ct&&mr()},Il)},wl="bigemap.dc-street",Et=()=>{R(wl,n.mapNameVisible.value)},yr=V=>{n.mapNameVisible.value=!!V,Et()},wr=V=>{n.theme.value=V},je={map:u,mapType:n.mapType,mapBase:n.mapBase,loadingSubtitle:n.loadingSubtitle,position:e.position,baseLayers:e.baseLayers??Nt,wmtsUrlProvider:s,toggleMapTypeCore:E,redrawAllEntities:_,setView:m,removeAllLayers:I,addImageryLayer:ne,addWmtsLayer:ae},vl={map:u,getIsDrawing:x,removePopup:H,showPointPopup:M,onPointClick:t.onPointClick},Cl=()=>{P(),t.emit("clear-button-click"),t.emit("clear-draw")},bl=V=>{n.currentDrawType.value=V,T(V)},El=()=>{n.currentDrawType.value=null},Tl=()=>{C(V=>{El(),V.operation==="draw"||V.operation==="edit"?t.emit("draw-end",V):V.operation==="delete"?t.emit("draw-delete",V):V.operation==="clear"&&t.emit("draw-clear",V)})};let Ae;const Sl=()=>{Ae&&clearTimeout(Ae),Ae=setTimeout(()=>{f.value.isLoading=!1,t.emit("ready"),t.emit("init")},Rt)},Dl=()=>{const V={map:u,state:f,setView:m,loadPoints:v,searchByText:p,searchByShape:S,updatePoints:b,clearPoints:w,startDrawing:T,stopDrawing:L,clearDrawings:P,removeDrawing:N,drawEntity:k,deleteEntity:D,setMapNameVisible:yr,setContourVisible:le,contourState:X,loadContourLabels:se,clearContourLabels:He,getContourLegend:hl,trajectoryState:Z.state,loadTrajectory:Z.load,playTrajectory:Z.play,pauseTrajectory:Z.pause,stopTrajectory:Z.stop,setTrajectorySpeed:Z.setSpeed,jumpTrajectoryTo:Z.jumpTo,clearTrajectory:Z.clear,maskState:Le.state,setMask:Le.setMask,setMaskVisible:Le.setVisible,clearMask:Le.clear,kmlState:ce.state,loadKmlFromUrl:ce.loadFromUrl,loadKmlFromText:ce.loadFromText,setKmlVisible:ce.setVisible,clearKml:ce.clear,weatherState:Ke.state,setWeather:Ke.setWeather,clearWeather:Ke.clear,lightingState:pe.state,setLightingEnabled:pe.setEnabled,setLightingPeriod:pe.setPeriod,setTheme:wr};t.expose(V),t.emit("expose",V)};let Ye=null,Tt=!1;l.onUnmounted(()=>{Wn(Ye),Ye=null,Ae&&clearTimeout(Ae)});const Ml=async()=>{try{bt("地图加载中","正在初始化地理数据..."),await h(),f.value.isLoading=!0,await Pa(je),Et(),Wn(Ye),Ye=Fa(vl),Tl(),pe.apply(),n.mapType.value=f.value.mapType,e.position&&await m(e.position.lng,e.position.lat,e.position.height),Sl(),Dl()}catch(V){throw f.value.isLoading=!1,f.value.error=V instanceof Error?V:new Error(String(V)),t.emit("error",V),V}};return{...n,state:f,map:u,showSearch:r,showControls:i,showDeleteControls:o,showStatus:a,wmtsEnabled:c,search:ml,onDelete:Cl,handleStartDrawing:bl,setMapNameVisible:yr,setContourVisible:le,contourVisible:O,contourState:X,trajectoryState:Z.state,maskState:Le.state,kmlState:ce.state,weatherState:Ke.state,lightingState:pe.state,setTheme:wr,toggleMapType:()=>{yl("视图切换中","正在切换 2D/3D 视图...",800),Na(je),n.mapType.value=f.value.mapType,f.value.mapType==="2d"?pl():gl(),Z.reapply(),ce.reapply(),pe.apply()},resetView:()=>_a(je),toggleMapBaseLayer:async()=>{if(!Tt){Tt=!0,bt("底图切换中","正在切换地图底图...");try{await ka(je),Et()}finally{Tt=!1,mr()}}},init:Ml}}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
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=x();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],m=c==="rain"?ba(h):Ea(h);r=new f.PostProcessStage({name:`weather_${c}`,fragmentShader:m}),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 Ta=6,Sa=18,Da=20;function Ma(e){return{day:e?.dayStartHour??Ta,dusk:e?.duskStartHour??Sa,night:e?.nightStartHour??Da}}function Ia(e,t){const{day:n,dusk:r,night:i}=Ma(t);return e>=n&&e<r?"day":e>=r&&e<i?"dusk":"night"}const ut={x:.5781,y:-.5781,z:.5758};function La(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 p=t?.now?.()??new Date;o.value.hour=p.getHours(),o.value.mode=i.value?"manual":"auto",o.value.period=i.value??Ia(o.value.hour,t)},u=()=>{const p=e.value;if(!p?.scene){c=void 0;return}const C=p.scene;(c!==void 0||a!==void 0)&&(C.light=a,s!==void 0&&(C.globe.enableLighting=s)),c=void 0},f=()=>{const p=e.value,C=x();if(!p?.scene||!C)return;const w=p.scene;s===void 0&&(a=w.light,s=!!w.globe.enableLighting),w.globe.enableLighting=!0;const S=La(o.value.period,C);w.light=S,c=S},h=()=>{d(),o.value.enabled&&r.value?f():u()},m=p=>{o.value.enabled=!!p,h()},E=p=>{i.value=p==="auto"?null:p,h()},v=()=>{o.value.enabled=!1,u()};return l.onUnmounted(()=>v()),d(),{state:o,setEnabled:m,setPeriod:E,apply:h,destroy:v}}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 Aa(){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 xa(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 D=>{const _=++u;try{const T=await e.searchByText({field:["name"],keyword:D,limit:10,caseSensitive:!1});if(_!==u)return;n.value=T||[],o.value=!1}catch(T){if(_!==u)return;y.error("搜索查询失败:",T),n.value=[],o.value=!0}finally{_===u&&(i.value=!1)}},m=D=>{if(t.value=D,c&&clearTimeout(c),!D.trim()){n.value=[],r.value=!1,o.value=!1;return}i.value=!0,r.value=!0,c=setTimeout(()=>{h(D.trim())},e.debounceTime)},E=D=>Ge(D.altitude)?D.altitude+Ir:e.position?.height??ue.height,v=D=>{if(!Ge(D.lng)||!Ge(D.lat))return;e.setView(D.lng,D.lat,E(D));const _=e.addWave({position:[D.lng,D.lat,Ge(D.altitude)?D.altitude:0],config:{color:"#0a84ff",radius:Mr,duration:ke.WAVE}});d&&clearTimeout(d),d=setTimeout(()=>e.removeWave(_),Ft)},p=(D,_)=>{s.value=_,v(D),r.value=!1},C=D=>{const _=f.value.length;_!==0&&(a.value=(a.value+D+_)%_)},w=()=>{const D=a.value,_=f.value[D];_&&p(_,D)},S=()=>{r.value=!1},k=()=>{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:m,handleResultClick:p,moveHighlight:C,selectHighlighted:w,closeResults:S,clearSearch:k}}function Na(e){e.toggleMapTypeCore();const n=(e.mapType.value==="3d"?"2d":"3d")==="3d"?Dr:Sr;setTimeout(()=>e.redrawAllEntities(),n)}function _a(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 ka(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 Pa(e){if(e.map.value)try{await dt(e)}catch(t){y.error("加载底图图层失败:",t)}}function Va(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 Ra(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 Ba(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 Ra(r.endPosition,i)||(t=null,e.removePopup())}}function Gn(e){return{...e}}function Fa(e){if(!e.map.value)return null;const t=B(),n=new t.ScreenSpaceEventHandler(e.map.value.scene.canvas);return n.setInputAction(Va(e),t.ScreenSpaceEventType.LEFT_CLICK),n.setInputAction(Ba(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"],Oa={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 za(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=Aa(),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||ue,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,mapId:e.mapId,terrainId:e.terrainId})),{map:u,state:f,initMap:h,setView:m,toggleMapType:E}=Zt(d.value),{loadPoints:v,searchByText:p,updatePoints:C,clearPoints:w,searchByShape:S}=on(u),{drawEntity:k,deleteEntity:D,redrawAllEntities:_}=un(u),{startDrawing:T,cancelDrawing:L,clearAllDrawings:P,removeDrawing:N,setCallback:b,getIsDrawing:A}=pn(u),{showPointPopup:M,removePopup:H}=yn(u,void 0,{displayConfig:e.popupConfig}),{addWave:G,removeWave:K}=wn(u),{addWmtsLayer:ae,addImageryLayer:ne,removeAllLayers:I,setLayerVisible:R}=En(u),{contourVisible:O,contourState:X,setContourVisible:le,loadLabels:se,clearLabels:He,getLegendData:hl,reapply:gl,remove:pl}=Dn(u,e.contourConfig,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),Z=Mn(u,void 0,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),Le=Ln(u),ce=Rn(u),Ke=Fn(u),pe=On(u,{enabled:e.lightingConfig===!0},{is3D:l.computed(()=>f.value.mapType==="3d")});n.theme.value=e.theme||"dark";const ml=xa({searchByText:p,setView:m,addWave:G,removeWave:K,position:e.position,debounceTime:e.searchDebounceTime??de.DEBOUNCE_DELAY});let Ct=0;const bt=(V,St)=>{Ct+=1,n.loadingTitle.value=V,n.loadingSubtitle.value=St,f.value.isLoading=!0},mr=()=>{f.value.isLoading=!1},yl=(V,St,Il)=>{bt(V,St);const Ll=Ct;setTimeout(()=>{Ll===Ct&&mr()},Il)},wl="bigemap.dc-street",Et=()=>{R(wl,n.mapNameVisible.value)},yr=V=>{n.mapNameVisible.value=!!V,Et()},wr=V=>{n.theme.value=V},je={map:u,mapType:n.mapType,mapBase:n.mapBase,loadingSubtitle:n.loadingSubtitle,position:e.position,baseLayers:e.baseLayers??Nt,wmtsUrlProvider:s,toggleMapTypeCore:E,redrawAllEntities:_,setView:m,removeAllLayers:I,addImageryLayer:ne,addWmtsLayer:ae},vl={map:u,getIsDrawing:A,removePopup:H,showPointPopup:M,onPointClick:t.onPointClick},Cl=()=>{P(),t.emit("clear-button-click"),t.emit("clear-draw")},bl=V=>{n.currentDrawType.value=V,T(V)},El=()=>{n.currentDrawType.value=null},Tl=()=>{b(V=>{El(),V.operation==="draw"||V.operation==="edit"?t.emit("draw-end",V):V.operation==="delete"?t.emit("draw-delete",V):V.operation==="clear"&&t.emit("draw-clear",V)})};let Ae;const Sl=()=>{Ae&&clearTimeout(Ae),Ae=setTimeout(()=>{f.value.isLoading=!1,t.emit("ready"),t.emit("init")},Rt)},Dl=()=>{const V={map:u,state:f,setView:m,loadPoints:v,searchByText:p,searchByShape:S,updatePoints:C,clearPoints:w,startDrawing:T,stopDrawing:L,clearDrawings:P,removeDrawing:N,drawEntity:k,deleteEntity:D,setMapNameVisible:yr,setContourVisible:le,contourState:X,loadContourLabels:se,clearContourLabels:He,getContourLegend:hl,trajectoryState:Z.state,loadTrajectory:Z.load,playTrajectory:Z.play,pauseTrajectory:Z.pause,stopTrajectory:Z.stop,setTrajectorySpeed:Z.setSpeed,jumpTrajectoryTo:Z.jumpTo,clearTrajectory:Z.clear,maskState:Le.state,setMask:Le.setMask,setMaskVisible:Le.setVisible,clearMask:Le.clear,kmlState:ce.state,loadKmlFromUrl:ce.loadFromUrl,loadKmlFromText:ce.loadFromText,setKmlVisible:ce.setVisible,clearKml:ce.clear,weatherState:Ke.state,setWeather:Ke.setWeather,clearWeather:Ke.clear,lightingState:pe.state,setLightingEnabled:pe.setEnabled,setLightingPeriod:pe.setPeriod,setTheme:wr};t.expose(V),t.emit("expose",V)};let Ye=null,Tt=!1;l.onUnmounted(()=>{Wn(Ye),Ye=null,Ae&&clearTimeout(Ae)});const Ml=async()=>{try{bt("地图加载中","正在初始化地理数据..."),await h(),f.value.isLoading=!0,await Pa(je),Et(),Wn(Ye),Ye=Fa(vl),Tl(),pe.apply(),n.mapType.value=f.value.mapType,e.position&&await m(e.position.lng,e.position.lat,e.position.height),Sl(),Dl()}catch(V){throw f.value.isLoading=!1,f.value.error=V instanceof Error?V:new Error(String(V)),t.emit("error",V),V}};return{...n,state:f,map:u,showSearch:r,showControls:i,showDeleteControls:o,showStatus:a,wmtsEnabled:c,search:ml,onDelete:Cl,handleStartDrawing:bl,setMapNameVisible:yr,setContourVisible:le,contourVisible:O,contourState:X,trajectoryState:Z.state,maskState:Le.state,kmlState:ce.state,weatherState:Ke.state,lightingState:pe.state,setTheme:wr,toggleMapType:()=>{yl("视图切换中","正在切换 2D/3D 视图...",800),Na(je),n.mapType.value=f.value.mapType,f.value.mapType==="2d"?pl():gl(),Z.reapply(),ce.reapply(),pe.apply()},resetView:()=>_a(je),toggleMapBaseLayer:async()=>{if(!Tt){Tt=!0,bt("底图切换中","正在切换地图底图...");try{await ka(je),Et()}finally{Tt=!1,mr()}}},init:Ml}}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 jn(e){return Object.prototype.hasOwnProperty.call(ht,e)}function Ua(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 Ua(n,t||"currentColor")}const Y=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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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 $a(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,b=>{r.value=b});const c=()=>{i.value&&(a.value=$a(i.value.getBoundingClientRect()))},d=b=>{r.value=b,t("search-input",b)},u=()=>{r.value="",t("search-clear","")},f=()=>{t("search-focus",r.value)},h=b=>{if(b.key==="Escape"){b.preventDefault(),t("search-close");return}if(b.key==="ArrowDown"){b.preventDefault(),t("search-navigate",1);return}if(b.key==="ArrowUp"){b.preventDefault(),t("search-navigate",-1);return}b.key==="Enter"&&(b.preventDefault(),t("search-select"))},m=b=>{if(!e.showResults)return;const w=b.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",m)}),l.onUnmounted(()=>{window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),document.removeEventListener("mousedown",m)});const E=l.computed(()=>e.showResults&&e.filteredList.length>0),v=l.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&!e.searchError),p=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:()=>[E.value?l.createVNode(Zn,{class:"teleported","data-theme":e.theme,style:a.value,list:e.filteredList,highlightIndex:e.highlightIndex,selectedIndex:e.selectedIndex,"onResult-click":(b,w)=>t("result-click",b,w),"onResult-hover":b=>t("result-hover",b),"onResult-leave":()=>t("result-leave")},null):null,v.value?l.createVNode(pt,{class:"teleported","data-theme":e.theme,style:a.value,keyword:r.value},null):null,p.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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{name:o(a.icon),size:a.size},null)]))])}}),Ga=500,er=1e3,Wa={bigemap:"生产地图",geoserver:"物探地图"};function We(e){return e&&typeof e.value=="object"?e.value:e}function Ha(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,m=[],E=null,v=null,p=0;const b=()=>{f=0,h=performance.now();const N=()=>{f+=1;const C=performance.now();C-h>=Ga&&(n.value=Math.round(f*1e3/(C-h)),f=0,h=C),u=requestAnimationFrame(N)};u=requestAnimationFrame(N)},w=()=>{try{const N=performance.memory;if(!N){r.value="--";return}const C=N.usedJSHeapSize,x=N.jsHeapSizeLimit;r.value=`${tr(C)} / ${tr(x)}`}catch{r.value="--"}},S=()=>{const N=We(e.map);if(!N)return;const C=A();if(!C)return;if(!!(C.SceneMode&&N.scene.mode===C.SceneMode.SCENE2D)){i.value={text:"2D 视图",detail:Wa[e.mapBase]||e.mapBase};return}try{const M=C.Cartographic.fromCartesian(N.camera.position);i.value={text:"3D 视图",detail:`视距 ${Ha(M.height)}`}}catch{i.value={text:"3D 视图",detail:"--"}}},k=N=>{v=N,p===0&&(p=requestAnimationFrame(()=>{p=0;const C=v;if(v=null,!C)return;const x=We(e.map);if(!x)return;const M=A();if(!M)return;const H=x.camera.pickEllipsoid(new M.Cartesian2(C.offsetX,C.offsetY),x.scene.globe.ellipsoid);if(!H)return;const G=M.Cartographic.fromCartesian(H);o.value=M.Math.toDegrees(G.longitude).toFixed(6),a.value=M.Math.toDegrees(G.latitude).toFixed(6)}))},D=()=>{!s.value||!c.value||(d.value=c.value.scrollWidth>s.value.clientWidth+1)},_=()=>{t.value=!t.value},T=N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),_())};l.onMounted(()=>{b(),w(),S(),D(),m.push(window.setInterval(w,er)),m.push(window.setInterval(S,er)),We(e.map)?.scene.canvas.addEventListener("mousemove",k),typeof ResizeObserver<"u"&&(E=new ResizeObserver(D),c.value&&E.observe(c.value),s.value&&E.observe(s.value))}),l.onUnmounted(()=>{cancelAnimationFrame(u),p!==0&&cancelAnimationFrame(p),v=null,E?.disconnect(),m.forEach(C=>window.clearInterval(C)),We(e.map)?.scene.canvas.removeEventListener("mousemove",k)});const L=()=>[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])])],P=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:_,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":P.value}]},[l.createVNode("span",{class:"map-status__track-inner",ref:c},[L()]),P.value?l.createVNode("span",{class:"map-status__track-inner","aria-hidden":"true"},[L()]):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=za(e.config,{theme:e.theme,popupConfig:e.popupConfig}),o=Kn(i,{emit:(M,...H)=>t(M,...H),expose:n,onPointClick:M=>t("point-click",M)});await o.init().catch(()=>{});const{mapType:a,mapBase:s,currentDrawType:c,loadingTitle:d,loadingSubtitle:u,theme:f,mapNameVisible:h,showControls:m,showDeleteControls:E,showStatus:v,wmtsEnabled:p}=o,{state:b,showSearch:w,search:S,onDelete:k,handleStartDrawing:D,toggleMapType:_,resetView:T,toggleMapBaseLayer:L,setMapNameVisible:P,setContourVisible:N,contourVisible:C,map:x}=o;return()=>l.createVNode(l.Fragment,null,[l.createVNode(ft,{visible:b.value.isLoading&&!b.value.error,title:d.value,subtitle:u.value},null),l.createVNode(qn,{visible:!!b.value.error,message:b.value.error?.message,onRetry:()=>t("error-retry")},null),l.createVNode(nr,{map:x,mapBase:s.value,visible:v.value},null),w.value?l.createVNode(Jn,{showSearch:!0,theme:f.value,filteredList:S.filteredList.value,showResults:S.showResults.value,input:S.searchInput.value,isSearching:S.isSearching.value,searchError:S.searchError.value,highlightIndex:S.highlightIndex.value,selectedIndex:S.selectedIndex.value,"onSearch-input":S.handleInputSearch,"onSearch-focus":()=>{S.showResults.value=!0},"onSearch-clear":S.clearSearch,"onSearch-close":()=>{S.showResults.value=!1},"onSearch-navigate":M=>S.moveHighlight(M),"onSearch-select":()=>S.selectHighlighted(),"onResult-click":S.handleResultClick,"onResult-hover":M=>{S.highlightIndex.value=M},"onResult-leave":()=>{S.highlightIndex.value=-1}},{"utils-right":()=>r["utils-right"]?r["utils-right"]():null}):null,m.value?l.createVNode(Qn,{showDeleteControls:E.value,mapType:a.value,mapBase:s.value,currentDrawType:c.value??void 0,mapNameVisible:h.value,contourVisible:C.value,tools:i.tools,showBaseSwitch:p.value,onDelete:k,"onToggle-map-type":_,"onToggle-map-base":L,"onToggle-map-view":T,"onToggle-map-name":M=>P(M),"onToggle-contour":()=>N(!C.value),"onStart-drawing":D},null):null,r.default?r.default():null])}}),Ka=Object.fromEntries(Hn.map(e=>[e,{type:Oa[e],default:void 0}])),ja=l.defineComponent({name:"MapContainer",inheritAttrs:!1,props:{config:{type:Object,default:void 0},...Ka,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 Ya=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 qa={fontSize:12,textColor:"#FFFFFF",textBgColor:"rgba(0, 0, 0, 0.6)",padding:4,rounded:!0,borderRadius:4};function sr(e){return{...qa,...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 Xa=3e3,Ie=new Map,Za=100;function Ja(e){const t=Ie.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(Ie.set(e,r);Ie.size>Za;){const s=Ie.keys().next().value;if(s===void 0)break;Ie.delete(s)}o()},r.onerror=o;const a=setTimeout(o,Xa)})}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 el(e,t,n,r,i){const o=await Ja(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 m=await el(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:!m}}function tl(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 nl="color_svg";function fr(e,t){return t===void 0?`${e}_no_text`:t===""?`${e}_empty_text`:`${e}_text_${t}`}function hr(e){return`${nl}_${e}`}function yt(e){return W[e]?.color||W.default.color}const wt=25,rl=8;function il(){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>=rl?(await il(),performance.now()):e}async function ol(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 al(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),m=t.resolveBaseSvg(f),E=f.showName&&f.name?String(f.name).trim():"",v=`${m}${h}${E}`;r[u]=v,E?o.has(v)||o.set(v,{key:v,color:h,text:E,svg:m}):i.has(v)||i.set(v,{key:v,color:h,svg:m})}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 ll(e,t){const n=JSON.stringify(W);for(const[r,i]of Object.entries(e))W[r]={color:i,text:W[r]?.text||W.default.text};n!==JSON.stringify(W)&&t()}function sl(){const e={default:W.default.color};for(const[t,n]of Object.entries(W))t!=="default"&&(e[t]=n.color);return e}const cl="color:";function gr(e){return`${cl}${e}`}class q{constructor(){this.maxIconCache=q.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?q.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 q.instance||(q.instance=new q),q.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(W),"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>q.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 ol(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 al(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){ll(t,()=>this.clearCache())}getStatusColorMap(){return sl()}buildFallbackTextIcon(t,n){return tl(t,n,this.defaultConfig)}}const ul=q.getInstance();function dl(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 fl extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="MapError"}}g.ANIMATION_DURATION=ke,g.AppButton=Ya,g.AppIcon=Y,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=ye,g.DEFAULT_MAP_CONFIG=Je,g.DEFAULT_MASK_CONFIG=Pt,g.DEFAULT_POSITION=ue,g.DEFAULT_TOOLS=Ze,g.DEFAULT_TRAJECTORY_CONFIG=kt,g.ErrorCode=pr,g.EventBus=Xe,g.GEOMETRY_CONFIG=J,g.GameLoading=ft,g.ICON_MAP=ht,g.IconManager=q,g.KmlError=F,g.KmlErrorCode=z,g.LIBRARIES=et,g.MORPH_3D_DELAY=Bt,g.MapContainer=ja,g.MapControls=Qn,g.MapError=qn,g.MapErrorClass=fl,g.MapManager=re,g.MapStatus=nr,g.MapTools=Jn,g.MapView=rr,g.NoResultsPanel=pt,g.PERFORMANCE_CONFIG=de,g.READY_DELAY=Rt,g.ResourceManager=Ut,g.STATUS_COLOR_MAP=W,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=dl,g.eventBus=Er,g.getBmgl=A,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=ul,g.isIconName=jn,g.logger=y,g.mapManager=ve,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"})}));
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 Ua(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 Ua(n,t||"currentColor")}const Y=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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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 $a(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,C=>{r.value=C});const c=()=>{i.value&&(a.value=$a(i.value.getBoundingClientRect()))},d=C=>{r.value=C,t("search-input",C)},u=()=>{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"))},m=C=>{if(!e.showResults)return;const w=C.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",m)}),l.onUnmounted(()=>{window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),document.removeEventListener("mousedown",m)});const E=l.computed(()=>e.showResults&&e.filteredList.length>0),v=l.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&!e.searchError),p=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:()=>[E.value?l.createVNode(Zn,{class:"teleported","data-theme":e.theme,style:a.value,list:e.filteredList,highlightIndex:e.highlightIndex,selectedIndex:e.selectedIndex,"onResult-click":(C,w)=>t("result-click",C,w),"onResult-hover":C=>t("result-hover",C),"onResult-leave":()=>t("result-leave")},null):null,v.value?l.createVNode(pt,{class:"teleported","data-theme":e.theme,style:a.value,keyword:r.value},null):null,p.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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{name:o(a.icon),size:a.size},null)]))])}}),Ga=500,er=1e3,Wa={bigemap:"生产地图",geoserver:"物探地图"};function We(e){return e&&typeof e.value=="object"?e.value:e}function Ha(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,m=[],E=null,v=null,p=0;const C=()=>{f=0,h=performance.now();const N=()=>{f+=1;const b=performance.now();b-h>=Ga&&(n.value=Math.round(f*1e3/(b-h)),f=0,h=b),u=requestAnimationFrame(N)};u=requestAnimationFrame(N)},w=()=>{try{const N=performance.memory;if(!N){r.value="--";return}const b=N.usedJSHeapSize,A=N.jsHeapSizeLimit;r.value=`${tr(b)} / ${tr(A)}`}catch{r.value="--"}},S=()=>{const N=We(e.map);if(!N)return;const b=x();if(!b)return;if(!!(b.SceneMode&&N.scene.mode===b.SceneMode.SCENE2D)){i.value={text:"2D 视图",detail:Wa[e.mapBase]||e.mapBase};return}try{const M=b.Cartographic.fromCartesian(N.camera.position);i.value={text:"3D 视图",detail:`视距 ${Ha(M.height)}`}}catch{i.value={text:"3D 视图",detail:"--"}}},k=N=>{v=N,p===0&&(p=requestAnimationFrame(()=>{p=0;const b=v;if(v=null,!b)return;const A=We(e.map);if(!A)return;const M=x();if(!M)return;const H=A.camera.pickEllipsoid(new M.Cartesian2(b.offsetX,b.offsetY),A.scene.globe.ellipsoid);if(!H)return;const G=M.Cartographic.fromCartesian(H);o.value=M.Math.toDegrees(G.longitude).toFixed(6),a.value=M.Math.toDegrees(G.latitude).toFixed(6)}))},D=()=>{!s.value||!c.value||(d.value=c.value.scrollWidth>s.value.clientWidth+1)},_=()=>{t.value=!t.value},T=N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),_())};l.onMounted(()=>{C(),w(),S(),D(),m.push(window.setInterval(w,er)),m.push(window.setInterval(S,er)),We(e.map)?.scene.canvas.addEventListener("mousemove",k),typeof ResizeObserver<"u"&&(E=new ResizeObserver(D),c.value&&E.observe(c.value),s.value&&E.observe(s.value))}),l.onUnmounted(()=>{cancelAnimationFrame(u),p!==0&&cancelAnimationFrame(p),v=null,E?.disconnect(),m.forEach(b=>window.clearInterval(b)),We(e.map)?.scene.canvas.removeEventListener("mousemove",k)});const L=()=>[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])])],P=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:_,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":P.value}]},[l.createVNode("span",{class:"map-status__track-inner",ref:c},[L()]),P.value?l.createVNode("span",{class:"map-status__track-inner","aria-hidden":"true"},[L()]):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=za(e.config,{theme:e.theme,popupConfig:e.popupConfig}),o=Kn(i,{emit:(M,...H)=>t(M,...H),expose:n,onPointClick:M=>t("point-click",M)});await o.init().catch(()=>{});const{mapType:a,mapBase:s,currentDrawType:c,loadingTitle:d,loadingSubtitle:u,theme:f,mapNameVisible:h,showControls:m,showDeleteControls:E,showStatus:v,wmtsEnabled:p}=o,{state:C,showSearch:w,search:S,onDelete:k,handleStartDrawing:D,toggleMapType:_,resetView:T,toggleMapBaseLayer:L,setMapNameVisible:P,setContourVisible:N,contourVisible:b,map:A}=o;return()=>l.createVNode(l.Fragment,null,[l.createVNode(ft,{visible:C.value.isLoading&&!C.value.error,title:d.value,subtitle:u.value},null),l.createVNode(qn,{visible:!!C.value.error,message:C.value.error?.message,onRetry:()=>t("error-retry")},null),l.createVNode(nr,{map:A,mapBase:s.value,visible:v.value},null),w.value?l.createVNode(Jn,{showSearch:!0,theme:f.value,filteredList:S.filteredList.value,showResults:S.showResults.value,input:S.searchInput.value,isSearching:S.isSearching.value,searchError:S.searchError.value,highlightIndex:S.highlightIndex.value,selectedIndex:S.selectedIndex.value,"onSearch-input":S.handleInputSearch,"onSearch-focus":()=>{S.showResults.value=!0},"onSearch-clear":S.clearSearch,"onSearch-close":()=>{S.showResults.value=!1},"onSearch-navigate":M=>S.moveHighlight(M),"onSearch-select":()=>S.selectHighlighted(),"onResult-click":S.handleResultClick,"onResult-hover":M=>{S.highlightIndex.value=M},"onResult-leave":()=>{S.highlightIndex.value=-1}},{"utils-right":()=>r["utils-right"]?r["utils-right"]():null}):null,m.value?l.createVNode(Qn,{showDeleteControls:E.value,mapType:a.value,mapBase:s.value,currentDrawType:c.value??void 0,mapNameVisible:h.value,contourVisible:b.value,tools:i.tools,showBaseSwitch:p.value,onDelete:k,"onToggle-map-type":_,"onToggle-map-base":L,"onToggle-map-view":T,"onToggle-map-name":M=>P(M),"onToggle-contour":()=>N(!b.value),"onStart-drawing":D},null):null,r.default?r.default():null])}}),Ka=Object.fromEntries(Hn.map(e=>[e,{type:Oa[e],default:void 0}])),ja=l.defineComponent({name:"MapContainer",inheritAttrs:!1,props:{config:{type:Object,default:void 0},...Ka,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 Ya=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 qa={fontSize:12,textColor:"#FFFFFF",textBgColor:"rgba(0, 0, 0, 0.6)",padding:4,rounded:!0,borderRadius:4};function sr(e){return{...qa,...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 Xa=3e3,Ie=new Map,Za=100;function Ja(e){const t=Ie.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(Ie.set(e,r);Ie.size>Za;){const s=Ie.keys().next().value;if(s===void 0)break;Ie.delete(s)}o()},r.onerror=o;const a=setTimeout(o,Xa)})}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 el(e,t,n,r,i){const o=await Ja(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 m=await el(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:!m}}function tl(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 nl="color_svg";function fr(e,t){return t===void 0?`${e}_no_text`:t===""?`${e}_empty_text`:`${e}_text_${t}`}function hr(e){return`${nl}_${e}`}function yt(e){return W[e]?.color||W.default.color}const wt=25,rl=8;function il(){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>=rl?(await il(),performance.now()):e}async function ol(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 al(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),m=t.resolveBaseSvg(f),E=f.showName&&f.name?String(f.name).trim():"",v=`${m}${h}${E}`;r[u]=v,E?o.has(v)||o.set(v,{key:v,color:h,text:E,svg:m}):i.has(v)||i.set(v,{key:v,color:h,svg:m})}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 ll(e,t){const n=JSON.stringify(W);for(const[r,i]of Object.entries(e))W[r]={color:i,text:W[r]?.text||W.default.text};n!==JSON.stringify(W)&&t()}function sl(){const e={default:W.default.color};for(const[t,n]of Object.entries(W))t!=="default"&&(e[t]=n.color);return e}const cl="color:";function gr(e){return`${cl}${e}`}class q{constructor(){this.maxIconCache=q.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?q.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 q.instance||(q.instance=new q),q.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(W),"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>q.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 ol(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 al(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){ll(t,()=>this.clearCache())}getStatusColorMap(){return sl()}buildFallbackTextIcon(t,n){return tl(t,n,this.defaultConfig)}}const ul=q.getInstance();function dl(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 fl extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="MapError"}}g.ANIMATION_DURATION=ke,g.AppButton=Ya,g.AppIcon=Y,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=ye,g.DEFAULT_MAP_CONFIG=Je,g.DEFAULT_MASK_CONFIG=Pt,g.DEFAULT_POSITION=ue,g.DEFAULT_TOOLS=Ze,g.DEFAULT_TRAJECTORY_CONFIG=kt,g.ErrorCode=pr,g.EventBus=Xe,g.GEOMETRY_CONFIG=J,g.GameLoading=ft,g.ICON_MAP=ht,g.IconManager=q,g.KmlError=F,g.KmlErrorCode=z,g.LIBRARIES=et,g.MORPH_3D_DELAY=Bt,g.MapContainer=ja,g.MapControls=Qn,g.MapError=qn,g.MapErrorClass=fl,g.MapManager=re,g.MapStatus=nr,g.MapTools=Jn,g.MapView=rr,g.NoResultsPanel=pt,g.PERFORMANCE_CONFIG=de,g.READY_DELAY=Rt,g.ResourceManager=Ut,g.STATUS_COLOR_MAP=W,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=dl,g.eventBus=Er,g.getBmgl=x,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=ul,g.isIconName=jn,g.logger=y,g.mapManager=ve,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"})}));