bigmap-plugin 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
- (function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.BigmapPlugin={},g.Vue))})(this,(function(g,o){"use strict";const dt={debug:10,info:20,warn:30,error:40,silent:Number.POSITIVE_INFINITY},ve="[sems-map]";function Yn(){try{const e=typeof process<"u"?process.env:void 0;if(e&&e.NODE_ENV==="production")return"warn"}catch{}return"debug"}let Pe=Yn();function qn(e){Pe=e}function Kn(){return Pe}function Ce(e){return dt[e]>=dt[Pe]}const w={debug(...e){Ce("debug")&&console.debug(ve,...e)},info(...e){Ce("info")&&console.info(ve,...e)},warn(...e){Ce("warn")&&console.warn(ve,...e)},error(...e){Ce("error")&&console.error(ve,...e)}},ft=Symbol("originalHandler");class Be{constructor(){this.events=new Map}on(t,n){return this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n),()=>this.off(t,n)}once(t,n){const r=i=>{n(i),this.off(t,r)};return r[ft]=n,this.on(t,r)}off(t,n){if(!n){this.events.delete(t);return}const r=this.events.get(t);if(!r)return;const i=r.findIndex(a=>a===n||a[ft]===n);i>-1&&r.splice(i,1),r.length===0&&this.events.delete(t)}async emit(t,n){const r=this.events.get(t);if(!r||r.length===0)return;const i=r.slice(),a=[];for(const l of i)try{const s=l(n);s&&typeof s.then=="function"&&a.push(s.catch(u=>{w.error(`[EventBus] Error in async handler for event "${String(t)}":`,u)}))}catch(s){w.error(`[EventBus] Error in handler for event "${String(t)}":`,s)}a.length>0&&await Promise.all(a)}clear(){this.events.clear()}getStats(){return Array.from(this.events.entries()).map(([t,n])=>({event:String(t),handlerCount:n.length}))}}const Xn=new Be,oe=new Map;function q(e){oe.set(e.type,e)}q({type:"area",name:"测面积",defaultSize:15,icon:"area",toolbarOrder:4,buildConfig:({shared:e})=>({material:e.fill,labelOptions:e.label})}),q({type:"polygon",name:"绘制多边形",defaultSize:14,icon:"polygon",toolbarOrder:1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})}),q({type:"circle",name:"绘制圆形",defaultSize:17,icon:"circle",toolbarOrder:2,buildConfig:({bmgl:e,config:t,shared:n})=>({material:n.fill,width:n.width,controlLine:{permanent:!0,lineStyle:{width:n.width,clampToGround:!0,material:n.border},textStyle:{font:t.labelFont,disableDepthTestDistance:1/0,verticalOrigin:e.VerticalOrigin.BOTTOM}}})}),q({type:"azimuth",name:"测方位",defaultSize:15,icon:"azimuth",toolbarOrder:6,buildConfig:({bmgl:e,config:t})=>({clampToGround:!0,material:new e.PolylineArrowMaterialProperty(e.Color.fromCssColorString(t.fillColor)),width:t.arrowWidth,labelOptions:{fillColor:e.Color.YELLOW}})}),q({type:"ruler",name:"测距离",defaultSize:15,icon:"ruler",toolbarOrder:5,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill,labelOptions:t.label})}),q({type:"polyline",name:"绘制线",defaultSize:16,icon:"polyline",toolbarOrder:3,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill})}),q({type:"triangle",name:"绘制三角形",defaultSize:16,icon:"triangle",inDefaultToolbar:!1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:4,material:t.fill})}),q({type:"rectangle",name:"绘制矩形",defaultSize:16,icon:"rectangle",toolbarOrder:0,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})});function Zn(e){oe.set(e.type,e)}function ht(e){return oe.get(e)}function gt(){return[...oe.values()]}function pt(){return[...oe.values()].filter(e=>e.inDefaultToolbar!==!1).sort((e,t)=>(e.toolbarOrder??Number.MAX_SAFE_INTEGER)-(t.toolbarOrder??Number.MAX_SAFE_INTEGER))}function mt(){return pt().map(e=>({icon:e.type,name:e.name,size:e.defaultSize}))}const be="/libs",te={lng:104.03770513,lat:30.48187111,height:2e4},Ee={heading:6.267876539812834,pitch:-1.3962634015954636,roll:.00016118230151462853},Te={FLY_TO:2,MORPH:.8,WAVE:3e3},ne={BATCH_SIZE:200,YIELD_BUDGET_MS:8,DEBOUNCE_DELAY:300,GRID_SIZE:.1},Re=mt(),wt={spacing:150,width:2},yt={autoPlay:!1,speed:1,loop:!1,follow:!1,followHeight:2e3,trailTime:10,duration:0,interval:1,markerColor:"#ff3b30",markerSize:12,markerIcon:"",lineColor:"#0a84ff",lineWidth:4,maxPoints:2e4},vt={fillColor:"#000000",fillAlpha:.8,outlineColor:"#44d5ff",outlineAlpha:1,outlineWidth:4,showOutline:!0},ze={containerId:"bigmap-container",libsUrl:be,mapType:"3d",position:te,mapId:"bigemap.cebjohn0",terrainId:"bigemap.dc-terrain",showSearch:!1,showControls:!0,showStatus:!1,showDeleteControls:!0,tools:Re,searchDebounceTime:ne.DEBOUNCE_DELAY},H={METERS_PER_DEGREE_LAT:111320,METERS_PER_DEGREE_LAT_APPROX:111e3,CAMERA_FOV_DEGREES:60,MIN_CAMERA_HEIGHT:1e3},Ct=500,bt=800,Jn=200,Qn=900,Et=1e4,er=100,tr=1e3,Tt={NEAR:3e3,NEAR_VALUE:1,FAR:1e5,FAR_VALUE:.1},nr=6,rr=1001,R={1:{color:"#9E9E9E",text:"未发布"},2:{color:"#2196F3",text:"已发布"},3:{color:"#FF9800",text:"未完成"},4:{color:"#4CAF50",text:"已完成"},5:{color:"#FF5722",text:"整改"},6:{color:"#E91E63",text:"整改中"},7:{color:"#8BC34A",text:"整改完成"},8:{color:"#009688",text:"合格"},9:{color:"#00BCD4",text:"整改合格"},10:{color:"#F44336",text:"不合格"},11:{color:"#9C27B0",text:"变观中"},12:{color:"#673AB7",text:"已变观"},13:{color:"#607D8B",text:"任务终止"},default:{color:"#2196F3",text:"未知状态"}},ir=e=>R[e]||R.default;function ar(e){if(!e)return{};const t={};for(const n of Object.keys(e)){const r=e[n];r!==void 0&&(t[n]=r)}return t}function Fe(...e){const t={...ze};for(const n of e){const r=ar(n);Object.assign(t,r),r.geoserver&&(t.geoserver={...t.geoserver||{},...r.geoserver})}return t}function or(e,t){return Fe(e,t)}class St{constructor(t){this.config=Fe(t)}get(t){return this.config[t]}set(t,n){this.config[t]=n}getAll(){return{...this.config}}update(t){this.config=Fe(this.config,t)}reset(){this.config={...ze}}}class Dt{constructor(){this.resources=new Set}register(t){this.resources.add(t)}unregister(t){this.resources.delete(t)}async cleanup(){const t=Array.from(this.resources);this.resources.clear(),await Promise.allSettled(t.map(async n=>{try{await n()}catch(r){w.error("[ResourceManager] Error during cleanup:",r)}}))}getResourceCount(){return this.resources.size}}function lr(e){return{isReady:!1,isLoading:!1,mapType:e==="2d"?"2d":"3d",cameraPosition:{lng:0,lat:0,height:0,altitude:0,heading:0,pitch:0,roll:0},bounds:null,error:null}}function sr(e){return{configManager:new St(e),eventBus:new Be,resourceManager:new Dt,map:o.shallowRef(null),state:o.ref(lr(e.mapType||"3d")),cancelled:{value:!1},destroyed:{value:!1},initializing:{value:!1}}}const Mt=be,Oe={"bigemap-2d":{name:"BigMap 2D",path:"/libs/bigemap/bigemap.js",dependencies:["bigemap-2d-css"]},"bigemap-2d-css":{name:"BigMap 2D CSS",path:"/libs/bigemap/bigemap.css",isCss:!0},"bigemap-3d":{name:"BigMap 3D",path:"/bigemap-gl.js/v1.1.0/bigemap-gl.js",dependencies:["bigemap-3d-css"]},"bigemap-3d-css":{name:"BigMap 3D CSS",path:"/libs/bigemap/widgets.css",isCss:!0},"bmgl-plot":{name:"BigMap Plot",path:"/libs/bigemap/bmgl-plot.min.js",dependencies:["bigemap-3d"]},"circle-wave":{name:"Circle Wave",path:"/libs/bigemap/circleWave.js",dependencies:["bmgl-plot"]},"bm-geometry-util":{name:"BigMap Geometry Util",path:"/libs/bigemap/bm.geometryutil.js",dependencies:["bigemap-3d"]},"move-marker":{name:"BigMap Move Marker",path:"/libs/bigemap/moveMarker.js",dependencies:["bigemap-3d","bm-geometry-util"]},"bmgl-header":{name:"BMGL Sandcastle Header",path:"/libs/bigemap/bmgl-header.js",dependencies:["bigemap-3d"]}};function Ge(e,t,n){if(e.path.startsWith("/libs/"))return n+e.path.slice(5);if(e.path.startsWith("/")){if(!t)throw new Error(`未配置 serverUrl,无法解析地图资源路径: ${e.path}`);return t.replace(/\/$/,"")+e.path}return e.path}const Se=3e4;class It{constructor(){this.loaded=new Set,this.pending=new Map}loadJs(t){return new Promise((n,r)=>{if(document.querySelector(`script[src="${t}"]`)){n();return}const i=document.createElement("script");i.src=t,i.async=!0;let a=!1;const l=setTimeout(()=>{a||(a=!0,i.remove(),r(new Error(`脚本加载超时(${Se/1e3}s): ${t}`)))},Se);i.onload=()=>{a||(a=!0,clearTimeout(l),n())},i.onerror=()=>{a||(a=!0,clearTimeout(l),i.remove(),r(new Error(`脚本加载失败: ${t}`)))},document.head.appendChild(i)})}loadCss(t){return new Promise((n,r)=>{if(document.querySelector(`link[href="${t}"]`)){n();return}const i=document.createElement("link");i.rel="stylesheet",i.href=t;let a=!1;const l=setTimeout(()=>{a||(a=!0,i.remove(),r(new Error(`样式加载超时(${Se/1e3}s): ${t}`)))},Se);i.onload=()=>{a||(a=!0,clearTimeout(l),n())},i.onerror=()=>{a||(a=!0,clearTimeout(l),i.remove(),r(new Error(`样式加载失败: ${t}`)))},document.head.appendChild(i)})}loadResource(t,n,r){const i=Ge(t,n,r);if(this.loaded.has(i))return Promise.resolve();if(this.pending.has(i))return this.pending.get(i);const a=t.isCss?this.loadCss(i):this.loadJs(i);return this.pending.set(i,a),a.then(()=>{this.loaded.add(i)}).finally(()=>{this.pending.delete(i)}),a}async loadWithDependencies(t,n,r,i){const l={...Oe,...i}[t];if(!l)throw new Error(`库配置未找到: ${t}`);for(const s of l.dependencies||[])await this.loadWithDependencies(s,n,r,i);await this.loadResource(l,n,r)}async loadScripts(t,n,r=Mt,i){await Promise.all(t.map(a=>this.loadWithDependencies(a,n,r,i)))}isLoaded(t,n,r){const i=Oe[t];if(!i||i.path.startsWith("/")&&!i.path.startsWith("/libs/")&&!n)return!1;const a=Ge(i,n||"",r||Mt);return this.loaded.has(a)}clearLoaded(){this.loaded.clear(),this.pending.clear()}}const Ue=new It;let le=null;function At(e){le=e}function D(){return le||(typeof window<"u"&&window.bmgl?(le=window.bmgl,le):null)}function N(){const e=D();if(!e)throw new Error("bmgl 库未就绪:请确保地图初始化完成后再调用该能力");return e}async function xt(e=3e3){const t=D();return t||new Promise((n,r)=>{const i=Date.now(),a=setInterval(()=>{const l=D();l?(clearInterval(a),n(l)):Date.now()-i>e&&(clearInterval(a),r(new Error("bmgl 加载超时")))},50)})}class Z{constructor(){this.entries=new Map}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}register(t,n,r,i){this.entries.set(t,{map:n,eventBus:r,resourceManager:i})}get(t){return this.entries.get(t)?.map}has(t){return this.entries.has(t)}getEventBus(t){return this.entries.get(t)?.eventBus}getResourceManager(t){return this.entries.get(t)?.resourceManager}async unregister(t){const n=this.entries.get(t);if(n&&(this.entries.delete(t),await n.resourceManager.cleanup(),n.eventBus.clear(),!n.map.isDestroyed?.()))try{n.map.destroy()}catch(r){w.error("[MapManager] Error destroying map:",r)}}getAllMapIds(){return Array.from(this.entries.keys())}async cleanupAll(){const t=this.getAllMapIds();await Promise.all(t.map(n=>this.unregister(n)))}}const se=Z.getInstance();function cr(e,t=3e3){return new Promise((n,r)=>{const i=Date.now(),a=setInterval(()=>{document.getElementById(e)?(clearInterval(a),n()):Date.now()-i>t&&(clearInterval(a),r(new Error(`容器未找到: ${e}`)))},16)})}async function ur(e){const t=e.configManager.get("containerId");if(!t)throw new Error("容器ID未定义");return await cr(t),t}async function dr(e){const t=e.configManager.get("serverUrl"),n=e.configManager.get("accessToken"),r=e.configManager.get("libsUrl"),i=e.configManager.get("extraLibs");try{await Ue.loadScripts(["bigemap-3d","bmgl-plot","circle-wave"],t,r,i)}catch(l){throw w.error("[loadBmglScripts] 地图服务连接失败,请确认 serverUrl 可达且服务已启动:",l),new Error("地图服务连接失败,请确认服务器地址正确且服务已启动")}const a=D();if(!a)throw new Error("BMGL 库加载失败");At(a),a.Config.HTTP_URL=t,n&&(console.log("accessToken",n),a.Config.accessToken=n),fr(a)}function fr(e){e.RequestScheduler&&(e.RequestScheduler.maximumRequests=120,e.RequestScheduler.maximumRequestsPerServer=18)}function hr(e){const t=D(),n=e.configManager.get("containerId");if(!t||!n)throw new Error("地图实例创建失败:BMGL 库或容器 ID 未就绪");const r=new t.Viewer(n,{mapId:e.configManager.get("mapId"),terrainId:e.configManager.get("terrainId"),requestRenderMode:!1,selectionIndicator:!1,infoBox:!1});return gr(r,e.state.value.mapType),r}function gr(e,t){t==="3d"&&(e.scene.globe.depthTestAgainstTerrain=!0);const n=e.scene,r=e.scene.globe;n.preloadFlightDestinations=!0,r.tileCacheSize=1e3,r.preloadAncestors=!0,r.preloadSiblings=!0,r.maximumScreenSpaceError=1.5}async function pr(e,t,n){if(se.has(n))try{await se.unregister(n)}catch(r){w.warn(`[registerMap] 清理残留地图实例失败 (${n}):`,r)}se.register(n,t,e.eventBus,e.resourceManager)}function Lt(e){return typeof e=="number"&&!Number.isNaN(e)?e:1e4}function Nt(e,t,n){const r=D();if(!r)throw new Error("BMGL 库未加载,无法构造相机目标位置");return r.Cartesian3.fromDegrees(e,t,n)}function kt(){return{heading:Ee.heading,pitch:Ee.pitch,roll:Ee.roll}}function mr(e){const t=e.configManager.get("position");t&&e.map.value?.camera.flyTo({destination:Nt(t.lng,t.lat,Lt(t.height)),orientation:kt(),duration:Te.FLY_TO})}function wr(e,t,n,r){e.map.value&&e.map.value.camera.flyTo({destination:Nt(t,n,Lt(r)),orientation:kt(),duration:Te.FLY_TO})}function yr(e){const t=D();if(!e.map.value||!t)return null;const n=e.map.value.camera.computeViewRectangle();return n?{minx:t.Math.toDegrees(n.west),maxx:t.Math.toDegrees(n.east),miny:t.Math.toDegrees(n.south),maxy:t.Math.toDegrees(n.north)}:vr(e)}function vr(e){const t=D();if(!t)return null;const n=e.map.value,r=n.scene.globe.ellipsoid;try{const i=n.camera.pickEllipsoid(new t.Cartesian2(0,0),r),a=n.camera.pickEllipsoid(new t.Cartesian2(n.scene.canvas.clientWidth,n.scene.canvas.clientHeight),r);if(!i||!a)return null;const l=r.cartesianToCartographic(i),s=r.cartesianToCartographic(a);return{minx:t.Math.toDegrees(l.longitude),maxx:t.Math.toDegrees(s.longitude),miny:t.Math.toDegrees(s.latitude),maxy:t.Math.toDegrees(l.latitude)}}catch{return null}}function Cr(e){return e.initializing.value||!!e.map.value||e.destroyed.value}async function br(e){if(!Cr(e)){e.cancelled.value=!1,e.initializing.value=!0,e.state.value.isLoading=!0,e.state.value.error=null;try{await Er(e)}catch(t){throw e.state.value.error=t instanceof Error?t:new Error(String(t)),await e.eventBus.emit("map:error",t),t}finally{e.initializing.value=!1,e.state.value.isLoading=!1}}}async function Er(e){const t=await ur(e);if(await dr(e),e.cancelled.value)return;const n=hr(e);if(e.cancelled.value){Tr(n);return}e.map.value=n,await pr(e,n,t),await mr(e),!e.cancelled.value&&(e.state.value.isReady=!0,await e.eventBus.emit("map:ready"))}function Tr(e){try{e.destroy()}catch(t){w.error("[useMap] 销毁未注册的地图实例失败:",t)}}async function _t(e){if(e.cancelled.value=!0,e.destroyed.value=!0,!e.map.value)return;const t=e.configManager.get("containerId");if(e.map.value=null,e.state.value.isReady=!1,t)try{await se.unregister(t)}catch(n){w.error("[useMap] 销毁地图失败:",n)}}function Vt(e,t,n){const r=D();if(!r)throw new Error("BMGL 库未加载,无法构造目标视角");return{destination:r.Cartesian3.fromDegrees(e,t,n),orientation:{heading:0,pitch:r.Math.toRadians(-90),roll:0}}}function Sr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="2d"))try{const n=D();if(!n)throw new Error("BMGL 库未加载,无法切换 2D 模式");const r=n.Cartographic.fromCartesian(t.camera.position);t.scene.morphTo2D?.(0),e.state.value.mapType="2d",e.eventBus.emit("map:mode-changed","2d"),t.camera.setView(Vt(n.Math.toDegrees(r.longitude),n.Math.toDegrees(r.latitude),r.height))}catch(n){w.error("切换到2D模式失败:",n)}}function Dr(e){const t=D();if(!t)throw new Error("BMGL 库未加载,无法计算 3D 目标视图");const n=t.Cartographic.fromCartesian(e.map.value.camera.position),r={lng:t.Math.toDegrees(n.longitude),lat:t.Math.toDegrees(n.latitude),height:Math.max(n.height,1e4)},i=yr(e);if(!i)return r;const a=(i.minx+i.maxx)/2,l=(i.miny+i.maxy)/2,s=(i.maxx-i.minx)*Math.cos(l*Math.PI/180)*H.METERS_PER_DEGREE_LAT_APPROX,u=(i.maxy-i.miny)*H.METERS_PER_DEGREE_LAT_APPROX,d=Math.max(s,u),c=t.Math.toRadians(H.CAMERA_FOV_DEGREES),f=Math.max(d/(2*Math.tan(c/2)),H.MIN_CAMERA_HEIGHT);return{lng:a,lat:l,height:f}}function Mr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="3d"))try{const n=Dr(e);t.scene.morphTo3D?.(0),e.state.value.mapType="3d",e.eventBus.emit("map:mode-changed","3d"),setTimeout(()=>{e.map.value&&e.map.value.camera.setView(Vt(n.lng,n.lat,n.height))},bt)}catch(n){w.error("切换到3D模式失败:",n)}}function Ir(e){e.state.value.mapType==="2d"?Mr(e):Sr(e)}function Pt(e){const t=sr(e),n=(i,a,l)=>wr(t,i,a,l),r=()=>Ir(t);return o.onBeforeUnmount(()=>{_t(t)}),{map:t.map,state:t.state,initMap:()=>br(t),setView:n,toggleMapType:r,destroy:()=>_t(t),on:t.eventBus.on.bind(t.eventBus),once:t.eventBus.once.bind(t.eventBus),off:t.eventBus.off.bind(t.eventBus),emit:t.eventBus.emit.bind(t.eventBus)}}function Ar(e){return{billboardCollection:null,billboardMap:new Map,pointDataCache:[],cacheIdIndex:new Map,gridIndex:null,gridSize:e,scaleByDistance:null}}function Bt(e,t,n){const r=Math.floor(t/e),i=Math.floor(n/e);return`${r},${i}`}function Rt(e,t){const n=Bt(e.gridSize,t.lng,t.lat),r=e.gridIndex?.get(n);r?r.push(t):e.gridIndex?.set(n,[t])}function zt(e,t){if(!e.gridIndex)return;const n=Bt(e.gridSize,t.lng,t.lat),r=e.gridIndex.get(n);if(!r)return;const i=r.indexOf(t);i>-1&&r.splice(i,1),r.length===0&&e.gridIndex.delete(n)}const xr=1e5;function Lr(e,t){const n=[];if(!e.gridIndex)return n;const r=Math.floor(t.west/e.gridSize),i=Math.floor(t.south/e.gridSize),a=Math.floor(t.east/e.gridSize),l=Math.floor(t.north/e.gridSize),s=(a-r+1)*(l-i+1),u=d=>d.lng>=t.west&&d.lng<=t.east&&d.lat>=t.south&&d.lat<=t.north;if(s>xr){for(const d of e.pointDataCache)u(d)&&n.push(d);return n}for(let d=r;d<=a;d++)for(let c=i;c<=l;c++){const f=e.gridIndex.get(`${d},${c}`)||[];for(const h of f)u(h)&&n.push(h)}return n}function Nr(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const[a,l]of e)a<t&&(t=a),l<n&&(n=l),a>r&&(r=a),l>i&&(i=l);return{west:t,south:n,east:r,north:i}}function kr(e){const[t,n]=e.center,r=e.radius/(H.METERS_PER_DEGREE_LAT*Math.cos(n*Math.PI/180)),i=e.radius/H.METERS_PER_DEGREE_LAT;return{west:t-r,east:t+r,south:n-i,north:n+i}}function _r(e){return e.type==="circle"?kr(e):Nr(e.coordinates)}function Vr(e,t){const[n,r]=e;let i=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const[s,u]=t[a],[d,c]=t[l];u>r!=c>r&&n<(d-s)*(r-u)/(c-u)+s&&(i=!i)}return i}function Pr(e,t){const[n,r]=t.center,i=t.radius*t.radius,a=(e.lng-n)*H.METERS_PER_DEGREE_LAT*Math.cos(r*Math.PI/180),l=(e.lat-r)*H.METERS_PER_DEGREE_LAT;return a*a+l*l<=i}function Br(e,t){return t.type==="circle"?e.filter(n=>Pr(n,t)):t.type==="polygon"||t.type==="triangle"?e.filter(n=>Vr([n.lng,n.lat],t.coordinates)):e}function Rr(e,t){if(!e.gridIndex||e.pointDataCache.length===0)return[];const n=_r(t);let r=Lr(e,n);return t.type!=="rectangle"&&(r=Br(r,t)),r}function zr(e,t){const{field:n,keyword:r,limit:i=10,caseSensitive:a=!1}=t,l=a?r.trim():r.trim().toLowerCase(),s=Array.isArray(n)?n:[n],u=[];for(const d of e.pointDataCache)if(s.some(f=>{const h=d[f];return h==null?!1:(a?String(h):String(h).toLowerCase()).includes(l)})&&(u.push(d),u.length>=i))break;return u}const Fr={lng:"lng",lat:"lat",altitude:"altitude",id:"id"};let Ft=0,Ot=!1,Gt=!1;function Or(){return Ot||(Ot=!0,w.warn("[useMapPoint] 检测到未提供 id 的点位,已启用自增 id 自动生成;建议通过 fieldMapping.id 提供稳定 id 以支持 updatePoints 精确定位")),Ft+=1,`__auto_${Ft}`}function Gr(){return typeof MessageChannel<"u"?new Promise(e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(0)}):new Promise(e=>setTimeout(e,0))}function Ur(e,t){if(!t.scaleByDistance){const n=Tt;t.scaleByDistance=new e.NearFarScalar(n.NEAR,n.NEAR_VALUE,n.FAR,n.FAR_VALUE)}return t.scaleByDistance}function Ut(e){const t=Ar(ne.GRID_SIZE),n=async()=>{if(!t.billboardCollection&&e.value){const d=D();d&&(t.billboardCollection=e.value.scene.primitives.add(new d.BillboardCollection))}return t.billboardCollection},r=()=>{if(t.billboardCollection)try{t.billboardCollection.removeAll()}catch(d){w.warn("[useMapPoint] removeAll billboard 失败:",d)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null},i=d=>{const c=t.cacheIdIndex.get(d);if(c===void 0)return;const f=t.pointDataCache[c],h=t.billboardMap.get(d);if(h&&t.billboardCollection)try{t.billboardCollection.remove(h)}catch(p){w.warn("[useMapPoint] 移除旧 billboard 失败:",p)}return t.billboardMap.delete(d),zt(t,f),c},a=(d,c,f,h)=>{const p=parseFloat(c[f.fieldMapping.lng])||0,b=parseFloat(c[f.fieldMapping.lat])||0,v=parseFloat(c[f.fieldMapping.altitude])||0,m=d.Cartesian3.fromDegrees(p,b,v),C=t.billboardCollection.add({position:m,image:c.icon,width:c.width||f.width,height:c.height||f.height,scaleByDistance:Ur(d,t),id:h,disableDepthTestDistance:Tt.NEAR,verticalOrigin:d.VerticalOrigin.BOTTOM});return C.pointData=c,{billboard:C,position:m,lng:p,lat:b,altitude:v}},l=async(d,c,f,h="append")=>{try{if(h==="replace"&&r(),!await n())return;const b=D();if(!b)return;const v={width:c?.width||20,height:c?.height||20,fieldMapping:{...Fr,...c?.fieldMapping||{}}},m=performance.now();t.gridIndex||(t.gridIndex=new Map);const C=Array.isArray(d)?d:[],y=C.length,E=ne.BATCH_SIZE,_=ne.YIELD_BUDGET_MS;let S=performance.now(),A=0;for(let V=0;V<y;V+=E){const U=C.slice(V,V+E);for(const z of U){if(!z.icon){A+=1,Gt||(Gt=!0,w.warn("[useMapPoint] 检测到缺失 icon 的点位,已跳过渲染;请在数据层通过 iconManager 预生成 icon 后传入"));continue}const M=z[v.fieldMapping.id],I=M!=null&&M!==""?String(M):Or(),F=i(I),{billboard:k,position:Y,lng:K,lat:pe,altitude:me}=a(b,z,v,I);t.billboardMap.set(I,k);const X={...z,id:I,lng:K,lat:pe,altitude:me,icon:z.icon};F!==void 0?t.pointDataCache[F]=X:(t.cacheIdIndex.set(I,t.pointDataCache.length),t.pointDataCache.push(X)),Rt(t,X)}V+E<y&&performance.now()-S>=_&&(await Gr(),S=performance.now())}A>0&&w.warn(`[useMapPoint] 本次加载跳过 ${A} 个缺失 icon 的点位`),console.log(`[useMapPoint] ${h} ${C.length} 个点位 billboard 渲染耗时:${(performance.now()-m).toFixed(0)}ms`)}catch(p){throw w.error("加载点位失败:",p),p}},s=async d=>{const c=D();for(const f of d){const h=String(f.id),p=t.billboardMap.get(h);if(p){if(f.icon&&(p.image=f.icon),f.width!==void 0&&(p.width=f.width),f.height!==void 0&&(p.height=f.height),c&&f.lng!==void 0&&f.lat!==void 0){const b=c.Cartesian3.fromDegrees(Number(f.lng),Number(f.lat),Number(f.altitude??0));p.position=b;const v=t.cacheIdIndex.get(h);if(v!==void 0){const m=t.pointDataCache[v];zt(t,m),m.lng=Number(f.lng),m.lat=Number(f.lat),f.altitude!==void 0&&(m.altitude=Number(f.altitude)),Rt(t,m)}}if(f.name!==void 0){const b=t.cacheIdIndex.get(h);b!==void 0&&(t.pointDataCache[b].name=String(f.name))}}}},u=async()=>{r()};return o.onUnmounted(()=>{try{const d=e.value?.scene;if(d?.primitives&&t.billboardCollection)try{d.primitives.remove(t.billboardCollection)}catch(c){w.warn("[useMapPoint] remove billboardCollection error:",c)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null,t.billboardCollection=null}catch(d){w.warn("[useMapPoint] onUnmounted cleanup error:",d)}}),{loadPoints:l,searchByShape:d=>Rr(t,d),searchByText:d=>zr(t,d),updatePoints:s,clearPoints:u}}function $t(e){return e?.rectangle?"rectangle":e?.polygon?"polygon":e?.polyline?"polyline":e?.ellipse||e?.position&&e?.billboard?"circle":"polygon"}function $e(e){if(e.length===0)return e;const t=e[0],n=e[e.length-1];return(Array.isArray(t)?t[0]===n[0]&&t[1]===n[1]:t.lng===n.lng&&t.lat===n.lat)?[...e]:[...e,t]}function $r(e,t=0){const n=D();return n?n.Cartesian3.fromDegrees(e.lng,e.lat,t):null}function Wt(e){const t=D();return t?{lng:t.Math.toDegrees(e.longitude),lat:t.Math.toDegrees(e.latitude)}:null}function De(e){const t=D();if(!t)return null;const n=t.Cartographic.fromCartesian(e);return Wt(n)}function We(e,t){return[[e.lng,e.lat],[t.lng,e.lat],[t.lng,t.lat],[e.lng,t.lat],[e.lng,e.lat]]}const ce={fillColor:"#ff0000",strokeColor:"#00ff00",lineColor:"#3366ff",strokeWidth:3,fillAlpha:.1,strokeAlpha:1,pointColor:"#ff0000",pixelSize:10,radius:1e3};function B(e,t){return N().Color.fromCssColorString(e).withAlpha(t)}function Ht(e){const t=N();return e.map(n=>Array.isArray(n)?t.Cartesian3.fromDegrees(n[0],n[1]):t.Cartesian3.fromDegrees(n.lng,n.lat))}function Wr(e,t=!0){const n=N(),r=ce;if(!e.coordinates||e.coordinates.length<3)throw new Error("多边形需要至少3个坐标点");const i=$e(e.coordinates),a=Ht(i),l=new n.Entity({polygon:{hierarchy:new n.PolygonHierarchy(a),material:B(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),s=new n.Entity({polyline:{positions:a,width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:l,strokeEntity:s,positions:a,closedCoordinates:i}}function Hr(e,t=!0){const n=N(),r=ce;if(!e.lineCoordinates||e.lineCoordinates.length<4)throw new Error("线段需要至少2个点");return{entity:new n.Entity({polyline:{positions:n.Cartesian3.fromDegreesArray(e.lineCoordinates),width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.lineColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}})}}function jr(e){const t=N(),n=ce;if(!e.center)throw new Error("圆形需要中心点坐标");const r=e.radius??n.radius;return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.center.lng,e.center.lat),ellipse:{semiMinorAxis:r,semiMajorAxis:r,height:0,material:B(e.fillColor??n.fillColor,e.fillAlpha??n.fillAlpha),outline:!0,outlineColor:B(e.strokeColor??n.strokeColor,e.strokeAlpha??n.strokeAlpha),outlineWidth:e.strokeWidth??n.strokeWidth}}),center:e.center,radius:r}}function Yr(e,t=!0){const n=N(),r=ce;if(!e.coordinates||e.coordinates.length<2)throw new Error("矩形需要两个对角点坐标");const[i,a]=e.coordinates,l=n.Rectangle.fromDegrees(Math.min(i.lng,a.lng),Math.min(i.lat,a.lat),Math.max(i.lng,a.lng),Math.max(i.lat,a.lat)),s=new n.Entity({rectangle:{coordinates:l,material:B(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),u=We(i,a),d=new n.Entity({polyline:{positions:Ht(u),width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:s,strokeEntity:d,coordinates:u}}function qr(e){const t=N(),n=ce;if(!e.point)throw new Error("点需要坐标");return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.point.lng,e.point.lat),point:{pixelSize:e.pixelSize??n.pixelSize,color:B(e.pointColor??n.pointColor,1),heightReference:t.HeightReference.CLAMP_TO_GROUND}}),point:[e.point.lng,e.point.lat]}}function Kr(e){const t=N();return!!(t.SceneMode&&e.scene.mode===t.SceneMode.SCENE2D)}const Xr={polygon:(e,t,n)=>{const r=Wr(e,t),i=n.entities.add(r.fillEntity),a=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:i,stroke:a},coordinates:r.closedCoordinates}},line:(e,t,n)=>{const r=Hr(e,t);return{nativeEntity:n.entities.add(r.entity),coordinates:e.lineCoordinates??[]}},circle:(e,t,n)=>{const r=jr(e);return{nativeEntity:n.entities.add(r.entity),coordinates:{center:r.center,radius:r.radius}}},rectangle:(e,t,n)=>{const r=Yr(e,t),i=n.entities.add(r.fillEntity),a=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:i,stroke:a},coordinates:r.coordinates}},point:(e,t,n)=>{const r=qr(e);return{nativeEntity:n.entities.add(r.entity),coordinates:r.point}}};function jt(e,t,n){const r=Xr[e];if(!r)throw new Error(`不支持的实体类型: ${e}`);return r(t,!Kr(n),n)}function Me(e,t){try{e.type==="polygon"||e.type==="rectangle"?(e.nativeEntity?.fill&&t.entities.remove(e.nativeEntity.fill),e.nativeEntity?.stroke&&t.entities.remove(e.nativeEntity.stroke)):e.nativeEntity&&t.entities.remove(e.nativeEntity)}catch(n){w.warn(`移除原生实体失败 (${e.id}):`,n)}}function He(e,t,n,r){return{color:e.fillColor||t.options.fillColor||n,alpha:e.fillAlpha!==void 0?e.fillAlpha:t.options.fillAlpha??r}}function Ie(e,t,n,r){return{color:e.strokeColor||t.options.strokeColor||n,alpha:e.strokeAlpha!==void 0?e.strokeAlpha:r}}function Zr(e,t){const n=N(),{fill:r,stroke:i}=e.nativeEntity,a=$e(t.coordinates),l=a.map(s=>n.Cartesian3.fromDegrees(s.lng,s.lat));r.polygon.hierarchy=new n.PolygonHierarchy(l),i.polyline.positions=l,e.coordinates=a}function Jr(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:a}=He(t,e,"#ff0000",.1);n.polygon.material=B(i,a)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:a}=Ie(t,e,"#00ff00",1);r.polyline.material=B(i,a)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=3&&Zr(e,t)}function Qr(e,t){const n=N(),{fill:r,stroke:i}=e.nativeEntity,[a,l]=t.coordinates;r.rectangle.coordinates=n.Rectangle.fromDegrees(Math.min(a.lng,l.lng),Math.min(a.lat,l.lat),Math.max(a.lng,l.lng),Math.max(a.lat,l.lat));const s=We(a,l);i.polyline.positions=s.map(u=>n.Cartesian3.fromDegrees(u[0],u[1])),e.coordinates=s}function ei(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:a}=He(t,e,"#ff0000",.1);n.rectangle.material=B(i,a)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:a}=Ie(t,e,"#00ff00",1);r.polyline.material=B(i,a)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=2&&Qr(e,t)}function ti(e,t){const n=N(),i=e.nativeEntity.polyline;if(i){if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:a,alpha:l}=Ie(t,e,"#3366ff",1);i.material=B(a,l)}t.strokeWidth!==void 0&&(i.width=t.strokeWidth),t.lineCoordinates&&t.lineCoordinates.length>=4&&(i.positions=n.Cartesian3.fromDegreesArray(t.lineCoordinates),e.coordinates=t.lineCoordinates)}}function ni(e,t){const n=N(),r=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:i,alpha:a}=He(t,e,"#ff0000",.1);r.ellipse.material=B(i,a)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:a}=Ie(t,e,"#00ff00",1);r.ellipse.outlineColor=B(i,a)}if(t.strokeWidth!==void 0&&(r.ellipse.outlineWidth=t.strokeWidth),t.radius!==void 0&&(r.ellipse.semiMinorAxis=t.radius,r.ellipse.semiMajorAxis=t.radius),t.center){r.position=n.Cartesian3.fromDegrees(t.center.lng,t.center.lat);const i=e.coordinates,a=i&&!Array.isArray(i)?i.radius:void 0;e.coordinates={center:t.center,radius:t.radius||a||1e3}}}function ri(e,t){const n=N(),r=e.nativeEntity,i=r.point;i&&(t.pointColor!==void 0&&(i.color=B(t.pointColor,1)),t.pixelSize!==void 0&&(i.pixelSize=t.pixelSize),t.point&&(r.position=n.Cartesian3.fromDegrees(t.point.lng,t.point.lat),e.coordinates=[t.point.lng,t.point.lat]))}function ii(e,t){const n=e.nativeEntity;e.type==="polygon"||e.type==="rectangle"?(n.fill.show=t,n.stroke.show=t):n.show=t}function ai(e,t,n){e==="polygon"?Jr(t,n):e==="rectangle"?ei(t,n):e==="line"?ti(t,n):e==="circle"?ni(t,n):e==="point"&&ri(t,n)}function oi(e,t){const n=t.coordinates;n&&((e.type==="polygon"||e.type==="rectangle")&&!e.coordinates&&Array.isArray(n)&&(e.coordinates=n),e.type==="line"&&!e.lineCoordinates&&t.type==="line"&&Array.isArray(n)&&(e.lineCoordinates=n),e.type==="circle"&&!e.center&&t.type==="circle"&&!Array.isArray(n)&&(e.center=n.center,e.radius=n.radius||1e3),e.type==="point"&&!e.point&&t.type==="point"&&Array.isArray(n)&&(e.point=n))}async function li(e,t,n,r,i){Me(t,r);const a={...t.options,...n,id:e,type:n.type};return oi(a,t),await i(a)!==null}function Yt(e){const t=new Map;let n="";const r=()=>!e.value||!e.value.entities?(w.warn("地图实例未就绪"),!1):!0,i=async()=>{if(r())return!0;try{return await xt(),r()}catch{return!1}},a=async c=>{try{if(!await i())return null;const f=e.value;if(!f)return null;const h=c.id||`${c.type}-${Date.now()}`,{nativeEntity:p,coordinates:b}=jt(c.type,c,f),v={id:h,type:c.type,options:{...c,id:h,type:c.type,visible:c.visible!==!1},nativeEntity:p,coordinates:b};return t.set(h,v),n=h,h}catch(f){return w.error("绘制实体失败:",f),null}},l=c=>{try{if(!r())return!1;const f=e.value;if(!f)return!1;if(!c)return t.forEach(p=>Me(p,f)),t.clear(),n="",!0;const h=t.get(c);return h?(Me(h,f),t.delete(c),n===c&&(n=""),!0):(w.warn(`实体未找到: ${c}`),!1)}catch(f){return w.error("删除实体失败:",f),!1}},s=()=>n,u=async(c,f)=>{try{const h=t.get(c);if(!h)return w.warn(`实体未找到:${c}`),!1;if(!await i())return!1;const p=e.value;return p?f.type&&f.type!==h.type?await li(c,h,f,p,a):(ai(h.type,h,f),f.name!==void 0&&(h.options.name=f.name),f.visible!==void 0&&ii(h,f.visible),h.options={...h.options,...f},t.set(c,h),!0):!1}catch(h){return w.error(`修改实体失败 (${c}):`,h),!1}},d=()=>{if(!r())return;const c=e.value;if(c)for(const[f,h]of t)try{Me(h,c),h.nativeEntity=jt(h.type,h.options,c).nativeEntity}catch(p){w.warn(`重绘实体失败 (${f}):`,p)}};return o.onUnmounted(()=>{try{t.clear(),n=""}catch(c){w.warn("[useMapEntity] onUnmounted cleanup error:",c)}}),{drawEntity:a,updateEntity:u,deleteEntity:l,redrawAllEntities:d,getCurrentEntityId:s}}function si(){return{drawInstance:null,editInstance:null,currentDrawId:"",currentDrawType:null,isDrawing:!1,isEditing:!1,drawCallback:null,mapInstance:null,mapHandler:null,eventListeners:[],lastEditedEntity:null,drawEntityIds:new Set}}const ue={fillColor:"#369",fillAlpha:.6,borderColor:"#fff",borderAlpha:.8,lineWidth:2,labelFont:"14px arial",arrowWidth:20};function Ae(e,t,n,r){return typeof e!="number"||Number.isNaN(e)?r:Math.min(n,Math.max(t,e))}class ci{constructor(t){this.config={...ue,...t},this.config.fillAlpha=Ae(this.config.fillAlpha,0,1,ue.fillAlpha),this.config.borderAlpha=Ae(this.config.borderAlpha,0,1,ue.borderAlpha),this.config.lineWidth=Ae(this.config.lineWidth,1,50,ue.lineWidth),this.config.arrowWidth=Ae(this.config.arrowWidth,1,100,ue.arrowWidth)}materials(t){const{fillColor:n,fillAlpha:r,borderColor:i,borderAlpha:a}=this.config;return{fill:t.Color.fromCssColorString(n).withAlpha(r),border:t.Color.fromCssColorString(i).withAlpha(a)}}label(t){const{labelFont:n}=this.config;return{fillColor:t.Color.WHITE,font:n,verticalOrigin:t.VerticalOrigin.BOTTOM,pixelOffset:new t.Cartesian2(0,-20),disableDepthTestDistance:5e3}}getDrawConfig(){const t=N(),{fill:n,border:r}=this.materials(t),i=this.label(t),a=this.config.lineWidth,l={bmgl:t,config:this.config,shared:{fill:n,border:r,label:i,width:a}},s={repeat:!0};for(const u of gt())u.buildConfig&&(s[u.type]=u.buildConfig(l));return s}getEditConfig(){const t=N();return{axis:{scale:1},control:{tolerance:4,marker:{eyeOffset:new t.Cartesian3(0,0,-20),verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:5e3}}}}}function qt(e){return e.map(t=>De(t)).filter(t=>t!==null)}function ui(e){try{const t=e.polygon.hierarchy.getValue().positions||[],n=qt(t);return{type:"polygon",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return w.error("提取多边形数据失败:",t),null}}function di(e){const t=N();try{const n=e.rectangle.coordinates.getValue(),r=t.Math.toDegrees(n.west),i=t.Math.toDegrees(n.south),a=t.Math.toDegrees(n.east),l=t.Math.toDegrees(n.north);return{type:"rectangle",path:[[r,l],[a,l],[a,i],[r,i],[r,l]],rawPath:[{lng:r,lat:l},{lng:a,lat:l},{lng:a,lat:i},{lng:r,lat:i}],radius:void 0}}catch(n){return w.error("提取矩形数据失败:",n),null}}function fi(e){try{const t=e.polyline.positions.getValue(),n=qt(t);return{type:"polyline",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return w.error("提取折线数据失败:",t),null}}function hi(e){try{const t=De(e.position.getValue());if(!t)return null;const n=e.ellipse.semiMajorAxis?.getValue()||0,r=e.ellipse.semiMinorAxis?.getValue()||0;return{type:"circle",center:[t.lng,t.lat],radius:Math.max(n,r),rawPath:[t]}}catch(t){return w.error("提取圆形数据失败:",t),null}}function gi(e){try{const t=De(e.position.getValue());return t?{type:"circle",center:[t.lng,t.lat],radius:e.radius||0,rawPath:[t]}:null}catch{return null}}function Kt(e){return e?e.polygon?ui(e):e.rectangle?di(e):e.polyline?fi(e):e.position&&e.ellipse?hi(e):e.billboard&&e.position?gi(e):null:null}function pi(e){return $t(e)}function mi(e){return e.editInstance&&(e.editInstance.isEditing||e.editInstance._isEditing||e.editInstance.editing)||!1}function wi(e){typeof e.finish=="function"?e.finish():typeof e.stop=="function"?e.stop():typeof e.disable=="function"?e.disable():typeof e.end=="function"?e.end():e.isEditing=!1}function de(e,t=!1){if(e.editInstance){t&&e.currentDrawId&&(e.lastEditedEntity=e.mapInstance?.entities.getById(e.currentDrawId)??null);try{wi(e.editInstance)}catch(n){w.error("结束编辑状态失败:",n)}finally{e.isEditing=!1}t&&e.lastEditedEntity&&yi(e)}}function J(e,t){if(e.drawCallback)try{e.drawCallback(t)}catch(n){w.error("绘图回调执行失败:",n)}else w.warn("绘图回调函数未设置")}function yi(e){if(!(!e.lastEditedEntity||!e.currentDrawId))try{const t=Kt(e.lastEditedEntity);if(!t)return;const n={type:t.type,layer:{_id:e.currentDrawId},path:t.rawPath||[]};t.type==="circle"&&t.radius!==void 0&&(n.radius=t.radius),J(e,{type:t.type,operation:"edit",id:e.currentDrawId,data:t,rawData:n}),e.lastEditedEntity=null}catch(t){w.error("手动触发编辑完成事件失败:",t)}}function vi(e,t,n){try{if(e.drawInstance||n(),!e.drawInstance)throw new Error("绘图实例初始化失败");if(e.isEditing&&de(e,!1),e.isDrawing=!0,e.currentDrawType=t,typeof e.drawInstance.enable=="function")e.drawInstance.enable(t);else if(typeof e.drawInstance.start=="function")e.drawInstance.start(t);else throw new Error("绘图实例没有可用的启用方法")}catch(r){throw w.error(`开始绘制 ${t} 失败:`,r),e.isDrawing=!1,e.currentDrawType=null,r}}function Ci(e){const t=(n,...r)=>{if(n){for(const i of r)if(typeof n[i]=="function"){n[i]();return}}};t(e.drawInstance,"disable","stop"),t(e.editInstance,"disable","stop")}function bi(e){e.currentDrawId="",e.currentDrawType=null,e.isDrawing=!1,e.isEditing=!1,e.lastEditedEntity=null}function Q(e){e.isEditing&&de(e,!1),Ci(e),bi(e)}function Ei(e,t=""){if(!e.mapInstance)return;const n=t||e.currentDrawId;if(e.isEditing&&de(e,!1),!n){Q(e);return}const r=e.mapInstance.entities.getById(n);if(r){const i=Kt(r);if(e.mapInstance.entities.remove(r),e.drawEntityIds.delete(n),e.currentDrawId===n&&(e.currentDrawId=""),i){const a={type:i.type,layer:{_id:n},path:i.rawPath||[]};i.type==="circle"&&i.radius!==void 0&&(a.radius=i.radius),J(e,{type:i.type,operation:"delete",id:n,data:i,rawData:a})}}Q(e)}function Ti(e){if(!e.mapInstance)return;e.isEditing&&de(e,!1);let t=0;if(e.drawEntityIds.size>0){for(const r of e.drawEntityIds){const i=e.mapInstance.entities.getById(r);i&&(e.mapInstance.entities.remove(i),t++)}e.drawEntityIds.clear()}else{const r=e.mapInstance.entities?.values||[];r.some(a=>!e.drawEntityIds.has(a?._id))||(e.mapInstance.entities.removeAll(),t=r.length)}const n=e.currentDrawType||"polygon";J(e,{type:n,operation:"clear",data:null,rawData:null,count:t}),Q(e)}class j{static process(t){if(!t?.type)return null;try{const n=j.getProcessor(t.type);if(!n)return null;const r=n(t);return r?{...r,id:t.layer?._id||""}:null}catch(n){return w.error("数据处理失败:",n),null}}static getProcessor(t){return{rectangle:j.processRectangle,polygon:j.processPolygon,circle:j.processCircle,triangle:j.processTriangle,polyline:j.processPolyline}[t]}static processRectangle(t){const[n,r]=t.path||[];return!n||!r?null:{type:"rectangle",path:[[n.lng,n.lat],[r.lng,n.lat],[r.lng,r.lat],[n.lng,r.lat],[n.lng,n.lat]]}}static processPolygon(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polygon",path:[...n,n[0]]}}static processCircle(t){const n=t.path;return!n||n.lng===void 0?null:{type:"circle",center:[n.lng,n.lat],radius:t.radius||0}}static processTriangle(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"triangle",path:[...n,n[0]]}}static processPolyline(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polyline",path:n}}}function Si(e,t,n){J(e,{type:pi(n),operation:"select",id:t,data:{id:t},rawData:n})}function Di(e){if(mi(e)){de(e,!0);return}e.isDrawing&&e.currentDrawType&&J(e,{type:e.currentDrawType,operation:"cancel",id:e.currentDrawId,data:null,rawData:null}),Q(e)}function Mi(e,t){if(!e.mapInstance)return;const n=N(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const i=r?.id?._id;if(typeof i!="string"||!i)return;const a=e.mapInstance.entities.getById(i);if(!a||!e.editInstance)return;e.currentDrawId=i,e.lastEditedEntity=a;const l=e.editInstance;typeof l.edit=="function"?l.edit(a):typeof l.start=="function"?l.start(a):typeof l.enable=="function"&&l.enable(a),e.isEditing=!0}function Ii(e,t){if(!e.mapInstance||e.isDrawing)return;const n=N(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const i=r?.id?._id;if(typeof i!="string"||!i)return;const a=e.mapInstance.entities.getById(i);a&&(e.currentDrawId=i,Si(e,i,a))}function Ai(e,t){const n=j.process(t.detail);if(!n)return;n.id&&e.drawEntityIds.add(n.id);const r={type:n.type,operation:"draw",id:n.id,data:n,rawData:t.detail};J(e,r),Q(e)}function xi(e,t){e.isEditing=!1;const n=j.process(t.detail);if(!n){e.lastEditedEntity=null;return}const r={type:n.type,operation:"edit",id:n.id,data:n,rawData:t.detail};J(e,r),e.lastEditedEntity=null}function Xt(e){e.eventListeners.forEach(({type:t})=>{try{e.mapHandler?.removeInputAction(t)}catch(n){w.warn(`移除 ${t} 事件监听器失败:`,n)}}),e.eventListeners=[]}function Li(e){Xt(e);const t=e.mapHandler;if(!t)return;const n=N(),r=[n.ScreenSpaceEventType.RIGHT_CLICK,n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,n.ScreenSpaceEventType.LEFT_CLICK],i=[()=>Di(e),a=>Mi(e,a),a=>Ii(e,a)];r.forEach((a,l)=>{t.setInputAction(i[l],a),e.eventListeners.push({type:a})})}function Ni(e){e.drawInstance&&(e.drawInstance.on("bm_draw_end",t=>Ai(e,t)),e.editInstance&&e.editInstance.on("bm_edit_end",t=>xi(e,t)))}function ki(e,t,n){try{if(e.mapInstance=o.isRef(t)?t.value:t,!e.mapInstance)throw new Error("地图实例不可用");if(!D())throw new Error("BMGL 库未加载");if(e.mapHandler=e.mapInstance.screenSpaceEventHandler,!e.mapHandler)throw new Error("地图事件处理器不可用");const r=N(),i=new ci(n);e.drawInstance=new r.Plot.Draw(e.mapInstance,i.getDrawConfig()),e.editInstance=new r.Plot.Edit(e.mapInstance,i.getEditConfig()),Li(e),Ni(e)}catch(r){throw w.error("绘图工具初始化失败:",r),r}}function Zt(e){try{Q(e),Xt(e),e.drawInstance&&typeof e.drawInstance.destroy=="function"&&e.drawInstance.destroy(),e.editInstance&&typeof e.editInstance.destroy=="function"&&e.editInstance.destroy(),e.drawInstance=null,e.editInstance=null,e.drawCallback=null,e.mapHandler=null,e.lastEditedEntity=null}catch(t){w.error("清理绘图工具资源失败:",t)}}function Jt(e,t){const n=si(),r=()=>ki(n,e,t),i=s=>{n.drawCallback=s},a=()=>({isDrawing:n.isDrawing,isEditing:n.isEditing,currentDrawId:n.currentDrawId,currentDrawType:n.currentDrawType,drawInstance:!!n.drawInstance,editInstance:!!n.editInstance}),l=()=>n.isDrawing;if(e&&typeof e=="object"&&"value"in e)o.watch(e,s=>{if(s&&!n.drawInstance)try{r()}catch(u){w.warn("自动初始化失败,将在绘图时重试:",u)}},{immediate:!0});else if(e)try{r()}catch(s){w.warn("自动初始化失败,将在绘图时重试:",s)}return o.onUnmounted(()=>{Zt(n)}),{startDrawing:s=>vi(n,s,r),cancelDrawing:()=>Q(n),removeDrawing:(s="")=>Ei(n,s),clearAllDrawings:()=>Ti(n),setCallback:i,getDrawingStatus:a,getIsDrawing:l,initialize:r,cleanup:()=>Zt(n)}}function _i(){return{popupLayer:null,divLayerManager:null,mapInstance:null,currentPopupData:null,displayConfig:null,popupSeq:0}}function fe(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Vi(e){return e&&/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)?e:""}function re(e,t){return typeof e=="number"&&!Number.isNaN(e)?e.toFixed(t):"-"}function Pi(e){return R[e||"default"]||R.default}function Bi(e){return[`--status-color: ${e.color}`,`--status-bg: ${e.color}10`,`--status-border: ${e.color}30`,`--status-shadow: ${e.color}30`].join(";")}function Ri(e,t){const n=[e.lineCode,e.lineNo,e.pointNo].filter(i=>i!=null&&i!==""),r=n.length?`<div class="map-point-popup-subtitle"><span>${n.map(i=>fe(i)).join('<span class="map-point-popup-divider">|</span>')}</span></div>`:"";return`
1
+ (function(g,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(g=typeof globalThis<"u"?globalThis:g||self,o(g.BigmapPlugin={},g.Vue))})(this,(function(g,o){"use strict";const dt={debug:10,info:20,warn:30,error:40,silent:Number.POSITIVE_INFINITY},ve="[sems-map]";function qn(){try{const e=typeof process<"u"?process.env:void 0;if(e&&e.NODE_ENV==="production")return"warn"}catch{}return"debug"}let Pe=qn();function Kn(e){Pe=e}function Xn(){return Pe}function Ce(e){return dt[e]>=dt[Pe]}const w={debug(...e){Ce("debug")&&console.debug(ve,...e)},info(...e){Ce("info")&&console.info(ve,...e)},warn(...e){Ce("warn")&&console.warn(ve,...e)},error(...e){Ce("error")&&console.error(ve,...e)}},ft=Symbol("originalHandler");class Be{constructor(){this.events=new Map}on(t,n){return this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(n),()=>this.off(t,n)}once(t,n){const r=a=>{n(a),this.off(t,r)};return r[ft]=n,this.on(t,r)}off(t,n){if(!n){this.events.delete(t);return}const r=this.events.get(t);if(!r)return;const a=r.findIndex(i=>i===n||i[ft]===n);a>-1&&r.splice(a,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 a=r.slice(),i=[];for(const l of a)try{const s=l(n);s&&typeof s.then=="function"&&i.push(s.catch(u=>{w.error(`[EventBus] Error in async handler for event "${String(t)}":`,u)}))}catch(s){w.error(`[EventBus] Error in handler for event "${String(t)}":`,s)}i.length>0&&await Promise.all(i)}clear(){this.events.clear()}getStats(){return Array.from(this.events.entries()).map(([t,n])=>({event:String(t),handlerCount:n.length}))}}const Zn=new Be,oe=new Map;function q(e){oe.set(e.type,e)}q({type:"area",name:"测面积",defaultSize:15,icon:"area",toolbarOrder:4,buildConfig:({shared:e})=>({material:e.fill,labelOptions:e.label})}),q({type:"polygon",name:"绘制多边形",defaultSize:14,icon:"polygon",toolbarOrder:1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})}),q({type:"circle",name:"绘制圆形",defaultSize:17,icon:"circle",toolbarOrder:2,buildConfig:({bmgl:e,config:t,shared:n})=>({material:n.fill,width:n.width,controlLine:{permanent:!0,lineStyle:{width:n.width,clampToGround:!0,material:n.border},textStyle:{font:t.labelFont,disableDepthTestDistance:1/0,verticalOrigin:e.VerticalOrigin.BOTTOM}}})}),q({type:"azimuth",name:"测方位",defaultSize:15,icon:"azimuth",toolbarOrder:6,buildConfig:({bmgl:e,config:t})=>({clampToGround:!0,material:new e.PolylineArrowMaterialProperty(e.Color.fromCssColorString(t.fillColor)),width:t.arrowWidth,labelOptions:{fillColor:e.Color.YELLOW}})}),q({type:"ruler",name:"测距离",defaultSize:15,icon:"ruler",toolbarOrder:5,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill,labelOptions:t.label})}),q({type:"polyline",name:"绘制线",defaultSize:16,icon:"polyline",toolbarOrder:3,buildConfig:({config:e,shared:t})=>({width:e.lineWidth+3,clampToGround:!0,material:t.fill})}),q({type:"triangle",name:"绘制三角形",defaultSize:16,icon:"triangle",inDefaultToolbar:!1,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:4,material:t.fill})}),q({type:"rectangle",name:"绘制矩形",defaultSize:16,icon:"rectangle",toolbarOrder:0,buildConfig:({bmgl:e,shared:t})=>({classificationType:e.ClassificationType.BOTH,width:t.width,material:t.fill})});function Jn(e){oe.set(e.type,e)}function ht(e){return oe.get(e)}function gt(){return[...oe.values()]}function pt(){return[...oe.values()].filter(e=>e.inDefaultToolbar!==!1).sort((e,t)=>(e.toolbarOrder??Number.MAX_SAFE_INTEGER)-(t.toolbarOrder??Number.MAX_SAFE_INTEGER))}function mt(){return pt().map(e=>({icon:e.type,name:e.name,size:e.defaultSize}))}const be="/libs",te={lng:104.03770513,lat:30.48187111,height:2e4},Ee={heading:6.267876539812834,pitch:-1.3962634015954636,roll:.00016118230151462853},Te={FLY_TO:2,MORPH:.8,WAVE:3e3},ne={BATCH_SIZE:200,YIELD_BUDGET_MS:8,DEBOUNCE_DELAY:300,GRID_SIZE:.1},Re=mt(),wt=["bigemap.dc-satellite","bigemap.dc-street"],yt={spacing:150,width:2},vt={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},Ct={fillColor:"#000000",fillAlpha:.8,outlineColor:"#44d5ff",outlineAlpha:1,outlineWidth:4,showOutline:!0},ze={containerId:"bigmap-container",libsUrl:be,mapType:"3d",position:te,mapId:"bigemap.cebjohn0",terrainId:"bigemap.dc-terrain",baseLayers:wt,showSearch:!1,showControls:!0,showStatus:!1,showDeleteControls:!0,tools:Re,searchDebounceTime:ne.DEBOUNCE_DELAY},H={METERS_PER_DEGREE_LAT:111320,METERS_PER_DEGREE_LAT_APPROX:111e3,CAMERA_FOV_DEGREES:60,MIN_CAMERA_HEIGHT:1e3},bt=500,Et=800,Qn=200,er=900,Tt=1e4,tr=100,nr=1e3,St={NEAR:3e3,NEAR_VALUE:1,FAR:1e5,FAR_VALUE:.1},rr=6,ar=1001,R={1:{color:"#9E9E9E",text:"未发布"},2:{color:"#2196F3",text:"已发布"},3:{color:"#FF9800",text:"未完成"},4:{color:"#4CAF50",text:"已完成"},5:{color:"#FF5722",text:"整改"},6:{color:"#E91E63",text:"整改中"},7:{color:"#8BC34A",text:"整改完成"},8:{color:"#009688",text:"合格"},9:{color:"#00BCD4",text:"整改合格"},10:{color:"#F44336",text:"不合格"},11:{color:"#9C27B0",text:"变观中"},12:{color:"#673AB7",text:"已变观"},13:{color:"#607D8B",text:"任务终止"},default:{color:"#2196F3",text:"未知状态"}},ir=e=>R[e]||R.default;function or(e){if(!e)return{};const t={};for(const n of Object.keys(e)){const r=e[n];r!==void 0&&(t[n]=r)}return t}function Fe(...e){const t={...ze};for(const n of e){const r=or(n);Object.assign(t,r),r.geoserver&&(t.geoserver={...t.geoserver||{},...r.geoserver})}return t}function lr(e,t){return Fe(e,t)}class Dt{constructor(t){this.config=Fe(t)}get(t){return this.config[t]}set(t,n){this.config[t]=n}getAll(){return{...this.config}}update(t){this.config=Fe(this.config,t)}reset(){this.config={...ze}}}class Mt{constructor(){this.resources=new Set}register(t){this.resources.add(t)}unregister(t){this.resources.delete(t)}async cleanup(){const t=Array.from(this.resources);this.resources.clear(),await Promise.allSettled(t.map(async n=>{try{await n()}catch(r){w.error("[ResourceManager] Error during cleanup:",r)}}))}getResourceCount(){return this.resources.size}}function sr(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 cr(e){return{configManager:new Dt(e),eventBus:new Be,resourceManager:new Mt,map:o.shallowRef(null),state:o.ref(sr(e.mapType||"3d")),cancelled:{value:!1},destroyed:{value:!1},initializing:{value:!1}}}const It=be,Oe={"bigemap-2d":{name:"BigMap 2D",path:"/libs/bigemap/bigemap.js",dependencies:["bigemap-2d-css"]},"bigemap-2d-css":{name:"BigMap 2D CSS",path:"/libs/bigemap/bigemap.css",isCss:!0},"bigemap-3d":{name:"BigMap 3D",path:"/bigemap-gl.js/v1.1.0/bigemap-gl.js",dependencies:["bigemap-3d-css"]},"bigemap-3d-css":{name:"BigMap 3D CSS",path:"/libs/bigemap/widgets.css",isCss:!0},"bmgl-plot":{name:"BigMap Plot",path:"/libs/bigemap/bmgl-plot.min.js",dependencies:["bigemap-3d"]},"circle-wave":{name:"Circle Wave",path:"/libs/bigemap/circleWave.js",dependencies:["bmgl-plot"]},"bm-geometry-util":{name:"BigMap Geometry Util",path:"/libs/bigemap/bm.geometryutil.js",dependencies:["bigemap-3d"]},"move-marker":{name:"BigMap Move Marker",path:"/libs/bigemap/moveMarker.js",dependencies:["bigemap-3d","bm-geometry-util"]},"bmgl-header":{name:"BMGL Sandcastle Header",path:"/libs/bigemap/bmgl-header.js",dependencies:["bigemap-3d"]}};function Ge(e,t,n){if(e.path.startsWith("/libs/"))return n+e.path.slice(5);if(e.path.startsWith("/")){if(!t)throw new Error(`未配置 serverUrl,无法解析地图资源路径: ${e.path}`);return t.replace(/\/$/,"")+e.path}return e.path}const Se=3e4;class At{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 a=document.createElement("script");a.src=t,a.async=!0;let i=!1;const l=setTimeout(()=>{i||(i=!0,a.remove(),r(new Error(`脚本加载超时(${Se/1e3}s): ${t}`)))},Se);a.onload=()=>{i||(i=!0,clearTimeout(l),n())},a.onerror=()=>{i||(i=!0,clearTimeout(l),a.remove(),r(new Error(`脚本加载失败: ${t}`)))},document.head.appendChild(a)})}loadCss(t){return new Promise((n,r)=>{if(document.querySelector(`link[href="${t}"]`)){n();return}const a=document.createElement("link");a.rel="stylesheet",a.href=t;let i=!1;const l=setTimeout(()=>{i||(i=!0,a.remove(),r(new Error(`样式加载超时(${Se/1e3}s): ${t}`)))},Se);a.onload=()=>{i||(i=!0,clearTimeout(l),n())},a.onerror=()=>{i||(i=!0,clearTimeout(l),a.remove(),r(new Error(`样式加载失败: ${t}`)))},document.head.appendChild(a)})}loadResource(t,n,r){const a=Ge(t,n,r);if(this.loaded.has(a))return Promise.resolve();if(this.pending.has(a))return this.pending.get(a);const i=t.isCss?this.loadCss(a):this.loadJs(a);return this.pending.set(a,i),i.then(()=>{this.loaded.add(a)}).finally(()=>{this.pending.delete(a)}),i}async loadWithDependencies(t,n,r,a){const l={...Oe,...a}[t];if(!l)throw new Error(`库配置未找到: ${t}`);for(const s of l.dependencies||[])await this.loadWithDependencies(s,n,r,a);await this.loadResource(l,n,r)}async loadScripts(t,n,r=It,a){await Promise.all(t.map(i=>this.loadWithDependencies(i,n,r,a)))}isLoaded(t,n,r){const a=Oe[t];if(!a||a.path.startsWith("/")&&!a.path.startsWith("/libs/")&&!n)return!1;const i=Ge(a,n||"",r||It);return this.loaded.has(i)}clearLoaded(){this.loaded.clear(),this.pending.clear()}}const Ue=new At;let le=null;function Lt(e){le=e}function D(){return le||(typeof window<"u"&&window.bmgl?(le=window.bmgl,le):null)}function N(){const e=D();if(!e)throw new Error("bmgl 库未就绪:请确保地图初始化完成后再调用该能力");return e}async function xt(e=3e3){const t=D();return t||new Promise((n,r)=>{const a=Date.now(),i=setInterval(()=>{const l=D();l?(clearInterval(i),n(l)):Date.now()-a>e&&(clearInterval(i),r(new Error("bmgl 加载超时")))},50)})}class Z{constructor(){this.entries=new Map}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}register(t,n,r,a){this.entries.set(t,{map:n,eventBus:r,resourceManager:a})}get(t){return this.entries.get(t)?.map}has(t){return this.entries.has(t)}getEventBus(t){return this.entries.get(t)?.eventBus}getResourceManager(t){return this.entries.get(t)?.resourceManager}async unregister(t){const n=this.entries.get(t);if(n&&(this.entries.delete(t),await n.resourceManager.cleanup(),n.eventBus.clear(),!n.map.isDestroyed?.()))try{n.map.destroy()}catch(r){w.error("[MapManager] Error destroying map:",r)}}getAllMapIds(){return Array.from(this.entries.keys())}async cleanupAll(){const t=this.getAllMapIds();await Promise.all(t.map(n=>this.unregister(n)))}}const se=Z.getInstance();function ur(e,t=3e3){return new Promise((n,r)=>{const a=Date.now(),i=setInterval(()=>{document.getElementById(e)?(clearInterval(i),n()):Date.now()-a>t&&(clearInterval(i),r(new Error(`容器未找到: ${e}`)))},16)})}async function dr(e){const t=e.configManager.get("containerId");if(!t)throw new Error("容器ID未定义");return await ur(t),t}async function fr(e){const t=e.configManager.get("serverUrl"),n=e.configManager.get("accessToken"),r=e.configManager.get("libsUrl"),a=e.configManager.get("extraLibs");try{await Ue.loadScripts(["bigemap-3d","bmgl-plot","circle-wave"],t,r,a)}catch(l){throw w.error("[loadBmglScripts] 地图服务连接失败,请确认 serverUrl 可达且服务已启动:",l),new Error("地图服务连接失败,请确认服务器地址正确且服务已启动")}const i=D();if(!i)throw new Error("BMGL 库加载失败");Lt(i),i.Config.HTTP_URL=t,n&&(console.log("accessToken",n),i.Config.accessToken=n),hr(i)}function hr(e){e.RequestScheduler&&(e.RequestScheduler.maximumRequests=120,e.RequestScheduler.maximumRequestsPerServer=18)}function gr(e){const t=D(),n=e.configManager.get("containerId");if(!t||!n)throw new Error("地图实例创建失败:BMGL 库或容器 ID 未就绪");const r=new t.Viewer(n,{mapId:e.configManager.get("mapId"),terrainId:e.configManager.get("terrainId"),requestRenderMode:!1,selectionIndicator:!1,infoBox:!1});return pr(r,e.state.value.mapType),r}function pr(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 mr(e,t,n){if(se.has(n))try{await se.unregister(n)}catch(r){w.warn(`[registerMap] 清理残留地图实例失败 (${n}):`,r)}se.register(n,t,e.eventBus,e.resourceManager)}function Nt(e){return typeof e=="number"&&!Number.isNaN(e)?e:1e4}function kt(e,t,n){const r=D();if(!r)throw new Error("BMGL 库未加载,无法构造相机目标位置");return r.Cartesian3.fromDegrees(e,t,n)}function _t(){return{heading:Ee.heading,pitch:Ee.pitch,roll:Ee.roll}}function wr(e){const t=e.configManager.get("position");t&&e.map.value?.camera.flyTo({destination:kt(t.lng,t.lat,Nt(t.height)),orientation:_t(),duration:Te.FLY_TO})}function yr(e,t,n,r){e.map.value&&e.map.value.camera.flyTo({destination:kt(t,n,Nt(r)),orientation:_t(),duration:Te.FLY_TO})}function vr(e){const t=D();if(!e.map.value||!t)return null;const n=e.map.value.camera.computeViewRectangle();return n?{minx:t.Math.toDegrees(n.west),maxx:t.Math.toDegrees(n.east),miny:t.Math.toDegrees(n.south),maxy:t.Math.toDegrees(n.north)}:Cr(e)}function Cr(e){const t=D();if(!t)return null;const n=e.map.value,r=n.scene.globe.ellipsoid;try{const a=n.camera.pickEllipsoid(new t.Cartesian2(0,0),r),i=n.camera.pickEllipsoid(new t.Cartesian2(n.scene.canvas.clientWidth,n.scene.canvas.clientHeight),r);if(!a||!i)return null;const l=r.cartesianToCartographic(a),s=r.cartesianToCartographic(i);return{minx:t.Math.toDegrees(l.longitude),maxx:t.Math.toDegrees(s.longitude),miny:t.Math.toDegrees(s.latitude),maxy:t.Math.toDegrees(l.latitude)}}catch{return null}}function br(e){return e.initializing.value||!!e.map.value||e.destroyed.value}async function Er(e){if(!br(e)){e.cancelled.value=!1,e.initializing.value=!0,e.state.value.isLoading=!0,e.state.value.error=null;try{await Tr(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 Tr(e){const t=await dr(e);if(await fr(e),e.cancelled.value)return;const n=gr(e);if(e.cancelled.value){Sr(n);return}e.map.value=n,await mr(e,n,t),await wr(e),!e.cancelled.value&&(e.state.value.isReady=!0,await e.eventBus.emit("map:ready"))}function Sr(e){try{e.destroy()}catch(t){w.error("[useMap] 销毁未注册的地图实例失败:",t)}}async function Vt(e){if(e.cancelled.value=!0,e.destroyed.value=!0,!e.map.value)return;const t=e.configManager.get("containerId");if(e.map.value=null,e.state.value.isReady=!1,t)try{await se.unregister(t)}catch(n){w.error("[useMap] 销毁地图失败:",n)}}function Pt(e,t,n){const r=D();if(!r)throw new Error("BMGL 库未加载,无法构造目标视角");return{destination:r.Cartesian3.fromDegrees(e,t,n),orientation:{heading:0,pitch:r.Math.toRadians(-90),roll:0}}}function Dr(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="2d"))try{const n=D();if(!n)throw new Error("BMGL 库未加载,无法切换 2D 模式");const r=n.Cartographic.fromCartesian(t.camera.position);t.scene.morphTo2D?.(0),e.state.value.mapType="2d",e.eventBus.emit("map:mode-changed","2d"),t.camera.setView(Pt(n.Math.toDegrees(r.longitude),n.Math.toDegrees(r.latitude),r.height))}catch(n){w.error("切换到2D模式失败:",n)}}function Mr(e){const t=D();if(!t)throw new Error("BMGL 库未加载,无法计算 3D 目标视图");const n=t.Cartographic.fromCartesian(e.map.value.camera.position),r={lng:t.Math.toDegrees(n.longitude),lat:t.Math.toDegrees(n.latitude),height:Math.max(n.height,1e4)},a=vr(e);if(!a)return r;const i=(a.minx+a.maxx)/2,l=(a.miny+a.maxy)/2,s=(a.maxx-a.minx)*Math.cos(l*Math.PI/180)*H.METERS_PER_DEGREE_LAT_APPROX,u=(a.maxy-a.miny)*H.METERS_PER_DEGREE_LAT_APPROX,d=Math.max(s,u),c=t.Math.toRadians(H.CAMERA_FOV_DEGREES),f=Math.max(d/(2*Math.tan(c/2)),H.MIN_CAMERA_HEIGHT);return{lng:i,lat:l,height:f}}function Ir(e){const t=e.map.value;if(!(!t||!e.state.value.isReady||e.state.value.mapType==="3d"))try{const n=Mr(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(Pt(n.lng,n.lat,n.height))},Et)}catch(n){w.error("切换到3D模式失败:",n)}}function Ar(e){e.state.value.mapType==="2d"?Ir(e):Dr(e)}function Bt(e){const t=cr(e),n=(a,i,l)=>yr(t,a,i,l),r=()=>Ar(t);return o.onBeforeUnmount(()=>{Vt(t)}),{map:t.map,state:t.state,initMap:()=>Er(t),setView:n,toggleMapType:r,destroy:()=>Vt(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 Lr(e){return{billboardCollection:null,billboardMap:new Map,pointDataCache:[],cacheIdIndex:new Map,gridIndex:null,gridSize:e,scaleByDistance:null}}function Rt(e,t,n){const r=Math.floor(t/e),a=Math.floor(n/e);return`${r},${a}`}function zt(e,t){const n=Rt(e.gridSize,t.lng,t.lat),r=e.gridIndex?.get(n);r?r.push(t):e.gridIndex?.set(n,[t])}function Ft(e,t){if(!e.gridIndex)return;const n=Rt(e.gridSize,t.lng,t.lat),r=e.gridIndex.get(n);if(!r)return;const a=r.indexOf(t);a>-1&&r.splice(a,1),r.length===0&&e.gridIndex.delete(n)}const xr=1e5;function Nr(e,t){const n=[];if(!e.gridIndex)return n;const r=Math.floor(t.west/e.gridSize),a=Math.floor(t.south/e.gridSize),i=Math.floor(t.east/e.gridSize),l=Math.floor(t.north/e.gridSize),s=(i-r+1)*(l-a+1),u=d=>d.lng>=t.west&&d.lng<=t.east&&d.lat>=t.south&&d.lat<=t.north;if(s>xr){for(const d of e.pointDataCache)u(d)&&n.push(d);return n}for(let d=r;d<=i;d++)for(let c=a;c<=l;c++){const f=e.gridIndex.get(`${d},${c}`)||[];for(const h of f)u(h)&&n.push(h)}return n}function kr(e){let t=1/0,n=1/0,r=-1/0,a=-1/0;for(const[i,l]of e)i<t&&(t=i),l<n&&(n=l),i>r&&(r=i),l>a&&(a=l);return{west:t,south:n,east:r,north:a}}function _r(e){const[t,n]=e.center,r=e.radius/(H.METERS_PER_DEGREE_LAT*Math.cos(n*Math.PI/180)),a=e.radius/H.METERS_PER_DEGREE_LAT;return{west:t-r,east:t+r,south:n-a,north:n+a}}function Vr(e){return e.type==="circle"?_r(e):kr(e.coordinates)}function Pr(e,t){const[n,r]=e;let a=!1;for(let i=0,l=t.length-1;i<t.length;l=i++){const[s,u]=t[i],[d,c]=t[l];u>r!=c>r&&n<(d-s)*(r-u)/(c-u)+s&&(a=!a)}return a}function Br(e,t){const[n,r]=t.center,a=t.radius*t.radius,i=(e.lng-n)*H.METERS_PER_DEGREE_LAT*Math.cos(r*Math.PI/180),l=(e.lat-r)*H.METERS_PER_DEGREE_LAT;return i*i+l*l<=a}function Rr(e,t){return t.type==="circle"?e.filter(n=>Br(n,t)):t.type==="polygon"||t.type==="triangle"?e.filter(n=>Pr([n.lng,n.lat],t.coordinates)):e}function zr(e,t){if(!e.gridIndex||e.pointDataCache.length===0)return[];const n=Vr(t);let r=Nr(e,n);return t.type!=="rectangle"&&(r=Rr(r,t)),r}function Fr(e,t){const{field:n,keyword:r,limit:a=10,caseSensitive:i=!1}=t,l=i?r.trim():r.trim().toLowerCase(),s=Array.isArray(n)?n:[n],u=[];for(const d of e.pointDataCache)if(s.some(f=>{const h=d[f];return h==null?!1:(i?String(h):String(h).toLowerCase()).includes(l)})&&(u.push(d),u.length>=a))break;return u}const Or={lng:"lng",lat:"lat",altitude:"altitude",id:"id"};let Ot=0,Gt=!1,Ut=!1;function Gr(){return Gt||(Gt=!0,w.warn("[useMapPoint] 检测到未提供 id 的点位,已启用自增 id 自动生成;建议通过 fieldMapping.id 提供稳定 id 以支持 updatePoints 精确定位")),Ot+=1,`__auto_${Ot}`}function Ur(){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 $r(e,t){if(!t.scaleByDistance){const n=St;t.scaleByDistance=new e.NearFarScalar(n.NEAR,n.NEAR_VALUE,n.FAR,n.FAR_VALUE)}return t.scaleByDistance}function $t(e){const t=Lr(ne.GRID_SIZE),n=async()=>{if(!t.billboardCollection&&e.value){const d=D();d&&(t.billboardCollection=e.value.scene.primitives.add(new d.BillboardCollection))}return t.billboardCollection},r=()=>{if(t.billboardCollection)try{t.billboardCollection.removeAll()}catch(d){w.warn("[useMapPoint] removeAll billboard 失败:",d)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null},a=d=>{const c=t.cacheIdIndex.get(d);if(c===void 0)return;const f=t.pointDataCache[c],h=t.billboardMap.get(d);if(h&&t.billboardCollection)try{t.billboardCollection.remove(h)}catch(p){w.warn("[useMapPoint] 移除旧 billboard 失败:",p)}return t.billboardMap.delete(d),Ft(t,f),c},i=(d,c,f,h)=>{const p=parseFloat(c[f.fieldMapping.lng])||0,b=parseFloat(c[f.fieldMapping.lat])||0,v=parseFloat(c[f.fieldMapping.altitude])||0,m=d.Cartesian3.fromDegrees(p,b,v),C=t.billboardCollection.add({position:m,image:c.icon,width:c.width||f.width,height:c.height||f.height,scaleByDistance:$r(d,t),id:h,disableDepthTestDistance:St.NEAR,verticalOrigin:d.VerticalOrigin.BOTTOM});return C.pointData=c,{billboard:C,position:m,lng:p,lat:b,altitude:v}},l=async(d,c,f,h="append")=>{try{if(h==="replace"&&r(),!await n())return;const b=D();if(!b)return;const v={width:c?.width||20,height:c?.height||20,fieldMapping:{...Or,...c?.fieldMapping||{}}},m=performance.now();t.gridIndex||(t.gridIndex=new Map);const C=Array.isArray(d)?d:[],y=C.length,E=ne.BATCH_SIZE,_=ne.YIELD_BUDGET_MS;let S=performance.now(),A=0;for(let V=0;V<y;V+=E){const U=C.slice(V,V+E);for(const z of U){if(!z.icon){A+=1,Ut||(Ut=!0,w.warn("[useMapPoint] 检测到缺失 icon 的点位,已跳过渲染;请在数据层通过 iconManager 预生成 icon 后传入"));continue}const M=z[v.fieldMapping.id],I=M!=null&&M!==""?String(M):Gr(),F=a(I),{billboard:k,position:Y,lng:K,lat:pe,altitude:me}=i(b,z,v,I);t.billboardMap.set(I,k);const X={...z,id:I,lng:K,lat:pe,altitude:me,icon:z.icon};F!==void 0?t.pointDataCache[F]=X:(t.cacheIdIndex.set(I,t.pointDataCache.length),t.pointDataCache.push(X)),zt(t,X)}V+E<y&&performance.now()-S>=_&&(await Ur(),S=performance.now())}A>0&&w.warn(`[useMapPoint] 本次加载跳过 ${A} 个缺失 icon 的点位`),console.log(`[useMapPoint] ${h} ${C.length} 个点位 billboard 渲染耗时:${(performance.now()-m).toFixed(0)}ms`)}catch(p){throw w.error("加载点位失败:",p),p}},s=async d=>{const c=D();for(const f of d){const h=String(f.id),p=t.billboardMap.get(h);if(p){if(f.icon&&(p.image=f.icon),f.width!==void 0&&(p.width=f.width),f.height!==void 0&&(p.height=f.height),c&&f.lng!==void 0&&f.lat!==void 0){const b=c.Cartesian3.fromDegrees(Number(f.lng),Number(f.lat),Number(f.altitude??0));p.position=b;const v=t.cacheIdIndex.get(h);if(v!==void 0){const m=t.pointDataCache[v];Ft(t,m),m.lng=Number(f.lng),m.lat=Number(f.lat),f.altitude!==void 0&&(m.altitude=Number(f.altitude)),zt(t,m)}}if(f.name!==void 0){const b=t.cacheIdIndex.get(h);b!==void 0&&(t.pointDataCache[b].name=String(f.name))}}}},u=async()=>{r()};return o.onUnmounted(()=>{try{const d=e.value?.scene;if(d?.primitives&&t.billboardCollection)try{d.primitives.remove(t.billboardCollection)}catch(c){w.warn("[useMapPoint] remove billboardCollection error:",c)}t.billboardMap.clear(),t.pointDataCache=[],t.cacheIdIndex.clear(),t.gridIndex=null,t.billboardCollection=null}catch(d){w.warn("[useMapPoint] onUnmounted cleanup error:",d)}}),{loadPoints:l,searchByShape:d=>zr(t,d),searchByText:d=>Fr(t,d),updatePoints:s,clearPoints:u}}function Wt(e){return e?.rectangle?"rectangle":e?.polygon?"polygon":e?.polyline?"polyline":e?.ellipse||e?.position&&e?.billboard?"circle":"polygon"}function $e(e){if(e.length===0)return e;const t=e[0],n=e[e.length-1];return(Array.isArray(t)?t[0]===n[0]&&t[1]===n[1]:t.lng===n.lng&&t.lat===n.lat)?[...e]:[...e,t]}function Wr(e,t=0){const n=D();return n?n.Cartesian3.fromDegrees(e.lng,e.lat,t):null}function Ht(e){const t=D();return t?{lng:t.Math.toDegrees(e.longitude),lat:t.Math.toDegrees(e.latitude)}:null}function De(e){const t=D();if(!t)return null;const n=t.Cartographic.fromCartesian(e);return Ht(n)}function We(e,t){return[[e.lng,e.lat],[t.lng,e.lat],[t.lng,t.lat],[e.lng,t.lat],[e.lng,e.lat]]}const ce={fillColor:"#ff0000",strokeColor:"#00ff00",lineColor:"#3366ff",strokeWidth:3,fillAlpha:.1,strokeAlpha:1,pointColor:"#ff0000",pixelSize:10,radius:1e3};function B(e,t){return N().Color.fromCssColorString(e).withAlpha(t)}function jt(e){const t=N();return e.map(n=>Array.isArray(n)?t.Cartesian3.fromDegrees(n[0],n[1]):t.Cartesian3.fromDegrees(n.lng,n.lat))}function Hr(e,t=!0){const n=N(),r=ce;if(!e.coordinates||e.coordinates.length<3)throw new Error("多边形需要至少3个坐标点");const a=$e(e.coordinates),i=jt(a),l=new n.Entity({polygon:{hierarchy:new n.PolygonHierarchy(i),material:B(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),s=new n.Entity({polyline:{positions:i,width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:l,strokeEntity:s,positions:i,closedCoordinates:a}}function jr(e,t=!0){const n=N(),r=ce;if(!e.lineCoordinates||e.lineCoordinates.length<4)throw new Error("线段需要至少2个点");return{entity:new n.Entity({polyline:{positions:n.Cartesian3.fromDegreesArray(e.lineCoordinates),width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.lineColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}})}}function Yr(e){const t=N(),n=ce;if(!e.center)throw new Error("圆形需要中心点坐标");const r=e.radius??n.radius;return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.center.lng,e.center.lat),ellipse:{semiMinorAxis:r,semiMajorAxis:r,height:0,material:B(e.fillColor??n.fillColor,e.fillAlpha??n.fillAlpha),outline:!0,outlineColor:B(e.strokeColor??n.strokeColor,e.strokeAlpha??n.strokeAlpha),outlineWidth:e.strokeWidth??n.strokeWidth}}),center:e.center,radius:r}}function qr(e,t=!0){const n=N(),r=ce;if(!e.coordinates||e.coordinates.length<2)throw new Error("矩形需要两个对角点坐标");const[a,i]=e.coordinates,l=n.Rectangle.fromDegrees(Math.min(a.lng,i.lng),Math.min(a.lat,i.lat),Math.max(a.lng,i.lng),Math.max(a.lat,i.lat)),s=new n.Entity({rectangle:{coordinates:l,material:B(e.fillColor??r.fillColor,e.fillAlpha??r.fillAlpha)}}),u=We(a,i),d=new n.Entity({polyline:{positions:jt(u),width:e.strokeWidth??r.strokeWidth,material:B(e.strokeColor??r.strokeColor,e.strokeAlpha??r.strokeAlpha),clampToGround:t}});return{fillEntity:s,strokeEntity:d,coordinates:u}}function Kr(e){const t=N(),n=ce;if(!e.point)throw new Error("点需要坐标");return{entity:new t.Entity({position:t.Cartesian3.fromDegrees(e.point.lng,e.point.lat),point:{pixelSize:e.pixelSize??n.pixelSize,color:B(e.pointColor??n.pointColor,1),heightReference:t.HeightReference.CLAMP_TO_GROUND}}),point:[e.point.lng,e.point.lat]}}function Xr(e){const t=N();return!!(t.SceneMode&&e.scene.mode===t.SceneMode.SCENE2D)}const Zr={polygon:(e,t,n)=>{const r=Hr(e,t),a=n.entities.add(r.fillEntity),i=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:a,stroke:i},coordinates:r.closedCoordinates}},line:(e,t,n)=>{const r=jr(e,t);return{nativeEntity:n.entities.add(r.entity),coordinates:e.lineCoordinates??[]}},circle:(e,t,n)=>{const r=Yr(e);return{nativeEntity:n.entities.add(r.entity),coordinates:{center:r.center,radius:r.radius}}},rectangle:(e,t,n)=>{const r=qr(e,t),a=n.entities.add(r.fillEntity),i=n.entities.add(r.strokeEntity);return{nativeEntity:{fill:a,stroke:i},coordinates:r.coordinates}},point:(e,t,n)=>{const r=Kr(e);return{nativeEntity:n.entities.add(r.entity),coordinates:r.point}}};function Yt(e,t,n){const r=Zr[e];if(!r)throw new Error(`不支持的实体类型: ${e}`);return r(t,!Xr(n),n)}function Me(e,t){try{e.type==="polygon"||e.type==="rectangle"?(e.nativeEntity?.fill&&t.entities.remove(e.nativeEntity.fill),e.nativeEntity?.stroke&&t.entities.remove(e.nativeEntity.stroke)):e.nativeEntity&&t.entities.remove(e.nativeEntity)}catch(n){w.warn(`移除原生实体失败 (${e.id}):`,n)}}function He(e,t,n,r){return{color:e.fillColor||t.options.fillColor||n,alpha:e.fillAlpha!==void 0?e.fillAlpha:t.options.fillAlpha??r}}function Ie(e,t,n,r){return{color:e.strokeColor||t.options.strokeColor||n,alpha:e.strokeAlpha!==void 0?e.strokeAlpha:r}}function Jr(e,t){const n=N(),{fill:r,stroke:a}=e.nativeEntity,i=$e(t.coordinates),l=i.map(s=>n.Cartesian3.fromDegrees(s.lng,s.lat));r.polygon.hierarchy=new n.PolygonHierarchy(l),a.polyline.positions=l,e.coordinates=i}function Qr(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:a,alpha:i}=He(t,e,"#ff0000",.1);n.polygon.material=B(a,i)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:a,alpha:i}=Ie(t,e,"#00ff00",1);r.polyline.material=B(a,i)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=3&&Jr(e,t)}function ea(e,t){const n=N(),{fill:r,stroke:a}=e.nativeEntity,[i,l]=t.coordinates;r.rectangle.coordinates=n.Rectangle.fromDegrees(Math.min(i.lng,l.lng),Math.min(i.lat,l.lat),Math.max(i.lng,l.lng),Math.max(i.lat,l.lat));const s=We(i,l);a.polyline.positions=s.map(u=>n.Cartesian3.fromDegrees(u[0],u[1])),e.coordinates=s}function ta(e,t){const{fill:n,stroke:r}=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:a,alpha:i}=He(t,e,"#ff0000",.1);n.rectangle.material=B(a,i)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:a,alpha:i}=Ie(t,e,"#00ff00",1);r.polyline.material=B(a,i)}t.strokeWidth!==void 0&&(r.polyline.width=t.strokeWidth),t.coordinates&&t.coordinates.length>=2&&ea(e,t)}function na(e,t){const n=N(),a=e.nativeEntity.polyline;if(a){if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:i,alpha:l}=Ie(t,e,"#3366ff",1);a.material=B(i,l)}t.strokeWidth!==void 0&&(a.width=t.strokeWidth),t.lineCoordinates&&t.lineCoordinates.length>=4&&(a.positions=n.Cartesian3.fromDegreesArray(t.lineCoordinates),e.coordinates=t.lineCoordinates)}}function ra(e,t){const n=N(),r=e.nativeEntity;if(t.fillColor!==void 0||t.fillAlpha!==void 0){const{color:a,alpha:i}=He(t,e,"#ff0000",.1);r.ellipse.material=B(a,i)}if(t.strokeColor!==void 0||t.strokeAlpha!==void 0){const{color:a,alpha:i}=Ie(t,e,"#00ff00",1);r.ellipse.outlineColor=B(a,i)}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 a=e.coordinates,i=a&&!Array.isArray(a)?a.radius:void 0;e.coordinates={center:t.center,radius:t.radius||i||1e3}}}function aa(e,t){const n=N(),r=e.nativeEntity,a=r.point;a&&(t.pointColor!==void 0&&(a.color=B(t.pointColor,1)),t.pixelSize!==void 0&&(a.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 ia(e,t){const n=e.nativeEntity;e.type==="polygon"||e.type==="rectangle"?(n.fill.show=t,n.stroke.show=t):n.show=t}function oa(e,t,n){e==="polygon"?Qr(t,n):e==="rectangle"?ta(t,n):e==="line"?na(t,n):e==="circle"?ra(t,n):e==="point"&&aa(t,n)}function la(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 sa(e,t,n,r,a){Me(t,r);const i={...t.options,...n,id:e,type:n.type};return la(i,t),await a(i)!==null}function qt(e){const t=new Map;let n="";const r=()=>!e.value||!e.value.entities?(w.warn("地图实例未就绪"),!1):!0,a=async()=>{if(r())return!0;try{return await xt(),r()}catch{return!1}},i=async c=>{try{if(!await a())return null;const f=e.value;if(!f)return null;const h=c.id||`${c.type}-${Date.now()}`,{nativeEntity:p,coordinates:b}=Yt(c.type,c,f),v={id:h,type:c.type,options:{...c,id:h,type:c.type,visible:c.visible!==!1},nativeEntity:p,coordinates:b};return t.set(h,v),n=h,h}catch(f){return w.error("绘制实体失败:",f),null}},l=c=>{try{if(!r())return!1;const f=e.value;if(!f)return!1;if(!c)return t.forEach(p=>Me(p,f)),t.clear(),n="",!0;const h=t.get(c);return h?(Me(h,f),t.delete(c),n===c&&(n=""),!0):(w.warn(`实体未找到: ${c}`),!1)}catch(f){return w.error("删除实体失败:",f),!1}},s=()=>n,u=async(c,f)=>{try{const h=t.get(c);if(!h)return w.warn(`实体未找到:${c}`),!1;if(!await a())return!1;const p=e.value;return p?f.type&&f.type!==h.type?await sa(c,h,f,p,i):(oa(h.type,h,f),f.name!==void 0&&(h.options.name=f.name),f.visible!==void 0&&ia(h,f.visible),h.options={...h.options,...f},t.set(c,h),!0):!1}catch(h){return w.error(`修改实体失败 (${c}):`,h),!1}},d=()=>{if(!r())return;const c=e.value;if(c)for(const[f,h]of t)try{Me(h,c),h.nativeEntity=Yt(h.type,h.options,c).nativeEntity}catch(p){w.warn(`重绘实体失败 (${f}):`,p)}};return o.onUnmounted(()=>{try{t.clear(),n=""}catch(c){w.warn("[useMapEntity] onUnmounted cleanup error:",c)}}),{drawEntity:i,updateEntity:u,deleteEntity:l,redrawAllEntities:d,getCurrentEntityId:s}}function ca(){return{drawInstance:null,editInstance:null,currentDrawId:"",currentDrawType:null,isDrawing:!1,isEditing:!1,drawCallback:null,mapInstance:null,mapHandler:null,eventListeners:[],lastEditedEntity:null,drawEntityIds:new Set}}const ue={fillColor:"#369",fillAlpha:.6,borderColor:"#fff",borderAlpha:.8,lineWidth:2,labelFont:"14px arial",arrowWidth:20};function Ae(e,t,n,r){return typeof e!="number"||Number.isNaN(e)?r:Math.min(n,Math.max(t,e))}class ua{constructor(t){this.config={...ue,...t},this.config.fillAlpha=Ae(this.config.fillAlpha,0,1,ue.fillAlpha),this.config.borderAlpha=Ae(this.config.borderAlpha,0,1,ue.borderAlpha),this.config.lineWidth=Ae(this.config.lineWidth,1,50,ue.lineWidth),this.config.arrowWidth=Ae(this.config.arrowWidth,1,100,ue.arrowWidth)}materials(t){const{fillColor:n,fillAlpha:r,borderColor:a,borderAlpha:i}=this.config;return{fill:t.Color.fromCssColorString(n).withAlpha(r),border:t.Color.fromCssColorString(a).withAlpha(i)}}label(t){const{labelFont:n}=this.config;return{fillColor:t.Color.WHITE,font:n,verticalOrigin:t.VerticalOrigin.BOTTOM,pixelOffset:new t.Cartesian2(0,-20),disableDepthTestDistance:5e3}}getDrawConfig(){const t=N(),{fill:n,border:r}=this.materials(t),a=this.label(t),i=this.config.lineWidth,l={bmgl:t,config:this.config,shared:{fill:n,border:r,label:a,width:i}},s={repeat:!0};for(const u of gt())u.buildConfig&&(s[u.type]=u.buildConfig(l));return s}getEditConfig(){const t=N();return{axis:{scale:1},control:{tolerance:4,marker:{eyeOffset:new t.Cartesian3(0,0,-20),verticalOrigin:t.VerticalOrigin.BOTTOM,disableDepthTestDistance:5e3}}}}}function Kt(e){return e.map(t=>De(t)).filter(t=>t!==null)}function da(e){try{const t=e.polygon.hierarchy.getValue().positions||[],n=Kt(t);return{type:"polygon",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return w.error("提取多边形数据失败:",t),null}}function fa(e){const t=N();try{const n=e.rectangle.coordinates.getValue(),r=t.Math.toDegrees(n.west),a=t.Math.toDegrees(n.south),i=t.Math.toDegrees(n.east),l=t.Math.toDegrees(n.north);return{type:"rectangle",path:[[r,l],[i,l],[i,a],[r,a],[r,l]],rawPath:[{lng:r,lat:l},{lng:i,lat:l},{lng:i,lat:a},{lng:r,lat:a}],radius:void 0}}catch(n){return w.error("提取矩形数据失败:",n),null}}function ha(e){try{const t=e.polyline.positions.getValue(),n=Kt(t);return{type:"polyline",path:n.map(r=>[r.lng,r.lat]),rawPath:n,radius:void 0}}catch(t){return w.error("提取折线数据失败:",t),null}}function ga(e){try{const t=De(e.position.getValue());if(!t)return null;const n=e.ellipse.semiMajorAxis?.getValue()||0,r=e.ellipse.semiMinorAxis?.getValue()||0;return{type:"circle",center:[t.lng,t.lat],radius:Math.max(n,r),rawPath:[t]}}catch(t){return w.error("提取圆形数据失败:",t),null}}function pa(e){try{const t=De(e.position.getValue());return t?{type:"circle",center:[t.lng,t.lat],radius:e.radius||0,rawPath:[t]}:null}catch{return null}}function Xt(e){return e?e.polygon?da(e):e.rectangle?fa(e):e.polyline?ha(e):e.position&&e.ellipse?ga(e):e.billboard&&e.position?pa(e):null:null}function ma(e){return Wt(e)}function wa(e){return e.editInstance&&(e.editInstance.isEditing||e.editInstance._isEditing||e.editInstance.editing)||!1}function ya(e){typeof e.finish=="function"?e.finish():typeof e.stop=="function"?e.stop():typeof e.disable=="function"?e.disable():typeof e.end=="function"?e.end():e.isEditing=!1}function de(e,t=!1){if(e.editInstance){t&&e.currentDrawId&&(e.lastEditedEntity=e.mapInstance?.entities.getById(e.currentDrawId)??null);try{ya(e.editInstance)}catch(n){w.error("结束编辑状态失败:",n)}finally{e.isEditing=!1}t&&e.lastEditedEntity&&va(e)}}function J(e,t){if(e.drawCallback)try{e.drawCallback(t)}catch(n){w.error("绘图回调执行失败:",n)}else w.warn("绘图回调函数未设置")}function va(e){if(!(!e.lastEditedEntity||!e.currentDrawId))try{const t=Xt(e.lastEditedEntity);if(!t)return;const n={type:t.type,layer:{_id:e.currentDrawId},path:t.rawPath||[]};t.type==="circle"&&t.radius!==void 0&&(n.radius=t.radius),J(e,{type:t.type,operation:"edit",id:e.currentDrawId,data:t,rawData:n}),e.lastEditedEntity=null}catch(t){w.error("手动触发编辑完成事件失败:",t)}}function Ca(e,t,n){try{if(e.drawInstance||n(),!e.drawInstance)throw new Error("绘图实例初始化失败");if(e.isEditing&&de(e,!1),e.isDrawing=!0,e.currentDrawType=t,typeof e.drawInstance.enable=="function")e.drawInstance.enable(t);else if(typeof e.drawInstance.start=="function")e.drawInstance.start(t);else throw new Error("绘图实例没有可用的启用方法")}catch(r){throw w.error(`开始绘制 ${t} 失败:`,r),e.isDrawing=!1,e.currentDrawType=null,r}}function ba(e){const t=(n,...r)=>{if(n){for(const a of r)if(typeof n[a]=="function"){n[a]();return}}};t(e.drawInstance,"disable","stop"),t(e.editInstance,"disable","stop")}function Ea(e){e.currentDrawId="",e.currentDrawType=null,e.isDrawing=!1,e.isEditing=!1,e.lastEditedEntity=null}function Q(e){e.isEditing&&de(e,!1),ba(e),Ea(e)}function Ta(e,t=""){if(!e.mapInstance)return;const n=t||e.currentDrawId;if(e.isEditing&&de(e,!1),!n){Q(e);return}const r=e.mapInstance.entities.getById(n);if(r){const a=Xt(r);if(e.mapInstance.entities.remove(r),e.drawEntityIds.delete(n),e.currentDrawId===n&&(e.currentDrawId=""),a){const i={type:a.type,layer:{_id:n},path:a.rawPath||[]};a.type==="circle"&&a.radius!==void 0&&(i.radius=a.radius),J(e,{type:a.type,operation:"delete",id:n,data:a,rawData:i})}}Q(e)}function Sa(e){if(!e.mapInstance)return;e.isEditing&&de(e,!1);let t=0;if(e.drawEntityIds.size>0){for(const r of e.drawEntityIds){const a=e.mapInstance.entities.getById(r);a&&(e.mapInstance.entities.remove(a),t++)}e.drawEntityIds.clear()}else{const r=e.mapInstance.entities?.values||[];r.some(i=>!e.drawEntityIds.has(i?._id))||(e.mapInstance.entities.removeAll(),t=r.length)}const n=e.currentDrawType||"polygon";J(e,{type:n,operation:"clear",data:null,rawData:null,count:t}),Q(e)}class j{static process(t){if(!t?.type)return null;try{const n=j.getProcessor(t.type);if(!n)return null;const r=n(t);return r?{...r,id:t.layer?._id||""}:null}catch(n){return w.error("数据处理失败:",n),null}}static getProcessor(t){return{rectangle:j.processRectangle,polygon:j.processPolygon,circle:j.processCircle,triangle:j.processTriangle,polyline:j.processPolyline}[t]}static processRectangle(t){const[n,r]=t.path||[];return!n||!r?null:{type:"rectangle",path:[[n.lng,n.lat],[r.lng,n.lat],[r.lng,r.lat],[n.lng,r.lat],[n.lng,n.lat]]}}static processPolygon(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polygon",path:[...n,n[0]]}}static processCircle(t){const n=t.path;return!n||n.lng===void 0?null:{type:"circle",center:[n.lng,n.lat],radius:t.radius||0}}static processTriangle(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"triangle",path:[...n,n[0]]}}static processPolyline(t){const n=(t.path||[]).map(r=>[r.lng,r.lat]);return n.length===0?null:{type:"polyline",path:n}}}function Da(e,t,n){J(e,{type:ma(n),operation:"select",id:t,data:{id:t},rawData:n})}function Ma(e){if(wa(e)){de(e,!0);return}e.isDrawing&&e.currentDrawType&&J(e,{type:e.currentDrawType,operation:"cancel",id:e.currentDrawId,data:null,rawData:null}),Q(e)}function Ia(e,t){if(!e.mapInstance)return;const n=N(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const a=r?.id?._id;if(typeof a!="string"||!a)return;const i=e.mapInstance.entities.getById(a);if(!i||!e.editInstance)return;e.currentDrawId=a,e.lastEditedEntity=i;const l=e.editInstance;typeof l.edit=="function"?l.edit(i):typeof l.start=="function"?l.start(i):typeof l.enable=="function"&&l.enable(i),e.isEditing=!0}function Aa(e,t){if(!e.mapInstance||e.isDrawing)return;const n=N(),r=e.mapInstance.scene.pick(t.position);if(!n.defined(r))return;const a=r?.id?._id;if(typeof a!="string"||!a)return;const i=e.mapInstance.entities.getById(a);i&&(e.currentDrawId=a,Da(e,a,i))}function La(e,t){const n=j.process(t.detail);if(!n)return;n.id&&e.drawEntityIds.add(n.id);const r={type:n.type,operation:"draw",id:n.id,data:n,rawData:t.detail};J(e,r),Q(e)}function xa(e,t){e.isEditing=!1;const n=j.process(t.detail);if(!n){e.lastEditedEntity=null;return}const r={type:n.type,operation:"edit",id:n.id,data:n,rawData:t.detail};J(e,r),e.lastEditedEntity=null}function Zt(e){e.eventListeners.forEach(({type:t})=>{try{e.mapHandler?.removeInputAction(t)}catch(n){w.warn(`移除 ${t} 事件监听器失败:`,n)}}),e.eventListeners=[]}function Na(e){Zt(e);const t=e.mapHandler;if(!t)return;const n=N(),r=[n.ScreenSpaceEventType.RIGHT_CLICK,n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,n.ScreenSpaceEventType.LEFT_CLICK],a=[()=>Ma(e),i=>Ia(e,i),i=>Aa(e,i)];r.forEach((i,l)=>{t.setInputAction(a[l],i),e.eventListeners.push({type:i})})}function ka(e){e.drawInstance&&(e.drawInstance.on("bm_draw_end",t=>La(e,t)),e.editInstance&&e.editInstance.on("bm_edit_end",t=>xa(e,t)))}function _a(e,t,n){try{if(e.mapInstance=o.isRef(t)?t.value:t,!e.mapInstance)throw new Error("地图实例不可用");if(!D())throw new Error("BMGL 库未加载");if(e.mapHandler=e.mapInstance.screenSpaceEventHandler,!e.mapHandler)throw new Error("地图事件处理器不可用");const r=N(),a=new ua(n);e.drawInstance=new r.Plot.Draw(e.mapInstance,a.getDrawConfig()),e.editInstance=new r.Plot.Edit(e.mapInstance,a.getEditConfig()),Na(e),ka(e)}catch(r){throw w.error("绘图工具初始化失败:",r),r}}function Jt(e){try{Q(e),Zt(e),e.drawInstance&&typeof e.drawInstance.destroy=="function"&&e.drawInstance.destroy(),e.editInstance&&typeof e.editInstance.destroy=="function"&&e.editInstance.destroy(),e.drawInstance=null,e.editInstance=null,e.drawCallback=null,e.mapHandler=null,e.lastEditedEntity=null}catch(t){w.error("清理绘图工具资源失败:",t)}}function Qt(e,t){const n=ca(),r=()=>_a(n,e,t),a=s=>{n.drawCallback=s},i=()=>({isDrawing:n.isDrawing,isEditing:n.isEditing,currentDrawId:n.currentDrawId,currentDrawType:n.currentDrawType,drawInstance:!!n.drawInstance,editInstance:!!n.editInstance}),l=()=>n.isDrawing;if(e&&typeof e=="object"&&"value"in e)o.watch(e,s=>{if(s&&!n.drawInstance)try{r()}catch(u){w.warn("自动初始化失败,将在绘图时重试:",u)}},{immediate:!0});else if(e)try{r()}catch(s){w.warn("自动初始化失败,将在绘图时重试:",s)}return o.onUnmounted(()=>{Jt(n)}),{startDrawing:s=>Ca(n,s,r),cancelDrawing:()=>Q(n),removeDrawing:(s="")=>Ta(n,s),clearAllDrawings:()=>Sa(n),setCallback:a,getDrawingStatus:i,getIsDrawing:l,initialize:r,cleanup:()=>Jt(n)}}function Va(){return{popupLayer:null,divLayerManager:null,mapInstance:null,currentPopupData:null,displayConfig:null,popupSeq:0}}function fe(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Pa(e){return e&&/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)?e:""}function re(e,t){return typeof e=="number"&&!Number.isNaN(e)?e.toFixed(t):"-"}function Ba(e){return R[e||"default"]||R.default}function Ra(e){return[`--status-color: ${e.color}`,`--status-bg: ${e.color}10`,`--status-border: ${e.color}30`,`--status-shadow: ${e.color}30`].join(";")}function za(e,t){const n=[e.lineCode,e.lineNo,e.pointNo].filter(a=>a!=null&&a!==""),r=n.length?`<div class="map-point-popup-subtitle"><span>${n.map(a=>fe(a)).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>${fe(e.name||"点位信息")}</h3>
5
5
  <div class="map-point-popup-status">${fe(t.text)}</div>
6
6
  </div>
7
7
  ${r}
8
- </div>`}function Qt(e,t){return`
8
+ </div>`}function en(e,t){return`
9
9
  <div class="map-point-popup-field">
10
10
  <div class="map-point-popup-field-label">${fe(e)}</div>
11
11
  <div class="map-point-popup-field-value">${fe(t)}</div>
12
- </div>`}function zi(e,t){const n=t[e.key];if(n==null||n==="")return"-";if(typeof e.format=="function")return e.format(n,t);switch(e.format){case"lng":return re(n,6);case"lat":return re(n,6);case"altitude":return`${re(n,2)} m`;default:return String(n)}}function Fi(e){return`<div class="map-point-popup-grid">${e.map(t=>Qt(t.label,t.value)).join("")}</div>`}function Oi(e){const t=re(e.lng,6),n=re(e.lat,6),r=re(e.altitude,2),i=e.teamName||"-",a=e.realName||"-";return Fi([{label:"经度",value:t},{label:"纬度",value:n},{label:"高程",value:`${r} m`},{label:"班组",value:i},{label:"人员",value:a}])}function Gi(e,t){return`<div class="map-point-popup-grid">${t.map(r=>Qt(r.label,zi(r,e))).join("")}</div>`}function Ui(e,t){const n=Pi(e.status),r=Bi(n),i=Vi(t?.themeColor),a=i?`--popup-accent: ${i};`:"",l=t?.fields?.length?Gi(e,t.fields):Oi(e);return`
13
- <div class="map-point-popup" style="${r};${a}">
14
- ${Ri(e,n)}
12
+ </div>`}function Fa(e,t){const n=t[e.key];if(n==null||n==="")return"-";if(typeof e.format=="function")return e.format(n,t);switch(e.format){case"lng":return re(n,6);case"lat":return re(n,6);case"altitude":return`${re(n,2)} m`;default:return String(n)}}function Oa(e){return`<div class="map-point-popup-grid">${e.map(t=>en(t.label,t.value)).join("")}</div>`}function Ga(e){const t=re(e.lng,6),n=re(e.lat,6),r=re(e.altitude,2),a=e.teamName||"-",i=e.realName||"-";return Oa([{label:"经度",value:t},{label:"纬度",value:n},{label:"高程",value:`${r} m`},{label:"班组",value:a},{label:"人员",value:i}])}function Ua(e,t){return`<div class="map-point-popup-grid">${t.map(r=>en(r.label,Fa(r,e))).join("")}</div>`}function $a(e,t){const n=Ba(e.status),r=Ra(n),a=Pa(t?.themeColor),i=a?`--popup-accent: ${a};`:"",l=t?.fields?.length?Ua(e,t.fields):Ga(e);return`
13
+ <div class="map-point-popup" style="${r};${i}">
14
+ ${za(e,n)}
15
15
  <div class="map-point-popup-content">
16
16
  ${l}
17
17
  </div>
18
- </div>`}function je(e){return typeof e=="number"&&!Number.isNaN(e)}function $i(e,t){return t&&(e.mapInstance=o.isRef(t)?t.value:t),!!e.mapInstance}async function Wi(e,t,n){if($i(e,t),!e.divLayerManager&&e.mapInstance){const r=D();if(!r)return null;e.divLayerManager=new r.div.DivLayerManager(e.mapInstance,{click:(i,a)=>{n&&n({position:a,detail:i})}})}return e.divLayerManager}function Hi(e){const t=D();if(!t)throw new Error("BMGL 库未加载,无法转换弹窗坐标");return t.Cartesian3.fromDegrees(e.lng,e.lat,e.altitude||0)}function en(e,t,n){const r=_i();r.displayConfig=n?.displayConfig||null;const i=()=>{if(r.popupLayer&&r.divLayerManager){try{r.divLayerManager.removeLayer(r.popupLayer)}catch(d){w.warn("移除弹窗时发生错误:",d)}r.popupLayer=null}r.currentPopupData=null},a=async(d,c={})=>{try{if(!d)throw new Error("点位数据不能为空");const f=++r.popupSeq,h={lng:je(d.lng)?d.lng:te.lng,lat:je(d.lat)?d.lat:te.lat,altitude:je(d.altitude)?d.altitude:0};i();const p=await Wi(r,e,t);if(!p)throw new Error("DivLayerManager 初始化失败");if(f!==r.popupSeq)return;r.currentPopupData={...d};const b={offsetX:0,offsetY:-20,className:"map-point-popup",...c},v=D();if(!v)throw new Error("BMGL 库未加载,无法创建弹窗");const m=new v.div.DivLayer(Ui(d,r.displayConfig||void 0),Hi(h),{offset:{x:b.offsetX,y:b.offsetY}});r.popupLayer=m,p.addLayer(m)}catch(f){w.error("显示点位弹窗失败:",f),i()}},l=()=>{i()},s=()=>r.popupLayer!==null,u=()=>r.currentPopupData;return o.onUnmounted(()=>{try{l()}catch(c){w.warn("[useMapPopup] onUnmounted removePopup error:",c)}const d=r.divLayerManager;if(d&&typeof d.destroy=="function")try{d.destroy()}catch(c){w.warn("[useMapPopup] onUnmounted destroy manager error:",c)}r.divLayerManager=null,r.mapInstance=null,r.currentPopupData=null}),{showPointPopup:a,removePopup:l,isPopupVisible:s,getCurrentPopupData:u}}function tn(e){let t=null;const n=()=>o.isRef(e)?e.value:e,r=new Set,i=new Map,a=s=>{try{if(t=n(),!t)throw new Error("地图实例不可用");const{position:u,config:d={}}=s,c=`circleWave_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,f=new CircleWave(t,c),{color:h="#0a84ff",radius:p=100,duration:b=3e3,ttl:v=0}=d;return f.add(u,h,p,b),r.add(c),v>0&&i.set(c,setTimeout(()=>{i.delete(c),l(c)},v)),c}catch(u){throw w.error("添加波动效果失败:",u),u}},l=s=>{try{if(t||(t=n()),!t||!t.entities)return w.warn("地图实例或 entities 不可用"),r.delete(s),!1;const u=t.entities.getById(s);if(!u)return w.warn(`未找到要删除的波动实体, ID: ${s}`),r.delete(s),!1;t.entities.remove(u),r.delete(s);const d=i.get(s);return d&&(clearTimeout(d),i.delete(s)),!0}catch(u){return w.error(`删除波动效果失败, ID: ${s}:`,u),r.delete(s),!1}};return o.onUnmounted(()=>{i.forEach(s=>clearTimeout(s)),i.clear();for(const s of Array.from(r))try{l(s)}catch(u){w.warn(`[useMapCircleWave] onUnmounted removeWave error (${s}):`,u)}r.clear()}),{addWave:a,removeWave:l}}function ji(){return{layers:new Map}}function nn(e){return e.value?e.value:(w.warn("[useMapLayers] 地图未初始化"),null)}function rn(e,t,n){const r=e.layers.get(n);if(r){try{t.value&&t.value.imageryLayers.remove(r,!1)}catch(i){w.warn(`移除同名旧图层失败 (${n}):`,i)}e.layers.delete(n)}}function Yi(e,t,n){const r=nn(t);if(!r)throw new Error("地图未初始化,无法添加影像图层");const i=N();rn(e,t,n);const a=new i.ImageryLayer(new i.BMImageryProvider({mapId:n}));return r.imageryLayers.add(a),e.layers.set(n,a),a}function qi(e,t,n,r="wmts-layer"){const i=nn(t);if(!i)throw new Error("地图未初始化,无法添加 WMTS 图层");const a=N();rn(e,t,r);const l=new a.WebMapTileServiceImageryProvider({url:n,layer:r,style:"default",format:"image/png",tileMatrixSetID:"EPSG:3857"}),s=i.imageryLayers.add(new a.ImageryLayer(l,{maximumTerrainLevel:21}));return e.layers.set(r,s),s}function Ki(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n?{layer:n,key:t}:(w.warn(`图层未找到: ${t}`),{layer:null,key:null})}return{layer:t,key:null}}function Xi(e,t,n){try{const{layer:r,key:i}=Ki(e,n);if(!r)return!1;if(t.value&&t.value.imageryLayers.remove(r,!1),i!==null)e.layers.delete(i);else for(const[a,l]of e.layers.entries())if(l===r){e.layers.delete(a);break}return!0}catch(r){return w.error("移除图层失败:",r),!1}}function Zi(e,t){const n=t.value;if(n)try{e.layers.forEach(r=>{n.imageryLayers.remove(r,!1)}),e.layers.clear()}catch(r){w.error("移除所有图层失败:",r)}}function an(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n||(w.warn(`图层未找到: ${t}`),null)}return t}function Ji(e,t,n){try{const r=an(e,t);return r?(r.show=n,!0):!1}catch(r){return w.error("设置图层可见性失败:",r),!1}}function Qi(e,t,n){try{if(typeof n!="number"||Number.isNaN(n)||n<0||n>1)return w.warn("透明度必须在 0-1 之间"),!1;const r=an(e,t);return r?(r.alpha=n,!0):!1}catch(r){return w.error("设置图层透明度失败:",r),!1}}function ea(e){const t=[];return e.layers.forEach((n,r)=>{t.push({name:r,layer:n})}),t}function on(e){const t=ji();return o.onUnmounted(()=>{try{t.layers.clear()}catch(n){w.warn("[useMapLayers] onUnmounted cleanup error:",n)}}),{addImageryLayer:n=>Yi(t,e,n),addWmtsLayer:(n,r)=>qi(t,e,n,r),removeLayer:n=>Xi(t,e,n),removeAllLayers:()=>Zi(t,e),setLayerVisible:(n,r)=>Ji(t,n,r),setLayerOpacity:(n,r)=>Qi(t,n,r),getAllLayers:()=>ea(t)}}function ta(e){return{...wt,...e}}function na(e,t){const n=e.Material.fromType("ElevationContour"),r=n.uniforms;return r.width=t.width,r.spacing=t.spacing,r.color=e.Color.RED.clone(),n}function ln(e,t){const n=o.ref(!1),r=s=>{const u=e.value;if(u?.scene?.globe)if(s){const d=D();if(!d)return;u.scene.globe.material=na(d,ta(t))}else u.scene.globe.material=void 0};return{contourVisible:n,setContourVisible:s=>{n.value=!!s,r(n.value)},reapply:()=>{n.value&&r(!0)},remove:()=>{r(!1)}}}const ra=2e4;function ia(e,t={}){if(!Array.isArray(e)||e.length<2)throw new Error("轨迹至少需要2个点");const n=t.interval&&t.interval>0?t.interval:1;e.some(h=>typeof h.time=="number"&&Number.isFinite(h.time));const r=e.map((h,p)=>({...h,time:typeof h.time=="number"&&Number.isFinite(h.time)?h.time:p*n}));r.sort((h,p)=>h.time-p.time);const i=[];let a=-1/0;for(const h of r)h.time>a&&(i.push(h),a=h.time);if(i.length<2)throw new Error("轨迹时间戳无效,无法构成回放时间表");const l=i.map(h=>h.time),s=l[0],u=l[l.length-1]-s,d=t.duration&&t.duration>0?t.duration:u,c=t.maxPoints&&t.maxPoints>=2?Math.floor(t.maxPoints):ra;let f=i;if(i.length>c){const h=Math.ceil(i.length/c);f=i.filter((b,v)=>v%h===0);const p=i[i.length-1];f[f.length-1]!==p&&f.push(p)}return{points:i,times:l,displayPoints:f,duration:d,minTime:s}}function he(e,t){const{points:n,times:r,duration:i,minTime:a}=e,l=n.length;if(t<=r[0]){const m=n[0];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:0,progress:0}}if(t>=r[l-1]){const m=n[l-1];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:l-1,progress:1}}let s=0,u=l-1;for(;s<u;){const m=s+u+1>>1;r[m]<=t?s=m:u=m-1}const d=s,c=r[d+1]-r[d],f=c>0?(t-r[d])/c:0,h=n[d],p=n[d+1],b=h.altitude??0,v=p.altitude??0;return{lng:h.lng+(p.lng-h.lng)*f,lat:h.lat+(p.lat-h.lat)*f,altitude:b+(v-b)*f,index:d,progress:i>0?(t-a)/i:0}}function aa(e,t={}){const n=e.duration,r=!!t.loop;let i=0,a=Math.max(0,t.speed??1),l=t.autoPlay?"playing":"idle";const s={status:l,currentTime:0,duration:n,progress:0,pointCount:e.points.length},u=m=>Math.max(0,Math.min(n,m)),d=()=>{s.status=l,s.currentTime=u(i),s.duration=n,s.progress=n>0?s.currentTime/n:0,s.pointCount=e.points.length},c=()=>{n<=0||(l==="ended"&&(i=0),l="playing",d())},f=()=>{l==="playing"&&(l="paused"),d()},h=()=>{i=0,l="idle",d()},p=m=>{a=Math.max(0,m),d()},b=m=>{i=u(m),l==="ended"&&(l="paused"),d()},v=m=>{l!=="playing"||n<=0||(i+=m*a,i>=n&&(r?i=i%n:(i=n,l="ended")),d())};return d(),{state:s,play:c,pause:f,stop:h,setSpeed:p,jumpTo:b,tick:v}}function oa(e){const t=D();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function Ye(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function la(e,t,n,r){const i=t.map(a=>e.Cartesian3.fromDegrees(a.lng,a.lat,a.altitude??0));return new e.Entity({polyline:{positions:i,width:n.lineWidth,material:Ye(e,n.lineColor,.9),clampToGround:r}})}function sa(e,t,n){return new e.Entity({polyline:{positions:[],width:t.lineWidth,material:Ye(e,t.markerColor,.9),clampToGround:n}})}function ca(e,t){if(!e?.billboard||!t.markerIcon||typeof Image>"u")return;const n=t.markerSize*2,r=new Image;r.onload=()=>{!e.billboard||!r.naturalWidth||!r.naturalHeight||(e.billboard.width=n,e.billboard.height=r.naturalHeight/r.naturalWidth*n)},r.src=t.markerIcon}function ua(e,t,n=!0){const r=new e.ConstantPositionProperty(e.Cartesian3.fromDegrees(0,0,0)),i=new e.Entity({position:r}),a=n?e.HeightReference.CLAMP_TO_GROUND:e.HeightReference.NONE;return t.markerIcon?i.billboard={image:t.markerIcon,width:t.markerSize*2,heightReference:a,verticalOrigin:e.VerticalOrigin.BOTTOM}:i.point={pixelSize:t.markerSize,color:Ye(e,t.markerColor,1),heightReference:a},ca(i,t),i}function da(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function qe(e){return{...yt,...e}}const fa=100,ha=.25;function sn(e,t,n){const r=o.ref({status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}),i=qe(t);let a=null,l=null,s=i,u=null,d=null,c=null,f=null,h=null,p=0,b=0;const v=()=>{const T=e.value;return T&&T.entities?T:null},m=()=>{h!==null&&(cancelAnimationFrame(h),h=null)},C=()=>{const T=v();T&&(u&&T.entities.remove(u),d&&T.entities.remove(d),c&&T.entities.remove(c)),u=null,d=null,c=null,f=null},y=()=>{l&&(r.value={...l.state})},E=T=>{if(!f)return;const L=D();L&&f.setValue(L.Cartesian3.fromDegrees(T.lng,T.lat,T.altitude))},_=T=>{if(!d||!a||!l)return;const L=D();if(!L)return;const P=l.state.currentTime,W=s.trailTime>0?Math.max(0,P-s.trailTime):0,ie=he(a,a.minTime+W),ee=a.points.slice(ie.index,T.index+1),O=da(L,ee);O.push(L.Cartesian3.fromDegrees(T.lng,T.lat,T.altitude)),d.polyline&&(d.polyline.positions=O)},S=T=>{const L=e.value;if(!L?.camera)return;const P=D();P&&L.camera.setView({destination:P.Cartesian3.fromDegrees(T.lng,T.lat,s.followHeight),orientation:{heading:0,pitch:P.Math.toRadians(-90),roll:0}})},A=T=>{if(!l||!a||l.state.status!=="playing"){m();return}h=requestAnimationFrame(A);const L=Math.min(Math.max((T-p)/1e3,0),ha);p=T,l.tick(L);const P=he(a,a.minTime+l.state.currentTime);E(P),T-b>=fa&&(_(P),b=T),s.follow&&S(P),y()},V=()=>{h===null&&(p=performance.now(),b=0,h=requestAnimationFrame(A))},U=(T,L)=>{if(!a)return;const P=!oa(T);u=la(L,a.displayPoints,s,P),d=sa(L,s,P),c=ua(L,s,P),f=c.position??null,T.entities.add(u),T.entities.add(d),T.entities.add(c);const W=he(a,a.minTime+(l?l.state.currentTime:0));E(W),_(W)},z=(T,L)=>{const P=v(),W=D();if(!P||!W)return;Ue.loadScripts(["move-marker","bmgl-header"],n?.serverUrl,n?.libsUrl||be).catch(ee=>w.warn("[useMapTrajectory] 轨迹辅助库加载失败:",ee)),s=qe({...i,...L});let ie;try{ie=ia(T,s)}catch(ee){w.warn("[useMapTrajectory] 轨迹数据无效:",ee);return}m(),C(),a=ie,l=aa(a,s),U(P,W),y(),s.autoPlay&&M()},M=()=>{l&&(l.play(),y(),l.state.status==="playing"&&V())},I=()=>{l&&(l.pause(),m(),y())},F=()=>{if(m(),!l||!a)return;l.stop();const T=he(a,a.minTime);E(T),_(T),y()},k=T=>{l&&(l.setSpeed(T),y())},Y=T=>{if(!l||!a)return;l.jumpTo(T);const L=he(a,a.minTime+l.state.currentTime);E(L),_(L),y()},K=()=>{m(),C(),a=null,l=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}},pe=()=>{const T=v(),L=D();!T||!L||!a||!l||(C(),U(T,L))},me=()=>{m(),C()},X=()=>{m(),C(),a=null,l=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}};return o.onUnmounted(()=>{X()}),{state:r,load:z,play:M,pause:I,stop:F,setSpeed:k,jumpTo:Y,clear:K,reapply:pe,remove:me,destroy:X}}function ga(e){const t=D();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function pa(e,t=30){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(const u of e)u.lng<n&&(n=u.lng),u.lng>r&&(r=u.lng),u.lat<i&&(i=u.lat),u.lat>a&&(a=u.lat);const l=Math.max(r-n,a-i)||1,s=Math.max(t,l*4);return[{lng:Math.max(-180,n-s),lat:Math.max(-85,i-s)},{lng:Math.min(180,r+s),lat:Math.max(-85,i-s)},{lng:Math.min(180,r+s),lat:Math.min(85,a+s)},{lng:Math.max(-180,n-s),lat:Math.min(85,a+s)}]}function cn(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function Ke(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function ma(e,t,n,r,i){const a={hierarchy:{positions:Ke(e,t),holes:[{positions:Ke(e,n)}]},material:cn(e,r.fillColor,r.fillAlpha)};return i||(a.height=0),new e.Entity({polygon:a})}function wa(e,t,n,r){return new e.Entity({polyline:{positions:Ke(e,t),width:n.outlineWidth,material:new e.PolylineGlowMaterialProperty({glowPower:.4,color:cn(e,n.outlineColor,n.outlineAlpha)}),clampToGround:r}})}function xe(e){return{...vt,...e}}function un(e,t){const n=o.ref({visible:!1,hasMask:!1,boundaryCount:0});let r=xe(t),i=null,a=null,l=null,s=null;const u=()=>{const y=e.value;return y&&y.entities?y:null},d=()=>{const y=u();y&&(a&&y.entities.remove(a),l&&y.entities.remove(l)),a=null,l=null},c=(y,E)=>{if(!i)return;const _=!ga(y),S=r.outerRing??pa(i);a=ma(E,S,i,r,_),l=r.showOutline?wa(E,i,r,_):null,y.entities.add(a),l&&y.entities.add(l)},f=()=>{const y=u(),E=D();!y||!E||!i||(d(),c(y,E))},h=()=>{const y=e.value?.scene;if(s||!y?.morphComplete)return;const E=()=>f();y.morphComplete.addEventListener(E),s=()=>y.morphComplete.removeEventListener(E)},p=(y,E)=>{const _=u(),S=D();!_||!S||!y||!y.length||(r=xe({...t,...E}),i=y,d(),c(_,S),n.value={visible:!0,hasMask:!0,boundaryCount:y.length},h())},b=y=>{a&&(a.show=!!y),l&&(l.show=!!y),n.value={...n.value,visible:!!y}},v=()=>{d()},m=()=>{s&&(s(),s=null),d(),i=null,r=xe(t),n.value={visible:!1,hasMask:!1,boundaryCount:0}},C=()=>{m()};return o.onUnmounted(()=>{C()}),{state:n,setMask:p,setVisible:b,clear:m,reapply:f,remove:v,destroy:C}}function ya(e=.5){return`
18
+ </div>`}function je(e){return typeof e=="number"&&!Number.isNaN(e)}function Wa(e,t){return t&&(e.mapInstance=o.isRef(t)?t.value:t),!!e.mapInstance}async function Ha(e,t,n){if(Wa(e,t),!e.divLayerManager&&e.mapInstance){const r=D();if(!r)return null;e.divLayerManager=new r.div.DivLayerManager(e.mapInstance,{click:(a,i)=>{n&&n({position:i,detail:a})}})}return e.divLayerManager}function ja(e){const t=D();if(!t)throw new Error("BMGL 库未加载,无法转换弹窗坐标");return t.Cartesian3.fromDegrees(e.lng,e.lat,e.altitude||0)}function tn(e,t,n){const r=Va();r.displayConfig=n?.displayConfig||null;const a=()=>{if(r.popupLayer&&r.divLayerManager){try{r.divLayerManager.removeLayer(r.popupLayer)}catch(d){w.warn("移除弹窗时发生错误:",d)}r.popupLayer=null}r.currentPopupData=null},i=async(d,c={})=>{try{if(!d)throw new Error("点位数据不能为空");const f=++r.popupSeq,h={lng:je(d.lng)?d.lng:te.lng,lat:je(d.lat)?d.lat:te.lat,altitude:je(d.altitude)?d.altitude:0};a();const p=await Ha(r,e,t);if(!p)throw new Error("DivLayerManager 初始化失败");if(f!==r.popupSeq)return;r.currentPopupData={...d};const b={offsetX:0,offsetY:-20,className:"map-point-popup",...c},v=D();if(!v)throw new Error("BMGL 库未加载,无法创建弹窗");const m=new v.div.DivLayer($a(d,r.displayConfig||void 0),ja(h),{offset:{x:b.offsetX,y:b.offsetY}});r.popupLayer=m,p.addLayer(m)}catch(f){w.error("显示点位弹窗失败:",f),a()}},l=()=>{a()},s=()=>r.popupLayer!==null,u=()=>r.currentPopupData;return o.onUnmounted(()=>{try{l()}catch(c){w.warn("[useMapPopup] onUnmounted removePopup error:",c)}const d=r.divLayerManager;if(d&&typeof d.destroy=="function")try{d.destroy()}catch(c){w.warn("[useMapPopup] onUnmounted destroy manager error:",c)}r.divLayerManager=null,r.mapInstance=null,r.currentPopupData=null}),{showPointPopup:i,removePopup:l,isPopupVisible:s,getCurrentPopupData:u}}function nn(e){let t=null;const n=()=>o.isRef(e)?e.value:e,r=new Set,a=new Map,i=s=>{try{if(t=n(),!t)throw new Error("地图实例不可用");const{position:u,config:d={}}=s,c=`circleWave_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,f=new CircleWave(t,c),{color:h="#0a84ff",radius:p=100,duration:b=3e3,ttl:v=0}=d;return f.add(u,h,p,b),r.add(c),v>0&&a.set(c,setTimeout(()=>{a.delete(c),l(c)},v)),c}catch(u){throw w.error("添加波动效果失败:",u),u}},l=s=>{try{if(t||(t=n()),!t||!t.entities)return w.warn("地图实例或 entities 不可用"),r.delete(s),!1;const u=t.entities.getById(s);if(!u)return w.warn(`未找到要删除的波动实体, ID: ${s}`),r.delete(s),!1;t.entities.remove(u),r.delete(s);const d=a.get(s);return d&&(clearTimeout(d),a.delete(s)),!0}catch(u){return w.error(`删除波动效果失败, ID: ${s}:`,u),r.delete(s),!1}};return o.onUnmounted(()=>{a.forEach(s=>clearTimeout(s)),a.clear();for(const s of Array.from(r))try{l(s)}catch(u){w.warn(`[useMapCircleWave] onUnmounted removeWave error (${s}):`,u)}r.clear()}),{addWave:i,removeWave:l}}function Ya(){return{layers:new Map}}function rn(e){return e.value?e.value:(w.warn("[useMapLayers] 地图未初始化"),null)}function an(e,t,n){const r=e.layers.get(n);if(r){try{t.value&&t.value.imageryLayers.remove(r,!1)}catch(a){w.warn(`移除同名旧图层失败 (${n}):`,a)}e.layers.delete(n)}}function qa(e,t,n){const r=rn(t);if(!r)throw new Error("地图未初始化,无法添加影像图层");const a=N();an(e,t,n);const i=new a.ImageryLayer(new a.BMImageryProvider({mapId:n}));return r.imageryLayers.add(i),e.layers.set(n,i),i}function Ka(e,t,n,r="wmts-layer"){const a=rn(t);if(!a)throw new Error("地图未初始化,无法添加 WMTS 图层");const i=N();an(e,t,r);const l=new i.WebMapTileServiceImageryProvider({url:n,layer:r,style:"default",format:"image/png",tileMatrixSetID:"EPSG:3857"}),s=a.imageryLayers.add(new i.ImageryLayer(l,{maximumTerrainLevel:21}));return e.layers.set(r,s),s}function Xa(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n?{layer:n,key:t}:(w.warn(`图层未找到: ${t}`),{layer:null,key:null})}return{layer:t,key:null}}function Za(e,t,n){try{const{layer:r,key:a}=Xa(e,n);if(!r)return!1;if(t.value&&t.value.imageryLayers.remove(r,!1),a!==null)e.layers.delete(a);else for(const[i,l]of e.layers.entries())if(l===r){e.layers.delete(i);break}return!0}catch(r){return w.error("移除图层失败:",r),!1}}function Ja(e,t){const n=t.value;if(n)try{e.layers.forEach(r=>{n.imageryLayers.remove(r,!1)}),e.layers.clear()}catch(r){w.error("移除所有图层失败:",r)}}function on(e,t){if(typeof t=="string"){const n=e.layers.get(t);return n||(w.warn(`图层未找到: ${t}`),null)}return t}function Qa(e,t,n){try{const r=on(e,t);return r?(r.show=n,!0):!1}catch(r){return w.error("设置图层可见性失败:",r),!1}}function ei(e,t,n){try{if(typeof n!="number"||Number.isNaN(n)||n<0||n>1)return w.warn("透明度必须在 0-1 之间"),!1;const r=on(e,t);return r?(r.alpha=n,!0):!1}catch(r){return w.error("设置图层透明度失败:",r),!1}}function ti(e){const t=[];return e.layers.forEach((n,r)=>{t.push({name:r,layer:n})}),t}function ln(e){const t=Ya();return o.onUnmounted(()=>{try{t.layers.clear()}catch(n){w.warn("[useMapLayers] onUnmounted cleanup error:",n)}}),{addImageryLayer:n=>qa(t,e,n),addWmtsLayer:(n,r)=>Ka(t,e,n,r),removeLayer:n=>Za(t,e,n),removeAllLayers:()=>Ja(t,e),setLayerVisible:(n,r)=>Qa(t,n,r),setLayerOpacity:(n,r)=>ei(t,n,r),getAllLayers:()=>ti(t)}}function ni(e){return{...yt,...e}}function ri(e,t){const n=e.Material.fromType("ElevationContour"),r=n.uniforms;return r.width=t.width,r.spacing=t.spacing,r.color=e.Color.RED.clone(),n}function sn(e,t){const n=o.ref(!1),r=s=>{const u=e.value;if(u?.scene?.globe)if(s){const d=D();if(!d)return;u.scene.globe.material=ri(d,ni(t))}else u.scene.globe.material=void 0};return{contourVisible:n,setContourVisible:s=>{n.value=!!s,r(n.value)},reapply:()=>{n.value&&r(!0)},remove:()=>{r(!1)}}}const ai=2e4;function ii(e,t={}){if(!Array.isArray(e)||e.length<2)throw new Error("轨迹至少需要2个点");const n=t.interval&&t.interval>0?t.interval:1;e.some(h=>typeof h.time=="number"&&Number.isFinite(h.time));const r=e.map((h,p)=>({...h,time:typeof h.time=="number"&&Number.isFinite(h.time)?h.time:p*n}));r.sort((h,p)=>h.time-p.time);const a=[];let i=-1/0;for(const h of r)h.time>i&&(a.push(h),i=h.time);if(a.length<2)throw new Error("轨迹时间戳无效,无法构成回放时间表");const l=a.map(h=>h.time),s=l[0],u=l[l.length-1]-s,d=t.duration&&t.duration>0?t.duration:u,c=t.maxPoints&&t.maxPoints>=2?Math.floor(t.maxPoints):ai;let f=a;if(a.length>c){const h=Math.ceil(a.length/c);f=a.filter((b,v)=>v%h===0);const p=a[a.length-1];f[f.length-1]!==p&&f.push(p)}return{points:a,times:l,displayPoints:f,duration:d,minTime:s}}function he(e,t){const{points:n,times:r,duration:a,minTime:i}=e,l=n.length;if(t<=r[0]){const m=n[0];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:0,progress:0}}if(t>=r[l-1]){const m=n[l-1];return{lng:m.lng,lat:m.lat,altitude:m.altitude??0,index:l-1,progress:1}}let s=0,u=l-1;for(;s<u;){const m=s+u+1>>1;r[m]<=t?s=m:u=m-1}const d=s,c=r[d+1]-r[d],f=c>0?(t-r[d])/c:0,h=n[d],p=n[d+1],b=h.altitude??0,v=p.altitude??0;return{lng:h.lng+(p.lng-h.lng)*f,lat:h.lat+(p.lat-h.lat)*f,altitude:b+(v-b)*f,index:d,progress:a>0?(t-i)/a:0}}function oi(e,t={}){const n=e.duration,r=!!t.loop;let a=0,i=Math.max(0,t.speed??1),l=t.autoPlay?"playing":"idle";const s={status:l,currentTime:0,duration:n,progress:0,pointCount:e.points.length},u=m=>Math.max(0,Math.min(n,m)),d=()=>{s.status=l,s.currentTime=u(a),s.duration=n,s.progress=n>0?s.currentTime/n:0,s.pointCount=e.points.length},c=()=>{n<=0||(l==="ended"&&(a=0),l="playing",d())},f=()=>{l==="playing"&&(l="paused"),d()},h=()=>{a=0,l="idle",d()},p=m=>{i=Math.max(0,m),d()},b=m=>{a=u(m),l==="ended"&&(l="paused"),d()},v=m=>{l!=="playing"||n<=0||(a+=m*i,a>=n&&(r?a=a%n:(a=n,l="ended")),d())};return d(),{state:s,play:c,pause:f,stop:h,setSpeed:p,jumpTo:b,tick:v}}function li(e){const t=D();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function Ye(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function si(e,t,n,r){const a=t.map(i=>e.Cartesian3.fromDegrees(i.lng,i.lat,i.altitude??0));return new e.Entity({polyline:{positions:a,width:n.lineWidth,material:Ye(e,n.lineColor,.9),clampToGround:r}})}function ci(e,t,n){return new e.Entity({polyline:{positions:[],width:t.lineWidth,material:Ye(e,t.markerColor,.9),clampToGround:n}})}function ui(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 di(e,t,n=!0){const r=new e.ConstantPositionProperty(e.Cartesian3.fromDegrees(0,0,0)),a=new e.Entity({position:r}),i=n?e.HeightReference.CLAMP_TO_GROUND:e.HeightReference.NONE;return t.markerIcon?a.billboard={image:t.markerIcon,width:t.markerSize*2,heightReference:i,verticalOrigin:e.VerticalOrigin.BOTTOM}:a.point={pixelSize:t.markerSize,color:Ye(e,t.markerColor,1),heightReference:i},ui(a,t),a}function fi(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function qe(e){return{...vt,...e}}const hi=100,gi=.25;function cn(e,t,n){const r=o.ref({status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}),a=qe(t);let i=null,l=null,s=a,u=null,d=null,c=null,f=null,h=null,p=0,b=0;const v=()=>{const T=e.value;return T&&T.entities?T:null},m=()=>{h!==null&&(cancelAnimationFrame(h),h=null)},C=()=>{const T=v();T&&(u&&T.entities.remove(u),d&&T.entities.remove(d),c&&T.entities.remove(c)),u=null,d=null,c=null,f=null},y=()=>{l&&(r.value={...l.state})},E=T=>{if(!f)return;const x=D();x&&f.setValue(x.Cartesian3.fromDegrees(T.lng,T.lat,T.altitude))},_=T=>{if(!d||!i||!l)return;const x=D();if(!x)return;const P=l.state.currentTime,W=s.trailTime>0?Math.max(0,P-s.trailTime):0,ae=he(i,i.minTime+W),ee=i.points.slice(ae.index,T.index+1),O=fi(x,ee);O.push(x.Cartesian3.fromDegrees(T.lng,T.lat,T.altitude)),d.polyline&&(d.polyline.positions=O)},S=T=>{const x=e.value;if(!x?.camera)return;const P=D();P&&x.camera.setView({destination:P.Cartesian3.fromDegrees(T.lng,T.lat,s.followHeight),orientation:{heading:0,pitch:P.Math.toRadians(-90),roll:0}})},A=T=>{if(!l||!i||l.state.status!=="playing"){m();return}h=requestAnimationFrame(A);const x=Math.min(Math.max((T-p)/1e3,0),gi);p=T,l.tick(x);const P=he(i,i.minTime+l.state.currentTime);E(P),T-b>=hi&&(_(P),b=T),s.follow&&S(P),y()},V=()=>{h===null&&(p=performance.now(),b=0,h=requestAnimationFrame(A))},U=(T,x)=>{if(!i)return;const P=!li(T);u=si(x,i.displayPoints,s,P),d=ci(x,s,P),c=di(x,s,P),f=c.position??null,T.entities.add(u),T.entities.add(d),T.entities.add(c);const W=he(i,i.minTime+(l?l.state.currentTime:0));E(W),_(W)},z=(T,x)=>{const P=v(),W=D();if(!P||!W)return;Ue.loadScripts(["move-marker","bmgl-header"],n?.serverUrl,n?.libsUrl||be).catch(ee=>w.warn("[useMapTrajectory] 轨迹辅助库加载失败:",ee)),s=qe({...a,...x});let ae;try{ae=ii(T,s)}catch(ee){w.warn("[useMapTrajectory] 轨迹数据无效:",ee);return}m(),C(),i=ae,l=oi(i,s),U(P,W),y(),s.autoPlay&&M()},M=()=>{l&&(l.play(),y(),l.state.status==="playing"&&V())},I=()=>{l&&(l.pause(),m(),y())},F=()=>{if(m(),!l||!i)return;l.stop();const T=he(i,i.minTime);E(T),_(T),y()},k=T=>{l&&(l.setSpeed(T),y())},Y=T=>{if(!l||!i)return;l.jumpTo(T);const x=he(i,i.minTime+l.state.currentTime);E(x),_(x),y()},K=()=>{m(),C(),i=null,l=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}},pe=()=>{const T=v(),x=D();!T||!x||!i||!l||(C(),U(T,x))},me=()=>{m(),C()},X=()=>{m(),C(),i=null,l=null,r.value={status:"idle",currentTime:0,duration:0,progress:0,pointCount:0}};return o.onUnmounted(()=>{X()}),{state:r,load:z,play:M,pause:I,stop:F,setSpeed:k,jumpTo:Y,clear:K,reapply:pe,remove:me,destroy:X}}function pi(e){const t=D();return!!(t&&t.SceneMode&&e?.scene?.mode===t.SceneMode.SCENE2D)}function mi(e,t=30){let n=1/0,r=-1/0,a=1/0,i=-1/0;for(const u of e)u.lng<n&&(n=u.lng),u.lng>r&&(r=u.lng),u.lat<a&&(a=u.lat),u.lat>i&&(i=u.lat);const l=Math.max(r-n,i-a)||1,s=Math.max(t,l*4);return[{lng:Math.max(-180,n-s),lat:Math.max(-85,a-s)},{lng:Math.min(180,r+s),lat:Math.max(-85,a-s)},{lng:Math.min(180,r+s),lat:Math.min(85,i+s)},{lng:Math.max(-180,n-s),lat:Math.min(85,i+s)}]}function un(e,t,n=1){return e.Color.fromCssColorString(t).withAlpha(n)}function Ke(e,t){return t.map(n=>e.Cartesian3.fromDegrees(n.lng,n.lat,n.altitude??0))}function wi(e,t,n,r,a){const i={hierarchy:{positions:Ke(e,t),holes:[{positions:Ke(e,n)}]},material:un(e,r.fillColor,r.fillAlpha)};return a||(i.height=0),new e.Entity({polygon:i})}function yi(e,t,n,r){return new e.Entity({polyline:{positions:Ke(e,t),width:n.outlineWidth,material:new e.PolylineGlowMaterialProperty({glowPower:.4,color:un(e,n.outlineColor,n.outlineAlpha)}),clampToGround:r}})}function Le(e){return{...Ct,...e}}function dn(e,t){const n=o.ref({visible:!1,hasMask:!1,boundaryCount:0});let r=Le(t),a=null,i=null,l=null,s=null;const u=()=>{const y=e.value;return y&&y.entities?y:null},d=()=>{const y=u();y&&(i&&y.entities.remove(i),l&&y.entities.remove(l)),i=null,l=null},c=(y,E)=>{if(!a)return;const _=!pi(y),S=r.outerRing??mi(a);i=wi(E,S,a,r,_),l=r.showOutline?yi(E,a,r,_):null,y.entities.add(i),l&&y.entities.add(l)},f=()=>{const y=u(),E=D();!y||!E||!a||(d(),c(y,E))},h=()=>{const y=e.value?.scene;if(s||!y?.morphComplete)return;const E=()=>f();y.morphComplete.addEventListener(E),s=()=>y.morphComplete.removeEventListener(E)},p=(y,E)=>{const _=u(),S=D();!_||!S||!y||!y.length||(r=Le({...t,...E}),a=y,d(),c(_,S),n.value={visible:!0,hasMask:!0,boundaryCount:y.length},h())},b=y=>{i&&(i.show=!!y),l&&(l.show=!!y),n.value={...n.value,visible:!!y}},v=()=>{d()},m=()=>{s&&(s(),s=null),d(),a=null,r=Le(t),n.value={visible:!1,hasMask:!1,boundaryCount:0}},C=()=>{m()};return o.onUnmounted(()=>{C()}),{state:n,setMask:p,setVisible:b,clear:m,reapply:f,remove:v,destroy:C}}function vi(e=.5){return`
19
19
  uniform sampler2D colorTexture;
20
20
  varying vec2 v_textureCoordinates;
21
21
 
@@ -42,7 +42,7 @@ void main(void){
42
42
 
43
43
  gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(c,1), ${e});
44
44
  }
45
- `}function va(e=.3){return`
45
+ `}function Ci(e=.3){return`
46
46
  uniform sampler2D colorTexture;
47
47
  varying vec2 v_textureCoordinates;
48
48
 
@@ -73,7 +73,7 @@ void main(void){
73
73
 
74
74
  gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(finalColor,1), ${e});
75
75
  }
76
- `}const dn={rain:.5,snow:.3};function fn(e,t){const n=o.ref({type:"clear",active:!1});let r=null;const i=()=>{const u=e.value;r&&u?.scene?.postProcessStages&&(u.scene.postProcessStages.remove(r),r=null)},a=(u,d)=>{const c=e.value,f=D();if(!c?.scene?.postProcessStages||!f)return;if(i(),u==="clear"||!dn[u]){n.value={type:"clear",active:!1};return}const h=d?.opacity??t?.opacity??dn[u],p=u==="rain"?ya(h):va(h);r=new f.PostProcessStage({name:`weather_${u}`,fragmentShader:p}),c.scene.postProcessStages.add(r),n.value={type:u,active:!0}},l=()=>{i(),r=null,n.value={type:"clear",active:!1}},s=()=>{l()};return o.onUnmounted(()=>{s()}),{state:n,setWeather:a,clear:l,destroy:s}}const Ca=6,ba=18,Ea=20;function Ta(e){return{day:e?.dayStartHour??Ca,dusk:e?.duskStartHour??ba,night:e?.nightStartHour??Ea}}function Sa(e,t){const{day:n,dusk:r,night:i}=Ta(t);return e>=n&&e<r?"day":e>=r&&e<i?"dusk":"night"}const Xe={x:.5781,y:-.5781,z:.5758};function Da(e,t){if(e==="day")return new t.SunLight;const n=e==="night";return new t.DirectionalLight({direction:new t.Cartesian3(Xe.x,Xe.y,Xe.z),color:n?new t.Color(.9,.925,1):t.Color.fromCssColorString("#deca7c"),intensity:n?.5:1})}function hn(e,t,n){const r=n?.is3D??o.ref(!0),i=o.ref(null),a=o.ref({enabled:!!t?.enabled,mode:"auto",period:"night",hour:0});let l,s,u;const d=()=>{const m=t?.now?.()??new Date;a.value.hour=m.getHours(),a.value.mode=i.value?"manual":"auto",a.value.period=i.value??Sa(a.value.hour,t)},c=()=>{const m=e.value;if(!m?.scene){u=void 0;return}const C=m.scene;(u!==void 0||l!==void 0)&&(C.light=l,s!==void 0&&(C.globe.enableLighting=s)),u=void 0},f=()=>{const m=e.value,C=D();if(!m?.scene||!C)return;const y=m.scene;s===void 0&&(l=y.light,s=!!y.globe.enableLighting),y.globe.enableLighting=!0;const E=Da(a.value.period,C);y.light=E,u=E},h=()=>{d(),a.value.enabled&&r.value?f():c()},p=m=>{a.value.enabled=!!m,h()},b=m=>{i.value=m==="auto"?null:m,h()},v=()=>{a.value.enabled=!1,c()};return o.onUnmounted(()=>v()),d(),{state:a,setEnabled:p,setPeriod:b,apply:h,destroy:v}}function gn(e,t){const n=e.layer||"PostGIS:dommap";return`${e.baseUrl.replace(/\/$/,"")}?layer=${n}&geo-token=${t}&style=&tilematrixset=EPSG%3A3857&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fvnd.jpeg-png&TileMatrix=EPSG%3A3857%3A{TileMatrix}&TileCol={TileCol}&TileRow={TileRow}`}function pn(e){return async()=>{const t=e.token;if(!t)throw new Error("未提供 GeoServer 令牌(geoserver.token),无法拼接 WMTS 地址");return gn(e,t)}}function Ma(){return{mapType:o.ref("3d"),mapBase:o.ref("bigemap"),currentDrawType:o.ref(null),loadingTitle:o.ref("地图加载中"),loadingSubtitle:o.ref("正在初始化地理数据..."),theme:o.ref("dark"),mapNameVisible:o.ref(!1)}}function Le(e){return typeof e=="number"&&!Number.isNaN(e)}function Ia(e){const t=o.ref(""),n=o.ref([]),r=o.ref(!1),i=o.ref(!1),a=o.ref(!1),l=o.ref(-1),s=o.ref(-1);let u,d,c=0;const f=o.computed(()=>t.value.trim()?n.value:[]),h=async S=>{const A=++c;try{const V=await e.searchByText({field:["name"],keyword:S,limit:10,caseSensitive:!1});if(A!==c)return;n.value=V||[],a.value=!1}catch(V){if(A!==c)return;w.error("搜索查询失败:",V),n.value=[],a.value=!0}finally{A===c&&(i.value=!1)}},p=S=>{if(t.value=S,u&&clearTimeout(u),!S.trim()){n.value=[],r.value=!1,a.value=!1;return}i.value=!0,r.value=!0,u=setTimeout(()=>{h(S.trim())},e.debounceTime)},b=S=>Le(S.altitude)?S.altitude+tr:e.position?.height??te.height,v=S=>{if(!Le(S.lng)||!Le(S.lat))return;e.setView(S.lng,S.lat,b(S));const A=e.addWave({position:[S.lng,S.lat,Le(S.altitude)?S.altitude:0],config:{color:"#0a84ff",radius:er,duration:Te.WAVE}});d&&clearTimeout(d),d=setTimeout(()=>e.removeWave(A),Et)},m=(S,A)=>{s.value=A,v(S),r.value=!1},C=S=>{const A=f.value.length;A!==0&&(l.value=(l.value+S+A)%A)},y=()=>{const S=l.value,A=f.value[S];A&&m(A,S)},E=()=>{r.value=!1},_=()=>{t.value="",n.value=[],r.value=!1,a.value=!1,s.value=-1,l.value=-1};return o.onUnmounted(()=>{u&&clearTimeout(u),d&&clearTimeout(d)}),{searchInput:t,searchList:n,showResults:r,isSearching:i,searchError:a,highlightIndex:l,selectedIndex:s,filteredList:f,handleInputSearch:p,handleResultClick:m,moveHighlight:C,selectHighlighted:y,closeResults:E,clearSearch:_}}function Aa(e){e.toggleMapTypeCore();const n=(e.mapType.value==="3d"?"2d":"3d")==="3d"?Qn:Jn;setTimeout(()=>e.redrawAllEntities(),n)}function xa(e){e.position&&e.setView(e.position.lng,e.position.lat,e.position.height)}async function Ze(e){e.loadingSubtitle.value="正在添加卫星影像图层...",await e.addImageryLayer("bigemap.dc-satellite"),e.loadingSubtitle.value="正在添加街道地名图层...",await e.addImageryLayer("bigemap.dc-street")}async function mn(e){if(!e.wmtsUrlProvider)throw new Error("未配置 wmtsUrlProvider,无法切换到生产底图");const t=await e.wmtsUrlProvider();if(!t)throw new Error("wmtsUrlProvider 未返回有效地址,无法切换到生产底图");await e.addWmtsLayer(t,"geoserver")}async function La(e){if(!e.map.value)return;const t=e.mapBase.value,n=t==="bigemap"?"geoserver":"bigemap";e.loadingSubtitle.value="正在切换地图底图...";try{await e.removeAllLayers(),n==="bigemap"?await Ze(e):await mn(e),e.mapBase.value=n}catch(r){w.error("切换地图底图失败:",r);try{await e.removeAllLayers(),t==="bigemap"?await Ze(e):await mn(e)}catch(i){w.error("恢复原底图失败:",i)}}finally{e.loadingSubtitle.value="正在初始化地理数据..."}}async function Na(e){if(e.map.value)try{await Ze(e)}catch(t){w.error("加载默认图层失败:",t)}}function ka(e){return t=>{if(e.getIsDrawing()||!e.map.value||!t.position)return;e.removePopup();const n=e.map.value.scene.pick(t.position);if(n&&n.primitive&&n.primitive.pointData){const r=n.primitive.pointData;e.onPointClick(r),e.showPointPopup(wn(r),{offsetX:0,offsetY:-25})}}}function _a(e,t){const n=document.querySelector(".map-point-popup");if(!n)return!1;const r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.left+e.x,l=r.top+e.y;return a>=i.left-8&&a<=i.right+8&&l>=i.top-8&&l<=i.bottom+8}function Va(e){let t=null;const n=r=>r?.id??r?.pointNo??r?.name??"";return r=>{if(e.getIsDrawing()||!e.map.value||!r.endPosition)return;const i=e.map.value.scene.canvas,a=e.map.value.scene.pick(r.endPosition);if(a&&a.primitive&&a.primitive.pointData){const l=a.primitive.pointData,s=n(l);s!==t&&(t=s,e.showPointPopup(wn(l),{offsetX:0,offsetY:-25}))}else _a(r.endPosition,i)||(t=null,e.removePopup())}}function wn(e){return{...e}}function Pa(e){if(!e.map.value)return null;const t=N(),n=new t.ScreenSpaceEventHandler(e.map.value.scene.canvas);return n.setInputAction(ka(e),t.ScreenSpaceEventType.LEFT_CLICK),n.setInputAction(Va(e),t.ScreenSpaceEventType.MOUSE_MOVE),n}function yn(e){if(e&&typeof e.destroy=="function")try{e.destroy()}catch(t){w.warn("[useMapView] destroy click listener error:",t)}}const vn=["containerId","position","serverUrl","accessToken","libsUrl","showSearch","showControls","showDeleteControls","showStatus","tools","searchDebounceTime","wmtsUrlProvider","geoserver","contourConfig","lightingConfig"],Ba={containerId:String,position:Object,serverUrl:String,accessToken:String,libsUrl:String,showSearch:Boolean,showControls:Boolean,showDeleteControls:Boolean,showStatus:Boolean,tools:Array,searchDebounceTime:Number,wmtsUrlProvider:Function,geoserver:Object,contourConfig:Object,lightingConfig:Boolean};function Ra(e,t){const n=e??{},r={};for(const i of vn)r[i]=n[i];return{...r,theme:t.theme,popupConfig:t.popupConfig}}function Cn(e,t){const n=Ma(),r=o.computed(()=>!!e.showSearch),i=o.computed(()=>e.showControls!==!1),a=o.computed(()=>e.showDeleteControls!==!1),l=o.computed(()=>!!e.showStatus),s=e.wmtsUrlProvider??(e.geoserver?pn(e.geoserver):void 0),u=o.computed(()=>!!s),d=o.computed(()=>({containerId:e.containerId,position:e.position||te,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl})),{map:c,state:f,initMap:h,setView:p,toggleMapType:b}=Pt(d.value),{loadPoints:v,searchByText:m,updatePoints:C,clearPoints:y,searchByShape:E}=Ut(c),{drawEntity:_,deleteEntity:S,redrawAllEntities:A}=Yt(c),{startDrawing:V,cancelDrawing:U,clearAllDrawings:z,removeDrawing:M,setCallback:I,getIsDrawing:F}=Jt(c),{showPointPopup:k,removePopup:Y}=en(c,void 0,{displayConfig:e.popupConfig}),{addWave:K,removeWave:pe}=tn(c),{addWmtsLayer:me,addImageryLayer:X,removeAllLayers:T,setLayerVisible:L}=on(c),{contourVisible:P,setContourVisible:W,reapply:ie,remove:ee}=ln(c,e.contourConfig),O=sn(c,void 0,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),we=un(c),ke=fn(c),ae=hn(c,{enabled:e.lightingConfig===!0},{is3D:o.computed(()=>f.value.mapType==="3d")});n.theme.value=e.theme||"dark";const uo=Ia({searchByText:m,setView:p,addWave:K,removeWave:pe,position:e.position,debounceTime:e.searchDebounceTime??ne.DEBOUNCE_DELAY});let ot=0;const lt=(x,ut)=>{ot+=1,n.loadingTitle.value=x,n.loadingSubtitle.value=ut,f.value.isLoading=!0},Wn=()=>{f.value.isLoading=!1},fo=(x,ut,Eo)=>{lt(x,ut);const To=ot;setTimeout(()=>{To===ot&&Wn()},Eo)},ho="bigemap.dc-street",st=()=>{L(ho,n.mapNameVisible.value)},Hn=x=>{n.mapNameVisible.value=!!x,st()},jn=x=>{n.theme.value=x},_e={map:c,mapType:n.mapType,mapBase:n.mapBase,loadingSubtitle:n.loadingSubtitle,position:e.position,wmtsUrlProvider:s,toggleMapTypeCore:b,redrawAllEntities:A,setView:p,removeAllLayers:T,addImageryLayer:X,addWmtsLayer:me},go={map:c,getIsDrawing:F,removePopup:Y,showPointPopup:k,onPointClick:t.onPointClick},po=()=>{z(),t.emit("clear-button-click"),t.emit("clear-draw")},mo=x=>{n.currentDrawType.value=x,V(x)},wo=()=>{n.currentDrawType.value=null},yo=()=>{I(x=>{wo(),x.operation==="draw"||x.operation==="edit"?t.emit("draw-end",x):x.operation==="delete"?t.emit("draw-delete",x):x.operation==="clear"&&t.emit("draw-clear",x)})};let ye;const vo=()=>{ye&&clearTimeout(ye),ye=setTimeout(()=>{f.value.isLoading=!1,t.emit("ready"),t.emit("init")},Ct)},Co=()=>{const x={map:c,state:f,setView:p,loadPoints:v,searchByText:m,searchByShape:E,updatePoints:C,clearPoints:y,startDrawing:V,stopDrawing:U,clearDrawings:z,removeDrawing:M,drawEntity:_,deleteEntity:S,setMapNameVisible:Hn,setContourVisible:W,trajectoryState:O.state,loadTrajectory:O.load,playTrajectory:O.play,pauseTrajectory:O.pause,stopTrajectory:O.stop,setTrajectorySpeed:O.setSpeed,jumpTrajectoryTo:O.jumpTo,clearTrajectory:O.clear,maskState:we.state,setMask:we.setMask,setMaskVisible:we.setVisible,clearMask:we.clear,weatherState:ke.state,setWeather:ke.setWeather,clearWeather:ke.clear,lightingState:ae.state,setLightingEnabled:ae.setEnabled,setLightingPeriod:ae.setPeriod,setTheme:jn};t.expose(x),t.emit("expose",x)};let Ve=null,ct=!1;o.onUnmounted(()=>{yn(Ve),Ve=null,ye&&clearTimeout(ye)});const bo=async()=>{try{lt("地图加载中","正在初始化地理数据..."),await h(),f.value.isLoading=!0,await Na(_e),st(),yn(Ve),Ve=Pa(go),yo(),ae.apply(),n.mapType.value=f.value.mapType,e.position&&await p(e.position.lng,e.position.lat,e.position.height),vo(),Co()}catch(x){throw f.value.isLoading=!1,f.value.error=x instanceof Error?x:new Error(String(x)),t.emit("error",x),x}};return{...n,state:f,map:c,showSearch:r,showControls:i,showDeleteControls:a,showStatus:l,wmtsEnabled:u,search:uo,onDelete:po,handleStartDrawing:mo,setMapNameVisible:Hn,setContourVisible:W,contourVisible:P,trajectoryState:O.state,maskState:we.state,weatherState:ke.state,lightingState:ae.state,setTheme:jn,toggleMapType:()=>{fo("视图切换中","正在切换 2D/3D 视图...",800),Aa(_e),n.mapType.value=f.value.mapType,f.value.mapType==="2d"?ee():ie(),O.reapply(),ae.apply()},resetView:()=>xa(_e),toggleMapBaseLayer:async()=>{if(!ct){ct=!0,lt("底图切换中","正在切换地图底图...");try{await La(_e),st()}finally{ct=!1,Wn()}}},init:bo}}const Je=o.defineComponent({name:"GameLoading",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载中"},subtitle:{type:String,default:"正在初始化地理数据..."}},setup(e){return()=>e.visible?o.createVNode("div",{class:"apple-loading-overlay"},[o.createVNode("div",{class:"apple-loading-content"},[o.createVNode("div",{class:"apple-spinner",role:"status","aria-label":"加载中"},null),o.createVNode("h2",{class:"apple-loading-title"},[e.title]),o.createVNode("p",{class:"apple-loading-subtitle"},[e.subtitle])])]):null}}),Qe={"2d":`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><!-- 2D 平面地图:2x2 坐标网格瓦片,表达俯视平面视角 -->\r
76
+ `}const fn={rain:.5,snow:.3};function hn(e,t){const n=o.ref({type:"clear",active:!1});let r=null;const a=()=>{const u=e.value;r&&u?.scene?.postProcessStages&&(u.scene.postProcessStages.remove(r),r=null)},i=(u,d)=>{const c=e.value,f=D();if(!c?.scene?.postProcessStages||!f)return;if(a(),u==="clear"||!fn[u]){n.value={type:"clear",active:!1};return}const h=d?.opacity??t?.opacity??fn[u],p=u==="rain"?vi(h):Ci(h);r=new f.PostProcessStage({name:`weather_${u}`,fragmentShader:p}),c.scene.postProcessStages.add(r),n.value={type:u,active:!0}},l=()=>{a(),r=null,n.value={type:"clear",active:!1}},s=()=>{l()};return o.onUnmounted(()=>{s()}),{state:n,setWeather:i,clear:l,destroy:s}}const bi=6,Ei=18,Ti=20;function Si(e){return{day:e?.dayStartHour??bi,dusk:e?.duskStartHour??Ei,night:e?.nightStartHour??Ti}}function Di(e,t){const{day:n,dusk:r,night:a}=Si(t);return e>=n&&e<r?"day":e>=r&&e<a?"dusk":"night"}const Xe={x:.5781,y:-.5781,z:.5758};function Mi(e,t){if(e==="day")return new t.SunLight;const n=e==="night";return new t.DirectionalLight({direction:new t.Cartesian3(Xe.x,Xe.y,Xe.z),color:n?new t.Color(.9,.925,1):t.Color.fromCssColorString("#deca7c"),intensity:n?.5:1})}function gn(e,t,n){const r=n?.is3D??o.ref(!0),a=o.ref(null),i=o.ref({enabled:!!t?.enabled,mode:"auto",period:"night",hour:0});let l,s,u;const d=()=>{const m=t?.now?.()??new Date;i.value.hour=m.getHours(),i.value.mode=a.value?"manual":"auto",i.value.period=a.value??Di(i.value.hour,t)},c=()=>{const m=e.value;if(!m?.scene){u=void 0;return}const C=m.scene;(u!==void 0||l!==void 0)&&(C.light=l,s!==void 0&&(C.globe.enableLighting=s)),u=void 0},f=()=>{const m=e.value,C=D();if(!m?.scene||!C)return;const y=m.scene;s===void 0&&(l=y.light,s=!!y.globe.enableLighting),y.globe.enableLighting=!0;const E=Mi(i.value.period,C);y.light=E,u=E},h=()=>{d(),i.value.enabled&&r.value?f():c()},p=m=>{i.value.enabled=!!m,h()},b=m=>{a.value=m==="auto"?null:m,h()},v=()=>{i.value.enabled=!1,c()};return o.onUnmounted(()=>v()),d(),{state:i,setEnabled:p,setPeriod:b,apply:h,destroy:v}}function pn(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 mn(e){return async()=>{const t=e.token;if(!t)throw new Error("未提供 GeoServer 令牌(geoserver.token),无法拼接 WMTS 地址");return pn(e,t)}}function Ii(){return{mapType:o.ref("3d"),mapBase:o.ref("bigemap"),currentDrawType:o.ref(null),loadingTitle:o.ref("地图加载中"),loadingSubtitle:o.ref("正在初始化地理数据..."),theme:o.ref("dark"),mapNameVisible:o.ref(!1)}}function xe(e){return typeof e=="number"&&!Number.isNaN(e)}function Ai(e){const t=o.ref(""),n=o.ref([]),r=o.ref(!1),a=o.ref(!1),i=o.ref(!1),l=o.ref(-1),s=o.ref(-1);let u,d,c=0;const f=o.computed(()=>t.value.trim()?n.value:[]),h=async S=>{const A=++c;try{const V=await e.searchByText({field:["name"],keyword:S,limit:10,caseSensitive:!1});if(A!==c)return;n.value=V||[],i.value=!1}catch(V){if(A!==c)return;w.error("搜索查询失败:",V),n.value=[],i.value=!0}finally{A===c&&(a.value=!1)}},p=S=>{if(t.value=S,u&&clearTimeout(u),!S.trim()){n.value=[],r.value=!1,i.value=!1;return}a.value=!0,r.value=!0,u=setTimeout(()=>{h(S.trim())},e.debounceTime)},b=S=>xe(S.altitude)?S.altitude+nr:e.position?.height??te.height,v=S=>{if(!xe(S.lng)||!xe(S.lat))return;e.setView(S.lng,S.lat,b(S));const A=e.addWave({position:[S.lng,S.lat,xe(S.altitude)?S.altitude:0],config:{color:"#0a84ff",radius:tr,duration:Te.WAVE}});d&&clearTimeout(d),d=setTimeout(()=>e.removeWave(A),Tt)},m=(S,A)=>{s.value=A,v(S),r.value=!1},C=S=>{const A=f.value.length;A!==0&&(l.value=(l.value+S+A)%A)},y=()=>{const S=l.value,A=f.value[S];A&&m(A,S)},E=()=>{r.value=!1},_=()=>{t.value="",n.value=[],r.value=!1,i.value=!1,s.value=-1,l.value=-1};return o.onUnmounted(()=>{u&&clearTimeout(u),d&&clearTimeout(d)}),{searchInput:t,searchList:n,showResults:r,isSearching:a,searchError:i,highlightIndex:l,selectedIndex:s,filteredList:f,handleInputSearch:p,handleResultClick:m,moveHighlight:C,selectHighlighted:y,closeResults:E,clearSearch:_}}function Li(e){e.toggleMapTypeCore();const n=(e.mapType.value==="3d"?"2d":"3d")==="3d"?er:Qn;setTimeout(()=>e.redrawAllEntities(),n)}function xi(e){e.position&&e.setView(e.position.lng,e.position.lat,e.position.height)}async function Ze(e){for(const t of e.baseLayers)e.loadingSubtitle.value=`正在添加底图图层(${t})...`,await e.addImageryLayer(t)}async function wn(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 Ni(e){if(!e.map.value)return;const t=e.mapBase.value,n=t==="bigemap"?"geoserver":"bigemap";e.loadingSubtitle.value="正在切换地图底图...";try{await e.removeAllLayers(),n==="bigemap"?await Ze(e):await wn(e),e.mapBase.value=n}catch(r){w.error("切换地图底图失败:",r);try{await e.removeAllLayers(),t==="bigemap"?await Ze(e):await wn(e)}catch(a){w.error("恢复原底图失败:",a)}}finally{e.loadingSubtitle.value="正在初始化地理数据..."}}async function ki(e){if(e.map.value)try{await Ze(e)}catch(t){w.error("加载底图图层失败:",t)}}function _i(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(yn(r),{offsetX:0,offsetY:-25})}}}function Vi(e,t){const n=document.querySelector(".map-point-popup");if(!n)return!1;const r=t.getBoundingClientRect(),a=n.getBoundingClientRect(),i=r.left+e.x,l=r.top+e.y;return i>=a.left-8&&i<=a.right+8&&l>=a.top-8&&l<=a.bottom+8}function Pi(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 a=e.map.value.scene.canvas,i=e.map.value.scene.pick(r.endPosition);if(i&&i.primitive&&i.primitive.pointData){const l=i.primitive.pointData,s=n(l);s!==t&&(t=s,e.showPointPopup(yn(l),{offsetX:0,offsetY:-25}))}else Vi(r.endPosition,a)||(t=null,e.removePopup())}}function yn(e){return{...e}}function Bi(e){if(!e.map.value)return null;const t=N(),n=new t.ScreenSpaceEventHandler(e.map.value.scene.canvas);return n.setInputAction(_i(e),t.ScreenSpaceEventType.LEFT_CLICK),n.setInputAction(Pi(e),t.ScreenSpaceEventType.MOUSE_MOVE),n}function vn(e){if(e&&typeof e.destroy=="function")try{e.destroy()}catch(t){w.warn("[useMapView] destroy click listener error:",t)}}const Cn=["containerId","position","serverUrl","accessToken","libsUrl","mapId","terrainId","baseLayers","showSearch","showControls","showDeleteControls","showStatus","tools","searchDebounceTime","wmtsUrlProvider","geoserver","contourConfig","lightingConfig"],Ri={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 zi(e,t){const n=e??{},r={};for(const a of Cn)r[a]=n[a];return{...r,theme:t.theme,popupConfig:t.popupConfig}}function bn(e,t){const n=Ii(),r=o.computed(()=>!!e.showSearch),a=o.computed(()=>e.showControls!==!1),i=o.computed(()=>e.showDeleteControls!==!1),l=o.computed(()=>!!e.showStatus),s=e.wmtsUrlProvider??(e.geoserver?mn(e.geoserver):void 0),u=o.computed(()=>!!s),d=o.computed(()=>({containerId:e.containerId,position:e.position||te,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,mapId:e.mapId,terrainId:e.terrainId})),{map:c,state:f,initMap:h,setView:p,toggleMapType:b}=Bt(d.value),{loadPoints:v,searchByText:m,updatePoints:C,clearPoints:y,searchByShape:E}=$t(c),{drawEntity:_,deleteEntity:S,redrawAllEntities:A}=qt(c),{startDrawing:V,cancelDrawing:U,clearAllDrawings:z,removeDrawing:M,setCallback:I,getIsDrawing:F}=Qt(c),{showPointPopup:k,removePopup:Y}=tn(c,void 0,{displayConfig:e.popupConfig}),{addWave:K,removeWave:pe}=nn(c),{addWmtsLayer:me,addImageryLayer:X,removeAllLayers:T,setLayerVisible:x}=ln(c),{contourVisible:P,setContourVisible:W,reapply:ae,remove:ee}=sn(c,e.contourConfig),O=cn(c,void 0,{serverUrl:e.serverUrl,libsUrl:e.libsUrl}),we=dn(c),ke=hn(c),ie=gn(c,{enabled:e.lightingConfig===!0},{is3D:o.computed(()=>f.value.mapType==="3d")});n.theme.value=e.theme||"dark";const fo=Ai({searchByText:m,setView:p,addWave:K,removeWave:pe,position:e.position,debounceTime:e.searchDebounceTime??ne.DEBOUNCE_DELAY});let ot=0;const lt=(L,ut)=>{ot+=1,n.loadingTitle.value=L,n.loadingSubtitle.value=ut,f.value.isLoading=!0},Hn=()=>{f.value.isLoading=!1},ho=(L,ut,To)=>{lt(L,ut);const So=ot;setTimeout(()=>{So===ot&&Hn()},To)},go="bigemap.dc-street",st=()=>{x(go,n.mapNameVisible.value)},jn=L=>{n.mapNameVisible.value=!!L,st()},Yn=L=>{n.theme.value=L},_e={map:c,mapType:n.mapType,mapBase:n.mapBase,loadingSubtitle:n.loadingSubtitle,position:e.position,baseLayers:e.baseLayers??wt,wmtsUrlProvider:s,toggleMapTypeCore:b,redrawAllEntities:A,setView:p,removeAllLayers:T,addImageryLayer:X,addWmtsLayer:me},po={map:c,getIsDrawing:F,removePopup:Y,showPointPopup:k,onPointClick:t.onPointClick},mo=()=>{z(),t.emit("clear-button-click"),t.emit("clear-draw")},wo=L=>{n.currentDrawType.value=L,V(L)},yo=()=>{n.currentDrawType.value=null},vo=()=>{I(L=>{yo(),L.operation==="draw"||L.operation==="edit"?t.emit("draw-end",L):L.operation==="delete"?t.emit("draw-delete",L):L.operation==="clear"&&t.emit("draw-clear",L)})};let ye;const Co=()=>{ye&&clearTimeout(ye),ye=setTimeout(()=>{f.value.isLoading=!1,t.emit("ready"),t.emit("init")},bt)},bo=()=>{const L={map:c,state:f,setView:p,loadPoints:v,searchByText:m,searchByShape:E,updatePoints:C,clearPoints:y,startDrawing:V,stopDrawing:U,clearDrawings:z,removeDrawing:M,drawEntity:_,deleteEntity:S,setMapNameVisible:jn,setContourVisible:W,trajectoryState:O.state,loadTrajectory:O.load,playTrajectory:O.play,pauseTrajectory:O.pause,stopTrajectory:O.stop,setTrajectorySpeed:O.setSpeed,jumpTrajectoryTo:O.jumpTo,clearTrajectory:O.clear,maskState:we.state,setMask:we.setMask,setMaskVisible:we.setVisible,clearMask:we.clear,weatherState:ke.state,setWeather:ke.setWeather,clearWeather:ke.clear,lightingState:ie.state,setLightingEnabled:ie.setEnabled,setLightingPeriod:ie.setPeriod,setTheme:Yn};t.expose(L),t.emit("expose",L)};let Ve=null,ct=!1;o.onUnmounted(()=>{vn(Ve),Ve=null,ye&&clearTimeout(ye)});const Eo=async()=>{try{lt("地图加载中","正在初始化地理数据..."),await h(),f.value.isLoading=!0,await ki(_e),st(),vn(Ve),Ve=Bi(po),vo(),ie.apply(),n.mapType.value=f.value.mapType,e.position&&await p(e.position.lng,e.position.lat,e.position.height),Co(),bo()}catch(L){throw f.value.isLoading=!1,f.value.error=L instanceof Error?L:new Error(String(L)),t.emit("error",L),L}};return{...n,state:f,map:c,showSearch:r,showControls:a,showDeleteControls:i,showStatus:l,wmtsEnabled:u,search:fo,onDelete:mo,handleStartDrawing:wo,setMapNameVisible:jn,setContourVisible:W,contourVisible:P,trajectoryState:O.state,maskState:we.state,weatherState:ke.state,lightingState:ie.state,setTheme:Yn,toggleMapType:()=>{ho("视图切换中","正在切换 2D/3D 视图...",800),Li(_e),n.mapType.value=f.value.mapType,f.value.mapType==="2d"?ee():ae(),O.reapply(),ie.apply()},resetView:()=>xi(_e),toggleMapBaseLayer:async()=>{if(!ct){ct=!0,lt("底图切换中","正在切换地图底图...");try{await Ni(_e),st()}finally{ct=!1,Hn()}}},init:Eo}}const Je=o.defineComponent({name:"GameLoading",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载中"},subtitle:{type:String,default:"正在初始化地理数据..."}},setup(e){return()=>e.visible?o.createVNode("div",{class:"apple-loading-overlay"},[o.createVNode("div",{class:"apple-loading-content"},[o.createVNode("div",{class:"apple-spinner",role:"status","aria-label":"加载中"},null),o.createVNode("h2",{class:"apple-loading-title"},[e.title]),o.createVNode("p",{class:"apple-loading-subtitle"},[e.subtitle])])]):null}}),Qe={"2d":`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><!-- 2D 平面地图:2x2 坐标网格瓦片,表达俯视平面视角 -->\r
77
77
  <path fill="#000000" d="M4 3.5h6.7a.5.5 0 0 1 .5.5v6.7a.5.5 0 0 1-.5.5H4a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5zm9.3 0H20a.5.5 0 0 1 .5.5v6.7a.5.5 0 0 1-.5.5h-6.7a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5zM4 12.8h6.7a.5.5 0 0 1 .5.5V20a.5.5 0 0 1-.5.5H4a.5.5 0 0 1-.5-.5v-6.7a.5.5 0 0 1 .5-.5zm9.3 0H20a.5.5 0 0 1 .5.5V20a.5.5 0 0 1-.5.5h-6.7a.5.5 0 0 1-.5-.5v-6.7a.5.5 0 0 1 .5-.5z"/></svg>\r
78
78
  `,"3d":`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><!-- 3D 立体:等轴测立方体(顶面 + 左右侧面),表达三维视角 -->\r
79
79
  <path fill="#000000" d="M12 2.6 20.6 7.1 12 11.6 3.4 7.1 12 2.6z"/>\r
@@ -104,4 +104,4 @@ void main(void){
104
104
  <circle cx="20" cy="8" r="1.6"></circle>\r
105
105
  <circle cx="12" cy="19" r="1.6"></circle>\r
106
106
  </svg>\r
107
- `,triangle:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755439485778" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35763" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M185.8 63.9c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM838.2 716.7c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM186.2 715.6c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7z" fill="#515151" p-id="35764"></path><path d="M287.2 818.1h447.6v37H287.2zM167.3 282h37v451h-37zM235.682 261.34l26.163-26.162L776.897 750.23l-26.163 26.162z" fill="#515151" p-id="35765"></path></svg>',view:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1767681773788" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6706" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M234.666667 224a10.666667 10.666667 0 0 0-10.666667 10.666667v149.333333a32 32 0 0 1-64 0v-149.333333A74.666667 74.666667 0 0 1 234.666667 160h149.333333a32 32 0 0 1 0 64h-149.333333zM597.333333 405.333333a21.333333 21.333333 0 0 1 21.333334 21.333334v170.666666a21.333333 21.333333 0 0 1-21.333334 21.333334h-170.666666a21.333333 21.333333 0 0 1-21.333334-21.333334v-170.666666a21.333333 21.333333 0 0 1 21.333334-21.333334h170.666666z m-170.666666-64a85.333333 85.333333 0 0 0-85.333334 85.333334v170.666666a85.333333 85.333333 0 0 0 85.333334 85.333334h170.666666a85.333333 85.333333 0 0 0 85.333334-85.333334v-170.666666a85.333333 85.333333 0 0 0-85.333334-85.333334h-170.666666z m-202.666667 448a10.666667 10.666667 0 0 0 10.666667 10.666667h149.333333a32 32 0 0 1 0 64h-149.333333A74.666667 74.666667 0 0 1 160 789.333333v-149.333333a32 32 0 0 1 64 0v149.333333z m565.333333 10.666667a10.666667 10.666667 0 0 0 10.666667-10.666667v-149.333333a32 32 0 0 1 64 0v149.333333a74.666667 74.666667 0 0 1-74.666667 74.666667h-149.333333a32 32 0 0 1 0-64h149.333333z m10.666667-565.333333a10.666667 10.666667 0 0 0-10.666667-10.666667h-149.333333a32 32 0 0 1 0-64h149.333333a74.666667 74.666667 0 0 1 74.666667 74.666667v149.333333a32 32 0 0 1-64 0v-149.333333z" fill="#000000" p-id="6707"></path></svg>',weather:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1766264800000" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8601" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><rect x="248" y="512" width="544" height="150" rx="72" fill="#272636" p-id="8602" /><circle cx="372" cy="504" r="120" fill="#272636" p-id="8603" /><circle cx="544" cy="452" r="150" fill="#272636" p-id="8604" /><circle cx="700" cy="504" r="118" fill="#272636" p-id="8605" /><path d="M366 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8606" /><path d="M492 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8607" /><path d="M618 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8608" /></svg>'};function bn(e){return Object.prototype.hasOwnProperty.call(Qe,e)}function za(e,t){return e.replace(/#[0-9a-fA-F]{6}/g,t).replace(/#[0-9a-fA-F]{3}/g,t).replace(/fill="(?!none")[^"]*"/g,`fill="${t}"`).replace(/stroke="(?!none")[^"]*"/g,`stroke="${t}"`)}function En(e,t){const n=Qe[e];return za(n,t||"currentColor")}const G=o.defineComponent({name:"AppIcon",inheritAttrs:!1,props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""}},setup(e){const t=o.computed(()=>bn(e.name)?En(e.name,e.color||void 0):""),n=o.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,...e.color?{color:e.color}:{}}));return()=>o.createVNode("span",{class:"app-icon iconfont-icon",style:n.value,role:"img","aria-hidden":"true"},[o.createVNode("span",{innerHTML:t.value},null)])}}),Tn=o.defineComponent({name:"MapError",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载失败"},message:{type:String,default:""}},emits:["retry"],setup(e,{emit:t}){return()=>e.visible?o.createVNode("div",{class:"map-error",role:"alert"},[o.createVNode("div",{class:"map-error__card"},[o.createVNode("div",{class:"map-error__icon"},[o.createVNode(G,{name:"view",size:28},null)]),o.createVNode("div",{class:"map-error__title"},[e.title]),o.createVNode("div",{class:"map-error__message"},[e.message||"初始化地理数据时出现异常,请检查网络连接后重试"]),o.createVNode("div",{class:"map-error__actions"},[o.createVNode("button",{type:"button",class:"map-error__retry",onClick:()=>t("retry")},[o.createTextVNode("重新加载")]),o.createVNode("span",{class:"map-error__hint"},[o.createTextVNode("若持续失败,请刷新页面")])])])]):null}}),Sn=o.defineComponent({name:"AppInput",inheritAttrs:!1,props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""},clearable:{type:Boolean,default:!1},prefixIcon:{type:String,default:""},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},ariaLabel:{type:String,default:""}},emits:["update:modelValue","input","clear","focus","blur","keydown"],setup(e,{emit:t,attrs:n}){const r=o.useSlots(),i=o.computed({get:()=>e.modelValue,set:d=>t("update:modelValue",d)}),a=o.computed(()=>e.clearable&&!e.disabled&&e.modelValue.length>0),l=d=>{const c=d.target.value;i.value=c,t("input",c)},s=()=>{i.value="",t("clear")},u=o.computed(()=>["app-input",{"app-input--disabled":e.disabled}]);return()=>{const d={},c={};for(const f of Object.keys(n))f.startsWith("on")&&f.length>2?c[f]=n[f]:d[f]=n[f];return o.createVNode("div",o.mergeProps({class:u.value},d),[e.prefixIcon?o.createVNode("span",{class:"app-input__prefix"},[o.createVNode(G,{name:e.prefixIcon,size:15},null)]):null,o.createVNode("input",o.mergeProps({class:"app-input__inner",type:"text",value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,autofocus:e.autofocus,"aria-label":e.ariaLabel||void 0,onInput:l,onFocus:f=>t("focus",f),onBlur:f=>t("blur",f),onKeydown:f=>t("keydown",f)},c),null),r.suffix?o.createVNode("span",{class:"app-input__suffix"},[r.suffix()]):null,a.value?o.createVNode("button",{type:"button",class:"app-input__clear","aria-label":"清除",onClick:s},[o.createVNode("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor"},[o.createVNode("path",{d:"M12 2a10 10 0 100 20 10 10 0 000-20zm4.24 12.83l-1.41 1.41L12 13.41l-2.83 2.83-1.41-1.41L10.59 12 7.76 9.17l1.41-1.41L12 10.59l2.83-2.83 1.41 1.41L13.41 12l2.83 2.83z"},null)])]):null])}}}),et=o.defineComponent({name:"AppSpinner",props:{size:{type:[Number,String],default:24},color:{type:String,default:""}},setup(e){const t=o.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,color:e.color||"currentColor"}));return()=>o.createVNode("span",{class:"app-spinner",style:t.value,role:"status","aria-label":"加载中"},[o.createVNode("span",{class:"app-spinner__circle"},null)])}}),Dn=o.defineComponent({name:"SearchResultsPanel",props:{list:{type:Array,default:()=>[]},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["result-click","result-hover","result-leave"],setup(e,{emit:t}){return()=>o.createVNode("div",{class:"search-results-panel"},[o.createVNode("div",{class:"results-header"},[o.createVNode("span",{class:"header-text"},[o.createTextVNode("搜索结果")])]),o.createVNode("div",{class:"results-content",role:"listbox","aria-label":"桩号搜索结果"},[e.list.map((n,r)=>o.createVNode("div",{key:n.id??r,class:["result-item",{highlight:e.highlightIndex===r,selected:e.selectedIndex===r}],role:"option","aria-selected":e.highlightIndex===r,onClick:()=>t("result-click",n,r),onMouseenter:()=>t("result-hover",r),onMouseleave:()=>t("result-leave")},[o.createVNode("div",{class:"result-icon"},[o.createVNode(G,{name:"location",size:16},null)]),o.createVNode("div",{class:"result-info"},[o.createVNode("div",{class:"result-name"},[n.name]),n.lng!==void 0&&n.lat!==void 0?o.createVNode("div",{class:"result-coordinates"},[n.lng.toFixed(6),o.createTextVNode(", "),n.lat.toFixed(6)]):null,n.altitude?o.createVNode("div",{class:"result-altitude"},[o.createTextVNode("海拔: "),n.altitude,o.createTextVNode("m")]):null]),o.createVNode("div",{class:"result-action"},[o.createVNode(G,{name:"aim",size:16},null)])]))]),o.createVNode("div",{class:"results-footer"},[o.createVNode("span",null,[o.createTextVNode("点击结果进行定位")])])])}}),tt=o.defineComponent({name:"NoResultsPanel",props:{keyword:{type:String,default:""},error:{type:Boolean,default:!1}},emits:["clear"],setup(e,{emit:t}){return()=>o.createVNode("div",{class:["no-results",{"no-results--error":e.error}]},[o.createVNode("div",{class:"no-results-content"},[o.createVNode(G,{name:e.error?"view":"search",size:32},null),o.createVNode("div",{class:"no-results-text"},[e.error?o.createVNode("p",null,[o.createTextVNode("查询失败,请检查网络后重试")]):o.createVNode("p",null,[o.createTextVNode('未找到"'),e.keyword,o.createTextVNode('"相关桩号'),o.createVNode("span",{class:"no-results-hint"},[o.createTextVNode(",请检查桩号格式后重新输入")])])]),e.error?o.createVNode("button",{type:"button",class:"no-results-retry",onClick:()=>t("clear")},[o.createTextVNode("清空重试")]):null])])}});function Fa(e){return{position:"fixed",top:`${e.bottom+nr}px`,left:`${e.left}px`,width:`${e.width}px`,zIndex:rr}}const Mn=o.defineComponent({name:"MapTools",inheritAttrs:!1,props:{showSearch:{type:Boolean,default:!1},theme:{type:String,default:"dark"},filteredList:{type:Array,default:()=>[]},showResults:{type:Boolean,default:!1},input:{type:String,default:""},isSearching:{type:Boolean,default:!1},searchError:{type:Boolean,default:!1},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["search-input","search-focus","search-clear","search-close","search-navigate","search-select","result-click","result-hover","result-leave"],setup(e,{emit:t,slots:n}){const r=o.ref(e.input),i=o.shallowRef(null),a=o.shallowRef(null),l=o.ref({}),s=o.computed(()=>e.showSearch);o.watch(()=>e.input,C=>{r.value=C});const u=()=>{i.value&&(l.value=Fa(i.value.getBoundingClientRect()))},d=C=>{r.value=C,t("search-input",C)},c=()=>{r.value="",t("search-clear","")},f=()=>{t("search-focus",r.value)},h=C=>{if(C.key==="Escape"){C.preventDefault(),t("search-close");return}if(C.key==="ArrowDown"){C.preventDefault(),t("search-navigate",1);return}if(C.key==="ArrowUp"){C.preventDefault(),t("search-navigate",-1);return}C.key==="Enter"&&(C.preventDefault(),t("search-select"))},p=C=>{if(!e.showResults)return;const y=C.target;a.value?.contains(y)||document.querySelector(".search-results-panel")?.contains(y)||document.querySelector(".no-results")?.contains(y)||t("search-close")};o.watch(()=>[e.showResults,e.filteredList.length],()=>{e.showResults&&u()}),o.onMounted(()=>{window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),document.addEventListener("mousedown",p)}),o.onUnmounted(()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),document.removeEventListener("mousedown",p)});const b=o.computed(()=>e.showResults&&e.filteredList.length>0),v=o.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&!e.searchError),m=o.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&e.searchError);return()=>o.createVNode("div",{class:"eapc-utils",ref:a},[s.value?o.createVNode("div",{class:"eapc-search"},[o.createVNode("div",{class:"search-container",ref:i},[o.createVNode(Sn,{class:"search-input",modelValue:r.value,placeholder:"请输入桩号进行搜索...",clearable:!0,prefixIcon:"search",ariaLabel:"桩号搜索","onUpdate:modelValue":d,onClear:c,onFocus:f,onKeydown:h},{suffix:()=>e.isSearching?o.createVNode(et,{size:14},null):r.value&&!e.searchError?o.createVNode("div",{class:"results-count"},[e.filteredList.length,o.createTextVNode("个结果")]):null})])]):null,o.createVNode(o.Teleport,{to:"body"},{default:()=>[b.value?o.createVNode(Dn,{class:"teleported","data-theme":e.theme,style:l.value,list:e.filteredList,highlightIndex:e.highlightIndex,selectedIndex:e.selectedIndex,"onResult-click":(C,y)=>t("result-click",C,y),"onResult-hover":C=>t("result-hover",C),"onResult-leave":()=>t("result-leave")},null):null,v.value?o.createVNode(tt,{class:"teleported","data-theme":e.theme,style:l.value,keyword:r.value},null):null,m.value?o.createVNode(tt,{class:"teleported","data-theme":e.theme,style:l.value,keyword:r.value,error:!0},null):null]}),o.createVNode("div",{class:"utils-right"},[n["utils-right"]?n["utils-right"]():null])])}}),In=o.defineComponent({name:"MapControls",inheritAttrs:!1,props:{showDeleteControls:{type:Boolean,default:!0},mapType:{type:String,default:"3d"},mapBase:{type:String,default:"bigemap"},currentDrawType:{type:String,default:null},mapNameVisible:{type:Boolean,default:!1},contourVisible:{type:Boolean,default:!1},tools:{type:Array,default:()=>Re},showBaseSwitch:{type:Boolean,default:!0}},emits:["delete","toggle-map-type","toggle-map-base","start-drawing","toggle-map-view","toggle-map-name","toggle-contour"],setup(e,{emit:t}){const n=o.computed(()=>e.currentDrawType!=null),r=l=>{n.value||t(l)},i=l=>{n.value&&e.currentDrawType!==l||t("start-drawing",l)},a=l=>{const s=ht(l);return s?s.icon:l};return()=>o.createVNode("div",{class:"eapc-control"},[e.showDeleteControls?o.createVNode("button",{type:"button",class:["item","delete-item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"清除绘制图形",onClick:()=>r("delete")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("清除绘制图形")]),o.createVNode(G,{name:"clear",size:18},null)]):null,o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapType==="3d"?"2D":"3D"}地图`,onClick:()=>r("toggle-map-type")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("切换"),e.mapType==="3d"?"2D":"3D",o.createTextVNode("地图")]),o.createVNode(G,{name:e.mapType,size:e.mapType==="3d"?24:22},null)]),o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"恢复视图",onClick:()=>r("toggle-map-view")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("恢复视图")]),o.createVNode(G,{name:"view",size:20},null)]),e.showBaseSwitch?o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapBase==="bigemap"?"物探地图":"生产地图"}底图`,onClick:()=>r("toggle-map-base")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("切换"),e.mapBase==="bigemap"?"物探地图":"生产地图"]),o.createVNode(G,{name:"base",size:20},null)]):null,o.createVNode("button",{type:"button",class:["item","label-switch-item","is-button",{"is-on":e.mapNameVisible}],role:"switch","aria-checked":e.mapNameVisible,"aria-label":e.mapNameVisible?"关闭地图名称注记":"加载地图名称注记",onClick:()=>t("toggle-map-name",!e.mapNameVisible)},[o.createVNode("span",{class:"txt"},[e.mapNameVisible?"关闭地图名称":"加载地图名称"]),o.createVNode("span",{class:"label-switch","aria-hidden":"true"},[o.createVNode("span",{class:"label-switch__track"},[o.createVNode("span",{class:"label-switch__thumb"},null)])])]),e.mapType==="3d"?o.createVNode("button",{type:"button",class:["item","is-button",{active:e.contourVisible}],"aria-pressed":e.contourVisible,"aria-label":e.contourVisible?"关闭等高线":"开启等高线",onClick:()=>t("toggle-contour")},[o.createVNode("span",{class:"txt"},[e.contourVisible?"关闭等高线":"开启等高线"]),o.createVNode(G,{name:"contour",size:18},null)]):null,o.createVNode("div",{class:"eapc-control__divider"},null),e.tools.map(l=>o.createVNode("button",{type:"button",key:l.icon,class:["item","tool-item","is-button",{active:e.currentDrawType===l.icon,"is-disabled":n.value&&e.currentDrawType!==l.icon}],disabled:n.value&&e.currentDrawType!==l.icon,"aria-pressed":e.currentDrawType===l.icon,"aria-label":l.name,onClick:()=>i(l.icon)},[o.createVNode("span",{class:"txt"},[l.name]),o.createVNode(G,{name:a(l.icon),size:l.size},null)]))])}}),Oa=500,An=1e3,Ga={bigemap:"生产地图",geoserver:"物探地图"};function Ne(e){return e&&typeof e.value=="object"?e.value:e}function Ua(e){return e>=1e3?`${(e/1e3).toFixed(2)} km`:`${Math.round(e)} m`}function xn(e){return e>=1024*1024*1024?`${(e/1024/1024/1024).toFixed(2)} GB`:`${(e/1024/1024).toFixed(1)} MB`}const Ln=o.defineComponent({name:"MapStatus",inheritAttrs:!1,props:{map:{type:Object,default:null},mapBase:{type:String,default:"bigemap"},visible:{type:Boolean,default:!1}},setup(e){const t=o.ref(!1),n=o.ref(0),r=o.ref("--"),i=o.ref({text:"--",detail:""}),a=o.ref("--"),l=o.ref("--"),s=o.shallowRef(null),u=o.shallowRef(null),d=o.ref(!1);let c=0,f=0,h=0,p=[],b=null,v=null,m=0;const C=()=>{f=0,h=performance.now();const M=()=>{f+=1;const I=performance.now();I-h>=Oa&&(n.value=Math.round(f*1e3/(I-h)),f=0,h=I),c=requestAnimationFrame(M)};c=requestAnimationFrame(M)},y=()=>{try{const M=performance.memory;if(!M){r.value="--";return}const I=M.usedJSHeapSize,F=M.jsHeapSizeLimit;r.value=`${xn(I)} / ${xn(F)}`}catch{r.value="--"}},E=()=>{const M=Ne(e.map);if(!M)return;const I=D();if(!I)return;if(!!(I.SceneMode&&M.scene.mode===I.SceneMode.SCENE2D)){i.value={text:"2D 视图",detail:Ga[e.mapBase]||e.mapBase};return}try{const k=I.Cartographic.fromCartesian(M.camera.position);i.value={text:"3D 视图",detail:`视距 ${Ua(k.height)}`}}catch{i.value={text:"3D 视图",detail:"--"}}},_=M=>{v=M,m===0&&(m=requestAnimationFrame(()=>{m=0;const I=v;if(v=null,!I)return;const F=Ne(e.map);if(!F)return;const k=D();if(!k)return;const Y=F.camera.pickEllipsoid(new k.Cartesian2(I.offsetX,I.offsetY),F.scene.globe.ellipsoid);if(!Y)return;const K=k.Cartographic.fromCartesian(Y);a.value=k.Math.toDegrees(K.longitude).toFixed(6),l.value=k.Math.toDegrees(K.latitude).toFixed(6)}))},S=()=>{!s.value||!u.value||(d.value=u.value.scrollWidth>s.value.clientWidth+1)},A=()=>{t.value=!t.value},V=M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),A())};o.onMounted(()=>{C(),y(),E(),S(),p.push(window.setInterval(y,An)),p.push(window.setInterval(E,An)),Ne(e.map)?.scene.canvas.addEventListener("mousemove",_),typeof ResizeObserver<"u"&&(b=new ResizeObserver(S),u.value&&b.observe(u.value),s.value&&b.observe(s.value))}),o.onUnmounted(()=>{cancelAnimationFrame(c),m!==0&&cancelAnimationFrame(m),v=null,b?.disconnect(),p.forEach(I=>window.clearInterval(I)),Ne(e.map)?.scene.canvas.removeEventListener("mousemove",_)});const U=()=>[o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("FPS")]),o.createVNode("b",{class:"map-status__value map-status__value--fps"},[n.value])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("内存")]),o.createVNode("span",{class:"map-status__value"},[r.value])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("层级")]),o.createVNode("span",{class:"map-status__value"},[i.value.text,i.value.detail?o.createVNode("em",{class:"map-status__detail"},[o.createTextVNode(" · "),i.value.detail]):null])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("坐标")]),o.createVNode("span",{class:"map-status__value map-status__value--coords"},[a.value,o.createTextVNode(", "),l.value])])],z=o.computed(()=>t.value&&d.value);return()=>e.visible?o.createVNode("div",{class:["map-status",t.value?"is-expanded":"is-collapsed"],role:"button",tabindex:0,title:t.value?"收起状态信息":"展开状态信息",onClick:A,onKeydown:V},[o.createVNode("span",{class:"map-status__badge","aria-hidden":t.value},[o.createVNode("b",{class:"map-status__badge-value"},[n.value])]),o.createVNode("span",{class:"map-status__expanded","aria-hidden":!t.value},[o.createVNode("span",{class:"map-status__row",ref:s},[o.createVNode("span",{class:["map-status__track",{"is-marquee":z.value}]},[o.createVNode("span",{class:"map-status__track-inner",ref:u},[U()]),z.value?o.createVNode("span",{class:"map-status__track-inner","aria-hidden":"true"},[U()]):null])])])]):null}}),Nn=o.defineComponent({name:"MapView",props:{config:{type:Object,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","error-retry","expose"],async setup(e,{emit:t,expose:n,slots:r}){const i=Ra(e.config,{theme:e.theme,popupConfig:e.popupConfig}),a=Cn(i,{emit:(k,...Y)=>t(k,...Y),expose:n,onPointClick:k=>t("point-click",k)});await a.init().catch(()=>{});const{mapType:l,mapBase:s,currentDrawType:u,loadingTitle:d,loadingSubtitle:c,theme:f,mapNameVisible:h,showControls:p,showDeleteControls:b,showStatus:v,wmtsEnabled:m}=a,{state:C,showSearch:y,search:E,onDelete:_,handleStartDrawing:S,toggleMapType:A,resetView:V,toggleMapBaseLayer:U,setMapNameVisible:z,setContourVisible:M,contourVisible:I,map:F}=a;return()=>o.createVNode(o.Fragment,null,[o.createVNode(Je,{visible:C.value.isLoading&&!C.value.error,title:d.value,subtitle:c.value},null),o.createVNode(Tn,{visible:!!C.value.error,message:C.value.error?.message,onRetry:()=>t("error-retry")},null),o.createVNode(Ln,{map:F,mapBase:s.value,visible:v.value},null),y.value?o.createVNode(Mn,{showSearch:!0,theme:f.value,filteredList:E.filteredList.value,showResults:E.showResults.value,input:E.searchInput.value,isSearching:E.isSearching.value,searchError:E.searchError.value,highlightIndex:E.highlightIndex.value,selectedIndex:E.selectedIndex.value,"onSearch-input":E.handleInputSearch,"onSearch-focus":()=>{E.showResults.value=!0},"onSearch-clear":E.clearSearch,"onSearch-close":()=>{E.showResults.value=!1},"onSearch-navigate":k=>E.moveHighlight(k),"onSearch-select":()=>E.selectHighlighted(),"onResult-click":E.handleResultClick,"onResult-hover":k=>{E.highlightIndex.value=k},"onResult-leave":()=>{E.highlightIndex.value=-1}},{"utils-right":()=>r["utils-right"]?r["utils-right"]():null}):null,p.value?o.createVNode(In,{showDeleteControls:b.value,mapType:l.value,mapBase:s.value,currentDrawType:u.value??void 0,mapNameVisible:h.value,contourVisible:I.value,tools:i.tools,showBaseSwitch:m.value,onDelete:_,"onToggle-map-type":A,"onToggle-map-base":U,"onToggle-map-view":V,"onToggle-map-name":k=>z(k),"onToggle-contour":()=>M(!I.value),"onStart-drawing":S},null):null,r.default?r.default():null])}}),$a=Object.fromEntries(vn.map(e=>[e,{type:Ba[e],default:void 0}])),Wa=o.defineComponent({name:"MapContainer",inheritAttrs:!1,props:{config:{type:Object,default:void 0},...$a,hideSearch:{type:Boolean,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","expose"],setup(e,{emit:t,slots:n,expose:r}){const i=o.ref(e.theme||"dark"),a=or(e.config,{containerId:e.containerId,position:e.position,serverUrl:e.serverUrl,accessToken:e.accessToken,libsUrl:e.libsUrl,showSearch:e.showSearch??e.hideSearch,showControls:e.showControls,showDeleteControls:e.showDeleteControls,showStatus:e.showStatus,tools:e.tools,searchDebounceTime:e.searchDebounceTime,wmtsUrlProvider:e.wmtsUrlProvider,geoserver:e.geoserver,contourConfig:e.contourConfig,lightingConfig:e.lightingConfig}),l=u=>{if(u&&typeof u.setTheme=="function"){const d=u.setTheme;u.setTheme=c=>{i.value=c,d(c)}}r(u),t("expose",u)},s=u=>(...d)=>{t(u,...d)};return()=>o.createVNode("div",{class:"map-container-wrapper","data-theme":i.value},[o.createVNode("div",{id:a.containerId,class:"map-container"},null),o.createVNode(o.Suspense,null,{default:()=>o.createVNode(Nn,{config:a,theme:i.value,popupConfig:e.popupConfig,onInit:s("init"),"onDraw-end":s("draw-end"),"onDraw-delete":s("draw-delete"),"onDraw-clear":s("draw-clear"),"onPoint-click":s("point-click"),"onClear-button-click":s("clear-button-click"),"onClear-draw":s("clear-draw"),onReady:s("ready"),onError:s("error"),onExpose:l},{default:u=>kn(n,"default",u),"utils-right":()=>kn(n,"utils-right",{})}),fallback:()=>o.createVNode(Je,{visible:!0},null)})])}});function kn(e,t,n){const r=e[t];return r?r(n):null}const Ha=o.defineComponent({name:"AppButton",inheritAttrs:!1,props:{type:{type:String,default:"primary"},size:{type:String,default:"medium"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},emits:["click"],setup(e,{slots:t,attrs:n,emit:r}){const i=o.computed(()=>["app-button",`app-button--${e.type}`,`app-button--${e.size}`,{"app-button--block":e.block},{"app-button--disabled":e.disabled||e.loading}]),a=l=>{e.disabled||e.loading||r("click",l)};return()=>o.createVNode("button",o.mergeProps({type:"button",class:i.value,disabled:e.disabled},n,{onClick:a}),[e.loading?o.createVNode(et,{size:14,class:"app-button__spinner"},null):null,t.default?o.createVNode("span",{class:"app-button__content"},[t.default()]):null])}});function _n(e,t){return/<svg\b[^>]*\sdata-keep-color\b/i.test(e)?e:e.replace(/#[0-9a-fA-F]{6}/g,t).replace(/#[0-9a-fA-F]{3}/g,t).replace(/fill="[^"]*"/g,`fill="${t}"`).replace(/stroke="[^"]*"/g,`stroke="${t}"`)}function Vn(e,t){const n=t/2;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"><circle cx="${n}" cy="${n}" r="${n}" fill="${e}"/></svg>`}function Pn(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)n+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(n)}`}const ja={fontSize:12,textColor:"#FFFFFF",textBgColor:"rgba(0, 0, 0, 0.6)",padding:4,rounded:!0,borderRadius:4};function Bn(e){return{...ja,...e}}let nt=null;function Rn(e,t){nt||(nt=document.createElement("canvas"));const n=nt.getContext("2d");return n.font=`${t}px Microsoft YaHei, sans-serif`,Math.ceil(n.measureText(e).width)}const Ya=3e3,ge=new Map,qa=100;function Ka(e){const t=ge.get(e);return t?Promise.resolve(t):new Promise(n=>{const r=new Image;let i=!1;const a=()=>{i||(i=!0,clearTimeout(l),n(r))};r.src=e,r.onload=()=>{if(r.naturalWidth>0&&r.naturalHeight>0)for(ge.set(e,r);ge.size>qa;){const s=ge.keys().next().value;if(s===void 0)break;ge.delete(s)}a()},r.onerror=a;const l=setTimeout(a,Ya)})}function Xa(e,t,n,r,i){e.fillStyle=t.textBgColor,t.rounded?(e.beginPath(),e.roundRect(n,0,r,i,t.borderRadius),e.fill()):e.fillRect(n,0,r,i)}function zn(e,t,n,r,i){e.font=`${t.fontSize}px Microsoft YaHei, sans-serif`,e.fillStyle=t.textColor,e.textAlign="center",e.textBaseline="middle",e.fillText(n,r/2,i/2)}async function Za(e,t,n,r,i){const a=await Ka(t.icon);return a.naturalWidth>0&&a.naturalHeight>0?(e.drawImage(a,r,i,n,n),!0):(e.fillStyle=t.color,e.fillRect(r,i,n,n),!1)}async function Fn(e,t,n,r){const i=n.iconSize||32,a=Bn(n.textConfig),l=Rn(t,a.fontSize)+a.padding*2,s=a.fontSize+a.padding*2,u=Math.max(i,l),d=s+i,c=document.createElement("canvas");c.width=u*r,c.height=d*r;const f=c.getContext("2d");f.scale(r,r);const h=(u-l)/2;Xa(f,a,h,l,s),zn(f,a,t,u,s);const p=await Za(f,e,i,(u-i)/2,s);return{icon:c,width:u,height:d,type:"text",text:t,status:e.status,color:e.color,degraded:!p}}function Ja(e,t,n){const r=n.iconSize||32,i=Bn(n.textConfig),a=Rn(t,i.fontSize)+i.padding*2,l=i.fontSize+i.padding*2,s=Math.max(r,a),u=l+r,d=document.createElement("canvas");d.width=s,d.height=u;const c=d.getContext("2d");return c.fillStyle=i.textBgColor,c.fillRect(0,0,s,l),zn(c,i,t,s,l),c.fillStyle=e.color,c.fillRect((s-r)/2,l,r,r),{icon:d,width:s,height:u,type:"text",text:t,status:e.status,color:e.color}}const Qa="color_svg";function On(e,t){return t===void 0?`${e}_no_text`:t===""?`${e}_empty_text`:`${e}_text_${t}`}function Gn(e){return`${Qa}_${e}`}function rt(e){return R[e]?.color||R.default.color}const it=25,eo=8;function to(){return typeof MessageChannel<"u"?new Promise(e=>{const t=new MessageChannel;t.port1.onmessage=()=>e(),t.port2.postMessage(0)}):new Promise(e=>setTimeout(e,0))}async function at(e){return performance.now()-e>=eo?(await to(),performance.now()):e}async function no(e,t){const n=new Map,r=new Map;t.forEach(i=>{const a=r.get(i.status)||[];a.push(i),r.set(i.status,a)});for(const[,i]of r){let a=performance.now();for(let l=0;l<i.length;l+=it){const s=i.slice(l,l+it);await Promise.all(s.map(async u=>{const d=u.id?.toString()??String(u.text??"");try{n.set(d,await e(u.status,u.text))}catch{n.set(d,await e(u.status))}})),l+it<i.length&&(a=await at(a))}}return n}async function ro(e,t){const n=Array.isArray(e)?e:[];if(n.length===0)return[];const r=new Array(n.length),i=new Map,a=new Map;for(let c=0;c<n.length;c++){const f=n[c],h=t.resolveColor(f),p=t.resolveBaseSvg(f),b=f.showName&&f.name?String(f.name).trim():"",v=`${p}${h}${b}`;r[c]=v,b?a.has(v)||a.set(v,{key:v,color:h,text:b,svg:p}):i.has(v)||i.set(v,{key:v,color:h,svg:p})}const l=new Map;let s=performance.now();for(const c of i.values()){const f=await t.createBaseIconBySvg(c.svg,c.color);f&&l.set(c.key,{icon:f.icon,width:f.width,height:f.height,type:f.type,text:f.text}),s=await at(s)}let u=0;const d=[];for(const c of a.values()){const f=t.peekTextIconBySvg(c.svg,c.color,c.text);f?(u++,l.set(c.key,f)):d.push(c)}t.onBatchStats?.({uniqueText:a.size,textHits:u,textGenerated:d.length}),s=performance.now();for(const c of d)l.set(c.key,await t.createTextIconBySvg(c.svg,c.color,c.text)),s=await at(s);for(let c=0;c<n.length;c++){const f=l.get(r[c]);if(!f)continue;const h=n[c];h.icon=f.icon,h.width=f.width,h.height=f.height}return n}function io(e,t){const n=JSON.stringify(R);for(const[r,i]of Object.entries(e))R[r]={color:i,text:R[r]?.text||R.default.text};n!==JSON.stringify(R)&&t()}function ao(){const e={default:R.default.color};for(const[t,n]of Object.entries(R))t!=="default"&&(e[t]=n.color);return e}const oo="color:";function Un(e){return`${oo}${e}`}class ${constructor(){this.maxIconCache=$.DEFAULT_MAX_ICON_CACHE,this.activeTasks=0,this.iconCache=new Map,this.colorCache=new Map,this.baseSvgCache=new Map,this.svgKeys=new Map,this.svgCount=0,this.compositeCache=new Map,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.rawSvg="",this.defaultConfig={iconSize:32}}static{this.DEFAULT_MAX_ICON_CACHE=8e3}static{this.TASK_MAX_ICON_CACHE=5e4}static{this.COMPOSITE_CACHE_CAP=2e4}get effectiveCacheLimit(){return this.activeTasks>0?$.TASK_MAX_ICON_CACHE:this.maxIconCache}touchCache(t){const n=this.iconCache.get(t);n&&(this.iconCache.delete(t),this.iconCache.set(t,n))}evictCacheIfNeeded(){for(;this.iconCache.size>this.effectiveCacheLimit;){const t=this.iconCache.keys().next().value;if(t===void 0)break;this.iconCache.delete(t)}}static getInstance(){return $.instance||($.instance=new $),$.instance}beginIconTask(){this.activeTasks++}endIconTask(){this.activeTasks>0&&this.activeTasks--,this.activeTasks===0&&(this.evictCacheIfNeeded(),this.evictCompositeCacheIfNeeded())}resolveSvgKey(t){const n=this.svgKeys.get(t);if(n)return n;const r=`svg#${this.svgCount++}`;return this.svgKeys.set(t,r),r}initialize(t,n){this.rawSvg=t,n&&(this.defaultConfig=n),n?.maxIconCache&&n.maxIconCache>0&&(this.maxIconCache=n.maxIconCache),this.preGenerateBaseColors()}preGenerateBaseColors(){if(this.colorCache.size>0||!this.rawSvg)return;new Set([...Object.keys(R),"default"]).forEach(n=>this.ensureColoredSvg(n,rt(n)))}ensureColoredSvg(t,n){const r=Gn(t);return this.colorCache.has(r)||this.colorCache.set(r,this.buildColoredSvg(n)),this.colorCache.get(r)}buildColoredSvg(t){const n=this.defaultConfig.iconSize||32;try{return _n(this.rawSvg,t)}catch{return Vn(t,n)}}normalizeText(t){const n=t?.trim();return n===""?"":n}buildBaseIcon(t,n){const i=`${this.resolveSvgKey(t||this.rawSvg)}${n}`,a=this.baseSvgCache.get(i);if(a)return a;const l=this.defaultConfig.iconSize||32,s=t||this.rawSvg;let u;try{u=Pn(_n(s,n))}catch{u=Pn(Vn(n,l))}const d={icon:u,width:l,height:l,type:"base",status:Un(n),color:n};return this.baseSvgCache.set(i,d),d}createBaseIconCore(t,n){return this.buildBaseIcon(this.rawSvg,n)}createBaseIconBySvg(t,n){return this.buildBaseIcon(t,n)}compositeKey(t,n,r){return`${this.resolveSvgKey(t||this.rawSvg)}${n}${r}`}peekTextIconBySvg(t,n,r){const i=this.compositeCache.get(this.compositeKey(t,n,r));if(i)return{icon:i.icon,width:i.width,height:i.height,type:i.type,text:i.text}}async createTextIconBySvg(t,n,r){const i=this.compositeKey(t,n,r),a=this.compositeCache.get(i);if(a)return{icon:a.icon,width:a.width,height:a.height,type:a.type,text:a.text};const l=this.buildBaseIcon(t,n),s=this.normalizeText(r)??"",u=await Fn(l,s,this.defaultConfig,this.dpr),d={icon:u.icon,width:u.width,height:u.height,type:u.type,text:u.text};return u.degraded||(this.compositeCache.set(i,{...u,text:s,status:l.status}),this.activeTasks===0&&this.evictCompositeCacheIfNeeded()),d}evictCompositeCacheIfNeeded(){for(;this.compositeCache.size>$.COMPOSITE_CACHE_CAP;){const t=this.compositeCache.keys().next().value;if(t===void 0)break;this.compositeCache.delete(t)}}matchCache(t,n,r){return t.status===n&&t.text===r}async createIcon(t,n){return this.createIconCore(t,rt(t),n)}async createIconByColor(t,n){return this.createIconCore(Un(t),t,n)}async createIconCore(t,n,r){const i=this.normalizeText(r),a=On(t,i),l=this.iconCache.get(a);if(l&&this.matchCache(l,t,i))return this.touchCache(a),{icon:l.icon,width:l.width,height:l.height,type:l.type,text:l.text};const s=await this.createBaseIconCore(t,n),u=i?await Fn(s,i,this.defaultConfig,this.dpr):s;return u.degraded||(this.iconCache.set(a,{...u,text:i,status:t}),this.evictCacheIfNeeded()),{icon:u.icon,width:u.width,height:u.height,type:u.type,text:u.text}}batchCreateIcons(t){return no(this.createIcon.bind(this),t)}batchCreatePointIcons(t){const n={resolveColor:r=>r.color||rt(r.status??"default"),resolveBaseSvg:r=>r.svg||this.rawSvg,createBaseIconBySvg:(r,i)=>Promise.resolve(this.buildBaseIcon(r,i)),createTextIconBySvg:(r,i,a)=>this.createTextIconBySvg(r,i,a),peekTextIconBySvg:(r,i,a)=>this.peekTextIconBySvg(r,i,a),iconSize:this.defaultConfig.iconSize||32,textConfig:this.defaultConfig.textConfig,dpr:this.dpr,onBatchStats:r=>{this.runtimeStats.textHits+=r.textHits,this.runtimeStats.textGenerated+=r.textGenerated,this.runtimeStats.uniqueText+=r.uniqueText}};return ro(t,n)}async createConditionalIcon(t,n){const r=n();return this.createIcon(t,r||void 0)}getIconHeightInfo(){const t=this.defaultConfig.iconSize||32,n=this.defaultConfig.textConfig||{},r=(n.fontSize??12)+(n.padding??0)*2;return{iconHeight:t,textHeight:r,totalHeight:t+r}}clearCache(){this.iconCache.clear(),this.colorCache.clear(),this.baseSvgCache.clear(),this.compositeCache.clear(),this.svgKeys.clear(),this.svgCount=0,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.preGenerateBaseColors()}clearCacheByStatus(t){for(const n of[...this.iconCache.keys()])n.startsWith(`${t}_`)&&this.iconCache.delete(n);this.colorCache.delete(Gn(t))}clearTextIconCache(t,n){this.iconCache.delete(On(t,n))}getCacheStats(){return{iconCache:this.iconCache.size,colorCache:this.colorCache.size,baseSvg:this.baseSvgCache.size,composite:this.compositeCache.size,total:this.iconCache.size+this.colorCache.size+this.baseSvgCache.size+this.compositeCache.size}}getRuntimeStats(){return{...this.runtimeStats}}getConfig(){return{...this.defaultConfig}}updateStatusColorMap(t){io(t,()=>this.clearCache())}getStatusColorMap(){return ao()}buildFallbackTextIcon(t,n){return Ja(t,n,this.defaultConfig)}}const lo=$.getInstance();function so(e){const t=e?.type,n=e?.data;if(t==="circle"&&Array.isArray(n?.center)&&n.center.length>=2)return{type:"circle",center:[n.center[0],n.center[1]],radius:Math.abs(Number(n.radius)||0)};if((t==="polygon"||t==="rectangle"||t==="triangle")&&Array.isArray(n?.path)&&n.path.length>=3){const r=n.path.map(i=>Array.isArray(i)&&i.length>=2?[Number(i[0]),Number(i[1])]:i&&typeof i.lng=="number"&&typeof i.lat=="number"?[i.lng,i.lat]:null).filter(i=>i!==null);if(r.length>=3)return{type:t,coordinates:r}}return null}var $n=(e=>(e.INIT_FAILED="INIT_FAILED",e.LOAD_SCRIPT_FAILED="LOAD_SCRIPT_FAILED",e.INVALID_PARAMS="INVALID_PARAMS",e.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",e.OPERATION_FAILED="OPERATION_FAILED",e))($n||{});class co extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="MapError"}}g.ANIMATION_DURATION=Te,g.AppButton=Ha,g.AppIcon=G,g.AppInput=Sn,g.AppSpinner=et,g.CAMERA_CONFIG=Ee,g.ConfigManager=St,g.DEFAULT_CONTOUR_CONFIG=wt,g.DEFAULT_LIBS_URL=be,g.DEFAULT_MAP_CONFIG=ze,g.DEFAULT_MASK_CONFIG=vt,g.DEFAULT_POSITION=te,g.DEFAULT_TOOLS=Re,g.DEFAULT_TRAJECTORY_CONFIG=yt,g.ErrorCode=$n,g.EventBus=Be,g.GEOMETRY_CONFIG=H,g.GameLoading=Je,g.ICON_MAP=Qe,g.IconManager=$,g.LIBRARIES=Oe,g.MORPH_3D_DELAY=bt,g.MapContainer=Wa,g.MapControls=In,g.MapError=Tn,g.MapErrorClass=co,g.MapManager=Z,g.MapStatus=Ln,g.MapTools=Mn,g.MapView=Nn,g.NoResultsPanel=tt,g.PERFORMANCE_CONFIG=ne,g.READY_DELAY=Ct,g.ResourceManager=Dt,g.STATUS_COLOR_MAP=R,g.ScriptLoader=It,g.SearchResultsPanel=Dn,g.WAVE_REMOVE_DELAY=Et,g.buildGeoServerWmtsUrl=gn,g.cartesianFromCoord=$r,g.cartesianToDegrees=De,g.cartographicToDegrees=Wt,g.closeCoordinates=$e,g.createGeoServerWmtsProvider=pn,g.createSearchShapeFromDrawEvent=so,g.eventBus=Xn,g.getBmgl=D,g.getDefaultToolbarEntries=pt,g.getDefaultTools=mt,g.getDrawToolEntries=gt,g.getDrawToolEntry=ht,g.getEntityType=$t,g.getLogLevel=Kn,g.getStatusInfo=ir,g.getSvg=En,g.iconManager=lo,g.isIconName=bn,g.logger=w,g.mapManager=se,g.normalizeMaskConfig=xe,g.normalizeTrajectoryConfig=qe,g.rectangleToPath=We,g.registerDrawTool=Zn,g.resolveUrl=Ge,g.scriptLoader=Ue,g.setBmgl=At,g.setLogLevel=qn,g.useMap=Pt,g.useMapCircleWave=tn,g.useMapContour=ln,g.useMapDraw=Jt,g.useMapEntity=Yt,g.useMapLayers=on,g.useMapLighting=hn,g.useMapMask=un,g.useMapPoint=Ut,g.useMapPopup=en,g.useMapTrajectory=sn,g.useMapView=Cn,g.useMapWeather=fn,g.waitForBmgl=xt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
107
+ `,triangle:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755439485778" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35763" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M185.8 63.9c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM838.2 716.7c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7zM186.2 715.6c-66.8 0-121 54.2-121 121s54.2 121 121 121 121-54.2 121-121-54.2-121-121-121z m-0.1 203.5c-45.7 0-82.7-37-82.7-82.7s37-82.7 82.7-82.7 82.7 37 82.7 82.7-37 82.7-82.7 82.7z" fill="#515151" p-id="35764"></path><path d="M287.2 818.1h447.6v37H287.2zM167.3 282h37v451h-37zM235.682 261.34l26.163-26.162L776.897 750.23l-26.163 26.162z" fill="#515151" p-id="35765"></path></svg>',view:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1767681773788" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6706" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M234.666667 224a10.666667 10.666667 0 0 0-10.666667 10.666667v149.333333a32 32 0 0 1-64 0v-149.333333A74.666667 74.666667 0 0 1 234.666667 160h149.333333a32 32 0 0 1 0 64h-149.333333zM597.333333 405.333333a21.333333 21.333333 0 0 1 21.333334 21.333334v170.666666a21.333333 21.333333 0 0 1-21.333334 21.333334h-170.666666a21.333333 21.333333 0 0 1-21.333334-21.333334v-170.666666a21.333333 21.333333 0 0 1 21.333334-21.333334h170.666666z m-170.666666-64a85.333333 85.333333 0 0 0-85.333334 85.333334v170.666666a85.333333 85.333333 0 0 0 85.333334 85.333334h170.666666a85.333333 85.333333 0 0 0 85.333334-85.333334v-170.666666a85.333333 85.333333 0 0 0-85.333334-85.333334h-170.666666z m-202.666667 448a10.666667 10.666667 0 0 0 10.666667 10.666667h149.333333a32 32 0 0 1 0 64h-149.333333A74.666667 74.666667 0 0 1 160 789.333333v-149.333333a32 32 0 0 1 64 0v149.333333z m565.333333 10.666667a10.666667 10.666667 0 0 0 10.666667-10.666667v-149.333333a32 32 0 0 1 64 0v149.333333a74.666667 74.666667 0 0 1-74.666667 74.666667h-149.333333a32 32 0 0 1 0-64h149.333333z m10.666667-565.333333a10.666667 10.666667 0 0 0-10.666667-10.666667h-149.333333a32 32 0 0 1 0-64h149.333333a74.666667 74.666667 0 0 1 74.666667 74.666667v149.333333a32 32 0 0 1-64 0v-149.333333z" fill="#000000" p-id="6707"></path></svg>',weather:'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1766264800000" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8601" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><rect x="248" y="512" width="544" height="150" rx="72" fill="#272636" p-id="8602" /><circle cx="372" cy="504" r="120" fill="#272636" p-id="8603" /><circle cx="544" cy="452" r="150" fill="#272636" p-id="8604" /><circle cx="700" cy="504" r="118" fill="#272636" p-id="8605" /><path d="M366 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8606" /><path d="M492 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8607" /><path d="M618 716l-26 82h40l26-82h-40z" fill="#272636" p-id="8608" /></svg>'};function En(e){return Object.prototype.hasOwnProperty.call(Qe,e)}function Fi(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 Tn(e,t){const n=Qe[e];return Fi(n,t||"currentColor")}const G=o.defineComponent({name:"AppIcon",inheritAttrs:!1,props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""}},setup(e){const t=o.computed(()=>En(e.name)?Tn(e.name,e.color||void 0):""),n=o.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,...e.color?{color:e.color}:{}}));return()=>o.createVNode("span",{class:"app-icon iconfont-icon",style:n.value,role:"img","aria-hidden":"true"},[o.createVNode("span",{innerHTML:t.value},null)])}}),Sn=o.defineComponent({name:"MapError",props:{visible:{type:Boolean,default:!1},title:{type:String,default:"地图加载失败"},message:{type:String,default:""}},emits:["retry"],setup(e,{emit:t}){return()=>e.visible?o.createVNode("div",{class:"map-error",role:"alert"},[o.createVNode("div",{class:"map-error__card"},[o.createVNode("div",{class:"map-error__icon"},[o.createVNode(G,{name:"view",size:28},null)]),o.createVNode("div",{class:"map-error__title"},[e.title]),o.createVNode("div",{class:"map-error__message"},[e.message||"初始化地理数据时出现异常,请检查网络连接后重试"]),o.createVNode("div",{class:"map-error__actions"},[o.createVNode("button",{type:"button",class:"map-error__retry",onClick:()=>t("retry")},[o.createTextVNode("重新加载")]),o.createVNode("span",{class:"map-error__hint"},[o.createTextVNode("若持续失败,请刷新页面")])])])]):null}}),Dn=o.defineComponent({name:"AppInput",inheritAttrs:!1,props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""},clearable:{type:Boolean,default:!1},prefixIcon:{type:String,default:""},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},ariaLabel:{type:String,default:""}},emits:["update:modelValue","input","clear","focus","blur","keydown"],setup(e,{emit:t,attrs:n}){const r=o.useSlots(),a=o.computed({get:()=>e.modelValue,set:d=>t("update:modelValue",d)}),i=o.computed(()=>e.clearable&&!e.disabled&&e.modelValue.length>0),l=d=>{const c=d.target.value;a.value=c,t("input",c)},s=()=>{a.value="",t("clear")},u=o.computed(()=>["app-input",{"app-input--disabled":e.disabled}]);return()=>{const d={},c={};for(const f of Object.keys(n))f.startsWith("on")&&f.length>2?c[f]=n[f]:d[f]=n[f];return o.createVNode("div",o.mergeProps({class:u.value},d),[e.prefixIcon?o.createVNode("span",{class:"app-input__prefix"},[o.createVNode(G,{name:e.prefixIcon,size:15},null)]):null,o.createVNode("input",o.mergeProps({class:"app-input__inner",type:"text",value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,autofocus:e.autofocus,"aria-label":e.ariaLabel||void 0,onInput:l,onFocus:f=>t("focus",f),onBlur:f=>t("blur",f),onKeydown:f=>t("keydown",f)},c),null),r.suffix?o.createVNode("span",{class:"app-input__suffix"},[r.suffix()]):null,i.value?o.createVNode("button",{type:"button",class:"app-input__clear","aria-label":"清除",onClick:s},[o.createVNode("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor"},[o.createVNode("path",{d:"M12 2a10 10 0 100 20 10 10 0 000-20zm4.24 12.83l-1.41 1.41L12 13.41l-2.83 2.83-1.41-1.41L10.59 12 7.76 9.17l1.41-1.41L12 10.59l2.83-2.83 1.41 1.41L13.41 12l2.83 2.83z"},null)])]):null])}}}),et=o.defineComponent({name:"AppSpinner",props:{size:{type:[Number,String],default:24},color:{type:String,default:""}},setup(e){const t=o.computed(()=>({width:`${e.size}px`,height:`${e.size}px`,color:e.color||"currentColor"}));return()=>o.createVNode("span",{class:"app-spinner",style:t.value,role:"status","aria-label":"加载中"},[o.createVNode("span",{class:"app-spinner__circle"},null)])}}),Mn=o.defineComponent({name:"SearchResultsPanel",props:{list:{type:Array,default:()=>[]},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["result-click","result-hover","result-leave"],setup(e,{emit:t}){return()=>o.createVNode("div",{class:"search-results-panel"},[o.createVNode("div",{class:"results-header"},[o.createVNode("span",{class:"header-text"},[o.createTextVNode("搜索结果")])]),o.createVNode("div",{class:"results-content",role:"listbox","aria-label":"桩号搜索结果"},[e.list.map((n,r)=>o.createVNode("div",{key:n.id??r,class:["result-item",{highlight:e.highlightIndex===r,selected:e.selectedIndex===r}],role:"option","aria-selected":e.highlightIndex===r,onClick:()=>t("result-click",n,r),onMouseenter:()=>t("result-hover",r),onMouseleave:()=>t("result-leave")},[o.createVNode("div",{class:"result-icon"},[o.createVNode(G,{name:"location",size:16},null)]),o.createVNode("div",{class:"result-info"},[o.createVNode("div",{class:"result-name"},[n.name]),n.lng!==void 0&&n.lat!==void 0?o.createVNode("div",{class:"result-coordinates"},[n.lng.toFixed(6),o.createTextVNode(", "),n.lat.toFixed(6)]):null,n.altitude?o.createVNode("div",{class:"result-altitude"},[o.createTextVNode("海拔: "),n.altitude,o.createTextVNode("m")]):null]),o.createVNode("div",{class:"result-action"},[o.createVNode(G,{name:"aim",size:16},null)])]))]),o.createVNode("div",{class:"results-footer"},[o.createVNode("span",null,[o.createTextVNode("点击结果进行定位")])])])}}),tt=o.defineComponent({name:"NoResultsPanel",props:{keyword:{type:String,default:""},error:{type:Boolean,default:!1}},emits:["clear"],setup(e,{emit:t}){return()=>o.createVNode("div",{class:["no-results",{"no-results--error":e.error}]},[o.createVNode("div",{class:"no-results-content"},[o.createVNode(G,{name:e.error?"view":"search",size:32},null),o.createVNode("div",{class:"no-results-text"},[e.error?o.createVNode("p",null,[o.createTextVNode("查询失败,请检查网络后重试")]):o.createVNode("p",null,[o.createTextVNode('未找到"'),e.keyword,o.createTextVNode('"相关桩号'),o.createVNode("span",{class:"no-results-hint"},[o.createTextVNode(",请检查桩号格式后重新输入")])])]),e.error?o.createVNode("button",{type:"button",class:"no-results-retry",onClick:()=>t("clear")},[o.createTextVNode("清空重试")]):null])])}});function Oi(e){return{position:"fixed",top:`${e.bottom+rr}px`,left:`${e.left}px`,width:`${e.width}px`,zIndex:ar}}const In=o.defineComponent({name:"MapTools",inheritAttrs:!1,props:{showSearch:{type:Boolean,default:!1},theme:{type:String,default:"dark"},filteredList:{type:Array,default:()=>[]},showResults:{type:Boolean,default:!1},input:{type:String,default:""},isSearching:{type:Boolean,default:!1},searchError:{type:Boolean,default:!1},highlightIndex:{type:Number,default:-1},selectedIndex:{type:Number,default:-1}},emits:["search-input","search-focus","search-clear","search-close","search-navigate","search-select","result-click","result-hover","result-leave"],setup(e,{emit:t,slots:n}){const r=o.ref(e.input),a=o.shallowRef(null),i=o.shallowRef(null),l=o.ref({}),s=o.computed(()=>e.showSearch);o.watch(()=>e.input,C=>{r.value=C});const u=()=>{a.value&&(l.value=Oi(a.value.getBoundingClientRect()))},d=C=>{r.value=C,t("search-input",C)},c=()=>{r.value="",t("search-clear","")},f=()=>{t("search-focus",r.value)},h=C=>{if(C.key==="Escape"){C.preventDefault(),t("search-close");return}if(C.key==="ArrowDown"){C.preventDefault(),t("search-navigate",1);return}if(C.key==="ArrowUp"){C.preventDefault(),t("search-navigate",-1);return}C.key==="Enter"&&(C.preventDefault(),t("search-select"))},p=C=>{if(!e.showResults)return;const y=C.target;i.value?.contains(y)||document.querySelector(".search-results-panel")?.contains(y)||document.querySelector(".no-results")?.contains(y)||t("search-close")};o.watch(()=>[e.showResults,e.filteredList.length],()=>{e.showResults&&u()}),o.onMounted(()=>{window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),document.addEventListener("mousedown",p)}),o.onUnmounted(()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),document.removeEventListener("mousedown",p)});const b=o.computed(()=>e.showResults&&e.filteredList.length>0),v=o.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&!e.searchError),m=o.computed(()=>e.showResults&&r.value!==""&&e.filteredList.length===0&&!e.isSearching&&e.searchError);return()=>o.createVNode("div",{class:"eapc-utils",ref:i},[s.value?o.createVNode("div",{class:"eapc-search"},[o.createVNode("div",{class:"search-container",ref:a},[o.createVNode(Dn,{class:"search-input",modelValue:r.value,placeholder:"请输入桩号进行搜索...",clearable:!0,prefixIcon:"search",ariaLabel:"桩号搜索","onUpdate:modelValue":d,onClear:c,onFocus:f,onKeydown:h},{suffix:()=>e.isSearching?o.createVNode(et,{size:14},null):r.value&&!e.searchError?o.createVNode("div",{class:"results-count"},[e.filteredList.length,o.createTextVNode("个结果")]):null})])]):null,o.createVNode(o.Teleport,{to:"body"},{default:()=>[b.value?o.createVNode(Mn,{class:"teleported","data-theme":e.theme,style:l.value,list:e.filteredList,highlightIndex:e.highlightIndex,selectedIndex:e.selectedIndex,"onResult-click":(C,y)=>t("result-click",C,y),"onResult-hover":C=>t("result-hover",C),"onResult-leave":()=>t("result-leave")},null):null,v.value?o.createVNode(tt,{class:"teleported","data-theme":e.theme,style:l.value,keyword:r.value},null):null,m.value?o.createVNode(tt,{class:"teleported","data-theme":e.theme,style:l.value,keyword:r.value,error:!0},null):null]}),o.createVNode("div",{class:"utils-right"},[n["utils-right"]?n["utils-right"]():null])])}}),An=o.defineComponent({name:"MapControls",inheritAttrs:!1,props:{showDeleteControls:{type:Boolean,default:!0},mapType:{type:String,default:"3d"},mapBase:{type:String,default:"bigemap"},currentDrawType:{type:String,default:null},mapNameVisible:{type:Boolean,default:!1},contourVisible:{type:Boolean,default:!1},tools:{type:Array,default:()=>Re},showBaseSwitch:{type:Boolean,default:!0}},emits:["delete","toggle-map-type","toggle-map-base","start-drawing","toggle-map-view","toggle-map-name","toggle-contour"],setup(e,{emit:t}){const n=o.computed(()=>e.currentDrawType!=null),r=l=>{n.value||t(l)},a=l=>{n.value&&e.currentDrawType!==l||t("start-drawing",l)},i=l=>{const s=ht(l);return s?s.icon:l};return()=>o.createVNode("div",{class:"eapc-control"},[e.showDeleteControls?o.createVNode("button",{type:"button",class:["item","delete-item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"清除绘制图形",onClick:()=>r("delete")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("清除绘制图形")]),o.createVNode(G,{name:"clear",size:18},null)]):null,o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapType==="3d"?"2D":"3D"}地图`,onClick:()=>r("toggle-map-type")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("切换"),e.mapType==="3d"?"2D":"3D",o.createTextVNode("地图")]),o.createVNode(G,{name:e.mapType,size:e.mapType==="3d"?24:22},null)]),o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":"恢复视图",onClick:()=>r("toggle-map-view")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("恢复视图")]),o.createVNode(G,{name:"view",size:20},null)]),e.showBaseSwitch?o.createVNode("button",{type:"button",class:["item","is-button",{"is-disabled":n.value}],disabled:n.value,"aria-label":`切换${e.mapBase==="bigemap"?"物探地图":"生产地图"}底图`,onClick:()=>r("toggle-map-base")},[o.createVNode("span",{class:"txt"},[o.createTextVNode("切换"),e.mapBase==="bigemap"?"物探地图":"生产地图"]),o.createVNode(G,{name:"base",size:20},null)]):null,o.createVNode("button",{type:"button",class:["item","label-switch-item","is-button",{"is-on":e.mapNameVisible}],role:"switch","aria-checked":e.mapNameVisible,"aria-label":e.mapNameVisible?"关闭地图名称注记":"加载地图名称注记",onClick:()=>t("toggle-map-name",!e.mapNameVisible)},[o.createVNode("span",{class:"txt"},[e.mapNameVisible?"关闭地图名称":"加载地图名称"]),o.createVNode("span",{class:"label-switch","aria-hidden":"true"},[o.createVNode("span",{class:"label-switch__track"},[o.createVNode("span",{class:"label-switch__thumb"},null)])])]),e.mapType==="3d"?o.createVNode("button",{type:"button",class:["item","is-button",{active:e.contourVisible}],"aria-pressed":e.contourVisible,"aria-label":e.contourVisible?"关闭等高线":"开启等高线",onClick:()=>t("toggle-contour")},[o.createVNode("span",{class:"txt"},[e.contourVisible?"关闭等高线":"开启等高线"]),o.createVNode(G,{name:"contour",size:18},null)]):null,o.createVNode("div",{class:"eapc-control__divider"},null),e.tools.map(l=>o.createVNode("button",{type:"button",key:l.icon,class:["item","tool-item","is-button",{active:e.currentDrawType===l.icon,"is-disabled":n.value&&e.currentDrawType!==l.icon}],disabled:n.value&&e.currentDrawType!==l.icon,"aria-pressed":e.currentDrawType===l.icon,"aria-label":l.name,onClick:()=>a(l.icon)},[o.createVNode("span",{class:"txt"},[l.name]),o.createVNode(G,{name:i(l.icon),size:l.size},null)]))])}}),Gi=500,Ln=1e3,Ui={bigemap:"生产地图",geoserver:"物探地图"};function Ne(e){return e&&typeof e.value=="object"?e.value:e}function $i(e){return e>=1e3?`${(e/1e3).toFixed(2)} km`:`${Math.round(e)} m`}function xn(e){return e>=1024*1024*1024?`${(e/1024/1024/1024).toFixed(2)} GB`:`${(e/1024/1024).toFixed(1)} MB`}const Nn=o.defineComponent({name:"MapStatus",inheritAttrs:!1,props:{map:{type:Object,default:null},mapBase:{type:String,default:"bigemap"},visible:{type:Boolean,default:!1}},setup(e){const t=o.ref(!1),n=o.ref(0),r=o.ref("--"),a=o.ref({text:"--",detail:""}),i=o.ref("--"),l=o.ref("--"),s=o.shallowRef(null),u=o.shallowRef(null),d=o.ref(!1);let c=0,f=0,h=0,p=[],b=null,v=null,m=0;const C=()=>{f=0,h=performance.now();const M=()=>{f+=1;const I=performance.now();I-h>=Gi&&(n.value=Math.round(f*1e3/(I-h)),f=0,h=I),c=requestAnimationFrame(M)};c=requestAnimationFrame(M)},y=()=>{try{const M=performance.memory;if(!M){r.value="--";return}const I=M.usedJSHeapSize,F=M.jsHeapSizeLimit;r.value=`${xn(I)} / ${xn(F)}`}catch{r.value="--"}},E=()=>{const M=Ne(e.map);if(!M)return;const I=D();if(!I)return;if(!!(I.SceneMode&&M.scene.mode===I.SceneMode.SCENE2D)){a.value={text:"2D 视图",detail:Ui[e.mapBase]||e.mapBase};return}try{const k=I.Cartographic.fromCartesian(M.camera.position);a.value={text:"3D 视图",detail:`视距 ${$i(k.height)}`}}catch{a.value={text:"3D 视图",detail:"--"}}},_=M=>{v=M,m===0&&(m=requestAnimationFrame(()=>{m=0;const I=v;if(v=null,!I)return;const F=Ne(e.map);if(!F)return;const k=D();if(!k)return;const Y=F.camera.pickEllipsoid(new k.Cartesian2(I.offsetX,I.offsetY),F.scene.globe.ellipsoid);if(!Y)return;const K=k.Cartographic.fromCartesian(Y);i.value=k.Math.toDegrees(K.longitude).toFixed(6),l.value=k.Math.toDegrees(K.latitude).toFixed(6)}))},S=()=>{!s.value||!u.value||(d.value=u.value.scrollWidth>s.value.clientWidth+1)},A=()=>{t.value=!t.value},V=M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),A())};o.onMounted(()=>{C(),y(),E(),S(),p.push(window.setInterval(y,Ln)),p.push(window.setInterval(E,Ln)),Ne(e.map)?.scene.canvas.addEventListener("mousemove",_),typeof ResizeObserver<"u"&&(b=new ResizeObserver(S),u.value&&b.observe(u.value),s.value&&b.observe(s.value))}),o.onUnmounted(()=>{cancelAnimationFrame(c),m!==0&&cancelAnimationFrame(m),v=null,b?.disconnect(),p.forEach(I=>window.clearInterval(I)),Ne(e.map)?.scene.canvas.removeEventListener("mousemove",_)});const U=()=>[o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("FPS")]),o.createVNode("b",{class:"map-status__value map-status__value--fps"},[n.value])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("内存")]),o.createVNode("span",{class:"map-status__value"},[r.value])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("层级")]),o.createVNode("span",{class:"map-status__value"},[a.value.text,a.value.detail?o.createVNode("em",{class:"map-status__detail"},[o.createTextVNode(" · "),a.value.detail]):null])]),o.createVNode("span",{class:"map-status__dot","aria-hidden":"true"},[o.createTextVNode("·")]),o.createVNode("span",{class:"map-status__item"},[o.createVNode("span",{class:"map-status__label"},[o.createTextVNode("坐标")]),o.createVNode("span",{class:"map-status__value map-status__value--coords"},[i.value,o.createTextVNode(", "),l.value])])],z=o.computed(()=>t.value&&d.value);return()=>e.visible?o.createVNode("div",{class:["map-status",t.value?"is-expanded":"is-collapsed"],role:"button",tabindex:0,title:t.value?"收起状态信息":"展开状态信息",onClick:A,onKeydown:V},[o.createVNode("span",{class:"map-status__badge","aria-hidden":t.value},[o.createVNode("b",{class:"map-status__badge-value"},[n.value])]),o.createVNode("span",{class:"map-status__expanded","aria-hidden":!t.value},[o.createVNode("span",{class:"map-status__row",ref:s},[o.createVNode("span",{class:["map-status__track",{"is-marquee":z.value}]},[o.createVNode("span",{class:"map-status__track-inner",ref:u},[U()]),z.value?o.createVNode("span",{class:"map-status__track-inner","aria-hidden":"true"},[U()]):null])])])]):null}}),kn=o.defineComponent({name:"MapView",props:{config:{type:Object,default:void 0},theme:{type:String,default:"dark"},popupConfig:{type:Object,default:()=>{}}},emits:["init","draw-end","draw-delete","draw-clear","point-click","clear-button-click","clear-draw","ready","error","error-retry","expose"],async setup(e,{emit:t,expose:n,slots:r}){const a=zi(e.config,{theme:e.theme,popupConfig:e.popupConfig}),i=bn(a,{emit:(k,...Y)=>t(k,...Y),expose:n,onPointClick:k=>t("point-click",k)});await i.init().catch(()=>{});const{mapType:l,mapBase:s,currentDrawType:u,loadingTitle:d,loadingSubtitle:c,theme:f,mapNameVisible:h,showControls:p,showDeleteControls:b,showStatus:v,wmtsEnabled:m}=i,{state:C,showSearch:y,search:E,onDelete:_,handleStartDrawing:S,toggleMapType:A,resetView:V,toggleMapBaseLayer:U,setMapNameVisible:z,setContourVisible:M,contourVisible:I,map:F}=i;return()=>o.createVNode(o.Fragment,null,[o.createVNode(Je,{visible:C.value.isLoading&&!C.value.error,title:d.value,subtitle:c.value},null),o.createVNode(Sn,{visible:!!C.value.error,message:C.value.error?.message,onRetry:()=>t("error-retry")},null),o.createVNode(Nn,{map:F,mapBase:s.value,visible:v.value},null),y.value?o.createVNode(In,{showSearch:!0,theme:f.value,filteredList:E.filteredList.value,showResults:E.showResults.value,input:E.searchInput.value,isSearching:E.isSearching.value,searchError:E.searchError.value,highlightIndex:E.highlightIndex.value,selectedIndex:E.selectedIndex.value,"onSearch-input":E.handleInputSearch,"onSearch-focus":()=>{E.showResults.value=!0},"onSearch-clear":E.clearSearch,"onSearch-close":()=>{E.showResults.value=!1},"onSearch-navigate":k=>E.moveHighlight(k),"onSearch-select":()=>E.selectHighlighted(),"onResult-click":E.handleResultClick,"onResult-hover":k=>{E.highlightIndex.value=k},"onResult-leave":()=>{E.highlightIndex.value=-1}},{"utils-right":()=>r["utils-right"]?r["utils-right"]():null}):null,p.value?o.createVNode(An,{showDeleteControls:b.value,mapType:l.value,mapBase:s.value,currentDrawType:u.value??void 0,mapNameVisible:h.value,contourVisible:I.value,tools:a.tools,showBaseSwitch:m.value,onDelete:_,"onToggle-map-type":A,"onToggle-map-base":U,"onToggle-map-view":V,"onToggle-map-name":k=>z(k),"onToggle-contour":()=>M(!I.value),"onStart-drawing":S},null):null,r.default?r.default():null])}}),Wi=Object.fromEntries(Cn.map(e=>[e,{type:Ri[e],default:void 0}])),Hi=o.defineComponent({name:"MapContainer",inheritAttrs:!1,props:{config:{type:Object,default:void 0},...Wi,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 a=o.ref(e.theme||"dark"),i=lr(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}),l=u=>{if(u&&typeof u.setTheme=="function"){const d=u.setTheme;u.setTheme=c=>{a.value=c,d(c)}}r(u),t("expose",u)},s=u=>(...d)=>{t(u,...d)};return()=>o.createVNode("div",{class:"map-container-wrapper","data-theme":a.value},[o.createVNode("div",{id:i.containerId,class:"map-container"},null),o.createVNode(o.Suspense,null,{default:()=>o.createVNode(kn,{config:i,theme:a.value,popupConfig:e.popupConfig,onInit:s("init"),"onDraw-end":s("draw-end"),"onDraw-delete":s("draw-delete"),"onDraw-clear":s("draw-clear"),"onPoint-click":s("point-click"),"onClear-button-click":s("clear-button-click"),"onClear-draw":s("clear-draw"),onReady:s("ready"),onError:s("error"),onExpose:l},{default:u=>_n(n,"default",u),"utils-right":()=>_n(n,"utils-right",{})}),fallback:()=>o.createVNode(Je,{visible:!0},null)})])}});function _n(e,t,n){const r=e[t];return r?r(n):null}const ji=o.defineComponent({name:"AppButton",inheritAttrs:!1,props:{type:{type:String,default:"primary"},size:{type:String,default:"medium"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},emits:["click"],setup(e,{slots:t,attrs:n,emit:r}){const a=o.computed(()=>["app-button",`app-button--${e.type}`,`app-button--${e.size}`,{"app-button--block":e.block},{"app-button--disabled":e.disabled||e.loading}]),i=l=>{e.disabled||e.loading||r("click",l)};return()=>o.createVNode("button",o.mergeProps({type:"button",class:a.value,disabled:e.disabled},n,{onClick:i}),[e.loading?o.createVNode(et,{size:14,class:"app-button__spinner"},null):null,t.default?o.createVNode("span",{class:"app-button__content"},[t.default()]):null])}});function Vn(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 Pn(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 Bn(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 Yi={fontSize:12,textColor:"#FFFFFF",textBgColor:"rgba(0, 0, 0, 0.6)",padding:4,rounded:!0,borderRadius:4};function Rn(e){return{...Yi,...e}}let nt=null;function zn(e,t){nt||(nt=document.createElement("canvas"));const n=nt.getContext("2d");return n.font=`${t}px Microsoft YaHei, sans-serif`,Math.ceil(n.measureText(e).width)}const qi=3e3,ge=new Map,Ki=100;function Xi(e){const t=ge.get(e);return t?Promise.resolve(t):new Promise(n=>{const r=new Image;let a=!1;const i=()=>{a||(a=!0,clearTimeout(l),n(r))};r.src=e,r.onload=()=>{if(r.naturalWidth>0&&r.naturalHeight>0)for(ge.set(e,r);ge.size>Ki;){const s=ge.keys().next().value;if(s===void 0)break;ge.delete(s)}i()},r.onerror=i;const l=setTimeout(i,qi)})}function Zi(e,t,n,r,a){e.fillStyle=t.textBgColor,t.rounded?(e.beginPath(),e.roundRect(n,0,r,a,t.borderRadius),e.fill()):e.fillRect(n,0,r,a)}function Fn(e,t,n,r,a){e.font=`${t.fontSize}px Microsoft YaHei, sans-serif`,e.fillStyle=t.textColor,e.textAlign="center",e.textBaseline="middle",e.fillText(n,r/2,a/2)}async function Ji(e,t,n,r,a){const i=await Xi(t.icon);return i.naturalWidth>0&&i.naturalHeight>0?(e.drawImage(i,r,a,n,n),!0):(e.fillStyle=t.color,e.fillRect(r,a,n,n),!1)}async function On(e,t,n,r){const a=n.iconSize||32,i=Rn(n.textConfig),l=zn(t,i.fontSize)+i.padding*2,s=i.fontSize+i.padding*2,u=Math.max(a,l),d=s+a,c=document.createElement("canvas");c.width=u*r,c.height=d*r;const f=c.getContext("2d");f.scale(r,r);const h=(u-l)/2;Zi(f,i,h,l,s),Fn(f,i,t,u,s);const p=await Ji(f,e,a,(u-a)/2,s);return{icon:c,width:u,height:d,type:"text",text:t,status:e.status,color:e.color,degraded:!p}}function Qi(e,t,n){const r=n.iconSize||32,a=Rn(n.textConfig),i=zn(t,a.fontSize)+a.padding*2,l=a.fontSize+a.padding*2,s=Math.max(r,i),u=l+r,d=document.createElement("canvas");d.width=s,d.height=u;const c=d.getContext("2d");return c.fillStyle=a.textBgColor,c.fillRect(0,0,s,l),Fn(c,a,t,s,l),c.fillStyle=e.color,c.fillRect((s-r)/2,l,r,r),{icon:d,width:s,height:u,type:"text",text:t,status:e.status,color:e.color}}const eo="color_svg";function Gn(e,t){return t===void 0?`${e}_no_text`:t===""?`${e}_empty_text`:`${e}_text_${t}`}function Un(e){return`${eo}_${e}`}function rt(e){return R[e]?.color||R.default.color}const at=25,to=8;function no(){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 it(e){return performance.now()-e>=to?(await no(),performance.now()):e}async function ro(e,t){const n=new Map,r=new Map;t.forEach(a=>{const i=r.get(a.status)||[];i.push(a),r.set(a.status,i)});for(const[,a]of r){let i=performance.now();for(let l=0;l<a.length;l+=at){const s=a.slice(l,l+at);await Promise.all(s.map(async u=>{const d=u.id?.toString()??String(u.text??"");try{n.set(d,await e(u.status,u.text))}catch{n.set(d,await e(u.status))}})),l+at<a.length&&(i=await it(i))}}return n}async function ao(e,t){const n=Array.isArray(e)?e:[];if(n.length===0)return[];const r=new Array(n.length),a=new Map,i=new Map;for(let c=0;c<n.length;c++){const f=n[c],h=t.resolveColor(f),p=t.resolveBaseSvg(f),b=f.showName&&f.name?String(f.name).trim():"",v=`${p}${h}${b}`;r[c]=v,b?i.has(v)||i.set(v,{key:v,color:h,text:b,svg:p}):a.has(v)||a.set(v,{key:v,color:h,svg:p})}const l=new Map;let s=performance.now();for(const c of a.values()){const f=await t.createBaseIconBySvg(c.svg,c.color);f&&l.set(c.key,{icon:f.icon,width:f.width,height:f.height,type:f.type,text:f.text}),s=await it(s)}let u=0;const d=[];for(const c of i.values()){const f=t.peekTextIconBySvg(c.svg,c.color,c.text);f?(u++,l.set(c.key,f)):d.push(c)}t.onBatchStats?.({uniqueText:i.size,textHits:u,textGenerated:d.length}),s=performance.now();for(const c of d)l.set(c.key,await t.createTextIconBySvg(c.svg,c.color,c.text)),s=await it(s);for(let c=0;c<n.length;c++){const f=l.get(r[c]);if(!f)continue;const h=n[c];h.icon=f.icon,h.width=f.width,h.height=f.height}return n}function io(e,t){const n=JSON.stringify(R);for(const[r,a]of Object.entries(e))R[r]={color:a,text:R[r]?.text||R.default.text};n!==JSON.stringify(R)&&t()}function oo(){const e={default:R.default.color};for(const[t,n]of Object.entries(R))t!=="default"&&(e[t]=n.color);return e}const lo="color:";function $n(e){return`${lo}${e}`}class ${constructor(){this.maxIconCache=$.DEFAULT_MAX_ICON_CACHE,this.activeTasks=0,this.iconCache=new Map,this.colorCache=new Map,this.baseSvgCache=new Map,this.svgKeys=new Map,this.svgCount=0,this.compositeCache=new Map,this.runtimeStats={textHits:0,textGenerated:0,uniqueText:0},this.dpr=typeof window<"u"&&window.devicePixelRatio||1,this.rawSvg="",this.defaultConfig={iconSize:32}}static{this.DEFAULT_MAX_ICON_CACHE=8e3}static{this.TASK_MAX_ICON_CACHE=5e4}static{this.COMPOSITE_CACHE_CAP=2e4}get effectiveCacheLimit(){return this.activeTasks>0?$.TASK_MAX_ICON_CACHE:this.maxIconCache}touchCache(t){const n=this.iconCache.get(t);n&&(this.iconCache.delete(t),this.iconCache.set(t,n))}evictCacheIfNeeded(){for(;this.iconCache.size>this.effectiveCacheLimit;){const t=this.iconCache.keys().next().value;if(t===void 0)break;this.iconCache.delete(t)}}static getInstance(){return $.instance||($.instance=new $),$.instance}beginIconTask(){this.activeTasks++}endIconTask(){this.activeTasks>0&&this.activeTasks--,this.activeTasks===0&&(this.evictCacheIfNeeded(),this.evictCompositeCacheIfNeeded())}resolveSvgKey(t){const n=this.svgKeys.get(t);if(n)return n;const r=`svg#${this.svgCount++}`;return this.svgKeys.set(t,r),r}initialize(t,n){this.rawSvg=t,n&&(this.defaultConfig=n),n?.maxIconCache&&n.maxIconCache>0&&(this.maxIconCache=n.maxIconCache),this.preGenerateBaseColors()}preGenerateBaseColors(){if(this.colorCache.size>0||!this.rawSvg)return;new Set([...Object.keys(R),"default"]).forEach(n=>this.ensureColoredSvg(n,rt(n)))}ensureColoredSvg(t,n){const r=Un(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 Vn(this.rawSvg,t)}catch{return Pn(t,n)}}normalizeText(t){const n=t?.trim();return n===""?"":n}buildBaseIcon(t,n){const a=`${this.resolveSvgKey(t||this.rawSvg)}${n}`,i=this.baseSvgCache.get(a);if(i)return i;const l=this.defaultConfig.iconSize||32,s=t||this.rawSvg;let u;try{u=Bn(Vn(s,n))}catch{u=Bn(Pn(n,l))}const d={icon:u,width:l,height:l,type:"base",status:$n(n),color:n};return this.baseSvgCache.set(a,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 a=this.compositeCache.get(this.compositeKey(t,n,r));if(a)return{icon:a.icon,width:a.width,height:a.height,type:a.type,text:a.text}}async createTextIconBySvg(t,n,r){const a=this.compositeKey(t,n,r),i=this.compositeCache.get(a);if(i)return{icon:i.icon,width:i.width,height:i.height,type:i.type,text:i.text};const l=this.buildBaseIcon(t,n),s=this.normalizeText(r)??"",u=await On(l,s,this.defaultConfig,this.dpr),d={icon:u.icon,width:u.width,height:u.height,type:u.type,text:u.text};return u.degraded||(this.compositeCache.set(a,{...u,text:s,status:l.status}),this.activeTasks===0&&this.evictCompositeCacheIfNeeded()),d}evictCompositeCacheIfNeeded(){for(;this.compositeCache.size>$.COMPOSITE_CACHE_CAP;){const t=this.compositeCache.keys().next().value;if(t===void 0)break;this.compositeCache.delete(t)}}matchCache(t,n,r){return t.status===n&&t.text===r}async createIcon(t,n){return this.createIconCore(t,rt(t),n)}async createIconByColor(t,n){return this.createIconCore($n(t),t,n)}async createIconCore(t,n,r){const a=this.normalizeText(r),i=Gn(t,a),l=this.iconCache.get(i);if(l&&this.matchCache(l,t,a))return this.touchCache(i),{icon:l.icon,width:l.width,height:l.height,type:l.type,text:l.text};const s=await this.createBaseIconCore(t,n),u=a?await On(s,a,this.defaultConfig,this.dpr):s;return u.degraded||(this.iconCache.set(i,{...u,text:a,status:t}),this.evictCacheIfNeeded()),{icon:u.icon,width:u.width,height:u.height,type:u.type,text:u.text}}batchCreateIcons(t){return ro(this.createIcon.bind(this),t)}batchCreatePointIcons(t){const n={resolveColor:r=>r.color||rt(r.status??"default"),resolveBaseSvg:r=>r.svg||this.rawSvg,createBaseIconBySvg:(r,a)=>Promise.resolve(this.buildBaseIcon(r,a)),createTextIconBySvg:(r,a,i)=>this.createTextIconBySvg(r,a,i),peekTextIconBySvg:(r,a,i)=>this.peekTextIconBySvg(r,a,i),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 ao(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(Un(t))}clearTextIconCache(t,n){this.iconCache.delete(Gn(t,n))}getCacheStats(){return{iconCache:this.iconCache.size,colorCache:this.colorCache.size,baseSvg:this.baseSvgCache.size,composite:this.compositeCache.size,total:this.iconCache.size+this.colorCache.size+this.baseSvgCache.size+this.compositeCache.size}}getRuntimeStats(){return{...this.runtimeStats}}getConfig(){return{...this.defaultConfig}}updateStatusColorMap(t){io(t,()=>this.clearCache())}getStatusColorMap(){return oo()}buildFallbackTextIcon(t,n){return Qi(t,n,this.defaultConfig)}}const so=$.getInstance();function co(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(a=>Array.isArray(a)&&a.length>=2?[Number(a[0]),Number(a[1])]:a&&typeof a.lng=="number"&&typeof a.lat=="number"?[a.lng,a.lat]:null).filter(a=>a!==null);if(r.length>=3)return{type:t,coordinates:r}}return null}var Wn=(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))(Wn||{});class uo extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="MapError"}}g.ANIMATION_DURATION=Te,g.AppButton=ji,g.AppIcon=G,g.AppInput=Dn,g.AppSpinner=et,g.CAMERA_CONFIG=Ee,g.ConfigManager=Dt,g.DEFAULT_CONTOUR_CONFIG=yt,g.DEFAULT_LIBS_URL=be,g.DEFAULT_MAP_CONFIG=ze,g.DEFAULT_MASK_CONFIG=Ct,g.DEFAULT_POSITION=te,g.DEFAULT_TOOLS=Re,g.DEFAULT_TRAJECTORY_CONFIG=vt,g.ErrorCode=Wn,g.EventBus=Be,g.GEOMETRY_CONFIG=H,g.GameLoading=Je,g.ICON_MAP=Qe,g.IconManager=$,g.LIBRARIES=Oe,g.MORPH_3D_DELAY=Et,g.MapContainer=Hi,g.MapControls=An,g.MapError=Sn,g.MapErrorClass=uo,g.MapManager=Z,g.MapStatus=Nn,g.MapTools=In,g.MapView=kn,g.NoResultsPanel=tt,g.PERFORMANCE_CONFIG=ne,g.READY_DELAY=bt,g.ResourceManager=Mt,g.STATUS_COLOR_MAP=R,g.ScriptLoader=At,g.SearchResultsPanel=Mn,g.WAVE_REMOVE_DELAY=Tt,g.buildGeoServerWmtsUrl=pn,g.cartesianFromCoord=Wr,g.cartesianToDegrees=De,g.cartographicToDegrees=Ht,g.closeCoordinates=$e,g.createGeoServerWmtsProvider=mn,g.createSearchShapeFromDrawEvent=co,g.eventBus=Zn,g.getBmgl=D,g.getDefaultToolbarEntries=pt,g.getDefaultTools=mt,g.getDrawToolEntries=gt,g.getDrawToolEntry=ht,g.getEntityType=Wt,g.getLogLevel=Xn,g.getStatusInfo=ir,g.getSvg=Tn,g.iconManager=so,g.isIconName=En,g.logger=w,g.mapManager=se,g.normalizeMaskConfig=Le,g.normalizeTrajectoryConfig=qe,g.rectangleToPath=We,g.registerDrawTool=Jn,g.resolveUrl=Ge,g.scriptLoader=Ue,g.setBmgl=Lt,g.setLogLevel=Kn,g.useMap=Bt,g.useMapCircleWave=nn,g.useMapContour=sn,g.useMapDraw=Qt,g.useMapEntity=qt,g.useMapLayers=ln,g.useMapLighting=gn,g.useMapMask=dn,g.useMapPoint=$t,g.useMapPopup=tn,g.useMapTrajectory=cn,g.useMapView=bn,g.useMapWeather=hn,g.waitForBmgl=xt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));