var sr=Object.defineProperty,lr=Object.defineProperties;var ar=Object.getOwnPropertyDescriptors;var wn=Object.getOwnPropertySymbols;var ur=Object.prototype.hasOwnProperty,cr=Object.prototype.propertyIsEnumerable;var Sn=(m,n,r)=>n in m?sr(m,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):m[n]=r,at=(m,n)=>{for(var r in n||(n={}))ur.call(n,r)&&Sn(m,r,n[r]);if(wn)for(var r of wn(n))cr.call(n,r)&&Sn(m,r,n[r]);return m},Lt=(m,n)=>lr(m,ar(n));var mt=(m,n,r)=>new Promise((u,h)=>{var c=y=>{try{g(r.next(y))}catch(w){h(w)}},p=y=>{try{g(r.throw(y))}catch(w){h(w)}},g=y=>y.done?u(y.value):Promise.resolve(y.value).then(c,p);g((r=r.apply(m,n)).next())});import{H as G,n as xe,h as bn}from"./townshipBoundaries-822b7d9e-1784132792831.js";import{_ as hr,g as fr,q as mr,h as pr,w as Kt,A as _n,o as gr,c as dr,a as yr,d as Nn,K as xr}from"./index-1784132792831.js";class yt{constructor(n,r){this.next=null,this.key=n,this.data=r,this.left=null,this.right=null}}function wr(m,n){return m>n?1:m0){if(n.right===null)break;if(r(m,n.right.key)>0){const g=n.right;if(n.right=g.left,g.left=n,n=g,n.right===null)break}h.right=n,h=n,n=n.right}else break}return h.right=n.left,c.left=n.right,n.left=u.right,n.right=u.left,n}function we(m,n,r,u){const h=new yt(m,n);if(r===null)return h.left=h.right=null,h;r=pt(m,r,u);const c=u(m,r.key);return c<0?(h.left=r.left,h.right=r,r.left=null):c>=0&&(h.right=r.right,h.left=r,r.right=null),h}function En(m,n,r){let u=null,h=null;if(n){n=pt(m,n,r);const c=r(n.key,m);c===0?(u=n.left,h=n.right):c<0?(h=n.right,n.right=null,u=n):(u=n.left,n.left=null,h=n)}return{left:u,right:h}}function Sr(m,n,r){return n===null?m:(m===null||(n=pt(m.key,n,r),n.left=m),n)}function be(m,n,r,u,h){if(m){u(`${n}${r?"└── ":"├── "}${h(m)} `);const c=n+(r?" ":"│ ");m.left&&be(m.left,c,!1,u,h),m.right&&be(m.right,c,!0,u,h)}}class Te{constructor(n=wr){this._root=null,this._size=0,this._comparator=n}insert(n,r){return this._size++,this._root=we(n,r,this._root,this._comparator)}add(n,r){const u=new yt(n,r);this._root===null&&(u.left=u.right=null,this._size++,this._root=u);const h=this._comparator,c=pt(n,this._root,h),p=h(n,c.key);return p===0?this._root=c:(p<0?(u.left=c.left,u.right=c,c.left=null):p>0&&(u.right=c.right,u.left=c,c.right=null),this._size++,this._root=u),this._root}remove(n){this._root=this._remove(n,this._root,this._comparator)}_remove(n,r,u){let h;return r===null?null:(r=pt(n,r,u),u(n,r.key)===0?(r.left===null?h=r.right:(h=pt(n,r.left,u),h.right=r.right),this._size--,h):r)}pop(){let n=this._root;if(n){for(;n.left;)n=n.left;return this._root=pt(n.key,this._root,this._comparator),this._root=this._remove(n.key,this._root,this._comparator),{key:n.key,data:n.data}}return null}findStatic(n){let r=this._root;const u=this._comparator;for(;r;){const h=u(n,r.key);if(h===0)return r;h<0?r=r.left:r=r.right}return null}find(n){return this._root&&(this._root=pt(n,this._root,this._comparator),this._comparator(n,this._root.key)!==0)?null:this._root}contains(n){let r=this._root;const u=this._comparator;for(;r;){const h=u(n,r.key);if(h===0)return!0;h<0?r=r.left:r=r.right}return!1}forEach(n,r){let u=this._root;const h=[];let c=!1;for(;!c;)u!==null?(h.push(u),u=u.left):h.length!==0?(u=h.pop(),n.call(r,u),u=u.right):c=!0;return this}range(n,r,u,h){const c=[],p=this._comparator;let g=this._root,y;for(;c.length!==0||g;)if(g)c.push(g),g=g.left;else{if(g=c.pop(),y=p(g.key,r),y>0)break;if(p(g.key,n)>=0&&u.call(h,g))return this;g=g.right}return this}keys(){const n=[];return this.forEach(({key:r})=>{n.push(r)}),n}values(){const n=[];return this.forEach(({data:r})=>{n.push(r)}),n}min(){return this._root?this.minNode(this._root).key:null}max(){return this._root?this.maxNode(this._root).key:null}minNode(n=this._root){if(n)for(;n.left;)n=n.left;return n}maxNode(n=this._root){if(n)for(;n.right;)n=n.right;return n}at(n){let r=this._root,u=!1,h=0;const c=[];for(;!u;)if(r)c.push(r),r=r.left;else if(c.length>0){if(r=c.pop(),h===n)return r;h++,r=r.right}else u=!0;return null}next(n){let r=this._root,u=null;if(n.right){for(u=n.right;u.left;)u=u.left;return u}const h=this._comparator;for(;r;){const c=h(n.key,r.key);if(c===0)break;c<0?(u=r,r=r.left):r=r.right}return u}prev(n){let r=this._root,u=null;if(n.left!==null){for(u=n.left;u.right;)u=u.right;return u}const h=this._comparator;for(;r;){const c=h(n.key,r.key);if(c===0)break;c<0?r=r.left:(u=r,r=r.right)}return u}clear(){return this._root=null,this._size=0,this}toList(){return _r(this._root)}load(n,r=[],u=!1){let h=n.length;const c=this._comparator;if(u&&Ee(n,r,0,h-1,c),this._root===null)this._root=_e(n,r,0,h),this._size=h;else{const p=Nr(this.toList(),br(n,r),c);h=this._size+h,this._root=Ne({head:p},0,h)}return this}isEmpty(){return this._root===null}get size(){return this._size}get root(){return this._root}toString(n=r=>String(r.key)){const r=[];return be(this._root,"",!0,u=>r.push(u),n),r.join("")}update(n,r,u){const h=this._comparator;let{left:c,right:p}=En(n,this._root,h);h(n,r)<0?p=we(r,u,p,h):c=we(r,u,c,h),this._root=Sr(c,p,h)}split(n){return En(n,this._root,this._comparator)}*[Symbol.iterator](){let n=this._root;const r=[];let u=!1;for(;!u;)n!==null?(r.push(n),n=n.left):r.length!==0?(n=r.pop(),yield n,n=n.right):u=!0}}function _e(m,n,r,u){const h=u-r;if(h>0){const c=r+Math.floor(h/2),p=m[c],g=n[c],y=new yt(p,g);return y.left=_e(m,n,r,c),y.right=_e(m,n,c+1,u),y}return null}function br(m,n){const r=new yt(null,null);let u=r;for(let h=0;h0?(n=c=c.next=r.pop(),n=n.right):u=!0;return c.next=null,h.next}function Ne(m,n,r){const u=r-n;if(u>0){const h=n+Math.floor(u/2),c=Ne(m,n,h),p=m.head;return p.left=c,m.head=m.head.next,p.right=Ne(m,h+1,r),p}return null}function Nr(m,n,r){const u=new yt(null,null);let h=u,c=m,p=n;for(;c!==null&&p!==null;)r(c.key,p.key)<0?(h.next=c,c=c.next):(h.next=p,p=p.next),h=h.next;return c!==null?h.next=c:p!==null&&(h.next=p),u.next}function Ee(m,n,r,u,h){if(r>=u)return;const c=m[r+u>>1];let p=r-1,g=u+1;for(;;){do p++;while(h(m[p],c)<0);do g--;while(h(m[g],c)>0);if(p>=g)break;let y=m[p];m[p]=m[g],m[g]=y,y=n[p],n[p]=n[g],n[g]=y}Ee(m,n,r,g,h),Ee(m,n,g+1,u,h)}const ut=11102230246251565e-32,J=134217729,Er=(3+8*ut)*ut;function Se(m,n,r,u,h){let c,p,g,y,w=n[0],N=u[0],o=0,x=0;N>w==N>-w?(c=w,w=n[++o]):(c=N,N=u[++x]);let b=0;if(ow==N>-w?(p=w+c,g=c-(p-w),w=n[++o]):(p=N+c,g=c-(p-N),N=u[++x]),c=p,g!==0&&(h[b++]=g);ow==N>-w?(p=c+w,y=p-c,g=c-(p-y)+(w-y),w=n[++o]):(p=c+N,y=p-c,g=c-(p-y)+(N-y),N=u[++x]),c=p,g!==0&&(h[b++]=g);for(;o=it||-Y>=it||(o=m-q,g=m-(q+o)+(o-h),o=r-z,w=r-(z+o)+(o-h),o=n-Z,y=n-(Z+o)+(o-c),o=u-W,N=u-(W+o)+(o-c),g===0&&y===0&&w===0&&N===0)||(it=Pr*p+Er*Math.abs(Y),Y+=q*N+W*g-(Z*w+z*y),Y>=it||-Y>=it))return Y;k=g*W,x=J*g,b=x-(x-g),F=g-b,x=J*W,C=x-(x-W),R=W-C,v=F*R-(k-b*C-F*C-b*R),B=y*z,x=J*y,b=x-(x-y),F=y-b,x=J*z,C=x-(x-z),R=z-C,U=F*R-(B-b*C-F*C-b*R),I=v-U,o=v-I,K[0]=v-(I+o)+(o-U),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,K[1]=O-(I+o)+(o-B),D=M+I,o=D-M,K[2]=M-(D-o)+(I-o),K[3]=D;const ct=Se(4,Et,4,K,Cn);k=q*N,x=J*q,b=x-(x-q),F=q-b,x=J*N,C=x-(x-N),R=N-C,v=F*R-(k-b*C-F*C-b*R),B=Z*w,x=J*Z,b=x-(x-Z),F=Z-b,x=J*w,C=x-(x-w),R=w-C,U=F*R-(B-b*C-F*C-b*R),I=v-U,o=v-I,K[0]=v-(I+o)+(o-U),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,K[1]=O-(I+o)+(o-B),D=M+I,o=D-M,K[2]=M-(D-o)+(I-o),K[3]=D;const ie=Se(ct,Cn,4,K,Tn);k=g*N,x=J*g,b=x-(x-g),F=g-b,x=J*N,C=x-(x-N),R=N-C,v=F*R-(k-b*C-F*C-b*R),B=y*w,x=J*y,b=x-(x-y),F=y-b,x=J*w,C=x-(x-w),R=w-C,U=F*R-(B-b*C-F*C-b*R),I=v-U,o=v-I,K[0]=v-(I+o)+(o-U),M=k+I,o=M-k,O=k-(M-o)+(I-o),I=O-B,o=O-I,K[1]=O-(I+o)+(o-B),D=M+I,o=D-M,K[2]=M-(D-o)+(I-o),K[3]=D;const Ct=Se(ie,Tn,4,K,Fn);return Fn[Ct-1]}function Mr(m,n,r,u,h,c){const p=(n-c)*(r-h),g=(m-h)*(u-c),y=p-g,w=Math.abs(p+g);return Math.abs(y)>=Tr*w?y:-Ir(m,n,r,u,h,c,w)}const At=(m,n)=>m.ll.x<=n.x&&n.x<=m.ur.x&&m.ll.y<=n.y&&n.y<=m.ur.y,Ce=(m,n)=>{if(n.ur.x{if(-gtm.x*n.y-m.y*n.x,Gn=(m,n)=>m.x*n.x+m.y*n.y,Mn=(m,n,r)=>{const u=Mr(m.x,m.y,n.x,n.y,r.x,r.y);return u>0?-1:u<0?1:0},ee=m=>Math.sqrt(Gn(m,m)),Lr=(m,n,r)=>{const u={x:n.x-m.x,y:n.y-m.y},h={x:r.x-m.x,y:r.y-m.y};return te(h,u)/ee(h)/ee(u)},Ar=(m,n,r)=>{const u={x:n.x-m.x,y:n.y-m.y},h={x:r.x-m.x,y:r.y-m.y};return Gn(h,u)/ee(h)/ee(u)},Rn=(m,n,r)=>n.y===0?null:{x:m.x+n.x/n.y*(r-m.y),y:r},kn=(m,n,r)=>n.x===0?null:{x:r,y:m.y+n.y/n.x*(r-m.x)},vr=(m,n,r,u)=>{if(n.x===0)return kn(r,u,m.x);if(u.x===0)return kn(m,n,r.x);if(n.y===0)return Rn(r,u,m.y);if(u.y===0)return Rn(m,n,r.y);const h=te(n,u);if(h==0)return null;const c={x:r.x-m.x,y:r.y-m.y},p=te(c,n)/h,g=te(c,u)/h,y=m.x+g*n.x,w=r.x+p*u.x,N=m.y+g*n.y,o=r.y+p*u.y,x=(y+w)/2,b=(N+o)/2;return{x,y:b}};class nt{static compare(n,r){const u=nt.comparePoints(n.point,r.point);return u!==0?u:(n.point!==r.point&&n.link(r),n.isLeft!==r.isLeft?n.isLeft?1:-1:dt.compare(n.segment,r.segment))}static comparePoints(n,r){return n.xr.x?1:n.yr.y?1:0}constructor(n,r){n.events===void 0?n.events=[this]:n.events.push(this),this.point=n,this.isLeft=r}link(n){if(n.point===this.point)throw new Error("Tried to link already linked events");const r=n.point.events;for(let u=0,h=r.length;u{const c=h.otherSE;r.set(h,{sine:Lr(this.point,n.point,c.point),cosine:Ar(this.point,n.point,c.point)})};return(h,c)=>{r.has(h)||u(h),r.has(c)||u(c);const{sine:p,cosine:g}=r.get(h),{sine:y,cosine:w}=r.get(c);return p>=0&&y>=0?gw?-1:0:p<0&&y<0?gw?1:0:yp?1:0}}}let Br=0;class dt{static compare(n,r){const u=n.leftSE.point.x,h=r.leftSE.point.x,c=n.rightSE.point.x,p=r.rightSE.point.x;if(pg&&y>w)return-1;const o=n.comparePoint(r.leftSE.point);if(o<0)return 1;if(o>0)return-1;const x=r.comparePoint(n.rightSE.point);return x!==0?x:-1}if(u>h){if(gy&&g>N)return 1;const o=r.comparePoint(n.leftSE.point);if(o!==0)return o;const x=n.comparePoint(r.rightSE.point);return x<0?1:x>0?-1:1}if(gy)return 1;if(cp){const o=n.comparePoint(r.rightSE.point);if(o<0)return 1;if(o>0)return-1}if(c!==p){const o=w-g,x=c-u,b=N-y,F=p-h;if(o>x&&bF)return-1}return c>p?1:cN?1:n.idr.id?1:0}constructor(n,r,u,h){this.id=++Br,this.leftSE=n,n.segment=this,n.otherSE=r,this.rightSE=r,r.segment=this,r.otherSE=n,this.rings=u,this.windings=h}static fromRing(n,r,u){let h,c,p;const g=nt.comparePoints(n,r);if(g<0)h=n,c=r,p=1;else if(g>0)h=r,c=n,p=-1;else throw new Error(`Tried to create degenerate segment at [${n.x}, ${n.y}]`);const y=new nt(h,!0),w=new nt(c,!1);return new dt(y,w,[u],[p])}replaceRightSE(n){this.rightSE=n,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const n=this.leftSE.point.y,r=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:nr?n:r}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(n){return n.x===this.leftSE.point.x&&n.y===this.leftSE.point.y||n.x===this.rightSE.point.x&&n.y===this.rightSE.point.y}comparePoint(n){if(this.isAnEndpoint(n))return 0;const r=this.leftSE.point,u=this.rightSE.point,h=this.vector();if(r.x===u.x)return n.x===r.x?0:n.x0&&g.swapEvents(),nt.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),u&&(h.checkForConsuming(),c.checkForConsuming()),r}swapEvents(){const n=this.rightSE;this.rightSE=this.leftSE,this.leftSE=n,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let r=0,u=this.windings.length;r0){const c=r;r=u,u=c}if(r.prev===u){const c=r;r=u,u=c}for(let c=0,p=u.rings.length;ch.length===1&&h[0].isSubject;this._isInResult=u(n)!==u(r);break}default:throw new Error(`Unrecognized operation type found ${ot.type}`)}return this._isInResult}}class Ln{constructor(n,r,u){if(!Array.isArray(n)||n.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=r,this.isExterior=u,this.segments=[],typeof n[0][0]!="number"||typeof n[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const h=vt.round(n[0][0],n[0][1]);this.bbox={ll:{x:h.x,y:h.y},ur:{x:h.x,y:h.y}};let c=h;for(let p=1,g=n.length;pthis.bbox.ur.x&&(this.bbox.ur.x=y.x),y.y>this.bbox.ur.y&&(this.bbox.ur.y=y.y),c=y)}(h.x!==c.x||h.y!==c.y)&&this.segments.push(dt.fromRing(c,h,this))}getSweepEvents(){const n=[];for(let r=0,u=this.segments.length;rthis.bbox.ur.x&&(this.bbox.ur.x=c.bbox.ur.x),c.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=c.bbox.ur.y),this.interiorRings.push(c)}this.multiPoly=r}getSweepEvents(){const n=this.exteriorRing.getSweepEvents();for(let r=0,u=this.interiorRings.length;rthis.bbox.ur.x&&(this.bbox.ur.x=c.bbox.ur.x),c.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=c.bbox.ur.y),this.polys.push(c)}this.isSubject=r}getSweepEvents(){const n=[];for(let r=0,u=this.polys.length;r0&&(n=p)}let r=n.segment.prevInResult(),u=r?r.prevInResult():null;for(;;){if(!r)return null;if(!u)return r.ringOut;if(u.ringOut!==r.ringOut)return u.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=u.prevInResult(),u=r?r.prevInResult():null}}}class vn{constructor(n){this.exteriorRing=n,n.poly=this,this.interiorRings=[]}addInterior(n){this.interiorRings.push(n),n.poly=this}getGeom(){const n=[this.exteriorRing.getGeom()];if(n[0]===null)return null;for(let r=0,u=this.interiorRings.length;r1&&arguments[1]!==void 0?arguments[1]:dt.compare;this.queue=n,this.tree=new Te(r),this.segments=[]}process(n){const r=n.segment,u=[];if(n.consumedBy)return n.isLeft?this.queue.remove(n.otherSE):this.tree.remove(r),u;const h=n.isLeft?this.tree.add(r):this.tree.find(r);if(!h)throw new Error(`Unable to find segment #${r.id} [${r.leftSE.point.x}, ${r.leftSE.point.y}] -> [${r.rightSE.point.x}, ${r.rightSE.point.y}] in SweepLine tree.`);let c=h,p=h,g,y;for(;g===void 0;)c=this.tree.prev(c),c===null?g=null:c.key.consumedBy===void 0&&(g=c.key);for(;y===void 0;)p=this.tree.next(p),p===null?y=null:p.key.consumedBy===void 0&&(y=p.key);if(n.isLeft){let w=null;if(g){const o=g.getIntersection(r);if(o!==null&&(r.isAnEndpoint(o)||(w=o),!g.isAnEndpoint(o))){const x=this._splitSafely(g,o);for(let b=0,F=x.length;b0?(this.tree.remove(r),u.push(n)):(this.segments.push(r),r.prev=g)}else{if(g&&y){const w=g.getIntersection(y);if(w!==null){if(!g.isAnEndpoint(w)){const N=this._splitSafely(g,w);for(let o=0,x=N.length;oBn)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const p=new Wr(c);let g=c.size,y=c.pop();for(;y;){const o=y.key;if(c.size===g){const b=o.segment;throw new Error(`Unable to pop() ${o.isLeft?"left":"right"} SweepEvent [${o.point.x}, ${o.point.y}] from segment #${b.id} [${b.leftSE.point.x}, ${b.leftSE.point.y}] -> [${b.rightSE.point.x}, ${b.rightSE.point.y}] from queue.`)}if(c.size>Bn)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(p.segments.length>Hr)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const x=p.process(o);for(let b=0,F=x.length;b1?n-1:0),u=1;u1?n-1:0),u=1;u1?n-1:0),u=1;u1?n-1:0),u=1;u[]},tileUrlTemplate:{type:String,default:"https://qkl-map.oss-cn-chengdu.aliyuncs.com/hy-result/{z}/{x}/{y}.png"},referenceTileUrlTemplate:{type:String,default:"https://map.shuxitech.com/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}"},terrainUrl:{type:String,default:""},center:{type:Array,default:()=>[102.600005,32.585593]},initialZoom:{type:Number,default:9},minimumZoomDistance:{type:Number,default:1},countyViewTargetOffset:{type:Object,default:null},autoApplyLayerMapView:{type:Boolean,default:!0},maxZoom:{type:Number,default:21},adminBoundaryLineScale:{type:Number,default:1},showNationalBackdrop:{type:Boolean,default:!0},enableImageryFeaturePick:{type:Boolean,default:!0},enableTownPolygonPick:{type:Boolean,default:!0},hideTownLabelStats:{type:Boolean,default:!1}},emits:["ready","scene-mounted","feature-loading","feature-info","layer-status","tile-status","map-click","draw-boundary","view-change"],setup(m,{expose:n,emit:r}){let u=[],h=null;const c=m,p=r,g=Nn(null),y=Nn(null),w=xr(null),N=fr(()=>c.activeLayer?[c.activeLayer,...Array.isArray(c.activeLayer.overlayLayers)?c.activeLayer.overlayLayers:[]].filter(Boolean):c.overlayLayers.length?c.overlayLayers.filter(Boolean):c.overlayLayer?[c.overlayLayer]:[]);let o=null,x=null,b=null,F=null,C=null,R=!1,I=0,M=null,O=!1,k=[],v=null,B=[],U=[],D=[],q=[],z=[],Z=[],W=null,Y=[],it=[],ct=[],ie=[];const Ct=new Map;mr(()=>{p("scene-mounted"),c.active&&Ot()}),pr(()=>It()),Kt(N,()=>ve(),{deep:!0}),Kt(()=>c.mapRanking,()=>se(),{deep:!0}),Kt(()=>c.hideTownLabelStats,()=>se()),Kt(()=>c.active,t=>mt(this,null,function*(){if(!t){It();return}yield _n(),Ot()}));function Ot(){var S,_,T,E;if(o||!y.value)return!!o;const t=window.Cesium;if(!t)return p("layer-status",{type:"error",text:"Cesium 运行资源加载失败"}),!1;R=!1;const e=zn(t),i=Pe(c.tileUrlTemplate),l=Pe(c.referenceTileUrlTemplate),a=Vn(i),s=l&&l!==i?Fe(t,l,{maximumLevel:c.maxZoom}):null,f=i?Fe(t,i,{maximumLevel:a?Math.min(c.maxZoom,qr):c.maxZoom,rectangle:a?jn(t):null}):null;if(o=new t.Viewer(y.value,{animation:!1,baseLayerPicker:!1,fullscreenButton:!1,geocoder:!1,homeButton:!1,infoBox:!1,navigationHelpButton:!1,sceneModePicker:!1,selectionIndicator:!1,timeline:!1,scene3DOnly:!0,imageryProvider:!1,terrainProvider:e,useBrowserRecommendedResolution:!1,requestRenderMode:!0,maximumRenderTimeChange:1/0,contextOptions:{webgl:{alpha:!0,antialias:!0}}}),Le(!1),s){const P=o.imageryLayers.addImageryProvider(s);P.alpha=1,P.brightness=.68,P.contrast=1.08,P.saturation=.48,P.gamma=.9}f&&(v=o.imageryLayers.addImageryProvider(f),v.alpha=a?.88:1,v.brightness=a?.96:.9,v.contrast=a?1.12:1.1,v.saturation=a?1.08:1.05,v.gamma=a?.98:.96),o.scene.globe.terrainExaggeration=c.terrainUrl?1.5:1,o.scene.globe.depthTestAgainstTerrain=!1,o.scene.globe.baseColor=t.Color.fromCssColorString("#061821"),o.scene.backgroundColor=t.Color.fromCssColorString("#020b12"),o.scene.skyAtmosphere.show=!1,o.scene.skyBox&&(o.scene.skyBox.show=!1),o.scene.fog.enabled=!0,o.scene.fog.density=18e-5,o.resolutionScale=Math.min(Math.max(window.devicePixelRatio||1,1),1.5),o.scene.fxaa=!1,o.scene.postProcessStages.fxaa.enabled=!1,o.scene.screenSpaceCameraController.enableCollisionDetection=!0,o.scene.screenSpaceCameraController.minimumZoomDistance=Math.max(1,Number(c.minimumZoomDistance)||1),o.scene.screenSpaceCameraController.maximumZoomDistance=56e4,(S=o.cesiumWidget)!=null&&S.creditContainer&&(o.cesiumWidget.creditContainer.style.display="none"),(_=o._cesiumWidget)!=null&&_._creditContainer&&(o._cesiumWidget._creditContainer.style.display="none"),qn(e,t),Ie().then(()=>{var P;!o||(P=o.isDestroyed)!=null&&P.call(o)||(Pi(),oe())}).catch(P=>{console.warn("[cesium-map] county outline load failed",P),p("layer-status",{type:"error",text:"红原县边界加载失败"})}),Ei(),Ai(),ri(),oi(),si(),oe(),ve(),se();const d={viewer:o,clearSelectedFeature:tt,focusProject:Qe,focusPasture:rn,focusTownByName:Ke,focusYakIndustryPoint:tn,focusVectorFeature:en,getVectorFeatureAnchorScreen:nn,getVectorFeaturesAnchorScreen:Ut,getVectorFeatureScreen:Ft,getYakIndustryPointScreen:he,destroy:It};return w.value=d,(E=(T=f==null?void 0:f.errorEvent)==null?void 0:T.addEventListener)==null||E.call(T,()=>{p("tile-status",{type:"warning",text:"牧场影像底图部分瓦片加载失败"})}),p("tile-status",{type:"success",text:"牧场影像底图已加载"}),window.setTimeout(()=>{var P;o&&!((P=o.isDestroyed)!=null&&P.call(o))&&p("ready")},0),_n(Dt),!0}function zn(t){if(!c.terrainUrl)return new t.EllipsoidTerrainProvider;try{return new t.CesiumTerrainProvider({url:c.terrainUrl,requestVertexNormals:!0,requestWaterMask:!1})}catch(e){return R=!0,new t.EllipsoidTerrainProvider}}function Fe(t,e,i={}){return e?new t.UrlTemplateImageryProvider({url:e,minimumLevel:i.minimumLevel||3,maximumLevel:i.maximumLevel||c.maxZoom,rectangle:i.rectangle||void 0,tilingScheme:new t.WebMercatorTilingScheme,credit:""}):null}function Pe(t){return String(t||"").trim()}function Vn(t){return/hy-result|qkl-map/i.test(String(t||""))}function jn(t){return t.Rectangle.fromDegrees(G.west-.035,G.south-.035,G.east+.035,G.north+.035)}function Un(t,e="feature"){const i=[];if(((t==null?void 0:t.features)||[]).forEach(l=>{const a=V(l==null?void 0:l.geometry);Ge(a).forEach(s=>{const f=Yn(s);f&&i.push(f)})}),!i.length)return[];try{return Qt.union(...i)}catch(l){return console.warn(`[cesium-map] ${e} union boundary failed`,l),i.map(a=>a)}}function Ie(){return mt(this,null,function*(){return u.length?u:(h||(h=Ht(Yr).then(t=>{const e=Un(t,"county outline");return u=e,e}).catch(t=>{throw h=null,t})),h)})}function Yn(t){if(!Array.isArray(t))return null;const e=t.map(i=>$n((i||[]).map($).filter(Boolean))).filter(i=>i.length>=4);return e.length?e:null}function $n(t=[]){if(!t.length)return[];const e=t[0],i=t[t.length-1];return ze(e,i)?t:[...t,e]}function qn(t,e){var l,a,s,f;const i=()=>{!o||R||(R=!0,o.terrainProvider=new e.EllipsoidTerrainProvider,o.scene.globe.terrainExaggeration=1,o.scene.requestRender(),p("layer-status",{type:"warning",text:"CXPT 地形服务暂不可用,已保留三维影像地图"}))};(a=(l=t==null?void 0:t.errorEvent)==null?void 0:l.addEventListener)==null||a.call(l,i),(f=(s=t==null?void 0:t.readyPromise)==null?void 0:s.catch)==null||f.call(s,i)}function Zn(){return Ot()}function Xn(){var t;return!!(o&&!((t=o.isDestroyed)!=null&&t.call(o)))}function Jn(){Me()}function Me(){if(!o){Ot();return}o.useDefaultRenderLoop=!0,Dt()}function Kn(){It()}function Dt(){var t;!o||(t=o.isDestroyed)!=null&&t.call(o)||(o.resize(),o.scene.requestRender())}function Re(){if(!(o!=null&&o.camera)||!window.Cesium)return null;const t=window.Cesium,e=o.camera;return{position:t.Cartesian3.clone(e.positionWC||e.position),direction:t.Cartesian3.clone(e.directionWC||e.direction),up:t.Cartesian3.clone(e.upWC||e.up)}}function Wt(t){var i,l,a,s,f,d;if(!(o!=null&&o.camera)||!t||!window.Cesium)return;const e=window.Cesium;(l=(i=o.camera).cancelFlight)==null||l.call(i),(s=(a=o.camera).lookAtTransform)==null||s.call(a,e.Matrix4.IDENTITY),o.camera.setView({destination:e.Cartesian3.clone(t.position),orientation:{direction:e.Cartesian3.clone(t.direction),up:e.Cartesian3.clone(t.up)}}),(d=(f=o.scene)==null?void 0:f.requestRender)==null||d.call(f)}function ke(t){var e,i;!t||typeof window=="undefined"||((e=window.requestAnimationFrame)==null||e.call(window,()=>Wt(t)),(i=window.setTimeout)==null||i.call(window,()=>Wt(t),80))}function Qn(){tt(),Le(!0)}function ti(t=N.value.find(e=>(e==null?void 0:e.mapView)||(e==null?void 0:e.cameraPosition))){return!o||!t?!1:(ln(t),!0)}function Le(t=!0){if(!o)return;const e=window.Cesium,i=ii(),l=Ae(c.initialZoom),a=ei(),s=e.Cartesian3.fromDegrees(i[0]+a.lng,i[1]+a.lat,ni()),f=new e.HeadingPitchRange(e.Math.toRadians(Zr),e.Math.toRadians(Xr),l);t?o.camera.flyToBoundingSphere(new e.BoundingSphere(s,1),{offset:f,duration:.9}):(o.camera.lookAt(s,f),o.camera.lookAtTransform(e.Matrix4.IDENTITY)),o.scene.requestRender()}function ei(){var l,a;const t=c.countyViewTargetOffset,e=Number((l=t==null?void 0:t.lng)!=null?l:t==null?void 0:t[0]),i=Number((a=t==null?void 0:t.lat)!=null?a:t==null?void 0:t[1]);return{lng:Number.isFinite(e)?e:0,lat:Number.isFinite(i)?i:-Jr}}function ni(){return c.terrainUrl?Kr:Qr}function re(){return c.terrainUrl?to:eo}function Ae(t){const e=Number.isFinite(Number(t))?Number(t):9;return Math.max(9e3,Math.min(58e4,365e3/Math.pow(1.62,e-9)))}function ii(){const t=$(c.center);return t||[(G.west+G.east)/2,(G.south+G.north)/2]}function ri(){!g.value||!window.ResizeObserver||(b=new ResizeObserver(()=>Dt()),b.observe(g.value))}function oi(){!o||F||(F=o.camera.moveEnd.addEventListener(oe))}function si(){!o||C||(C=o.scene.postRender.addEventListener(()=>{p("view-change")}))}function oe(){var l,a;if(!o||(l=o.isDestroyed)!=null&&l.call(o))return;const t=Number((a=o.camera.positionCartographic)==null?void 0:a.height)||32e4,e=Math.max(0,Math.min(1,(36e4-t)/3e5)),i={township:1.1+e*.35,countyOutline:1.9+e*.35,countyHalo:4.2+e*.65};U.forEach(s=>{s!=null&&s.polyline&&s.__hyBoundaryRole==="township"&&(s.polyline.width=i.township)}),ct.forEach(s=>{s!=null&&s.polyline&&s.__hyBoundaryRole==="county-outline"&&(s.polyline.width=i.countyOutline),s!=null&&s.polyline&&s.__hyBoundaryRole==="county-halo"&&(s.polyline.width=i.countyHalo)}),o.scene.requestRender()}function ve(){return mt(this,null,function*(){var i,l;if(!o)return;const t=++I;yn();const e=N.value;if(!e.length){p("layer-status",{type:"idle",text:"未选择专题图层"}),o.scene.requestRender();return}p("layer-status",{type:"loading",text:"正在加载三维专题图层"});try{if(yield Ie(),t!==I||!o)return;for(const a of e){if(t!==I)return;yield li(a,t)}if(t!==I)return;c.autoApplyLayerMapView&&ln(e.find(a=>(a==null?void 0:a.mapView)||(a==null?void 0:a.cameraPosition))),p("layer-status",{type:"success",text:`${e.map(a=>a.name).filter(Boolean).join("、")}已加载`})}catch(a){if(t!==I)return;console.warn("[cesium-map] topic layer failed",a),p("layer-status",{type:"error",text:"三维专题图层加载失败"})}finally{(l=(i=o==null?void 0:o.scene)==null?void 0:i.requestRender)==null||l.call(i)}})}function li(t,e){return mt(this,null,function*(){const i=String((t==null?void 0:t.sourceType)||"wms").toLowerCase();if(["geojson","wkt-api","wfs"].includes(i)){const l=yield hi(t);if(e!==I||!l)return;gi(l,t,D);return}if(i==="wmts"){ai(t);return}ci(t)})}function ai(t){const e=window.Cesium,i=t.tileMatrixSetID||t.tileMatrixSet||"EPSG:900913",l=Number.isFinite(Number(t.maximumLevel))?Number(t.maximumLevel):21,a=new e.WebMapTileServiceImageryProvider({url:t.url||"/geoserver/gwc/service/wmts",layer:t.layerName,style:t.style||t.styles||"",format:t.format||"image/png",tileMatrixSetID:i,tileMatrixLabels:t.tileMatrixLabels||ui(i,l),tilingScheme:/4326/i.test(i)?new e.GeographicTilingScheme:new e.WebMercatorTilingScheme,maximumLevel:l,credit:t.credit||""}),s=o.imageryLayers.addImageryProvider(a),f=String(t.layerName||"").includes("daping_yak_marks");s.alpha=f?bt(t.opacity,.94):bt(t.opacity,.86),f&&Be(s,t),s.__hyLayer=t,B.push(s)}function ui(t,e=21){return Array.from({length:e+1},(i,l)=>`${t}:${l}`)}function ci(t){const e=window.Cesium,i={service:"WMS",transparent:!0,format:"image/png",version:"1.1.1",styles:t.styles||""};t.cqlFilter&&(i.cql_filter=t.cqlFilter),t.sldBody&&(i.sld_body=t.sldBody);const l=new e.WebMapServiceImageryProvider({url:t.url||"/geoserver/ne/wms",layers:t.layerName,parameters:i,getFeatureInfoParameters:Lt(at({},i),{info_format:"application/json",feature_count:10})}),a=o.imageryLayers.addImageryProvider(l),s=String(t.layerName||"").includes("daping_yak_marks");a.alpha=s?bt(t.opacity,.94):bt(t.opacity,.86),s&&Be(a,t),a.__hyLayer=t,B.push(a)}function Be(t,e={}){t.brightness=Number.isFinite(Number(e.brightness))?Number(e.brightness):1.08,t.contrast=Number.isFinite(Number(e.contrast))?Number(e.contrast):1.18,t.saturation=Number.isFinite(Number(e.saturation))?Number(e.saturation):1.42,t.gamma=Number.isFinite(Number(e.gamma))?Number(e.gamma):.95}function hi(t){return mt(this,null,function*(){if(t.sourceType==="wkt-api")try{const e=yield fetch(t.apiUrl,{credentials:"same-origin"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return pi(yield e.json())}catch(e){if(!t.fallbackPath)throw e;return Ht(t.fallbackPath)}if(t.sourceType==="wfs"){const e=fi(t);return Ht(e)}return Ht(t.dataPath||t.fallbackPath)})}function Ht(t){return mt(this,null,function*(){if(!t)return null;const e=/^(https?:)?\/\//.test(t)||t.startsWith("/")?t:$r(t),i=yield fetch(e,{credentials:"same-origin"});if(!i.ok)throw new Error(`HTTP ${i.status}`);return i.json()})}function fi(t){const e=new URLSearchParams({service:"WFS",version:"1.1.0",request:"GetFeature",typeName:t.layerName,outputFormat:"application/json",srsName:"EPSG:4326"});return t.cqlFilter&&e.set("cql_filter",t.cqlFilter),t.maxFeatures&&e.set("maxFeatures",String(t.maxFeatures)),Array.isArray(t.propertyName)&&t.propertyName.length?e.set("propertyName",t.propertyName.join(",")):t.propertyName&&e.set("propertyName",t.propertyName),`${t.url||"/geoserver/ne/wfs"}?${e.toString()}`}function mi(t,e={},i=null,l=null){var S,_,T;const a=((S=t==null?void 0:t.data)==null?void 0:S.type)==="Feature"?t.data:((T=(_=t==null?void 0:t.data)==null?void 0:_.features)==null?void 0:T[0])||(t==null?void 0:t.feature)||null,s=(a==null?void 0:a.properties)||e||{},f=V((a==null?void 0:a.geometry)||s.geometry||s.geom||s.the_geom||s.theGeom||s.wkt||s.shape),d=(a==null?void 0:a.id)||s.id||s.gid||s.objectid||s.OBJECTID||(t==null?void 0:t.name);return{type:"Feature",id:d,properties:s,feature:{type:"Feature",id:d,properties:s,geometry:f},geometry:f,layer:i,lngLat:l}}function pi(t){var l;const e=(l=t==null?void 0:t.data)!=null?l:t;return{type:"FeatureCollection",features:(Array.isArray(e)?e:(e==null?void 0:e.rows)||(e==null?void 0:e.list)||(e==null?void 0:e.records)||(e==null?void 0:e.data)||[]).map((a,s)=>{var f;return{type:"Feature",id:(f=a==null?void 0:a.id)!=null?f:s,properties:at({},a),geometry:V(a==null?void 0:a.geometry)||pe(Oe(a))}}).filter(a=>a.geometry)}}function Oe(t={}){return t.wkt||t.WKT||t.geom||t.the_geom||t.theGeom||t.shape||t.Shape}function gi(t,e,i){((t==null?void 0:t.type)==="FeatureCollection"?t.features:(t==null?void 0:t.type)==="Feature"?[t]:[]).filter(a=>a==null?void 0:a.geometry).filter(a=>Ni(a.properties||{},e)).map(a=>di(a,e)).filter(Boolean).forEach(a=>xt(a,e,i))}function di(t,e){const i=V(t==null?void 0:t.geometry),l=(e==null?void 0:e.clipToHongyuanBoundary)===!0,a=yi(e);if(!i||!["Polygon","MultiPolygon"].includes(i.type)||!l&&!a)return t;let s=i.type==="Polygon"?[i.coordinates]:i.coordinates;try{l&&u.length&&(s=Qt.intersection(s,u)),a&&s.length&&(s=Qt.intersection(s,[xi(a)]))}catch(f){return console.warn("[cesium-map] vector layer clipping failed",e==null?void 0:e.key,f),t}return s.length?Lt(at({},t),{geometry:{type:"MultiPolygon",coordinates:s}}):null}function yi(t){if(!(t!=null&&t.clipBounds)||t.clipToLayerBounds===!1)return null;const e=t.clipBounds,i=Math.max(Number(e.west),G.west),l=Math.max(Number(e.south),G.south),a=Math.min(Number(e.east),G.east),s=Math.min(Number(e.north),G.north);return![i,l,a,s].every(Number.isFinite)||i>=a||l>=s?null:{west:i,south:l,east:a,north:s}}function xi(t){return[[[t.west,t.south],[t.east,t.south],[t.east,t.north],[t.west,t.north],[t.west,t.south]]]}function xt(t,e,i,l={}){const a=V(t.geometry);if(!a)return[];const s=bi(e,t.properties||{},l),f=Gt(a,t,e,s);return i.push(...f),f}function Gt(t,e,i,l){const a=window.Cesium,s=[],f=d=>{const S=o.entities.add(d);return S.__hyFeature=e,S.__hyLayer=i,s.push(S),S};if(t.type==="Point"){const d=$(t.coordinates);return!d||i.hidePointFeatures||i.hidePointMarkers||f({position:a.Cartesian3.fromDegrees(d[0],d[1],8),point:{pixelSize:l.pointSize,color:l.fill,outlineColor:l.stroke,outlineWidth:2,heightReference:a.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY},label:i.showPointLabels?Si(e):void 0}),s}if(t.type==="MultiPoint")return t.coordinates.forEach(d=>s.push(...Gt({type:"Point",coordinates:d},e,i,l))),s;if(t.type==="LineString"){const d=lt(t.coordinates);return d.length<2||f({polyline:{positions:d,width:l.lineWidth,material:new a.PolylineGlowMaterialProperty({glowPower:.16,color:l.stroke}),clampToGround:!0}}),s}if(t.type==="MultiLineString")return t.coordinates.forEach(d=>s.push(...Gt({type:"LineString",coordinates:d},e,i,l))),s;if(t.type==="Polygon"){const d=zt(t.coordinates);return d&&(f({polygon:{hierarchy:d,height:0,heightReference:a.HeightReference.CLAMP_TO_GROUND,perPositionHeight:!1,material:l.fill,outline:!1,classificationType:a.ClassificationType.BOTH}}),wi(t.coordinates,e,i,l,s)),s}return t.type==="MultiPolygon"&&t.coordinates.forEach(d=>s.push(...Gt({type:"Polygon",coordinates:d},e,i,l))),s}function wi(t,e,i,l,a){t.forEach(s=>{const f=lt(s);if(f.length<2)return;const d=o.entities.add({polyline:{positions:f,width:l.lineWidth,material:l.stroke,depthFailMaterial:l.stroke,clampToGround:!0}});d.__hyFeature=e,d.__hyLayer=i,a.push(d)})}function zt(t=[]){const e=window.Cesium,i=lt(t[0]||[]);if(i.length<3)return null;const l=t.slice(1).map(a=>{const s=lt(a);return s.length>=3?new e.PolygonHierarchy(s):null}).filter(Boolean);return new e.PolygonHierarchy(i,l)}function Si(t,e){const i=window.Cesium,l=t.properties||{},a=l.name||l.project_name||l.title||"";if(a)return{text:String(a),font:"600 14px PingFang SC, Microsoft YaHei, sans-serif",fillColor:i.Color.WHITE,outlineColor:i.Color.fromCssColorString("#03121e"),outlineWidth:3,style:i.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new i.Cartesian2(0,-22),heightReference:i.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,distanceDisplayCondition:new i.DistanceDisplayCondition(0,15e4)}}function bi(t,e,i={}){var E,P,L,H,A,Q,st,et,ft;const l=window.Cesium,a=_i(t,e),s=bt(t.opacity,.84),f=i.fillColor||(a==null?void 0:a.fillColor)||t.fillColor||t.color||"#24F6C4",d=i.strokeColor||(a==null?void 0:a.strokeColor)||t.strokeColor||t.color||"#B7FFF2",S=(L=(P=(E=i.fillAlpha)!=null?E:a==null?void 0:a.fillAlpha)!=null?P:t.fillAlpha)!=null?L:Math.min(.34,s*.34),_=(Q=(A=(H=i.strokeAlpha)!=null?H:a==null?void 0:a.strokeAlpha)!=null?A:t.strokeAlpha)!=null?Q:Math.max(.72,s),T=(ft=(et=(st=i.lineWidth)!=null?st:a==null?void 0:a.lineWidth)!=null?et:t.lineWidth)!=null?ft:Math.max(1.6,1.8*Number(c.adminBoundaryLineScale||1));return{fill:De(l,f,S),stroke:De(l,d,_),lineWidth:T,pointSize:i.pointSize||12}}function De(t,e,i){try{return t.Color.fromCssColorString(String(e||"#24F6C4")).withAlpha(bt(i,1))}catch(l){return t.Color.CYAN.withAlpha(bt(i,1))}}function _i(t,e){var i;return t!=null&&t.activeLegend?t.activeLegend:((t==null?void 0:t.legends)||[]).find(l=>We(e,l))||((i=t==null?void 0:t.legends)==null?void 0:i[0])}function Ni(t,e){const i=e==null?void 0:e.activeLegend;return i?We(t,i):!0}function We(t,e={}){return e.match?He(t,e.match):Array.isArray(e.matches)?e.matches.some(i=>He(t,i)):!0}function He(t,e={}){var i,l;return String((i=t==null?void 0:t[e.field])!=null?i:"")===String((l=e.value)!=null?l:"")}function Ei(){if(!o)return;j(U);const t=window.Cesium,e={stroke:t.Color.fromCssColorString("#B8FFF8").withAlpha(.82),fill:t.Color.TRANSPARENT,lineWidth:1.2,pointSize:0};Ci(xe.features||[]).forEach(i=>{var s;const l=lt(i.points);if(l.length<2)return;const a=o.entities.add({polyline:{positions:l,width:e.lineWidth,material:e.stroke,depthFailMaterial:e.stroke,clampToGround:!0,zIndex:7}});a.__hyBoundaryRole="township",a.__hyTownName=((s=i.townNames)==null?void 0:s[0])||"",U.push(a)}),o.scene.requestRender()}function Ci(t=[]){const e=new Map;t.forEach(l=>{var f;const a=String(((f=l==null?void 0:l.properties)==null?void 0:f.name)||"").trim(),s=V(l==null?void 0:l.geometry);Ge(s).forEach(d=>{const S=((d==null?void 0:d[0])||[]).map($).filter(Boolean);for(let _=0;_Lt(at({},l),{townNames:Array.from(l.townNames)})).filter(l=>l.count>1&&l.townNames.length>1);return Fi(i)}function Ge(t){return t!=null&&t.coordinates?t.type==="Polygon"?[t.coordinates]:t.type==="MultiPolygon"?t.coordinates:[]:[]}function Ti(t,e){const i=Tt(t),l=Tt(e);return i{a.points.forEach(f=>{const d=Tt(f),S=e.get(d)||[];S.push(s),e.set(d,S)})});const i=new Set,l=[];return t.forEach((a,s)=>{if(i.has(s))return;i.add(s);const f=[a.points[0],a.points[1]];Ve(f,e,t,i,!0),Ve(f,e,t,i,!1),l.push({points:f,townNames:a.townNames})}),l}function Ve(t,e,i,l,a){for(;t.length;){const s=a?t[0]:t[t.length-1],f=Tt(s),d=(e.get(f)||[]).filter(L=>!l.has(L));if(d.length!==1)return;const S=d[0],_=i[S];l.add(S);const[T,E]=_.points,P=Tt(T)===f?E:T;a?t.unshift(P):t.push(P)}}function Pi(){if(!o||!u.length)return;j(ct);const t=window.Cesium;Ii(t),u.forEach(e=>{const l=(Array.isArray(e==null?void 0:e[0])?e[0]:[]).map($).filter(Boolean);if(l.length<3)return;const a=zt(e);if(a){const d=o.entities.add({polygon:{hierarchy:a,material:t.Color.fromCssColorString("#20EAF2").withAlpha(.026),outline:!1,perPositionHeight:!1,heightReference:t.HeightReference.CLAMP_TO_GROUND,classificationType:t.ClassificationType.BOTH}});ct.push(d)}const s=o.entities.add({polyline:{positions:lt(l),width:4.8,material:new t.PolylineGlowMaterialProperty({glowPower:.16,color:t.Color.fromCssColorString("#78FFF7").withAlpha(.48)}),depthFailMaterial:t.Color.fromCssColorString("#78FFF7").withAlpha(.32),clampToGround:!0,zIndex:8}});s.__hyBoundaryRole="county-halo";const f=o.entities.add({polyline:{positions:lt(l),width:1.9,material:t.Color.fromCssColorString("#F2FFFB").withAlpha(.98),depthFailMaterial:t.Color.fromCssColorString("#F2FFFB").withAlpha(.9),clampToGround:!0,zIndex:9}});f.__hyBoundaryRole="county-outline",ct.push(s,f)}),o.scene.requestRender()}function Ii(t){const e=Mi();let i=[];try{i=Qt.difference([e],u)}catch(l){console.warn("[cesium-map] county outside mask failed",l),i=[e]}i.forEach(l=>{const a=zt(l);if(!a)return;const s=o.entities.add({polygon:{hierarchy:a,material:t.Color.fromCssColorString("#020A10").withAlpha(.52),outline:!1,perPositionHeight:!1,heightReference:t.HeightReference.CLAMP_TO_GROUND,classificationType:t.ClassificationType.BOTH,zIndex:1}});ct.push(s)})}function Mi(){const t=G.west-Wn,e=G.south-Hn,i=G.east+Wn,l=G.north+Hn;return[[[t,e],[i,e],[i,l],[t,l],[t,e]]]}function Ri(t,e=!1){const i=(Array.isArray(t)?t:[t]).map(Rt=>String(Rt||"").trim()).filter(Boolean).slice(0,2),l=`v15-centered-map-badge:${e?"h":"n"}:${i.join("|")}`;if(Ct.has(l))return Ct.get(l);const a=document.createElement("canvas"),s=a.getContext("2d");if(!s)return{image:"",width:1,height:1};const f=Math.min(4,Math.max(3,window.devicePixelRatio||2)),d="700 14px Microsoft YaHei, PingFang SC, sans-serif",S="700 9px Microsoft YaHei, PingFang SC, sans-serif",_="800 14px Microsoft YaHei, PingFang SC, sans-serif",T="600 9px Microsoft YaHei, PingFang SC, sans-serif",E=Li(i[1]);s.font=d;const P=Math.ceil(s.measureText(i[0]||"").width);let L=0;E&&(s.font=S,L+=Math.ceil(s.measureText(E.metric).width),s.font=_,L+=Math.ceil(s.measureText(E.value).width),s.font=T,L+=Math.ceil(s.measureText(E.unit).width),L+=E.metric?5:0,L+=E.unit?4:0);const H=Math.min(118,Math.max(E?96:62,P+20,L+20)),A=E?40:25,Q=E?5:0,st=6,et=H+st*2,ft=A+Q+st*2;a.width=Math.ceil(et*f),a.height=Math.ceil(ft*f),a.style.width=`${et}px`,a.style.height=`${ft}px`,s.scale(f,f),s.clearRect(0,0,et,ft);const X=st,rt=st,Nt=rt+A,_t=s.createLinearGradient(X,rt,X,Nt);_t.addColorStop(0,e?"rgba(8, 58, 70, 0.9)":"rgba(6, 45, 57, 0.78)"),_t.addColorStop(.55,e?"rgba(4, 34, 46, 0.88)":"rgba(3, 29, 41, 0.76)"),_t.addColorStop(1,e?"rgba(2, 22, 32, 0.88)":"rgba(2, 18, 29, 0.78)"),s.save(),s.shadowColor="rgba(48, 220, 255, 0.13)",s.shadowBlur=6,s.fillStyle=_t,je(s,X,rt,H,A),s.fill(),s.restore(),s.save(),s.globalCompositeOperation="lighter";const Jt=s.createLinearGradient(X,rt,X+H,rt);Jt.addColorStop(0,"rgba(42, 210, 255, 0)"),Jt.addColorStop(.5,e?"rgba(98, 246, 255, 0.34)":"rgba(98, 246, 255, 0.26)"),Jt.addColorStop(1,"rgba(42, 210, 255, 0)"),s.strokeStyle=Jt,s.lineWidth=1,s.beginPath(),s.moveTo(X+10,rt+2),s.lineTo(X+H-10,rt+2),s.stroke(),s.restore(),s.save(),s.strokeStyle=e?"rgba(126, 251, 246, 0.58)":"rgba(126, 251, 246, 0.46)",s.lineWidth=.9,je(s,X+.5,rt+.5,H-1,A-1),s.stroke(),s.restore();const Mt=X+H/2;Q>0&&(s.save(),s.shadowColor="rgba(48, 220, 255, 0.2)",s.shadowBlur=5,s.beginPath(),s.moveTo(Mt-5,Nt-1),s.lineTo(Mt+5,Nt-1),s.lineTo(Mt,Nt+Q),s.closePath(),s.fillStyle=e?"rgba(4, 42, 52, 0.98)":"rgba(3, 31, 43, 0.96)",s.fill(),s.strokeStyle=e?"rgba(126, 251, 246, 0.48)":"rgba(126, 251, 246, 0.34)",s.lineWidth=.8,s.stroke(),s.restore()),s.save(),s.textAlign="center",s.textBaseline="alphabetic",s.fillStyle="rgba(255, 255, 255, 0.98)",s.strokeStyle="rgba(0, 8, 14, 0.98)",s.lineJoin="round",s.shadowColor="rgba(0, 8, 14, 0.72)",s.shadowBlur=0,s.font=d,s.lineWidth=1.6;const or=rt+(E?12.5:A/2);if(Vt(s,i[0]||"",Mt,or),E){const Rt=rt+29.5;let kt=Mt-L/2;s.textAlign="left",s.shadowBlur=0,s.font=S,s.lineWidth=1.2,s.fillStyle="rgba(126, 251, 246, 0.9)",E.metric&&(Vt(s,E.metric,kt,Rt,{stroke:!1}),s.font=S,kt+=Math.ceil(s.measureText(E.metric).width)+5),s.font=_,s.lineWidth=1.4,s.fillStyle="#FFFFFF",s.shadowColor="rgba(0, 8, 14, 0.72)",s.shadowBlur=0,Vt(s,E.value,kt,Rt),s.shadowBlur=0,kt+=Math.ceil(s.measureText(E.value).width)+(E.unit?4:0),E.unit&&(s.font=T,s.fillStyle="rgba(232, 252, 255, 0.76)",Vt(s,E.unit,kt,Rt+1,{stroke:!1}))}s.restore();const xn={image:a.toDataURL("image/png"),width:et,height:ft};return Ct.set(l,xn),xn}function Vt(t,e,i,l,a={}){const s=t.measureText(e),f=ki(t.font),d=Number(s.actualBoundingBoxAscent)||f*.74,S=Number(s.actualBoundingBoxDescent)||f*.18,_=l+(d-S)/2;a.stroke!==!1&&t.lineWidth>0&&t.strokeText(e,i,_),t.fillText(e,i,_)}function ki(t){const e=String(t||"").match(/(\d+(?:\.\d+)?)px/);return e?Number(e[1]):14}function Li(t){const e=String(t||"").trim();if(!e)return null;const i=e.match(/^(.+?)\s+([+-]?\d[\d,.]*)(.*)$/u);if(i)return{metric:i[1].trim(),value:i[2].trim(),unit:i[3].trim()};const l=e.match(/^(.*?)([+-]?\d[\d,.]*)([\u4e00-\u9fa5A-Za-z/%]+)?$/u);return l?{metric:l[1].trim(),value:l[2].trim(),unit:(l[3]||"").trim()}:{metric:"",value:e,unit:""}}function je(t,e,i,l,a){const s=Math.min(7,l*.12,a*.34);t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+l-s,i),t.lineTo(e+l,i+s),t.lineTo(e+l,i+a-s),t.lineTo(e+l-s,i+a),t.lineTo(e+s,i+a),t.lineTo(e,i+a-s),t.lineTo(e,i+s),t.closePath()}function se(){var f;if(!o)return;j(q);const t=window.Cesium,e=c.mapRanking||{},i=Array.isArray(e.rows)?e.rows:[],l=new Map(i.map(d=>[ht(d.name),d])),a=e.showTownNames!==!1&&e.hideTownNames!==!0,s=(f=e.hideTownLabelStats)!=null?f:c.hideTownLabelStats;a&&bn.forEach(d=>{const S=l.get(ht(d.name)),_=[d.name];if(!s&&S&&e.showMapLabels!==!1){const H=e.metricLabel?`${e.metricLabel} `:"";_.push(`${H}${rr(S.value)}${S.unit||e.unit||""}`)}const T=$(d.center);if(!T)return;const E=Ri(_,!!S),P=!!(s||_.length===1),L=o.entities.add({position:t.Cartesian3.fromDegrees(T[0],T[1],18),billboard:{image:E.image,width:E.width,height:E.height,scale:1,verticalOrigin:P?t.VerticalOrigin.CENTER:t.VerticalOrigin.BOTTOM,horizontalOrigin:t.HorizontalOrigin.CENTER,pixelOffset:P?new t.Cartesian2(0,0):new t.Cartesian2(0,-4),heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new t.NearFarScalar(2e4,.94,36e4,.8),distanceDisplayCondition:new t.DistanceDisplayCondition(0,42e4)}});L.__hyTownName=d.name,L.__hyRankingRow=S||null,q.push(L)}),i.filter(d=>St(d)).forEach(d=>{const S=St(d),_=o.entities.add({position:t.Cartesian3.fromDegrees(S[0],S[1],16),point:{pixelSize:9,color:t.Color.fromCssColorString("#35F3FF"),outlineColor:t.Color.WHITE,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY},label:e.showPointMarkers===!1?void 0:{text:String(d.name||""),font:"600 12px PingFang SC, Microsoft YaHei, sans-serif",fillColor:t.Color.WHITE,outlineColor:t.Color.fromCssColorString("#03121e"),outlineWidth:3,style:t.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new t.Cartesian2(0,-18),heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}});_.__hyTownName=d.name,_.__hyRankingRow=d,q.push(_)}),o.scene.requestRender()}function Ai(){if(!o)return;const t=window.Cesium;x=new t.ScreenSpaceEventHandler(o.scene.canvas),x.setInputAction(e=>mt(this,null,function*(){var T,E,P;const i=vi(e.position),l=Bi(i);if(!l)return;const a=t.Cartographic.fromCartesian(l),s={lng:t.Math.toDegrees(a.longitude),lat:t.Math.toDegrees(a.latitude),height:a.height},f=Ue(i);if(O){zi(s);return}p("map-click",{lngLat:s,screen:f,overlayLayer:N.value[0]||null});const d=o.scene.pick(i),S=d==null?void 0:d.id,_=qi(s,f)||S;if(_!=null&&_.__hyFeature){le(_),p("feature-info",{feature:{id:_.__hyFeature.id,properties:_.__hyFeature.properties||{},feature:_.__hyFeature,geometry:_.__hyFeature.geometry||null,layer:_.__hyLayer,lngLat:s},screen:f});return}if(!(c.enableTownPolygonPick&&(S!=null&&S.__hyTownName)&&ce(S.__hyTownName))){if(c.enableTownPolygonPick){const L=Wi(s);if(L&&ce((T=L.properties)==null?void 0:T.name))return}if(c.enableImageryFeaturePick&&B.length){p("feature-loading",!0);try{const L=o.camera.getPickRay(i),H=yield o.imageryLayers.pickImageryLayerFeatures(L,o.scene),A=H==null?void 0:H[0];if(A){const Q=B.find(Nt=>{var _t;return Nt.imageryProvider===((_t=A.imageryLayer)==null?void 0:_t.imageryProvider)})||B[B.length-1],st=(Q==null?void 0:Q.__hyLayer)||N.value[0],et=A.properties||((E=A.data)==null?void 0:E.properties)||A.data||{},X=mi(A,et,st,s);Xe(X)||tt(),p("feature-info",{feature:{id:X.id||et.id||et.fid||A.name,properties:X.properties||et,feature:X.feature||A,geometry:X.geometry||((P=X.feature)==null?void 0:P.geometry)||null,layer:st,lngLat:s},screen:f})}else tt(),p("feature-info",{feature:null,screen:f})}catch(L){tt(),p("feature-info",{feature:null,screen:f})}finally{p("feature-loading",!1)}}}}),t.ScreenSpaceEventType.LEFT_CLICK)}function vi(t){var P,L,H,A;if(!t||!((P=o==null?void 0:o.scene)!=null&&P.canvas))return t;const e=window.Cesium,i=o.scene.canvas,l=(L=i.getBoundingClientRect)==null?void 0:L.call(i),a=Number(l==null?void 0:l.width)||0,s=Number(l==null?void 0:l.height)||0,f=Number(i.clientWidth||((H=g.value)==null?void 0:H.clientWidth))||a||1,d=Number(i.clientHeight||((A=g.value)==null?void 0:A.clientHeight))||s||1,S=Number(t.x),_=Number(t.y);if(!Number.isFinite(S)||!Number.isFinite(_)||!a||!s)return t;const T=f/a,E=d/s;return Math.abs(T-1)<.001&&Math.abs(E-1)<.001?t:new e.Cartesian2(S*T,_*E)}function Ue(t){var _,T,E,P;if(!t||!((_=o==null?void 0:o.scene)!=null&&_.canvas))return null;const e=o.scene.canvas,i=(T=e.getBoundingClientRect)==null?void 0:T.call(e),l=Number(i==null?void 0:i.width)||0,a=Number(i==null?void 0:i.height)||0,s=Number(e.clientWidth||((E=g.value)==null?void 0:E.clientWidth))||l||1,f=Number(e.clientHeight||((P=g.value)==null?void 0:P.clientHeight))||a||1,d=Number(t.x),S=Number(t.y);return!Number.isFinite(d)||!Number.isFinite(S)||!i?null:{x:(Number(i.left)||0)+d*(l/s),y:(Number(i.top)||0)+S*(a/f)}}function Bi(t){if(!o)return null;const e=o.camera.getPickRay(t);return e?o.scene.globe.pick(e,o.scene):null}function le(t){var e,i,l,a,s;tt(),M=t,t.point&&(t.__hyOriginalPointSize=t.point.pixelSize,t.point.pixelSize=18),(e=t.__hyFeature)!=null&&e.geometry&&["Polygon","MultiPolygon","LineString","MultiLineString"].includes(t.__hyFeature.geometry.type)&&jt(t.__hyFeature,{townName:t.__hyTownName||((l=(i=t.__hyFeature)==null?void 0:i.properties)==null?void 0:l.name),mode:"feature"}),(s=(a=o==null?void 0:o.scene)==null?void 0:a.requestRender)==null||s.call(a)}function tt(){var t,e;M!=null&&M.point&&M.__hyOriginalPointSize&&(M.point.pixelSize=M.__hyOriginalPointSize),M=null,j(Z),Ye(),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function jt(t,e={}){var E,P,L,H;if(!o||!(t!=null&&t.geometry))return[];const i=Oi({append:e.append===!0});if(!i)return[];const l=window.Cesium,a=e.mode==="town",s=e.highlightTone==="white"||e.mode==="white",f=e.highlightTone==="v21",d=a?"#30DCFF":s?"#FFFFFF":f?"#FFD166":"#FF2D2D",S=a?"#F2FFFF":s?"#FFFFFF":f?"#FFF1B8":"#FF2D2D",_={fill:l.Color.fromCssColorString(d).withAlpha((E=e.fillAlpha)!=null?E:a?.16:s?.035:f?.2:.16),stroke:l.Color.fromCssColorString(S).withAlpha((P=e.strokeAlpha)!=null?P:s?.9:.98),lineWidth:(L=e.lineWidth)!=null?L:a?4.2:s?3.8:f?4.4:5.2,pointSize:a?0:(H=e.pointSize)!=null?H:14},T=qe(t.geometry,t,i.entities,_);return T.forEach(A=>{var Q;A.__hyFeature=null,A.__hyLayer=null,A.__hyTownName=e.townName||((Q=t.properties)==null?void 0:Q.name)||"",A.__hySelectedOverlay=!0}),Z.push(...T),$e(i),T}function Oi(t={}){return!o||!window.Cesium?null:(t.append&&W||(Ye(),W=new window.Cesium.CustomDataSource("selected-feature-overlay"),o.dataSources.add(W),$e(W)),W)}function Ye(){var e,i;if(!(o!=null&&o.dataSources)){W=null;return}Array.from(new Set([W,...((i=(e=o.dataSources).getByName)==null?void 0:i.call(e,"selected-feature-overlay"))||[]].filter(Boolean))).forEach(l=>{try{o.dataSources.remove(l,!0)}catch(a){console.warn("[cesium-map] remove selected overlay failed",a)}}),W=null,Z=[]}function $e(t){var e,i;if(!(!(o!=null&&o.dataSources)||!t))try{if(o.dataSources.raiseToTop){o.dataSources.raiseToTop(t);return}for(;((i=(e=o.dataSources).indexOf)==null?void 0:i.call(e,t)){const S=i.add(d);return S.__hyFeature=e,s.push(S),S};if(t.type==="Point"){const d=$(t.coordinates);return!d||l.pointSize<=0||f({position:a.Cartesian3.fromDegrees(d[0],d[1]),point:{show:!0,color:l.fill,pixelSize:l.pointSize,outlineColor:l.stroke,outlineWidth:3,heightReference:a.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}}),s}return t.type==="MultiPoint"?(t.coordinates.forEach(d=>{s.push(...qe({type:"Point",coordinates:d},e,i,l))}),s):t.type==="LineString"?(ae(t.coordinates,e,i,l,s),s):t.type==="MultiLineString"?(t.coordinates.forEach(d=>{ae(d,e,i,l,s)}),s):t.type==="Polygon"?(Ze(t.coordinates,e,i,l,s),s):(t.type==="MultiPolygon"&&t.coordinates.forEach(d=>{Ze(d,e,i,l,s)}),s)}function Ze(t,e,i,l,a){const s=window.Cesium,f=zt(t);if(!f)return;const d=i.add({polygon:{hierarchy:f,height:0,heightReference:s.HeightReference.CLAMP_TO_GROUND,perPositionHeight:!1,clampToGround:!0,material:l.fill,outline:!1,classificationType:s.ClassificationType.BOTH,zIndex:999}});d.__hyFeature=e,a.push(d),t.forEach(S=>ae(S,e,i,l,a))}function ae(t,e,i,l,a){const s=window.Cesium,f=lt(t);if(f.length<2)return;const d=i.add({polyline:{positions:f,width:l.lineWidth,material:l.stroke,depthFailMaterial:l.stroke,heightReference:s.HeightReference.CLAMP_TO_GROUND,clampToGround:!0,classificationType:s.ClassificationType.BOTH,zIndex:1e3}});d.__hyFeature=e,a.push(d)}function Xe(t,e={}){var s,f,d,S,_;if(!o||!t)return!1;const i=t.properties||((s=t.feature)==null?void 0:s.properties)||(typeof t=="object"?t:{}),l=V(t.geometry||((f=t.feature)==null?void 0:f.geometry)||i.geometry||i.geom||i.wkt||t);if(!l)return!1;tt();const a={type:"Feature",id:t.id||((d=t.feature)==null?void 0:d.id)||i.id,properties:i,geometry:l};return jt(a,at({mode:"feature"},e)),(_=(S=o==null?void 0:o.scene)==null?void 0:S.requestRender)==null||_.call(S),Z.length>0}function Di(t){const e=ht(t);return e&&(xe.features||[]).find(i=>{var l;return ht((l=i==null?void 0:i.properties)==null?void 0:l.name)===e})||null}function ue(){var t,e;return((t=c.mapRanking)==null?void 0:t.scope)==="town"&&Array.isArray((e=c.mapRanking)==null?void 0:e.rows)&&c.mapRanking.rows.length>0}function Je(t){var i;if(!ue())return!1;const e=ht(t);return(((i=c.mapRanking)==null?void 0:i.rows)||[]).some(l=>ht(l.name)===e)}function Wi(t){return ue()&&(xe.features||[]).find(e=>{var l;const i=(l=e==null?void 0:e.properties)==null?void 0:l.name;return Je(i)&&cn(t,V(e==null?void 0:e.geometry))})||null}function ce(t,e={}){var l,a,s,f;if(!ue()||!Je(t))return!1;const i=Di(t);return i?(tt(),jt(i,{mode:"town",townName:((l=i.properties)==null?void 0:l.name)||t}),e.emitFeatureInfo!==!1&&p("feature-info",{feature:null}),e.emitStatus!==!1&&p("layer-status",{type:"success",text:`已选中${((a=i.properties)==null?void 0:a.name)||t}`}),(f=(s=o==null?void 0:o.scene)==null?void 0:s.requestRender)==null||f.call(s),!0):!1}function Ke(t,e={}){const i=bn.find(a=>ht(a.name)===ht(t)),l=$(i==null?void 0:i.center);return l?(e.select&&ce(t,{emitFeatureInfo:!1,emitStatus:!1}),sn(l,42e3),{screen:wt(l)}):null}function Qe(t={}){var f,d;const e=Zi(t),i=$i(S=>Xi(S,e));if(!i.length)return null;const l=Ji(i),a=Ki(l);tt(),M=i[0],M!=null&&M.point&&(M.__hyOriginalPointSize=M.point.pixelSize,M.point.pixelSize=18),a.forEach((S,_)=>{jt(S,{mode:"feature",highlightTone:e.highlightTone,append:_>0})});const s=ye(l);return s?Yt(s,.9):o.flyTo(i[0],{duration:.9,offset:Pt(18e3)}),(d=(f=o==null?void 0:o.scene)==null?void 0:f.requestRender)==null||d.call(f),{entity:i[0],entities:i,feature:l[0]||i[0].__hyFeature,features:l,highlightFeatures:a,screen:Ut(a.length?a:l)}}function tn(t={}){const e=St(t);let i=me(l=>$t(l,t));return i?(le(i),o.flyTo(i,{duration:.9,offset:Pt(16e3)})):e&&sn(e,16e3),{feature:(i==null?void 0:i.__hyFeature)||null,screen:he(t)}}function en(t={}){const e=me(i=>$t(i,t));return e?(le(e),o.flyTo(e,{duration:.9,offset:Pt(18e3)}),{feature:e.__hyFeature,screen:Ft(e.__hyFeature)}):null}function Ft(t){var i;const e=ir(V((t==null?void 0:t.geometry)||((i=t==null?void 0:t.feature)==null?void 0:i.geometry)));return e?wt(e):null}function nn(t){return Ut([t])||Ft(t)}function Ut(t=[]){const e=[];if((Array.isArray(t)?t:[t]).forEach(a=>{var S,_;const s=(a==null?void 0:a.properties)||((S=a==null?void 0:a.feature)==null?void 0:S.properties)||{},f=V((a==null?void 0:a.geometry)||((_=a==null?void 0:a.feature)==null?void 0:_.geometry)||s.geometry||s.geom||s.wkt||s.geo||s.the_geom||s.geometryWkt||s.geometry_wkt||s.shape);if(!f){const T=Ft(a);T&&e.push(T);return}const d=[];Xt(f.coordinates,d),e.push(...d.map(wt).filter(Boolean))}),!e.length)return null;const i=e.map(a=>Number(a.x)).filter(Number.isFinite),l=e.map(a=>Number(a.y)).filter(Number.isFinite);return!i.length||!l.length?null:{x:(Math.min(...i)+Math.max(...i))/2,y:Math.min(...l)}}function he(t={}){var a,s;const e=St(t);if(e)return wt(e);const i=me(f=>$t(f,t)),l=(s=(a=i==null?void 0:i.position)==null?void 0:a.getValue)==null?void 0:s.call(a,window.Cesium.JulianDate.now());return l?toLogicalScreen(window.Cesium.SceneTransforms.wgs84ToWindowCoordinates(o.scene,l)):null}function rn(t={}){var f,d;on();const e=Qi(t.grasslands||t),i=t.highlightTone==="white",l=i?null:{fillColor:"#FF3B30",strokeColor:"#FF3B30",fillAlpha:.1,strokeAlpha:.68,lineWidth:12},a=i?{fillColor:"#F7FFFF",strokeColor:"#F7FFFF",fillAlpha:.025,strokeAlpha:.9,lineWidth:3.8}:{fillColor:"#FF2D2D",strokeColor:"#FFE1E1",fillAlpha:.3,strokeAlpha:1,lineWidth:6.2};t.locateOnly||(e.forEach(S=>{l&&xt(S,{key:"pasture-focus-glow",name:t.name||"牧场高亮"},z,l),xt(S,{key:"pasture-focus",name:t.name||"牧场高亮"},z,a)}),(Array.isArray(t.yakMarks)?t.yakMarks:[]).forEach((S,_)=>{const T=St(S);T&&xt({type:"Feature",id:S.id||_,properties:at({},S),geometry:{type:"Point",coordinates:T}},{key:"pasture-focus-yak",name:"牦牛识别"},z,{fillColor:"#FFCB45",strokeColor:"#FFF4B8",pointSize:11})}));const s=ye(e);return s&&Yt(s,.9),(d=(f=o==null?void 0:o.scene)==null?void 0:f.requestRender)==null||d.call(f),!!e.length}function on(){var t,e;j(z),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function Hi(){tt()}function Gi(t){O=!!t,O||(k=[]),fe(),p("draw-boundary",{status:O?"drawing":"clear",pointCount:k.length,points:k})}function zi(t){k.push([t.lng,t.lat]),fe(),p("draw-boundary",{status:"drawing",pointCount:k.length,points:k})}function Vi(){k.pop(),fe(),p("draw-boundary",{status:"drawing",pointCount:k.length,points:k})}function ji(){if(k.length<3)return null;const t=Re(),e=[...k,k[0]],i={type:"Feature",properties:{source:"drawn"},geometry:{type:"Polygon",coordinates:[e]}};return O=!1,k=[],j(Y),xt(i,{key:"analysis-boundary",name:"分析边界"},Y,{fillColor:"#24F6C4",strokeColor:"#B7FFF2",fillAlpha:.12,strokeAlpha:1,lineWidth:3}),p("draw-boundary",{status:"complete",pointCount:0,points:[],feature:i}),Wt(t),ke(t),i}function Ui(){var t,e;O=!1,k=[],j(Y),j(it),p("draw-boundary",{status:"clear",pointCount:0,points:[]}),(e=(t=o==null?void 0:o.scene)==null?void 0:t.requestRender)==null||e.call(t)}function fe(){if(!o)return;const t=window.Cesium;j(Y),k.forEach(e=>{Y.push(o.entities.add({position:t.Cartesian3.fromDegrees(e[0],e[1],12),point:{pixelSize:10,color:t.Color.fromCssColorString("#24F6C4"),outlineColor:t.Color.WHITE,outlineWidth:2,heightReference:t.HeightReference.CLAMP_TO_GROUND,disableDepthTestDistance:Number.POSITIVE_INFINITY}}))}),k.length>1&&Y.push(o.entities.add({polyline:{positions:lt(k),width:3,material:t.Color.fromCssColorString("#24F6C4"),clampToGround:!0}})),o.scene.requestRender()}function Yi(t={}){var a,s,f,d,S,_,T;const e=((a=t.boundary)==null?void 0:a.type)==="Feature"||(s=t.boundary)!=null&&s.geometry?t.boundary:null,i=t.preserveView===!0||((f=e==null?void 0:e.properties)==null?void 0:f.source)==="drawn",l=i?Re():null;if(i&&((S=(d=o==null?void 0:o.camera)==null?void 0:d.cancelFlight)==null||S.call(d)),j(it),e&&xt(e,{key:"analysis-result-boundary"},it,{fillColor:"#24F6C4",strokeColor:"#B7FFF2",fillAlpha:.1,lineWidth:3}),(Array.isArray(t.matches)?t.matches:[]).forEach(E=>{const P=(E==null?void 0:E.type)==="Feature"?E:(E==null?void 0:E.feature)||null;P&&xt(P,{key:"analysis-result-feature"},it,{fillColor:"#30DCFF",strokeColor:"#C9FBFF",fillAlpha:.1,lineWidth:2.6})}),i)Wt(l),ke(l);else{const E=[e,...t.matches||[]].filter(Boolean),P=ye(E);P&&Yt(P,.9)}(T=(_=o==null?void 0:o.scene)==null?void 0:_.requestRender)==null||T.call(_)}function sn(t,e=22e3,i=.9){if(!o||!t)return;const l=window.Cesium,a=l.Cartesian3.fromDegrees(t[0],t[1],re());o.camera.flyToBoundingSphere(new l.BoundingSphere(a,1),{offset:Pt(e),duration:i})}function Yt(t,e=.9){if(!o||!t)return;const i=window.Cesium,l=[(Number(t.west)+Number(t.east))/2,(Number(t.south)+Number(t.north))/2];if(!l.every(Number.isFinite))return;const a=Math.max(Math.abs(Number(t.east)-Number(t.west)),Math.abs(Number(t.north)-Number(t.south))),s=Math.max(18e3,Math.min(16e4,a*135e3)),f=i.Cartesian3.fromDegrees(l[0],l[1],re());o.camera.flyToBoundingSphere(new i.BoundingSphere(f,1),{offset:Pt(s),duration:e})}function ln(t){if(!o||!t)return;const e=t.mapView||(t.cameraPosition?{cameraPosition:t.cameraPosition}:null);if(!e)return;const i=window.Cesium,l=Number.isFinite(Number(e.duration))?Number(e.duration):.9,a=$(e.targetLngLat);if(a){const s=Ae(c.initialZoom),f=Number.isFinite(Number(e.distanceScale))?Number(e.distanceScale):1,d=Math.max(18e3,Math.min(56e4,s*f)),S=Number.isFinite(Number(e.targetHeight))?Number(e.targetHeight):re(),_=Number.isFinite(Number(e.heading))?Number(e.heading):On,T=Number.isFinite(Number(e.pitch))?Number(e.pitch):Dn,E=i.Cartesian3.fromDegrees(a[0],a[1],S);o.camera.flyToBoundingSphere(new i.BoundingSphere(E,1),{offset:new i.HeadingPitchRange(i.Math.toRadians(_),i.Math.toRadians(T),d),duration:l});return}e.bounds&&Yt(e.bounds,l)}function Pt(t){const e=window.Cesium;return new e.HeadingPitchRange(e.Math.toRadians(On),e.Math.toRadians(Dn),t)}function wt(t){if(!o||!t)return null;const e=window.Cesium,i=e.Cartesian3.fromDegrees(t[0],t[1],16);return Ue(e.SceneTransforms.wgs84ToWindowCoordinates(o.scene,i))}function me(t){return[...D,...z].find(e=>e.__hyFeature&&t(e.__hyFeature))||null}function $i(t){return[...D,...z].filter(e=>e.__hyFeature&&t(e.__hyFeature))}function qi(t,e){if(!Number.isFinite(t==null?void 0:t.lng)||!Number.isFinite(t==null?void 0:t.lat))return null;const i=an(D),l=i.map(s=>{var f;return{entity:s,geometry:V((f=s.__hyFeature)==null?void 0:f.geometry)}}).filter(s=>s.geometry&&cn(t,s.geometry)).sort((s,f)=>hn(s.geometry)-hn(f.geometry));if(l.length)return l[0].entity;const a=i.map(s=>{var f;return{entity:s,distance:tr(V((f=s.__hyFeature)==null?void 0:f.geometry),e)}}).filter(s=>Number.isFinite(s.distance)).sort((s,f)=>s.distance-f.distance)[0];return(a==null?void 0:a.distance)<=18?a.entity:null}function $t(t,e={}){const i=(t==null?void 0:t.properties)||{},l=[e.id,e.key,e.featureId,e.projectId].filter(_=>_!=null&&_!=="").map(String),a=[t.id,i.id,i.key,i.feature_id,i.project_id].filter(_=>_!=null&&_!=="").map(String);if(l.some(_=>a.includes(_)))return!0;const s=[e.name,e.fullName,e.projectName].filter(Boolean).map(String),f=[i.name,i.fullName,i.project_name,i.projectName].filter(Boolean).map(String);if(s.some(_=>f.includes(_)))return!0;const d=St(e),S=St(Lt(at({},i),{geometry:t.geometry}));return!!(d&&S&&Math.abs(d[0]-S[0])<2e-5&&Math.abs(d[1]-S[1])<2e-5)}function Zi(t={}){return t&&typeof t=="object"?t:{name:t,projectName:t,project_name:t}}function Xi(t,e={}){if($t(t,e))return!0;const i=(t==null?void 0:t.properties)||{},l=qt([e.id,e.key,e.featureId,e.projectId,e.project_id]),a=qt([t==null?void 0:t.id,i.id,i.key,i.feature_id,i.project_id,i.gid]);if(l.some(d=>a.includes(d)))return!0;const s=qt([e.name,e.fullName,e.projectName,e.project_name,e.title]),f=qt([i.name,i.fullName,i.project_name,i.projectName,i.title]);return s.some(d=>f.includes(d))}function qt(t=[]){const e=[];return t.forEach(i=>{if(i==null||i==="")return;const l=String(i).trim();if(!l)return;e.push(l);const a=l.replace(/\s+/g,"");a&&a!==l&&e.push(a)}),Array.from(new Set(e))}function an(t=[]){const e=new Set;return t.filter(i=>{const l=i==null?void 0:i.__hyFeature;return!l||e.has(l)?!1:(e.add(l),!0)})}function Ji(t=[]){return an(t).map(e=>e.__hyFeature).filter(Boolean)}function Ki(t=[]){const e=t.filter(l=>{var s;const a=String(((s=V(l==null?void 0:l.geometry))==null?void 0:s.type)||"");return a.includes("Polygon")||a.includes("LineString")}),i=e.filter(l=>{var a;return((a=l==null?void 0:l.properties)==null?void 0:a.feature_role)==="工程范围"});return i.length?i:e}function Qi(t){return(Array.isArray(t)?t:(t==null?void 0:t.grasslands)||(t==null?void 0:t.features)||(t==null?void 0:t.rows)||(t==null?void 0:t.list)||(t?[t]:[])).map((i,l)=>{var s,f;if((i==null?void 0:i.type)==="Feature")return i;const a=V(i==null?void 0:i.geometry)||pe(Oe(i));return a?{type:"Feature",id:(f=(s=i==null?void 0:i.id)!=null?s:i==null?void 0:i.grasslandId)!=null?f:l,properties:at({},i),geometry:a}:null}).filter(Boolean)}function V(t){if(!t)return null;if(t.type==="Feature")return V(t.geometry);if(t.type&&Array.isArray(t.coordinates))return t;if(typeof t=="string"){const e=t.trim();if(!e)return null;if(e.startsWith("{")||e.startsWith("["))try{return V(JSON.parse(e))}catch(i){return null}return pe(e)}return null}function pe(t){const i=String(t||"").trim().replace(/^SRID=\d+;/i,"").match(/^([A-Z]+)(?:\s+[A-Z]+)?\s*(\(.+\))$/i);if(!i)return null;const l=i[1].toUpperCase(),a=i[2];return l==="POINT"?{type:"Point",coordinates:ge(a)}:l==="MULTIPOINT"?{type:"MultiPoint",coordinates:Zt(a).map(ge).filter(Boolean)}:l==="LINESTRING"?{type:"LineString",coordinates:de(a)}:l==="MULTILINESTRING"?{type:"MultiLineString",coordinates:Zt(a).map(de).filter(s=>s.length)}:l==="POLYGON"?{type:"Polygon",coordinates:un(a)}:l==="MULTIPOLYGON"?{type:"MultiPolygon",coordinates:Zt(a).map(un).filter(s=>s.length)}:null}function ge(t){const e=String(t||"").replace(/^\(+|\)+$/g,"").trim().split(/\s+/).slice(0,2).map(Number);return e.length===2&&e.every(Number.isFinite)?e:null}function de(t){return String(t||"").replace(/^\(+|\)+$/g,"").split(",").map(ge).filter(Boolean)}function un(t){return Zt(t).map(de).filter(e=>e.length>=3)}function Zt(t){const e=String(t||"").trim(),i=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,l=[];let a=0,s=-1;return Array.from(i).forEach((f,d)=>{f==="("?(a===0&&(s=d),a+=1):f===")"&&(a-=1,a===0&&s>=0&&(l.push(i.slice(s,d+1)),s=-1))}),l.length?l:[i]}function lt(t=[]){const e=window.Cesium;return t.map($).filter(Boolean).map(i=>e.Cartesian3.fromDegrees(i[0],i[1],8))}function $(t){if(!Array.isArray(t)||t.length<2)return null;const e=Number(t[0]),i=Number(t[1]);return Number.isFinite(e)&&Number.isFinite(i)?[e,i]:null}function St(t={}){const e=V(t.geometry);return(e==null?void 0:e.type)==="Point"?$(e.coordinates):[[t.longitude,t.latitude],[t.lng,t.lat],[t.lon,t.lat],[t.x,t.y],t.point,t.center,t.centroid,t.coordinates].map($).find(Boolean)||null}function cn(t,e){return!t||!(e!=null&&e.coordinates)?!1:e.type==="Polygon"?gn(t,e.coordinates):e.type==="MultiPolygon"?e.coordinates.some(i=>gn(t,i)):!1}function hn(t){return t!=null&&t.coordinates?t.type==="Polygon"?fn(t.coordinates):t.type==="MultiPolygon"?t.coordinates.reduce((e,i)=>e+fn(i),0):Number.POSITIVE_INFINITY:Number.POSITIVE_INFINITY}function fn(t=[]){const e=t[0]||[];if(e.length<3)return Number.POSITIVE_INFINITY;let i=0;for(let l=0;lmn(i,e))):t.type==="LineString"?pn(t.coordinates,e):t.type==="MultiLineString"?Math.min(...t.coordinates.map(i=>pn(i,e))):Number.POSITIVE_INFINITY}function mn(t,e){const i=wt($(t));return i?Math.hypot(Number(i.x)-Number(e.x),Number(i.y)-Number(e.y)):Number.POSITIVE_INFINITY}function pn(t=[],e){if(!Array.isArray(t)||t.length<2)return Number.POSITIVE_INFINITY;let i=Number.POSITIVE_INFINITY;for(let l=1;ldn(t,i))}function dn(t,e=[]){if(e.length<3)return!1;const i=Number(t.lng),l=Number(t.lat);if(!Number.isFinite(i)||!Number.isFinite(l))return!1;let a=!1;for(let s=0,f=e.length-1;sl!=P>l&&i<(E-_)*(l-T)/(P-T)+_&&(a=!a)}return a}function nr(t,e,i,l,a,s){const f=(t-i)*(s-l)-(e-l)*(a-i);return Math.abs(f)>1e-10?!1:(t-i)*(t-a)+(e-l)*(e-s)<=1e-10}function ir(t){if(!t)return null;if(t.type==="Point")return $(t.coordinates);const e=[];return Xt(t.coordinates,e),e.length?[e.reduce((i,l)=>i+l[0],0)/e.length,e.reduce((i,l)=>i+l[1],0)/e.length]:null}function Xt(t,e){const i=$(t);if(i&&!Array.isArray(t[0])){e.push(i);return}Array.isArray(t)&&t.forEach(l=>Xt(l,e))}function ye(t=[]){const e=[];if(t.forEach(f=>{var S;const d=V((f==null?void 0:f.geometry)||((S=f==null?void 0:f.feature)==null?void 0:S.geometry)||f);d&&Xt(d.coordinates,e)}),!e.length)return null;const i=e.map(f=>f[0]),l=e.map(f=>f[1]),a=Math.max(.006,(Math.max(...i)-Math.min(...i))*.18),s=Math.max(.006,(Math.max(...l)-Math.min(...l))*.18);return{west:Math.max(G.west,Math.min(...i)-a),south:Math.max(G.south,Math.min(...l)-s),east:Math.min(G.east,Math.max(...i)+a),north:Math.min(G.north,Math.max(...l)+s)}}function j(t){if(!o){t.length=0;return}t.splice(0).forEach(e=>o.entities.remove(e))}function yn(){B.splice(0).forEach(t=>{var e,i;return(i=(e=o==null?void 0:o.imageryLayers)==null?void 0:e.remove)==null?void 0:i.call(e,t,!0)}),j(D),tt()}function It(){var t,e,i;I+=1,(t=b==null?void 0:b.disconnect)==null||t.call(b),b=null,F==null||F(),F=null,C==null||C(),C=null,(e=x==null?void 0:x.destroy)==null||e.call(x),x=null,yn(),j(ie),j(ct),j(U),j(q),j(z),j(Y),j(it),o&&!((i=o.isDestroyed)!=null&&i.call(o))&&o.destroy(),o=null,v=null,w.value=null,y.value&&y.value.replaceChildren()}function bt(t,e=1){const i=Number(t);return Number.isFinite(i)?Math.max(0,Math.min(1,i)):e}function ht(t){return String(t||"").trim().replace(/(镇|乡)$/,"")}function rr(t){const e=Number(t);return Number.isFinite(e)?Number.isInteger(e)?String(e):String(Number(e.toFixed(2))):"--"}return n({loadMap:Zn,hasMap:Xn,play:Jn,resume:Me,pause:Kn,refreshView:Dt,resetView:Qn,focusLayerMapView:ti,destroyMap:It,highlightFeature:Xe,clearSelectedFeature:tt,clearFloatingOverlays:Hi,focusProject:Qe,focusPasture:rn,clearPastureFocus:on,focusTown:Ke,focusYakIndustryPoint:tn,focusVectorFeature:en,getVectorFeatureAnchorScreen:nn,getVectorFeaturesAnchorScreen:Ut,getVectorFeatureScreen:Ft,getYakIndustryPointScreen:he,setBoundaryDrawing:Gi,finishBoundaryDrawing:ji,undoBoundaryPoint:Vi,clearAnalysisBoundary:Ui,showAnalysisResult:Yi,canvasMap:w}),(t,e)=>(gr(),dr("div",{ref_key:"containerRef",ref:g,class:"cesium-map"},[yr("div",{ref_key:"viewerRef",ref:y,class:"cesium-map__viewer"},null,512)],512))}},uo=hr(no,[["__scopeId","data-v-19fc4a4c"]]);export{ao as C,lo as H,uo as M,Yr as a,$r as g};