vesium 1.0.1-beta.48 → 1.0.1-beta.50

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,2 +1,2 @@
1
- import{useMutationObserver as Le,tryOnScopeDispose as F,promiseTimeout as Te,refThrottled as j,watchThrottled as Ie,computedAsync as G,useElementBounding as ge,useElementSize as Re,watchImmediate as We}from"@vueuse/core";import{Viewer as _e,defined as q,Ellipsoid as V,Cartesian3 as N,Math as I,Cartographic as $,Material as Y,CallbackProperty as Oe,ConstantProperty as Me,Cartesian2 as J,ScreenSpaceEventHandler as xe,ScreenSpaceEventType as b,EllipsoidGeodesic as ke}from"cesium";import{shallowRef as L,shallowReadonly as he,provide as Fe,getCurrentScope as me,computed as h,watchEffect as S,toRaw as ye,toValue as y,markRaw as Ge,toRef as Q,inject as Ve,watch as R,ref as z,readonly as Ee,shallowReactive as Ne,nextTick as pe}from"vue";const X=Symbol("CREATE_VIEWER_INJECTION_KEY"),Z=new WeakMap;function $e(...e){const t=L(),o=he(t);Fe(X,o);const a=me();a&&Z.set(a,o);const r=h(()=>{var i;return(i=t.value)==null?void 0:i.canvas});return Le(document?.body,()=>{r.value&&!document?.body.contains(r.value)&&(t.value=void 0)},{childList:!0,subtree:!0}),S(i=>{const[n,l]=e,c=ye(y(n));if(c instanceof _e)t.value=Ge(c);else if(c){const s=c,f=l;t.value=new _e(s,f),i(()=>{var v,u;return!((v=t.value)!=null&&v.isDestroyed())&&((u=t.value)==null?void 0:u.destroy())})}else t.value=void 0}),F(()=>{t.value=void 0}),h(()=>{var i;return(i=t.value)!=null&&i.isDestroyed()?void 0:t.value})}const we=Object.prototype.toString;function U(e){return typeof e<"u"}function ze(e){return typeof e=="boolean"}function T(e){return typeof e=="function"}function He(e){return typeof e=="number"}function Ke(e){return typeof e=="string"}function Be(e){return we.call(e)==="[object Object]"}function Ue(e){return typeof window<"u"&&we.call(e)==="[object Window]"}function ee(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function je(e){return!!(e&&e.nodeName&&e.nodeType===1)}const qe=Array.isArray;function Ye(e){return/^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i.test(e)}function Je(e,t){if(e)throw new Error(t)}function Qe(e,t){return e===t||T(e?.equals)&&e.equals(t)||T(t?.equals)&&t.equals(e)}function Xe(e){return!q(e)||!!e.isConstant}function Ze(e,t,o="auto"){if(o==="pickPosition")return t.pickPosition(e);if(o==="globePick"){const a=t.camera.getPickRay(e);return a&&t.globe.pick(a,t)}else{if(t.globe.depthTestAgainstTerrain)return t.pickPosition(e);const a=t.pickPosition(e),r=t.camera.getPickRay(e),i=r&&t.globe.pick(r,t);if(!a)return i;const n=(a&&V.WGS84.cartesianToCartographic(a).height)??0,l=(i&&V.WGS84.cartesianToCartographic(i).height)??0;return n<l?a:i}}function Ce(e,t){return t.cartesianToCanvasCoordinates(e)}function Pe(e,t={}){if(!e)return;const{type:o="Array",alt:a=!1}=t;let r,i,n;if(e instanceof N){const l=V.WGS84.cartesianToCartographic(e);r=I.toDegrees(l.longitude),i=I.toDegrees(l.latitude),n=l.height}else if(e instanceof $){const l=e;r=I.toDegrees(l.longitude),i=I.toDegrees(l.latitude),n=l.height}else Array.isArray(e)?(r=I.toDegrees(e[0]),i=I.toDegrees(e[1]),n=e[2]):(r=e.longitude,i=e.latitude,n=e.height);return o==="Array"?a?[r,i,n]:[r,i]:a?{longitude:r,latitude:i,height:n}:{longitude:r,latitude:i}}function te(e,t=3){const o=`${e}`;let a=o.indexOf(".");const r=a<0?o:o.slice(0,Math.max(0,a));let i="0",n="0";return a>0&&(i=`0${o.slice(Math.max(0,a))}`,i=`${+i*60}`,a=i.indexOf("."),a>0&&(n=`0${i.slice(Math.max(0,a))}`,i=i.slice(0,Math.max(0,a)),n=`${+n*60}`,a=n.indexOf("."),n=n.slice(0,Math.max(0,a+4)),n=(+n).toFixed(t))),`${Math.abs(+r)}\xB0${+i}\u2032${+n}\u2033`}function ne(e){const[t,o]=e.split("\xB0")??[],[a,r]=o?.split("\u2032")??[],i=r?.split("\u2033")[0],n=Number(t)||0,l=(Number(a)||0)/60,c=(Number(i)||0)/60/60,s=n+l+c;if(s===0)return 0;{let f=s;return["W","w","S","s"].includes(e[e.length-1])&&(f=-f),f}}function et(e,t=3){const o=Pe(e,{alt:!0});if(!o)return;const[a,r,i]=o,n=te(a,t),l=te(r,t);return[`${n}${a>0?"E":"W"}`,`${l}${r>0?"N":"S"}`,i]}function tt(e){const[t,o,a]=e,r=ne(t),i=ne(o);return[r,i,Number(a)||0]}class nt extends Y{constructor(t){super(t)}}function ot(e){return Y._materialCache.getMaterial(e)}function rt(e,t){return Y._materialCache.addMaterial(e,t)}function H(e={}){const{primitive:t,id:o,primitiveCollection:a,collection:r}=e,i=o&&o.entityCollection||null,n=i&&i.owner||null;return[...Array.isArray(o)?o:[o].filter(Boolean),t,a,r,i,n].filter(c=>!!c)}function lt(e,t){if(!Array.isArray(t)||!t.length)return!1;const o=H(e);return o.length?o.some(a=>t.includes(a)):!1}function K(e){return e&&T(e.getValue)}function it(e,t){return K(e)?e.getValue(t):e}function oe(e,t=!1){return K(e)?e:T(e)?new Oe(e,t):new Me(e)}function at(e,t,o,a){let r;const i=c=>{var s;r?.(),q(c?.definitionChanged)&&(r=(s=c?.definitionChanged)==null?void 0:s.addEventListener(()=>{e.definitionChanged.raiseEvent(e,t,c,c)}))},n=`_${t}`,l=oe(o);e[n]=l,i(l),a?Object.defineProperty(e,t,{get(){return e[n]}}):Object.defineProperty(e,t,{get(){return e[n]},set(c){const s=e[n];e[n]!==c&&(e[n]=c,i(c),q(e.definitionChanged)&&e.definitionChanged.raiseEvent(e,t,c,s))}})}function be(e,t,o,a={}){const r=!!a.toProperty,i=!!a.shallowClone,n=a.changedEventKey||"definitionChanged",l=Reflect.get(e,n),c=`_${String(t)}`,s=r?oe(o):o;Reflect.set(e,c,s);const f={get(){const d=Reflect.get(e,c);return i?Array.isArray(d)?[...d]:{...d}:d}};let v;const u=(d,g)=>{var E;v?.(),v=(E=d?.definitionChanged)==null?void 0:E.addEventListener(()=>{l?.raiseEvent.bind(l)(e,t,d,g)})};a.readonly||(r&&K(o)&&u(o),f.set=d=>{if(r&&!K(d))throw new Error(`The value of ${String(t)} must be a Cesium.Property object`);const g=Reflect.get(e,c);g!==d&&(Reflect.set(e,c,d),l?.raiseEvent.bind(l)(e,t,d,g),r&&u(d))}),Object.defineProperty(e,t,f)}function ct(e,t,o,a={}){return be(e,t,o,{...a,toProperty:!0})}function re(e,t=100,o=!0,a=!1){const r=[];let i=!1;const n=async()=>{if(await Te(t),i=!1,a)try{e(...r[0])}catch(l){console.error(l)}if(o&&(!a||r.length>1))try{e(...r[r.length-1])}catch(l){console.error(l)}r.length=0};return(...l)=>{r.length<2?r.push(l):r[1]=l,i||(i=!0,n())}}function Se(e){if(e)return e instanceof N?e.clone():e instanceof $?V.WGS84.cartographicToCartesian(e):Array.isArray(e)?N.fromDegrees(e[0],e[1],e[2]):N.fromDegrees(e.longitude,e.latitude,e.height)}function ut(e){if(e)return e instanceof N?V.WGS84.cartesianToCartographic(e):e instanceof $?e.clone():Array.isArray(e)?$.fromDegrees(e[0],e[1],e[2]):$.fromDegrees(e.longitude,e.latitude,e.height)}function W(e){return(...t)=>{try{return e?.(...t)}catch(o){console.error(o)}}}function st(e,t){const o=new Set(t),a=e.filter(n=>!o.has(n)),r=new Set(e),i=t?.filter(n=>!r.has(n))??[];return{added:a,removed:i}}async function O(e,t={}){try{const{raw:o=!0}=t;let a;if(T(e))a=await e();else{const r=y(e);a=ee(r)?await r:r}return o?ye(a):a}catch(o){throw console.error(o),o}}function B(e,t,o={}){const a=Q(o.isActive??!0),r=S(i=>{const n=y(e),l=Array.isArray(n)?n:[n];if(l&&l.length&&a.value){const c=l.map(s=>{const f=y(s);return f?.addEventListener(t,f)});i(()=>c.forEach(s=>s?.()))}});return F(r.stop),r.stop}function w(){const e=me(),t=e?Z.get(e):void 0;if(t)return t;{const o=Ve(X);if(!o)throw new Error("The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?");return o}}function vt(e={}){let t=e.camera;if(!t){const n=w();t=()=>{var l;return(l=n.value)==null?void 0:l.scene.camera}}const o=h(()=>y(t)),a=h(()=>{var n;const l=y(e.event)||"changed";return(n=o.value)==null?void 0:n[l]}),r=j(L(Symbol("camera change")),e.delay??8,!0,!1),i=()=>{r.value=Symbol("camera change")};return R(o,()=>i()),B(a,()=>i()),{camera:o,position:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.position)==null?void 0:l.clone():void 0}),direction:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.direction)==null?void 0:l.clone():void 0}),up:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.up)==null?void 0:l.clone():void 0}),right:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.right)==null?void 0:l.clone():void 0}),positionCartographic:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.positionCartographic)==null?void 0:l.clone():void 0}),positionWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.positionWC)==null?void 0:l.clone():void 0}),directionWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.directionWC)==null?void 0:l.clone():void 0}),upWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.directionWC)==null?void 0:l.clone():void 0}),rightWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.directionWC)==null?void 0:l.clone():void 0}),viewRectangle:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.computeViewRectangle():void 0}),heading:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.heading:void 0}),pitch:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.pitch:void 0}),roll:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.roll:void 0}),level:h(()=>{var n,l;return r.value&&((l=(n=o.value)==null?void 0:n.positionCartographic)!=null&&l.height)?_t(o.value.positionCartographic.height):void 0})}}const dt=40487.57,ft=7096758e-11,gt=91610.74,De=-40467.74;function _t(e){return De+(dt-De)/(1+(e/gt)**ft)}function ht(e={}){const{delay:t=100}=e,o=w(),a=L(performance.now());B(()=>{var n;return(n=o.value)==null?void 0:n.scene.postRender},()=>a.value=performance.now());const r=z(0);Ie(a,(n,l)=>{r.value=n-l},{throttle:t});const i=h(()=>1e3/r.value);return{interval:Ee(r),fps:i}}function M(e,t,o){const a=Ne(new Set),r=(c,...s)=>{const f=e(c,...s);return ee(f)?new Promise((v,u)=>{f.then(d=>{a.add(d),v(d)}).catch(d=>u(d))}):(a.add(f),f)},i=(c,...s)=>(a.delete(c),t(c,...s)),n=(c,...s)=>{a.forEach(f=>{c(f)&&i(f,...s)})},l=(...c)=>{a.forEach(s=>{i(s,...c)})};return F(()=>l(...o)),{scope:he(a),add:r,remove:i,removeWhere:n,removeScope:l}}function mt(e,t={}){const{destroyOnRemove:o,collection:a,isActive:r=!0,evaluating:i}=t,n=G(()=>O(e),void 0,{evaluating:i}),l=w();return S(c=>{var s;if(y(r)){const v=Array.isArray(n.value)?[...n.value]:[n.value],u=a??((s=l.value)==null?void 0:s.dataSources);v.forEach(d=>d&&u?.add(d)),c(()=>{const d=y(o);!u?.isDestroyed()&&v.forEach(g=>g&&u?.remove(g,d))})}}),n}function yt(e={}){const{collection:t,destroyOnRemove:o}=e,a=w(),r=h(()=>{var u;return y(t)??((u=a.value)==null?void 0:u.dataSources)}),i=u=>{if(!r.value)throw new Error("collection is not defined");return r.value.add(u)},n=(u,d)=>{var g;return!!((g=r.value)!=null&&g.remove(u,d))},{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}=M(i,n,[o]);return{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}}function Et(e,t,o={}){const{referenceWindow:a,horizontal:r="center",vertical:i="bottom",offset:n={x:0,y:0}}=o,l=h(()=>Se(y(t))),c=w(),s=L();B(()=>{var _;return(_=c.value)==null?void 0:_.scene.postRender},()=>{var _;if((_=c.value)!=null&&_.scene)if(!l.value)s.value=void 0;else{const p=Ce(l.value,c.value.scene);s.value=J.equals(p,s.value)?s.value:p}});const f=ge(()=>{var _;return(_=c.value)==null?void 0:_.canvas.parentElement}),v=ge(e),u=h(()=>{const _=y(n);let p=_?.x??0;const C=y(r);C==="center"?p-=v.width.value/2:C==="right"&&(p-=v.width.value);let D=_?.y??0;const A=y(i);return A==="center"?D-=v.height.value/2:A==="bottom"&&(D-=v.height.value),{x:p,y:D}}),d=h(()=>{var _,p;const C={x:((_=s.value)==null?void 0:_.x)??0,y:((p=s.value)==null?void 0:p.y)??0};return y(a)&&(C.x+=f.x.value,C.y+=f.y.value),{x:u.value.x+C.x,y:u.value.y+C.y}}),g=h(()=>d.value.x),E=h(()=>d.value.y),m=h(()=>{var _,p;return{left:`${(_=g.value)==null?void 0:_.toFixed(2)}px`,top:`${(p=E.value)==null?void 0:p.toFixed(2)}px`}});return S(()=>{var _,p,C,D;const A=y(e);A&&y(o.applyStyle??!0)&&((p=(_=A.style)==null?void 0:_.setProperty)==null||p.call(_,"left",m.value.left),(D=(C=A.style)==null?void 0:C.setProperty)==null||D.call(C,"top",m.value.top))}),{x:g,y:E,style:m}}function pt(e,t={}){const{collection:o,isActive:a=!0,evaluating:r}=t,i=G(()=>O(e),[],{evaluating:r}),n=w();return S(l=>{var c;if(y(a)){const f=Array.isArray(i.value)?[...i.value]:[i.value],v=o??((c=n.value)==null?void 0:c.entities);f.forEach(u=>u&&v?.add(u)),l(()=>{f.forEach(u=>u&&v?.remove(u))})}}),i}function wt(e={}){const{collection:t}=e,o=w(),a=h(()=>{var v;return y(t)??((v=o.value)==null?void 0:v.entities)}),r=v=>{if(!a.value)throw new Error("collection is not defined");return a.value.contains(v)||a.value.add(v),v},i=v=>{var u;return!!((u=a.value)!=null&&u.remove(v))},{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}=M(r,i,[]);return{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}}const Ae=new WeakMap;function le(e,t={}){const{width:o=3,height:a=3,throttled:r=8}=t,i=Q(t.isActive??!0),n=w(),l=j(h(()=>{var s;return(s=y(e))==null?void 0:s.clone()}),r,!1,!0),c=L();return S(()=>{var s;if(n.value&&l.value&&i.value){const f=Ae.get(n.value);f&&f[0].equals(l.value)?c.value=f[1]:(Ae.set(n.value,[l.value.clone(),c.value]),c.value=(s=n.value)==null?void 0:s.scene.pick(l.value,y(o),y(a)))}}),c}function x(e,t,o={}){const{modifier:a}=o,r=w(),i=Q(o.isActive??!0),n=h(()=>{var f,v;if((v=(f=r.value)==null?void 0:f.cesiumWidget)!=null&&v.canvas)return new xe(r.value.cesiumWidget.canvas)}),l=R(n,(f,v)=>{var u;(u=r.value)!=null&&u.cesiumWidget&&v?.destroy()}),c=S(f=>{const v=y(e),u=y(a),d=y(n);!d||!i.value||!t||U(v)&&(d.setInputAction(t,v,u),f(()=>d.removeInputAction(v,u)))}),s=()=>{l(),c()};return F(s),s}function Ct(e){const t=L(),o=le(t),a=L(),r=z(!1),i=w(),n=z(!1);R(n,d=>{i.value&&(i.value.scene.screenSpaceCameraController.enableRotate=!d)});const l=()=>{n.value=!0},c=(d,g,E)=>{e({event:{startPosition:g.clone(),endPosition:E.clone()},pick:d,dragging:r.value,lockCamera:l}),pe(()=>{!r.value&&n.value&&(n.value=!1)})},s=x(b.LEFT_DOWN,d=>{r.value=!0,t.value=d.position.clone()}),f=x(b.MOUSE_MOVE,re(({startPosition:d,endPosition:g})=>{var E;a.value={startPosition:((E=a.value)==null?void 0:E.endPosition.clone())||d.clone(),endPosition:g.clone()}},8,!1,!0));R([o,a],([d,g])=>{if(d&&g){const{startPosition:E,endPosition:m}=g;r.value&&c(d,E,m)}});const v=x(b.LEFT_UP,d=>{r.value=!1,o.value&&a.value&&c(o.value,a.value.endPosition,d.position),t.value=void 0,a.value=void 0}),u=()=>{s(),f(),v()};return F(u),u}function Pt(e){const t=L(),o=le(()=>{var r;return(r=t.value)==null?void 0:r.endPosition}),a=(r,i,n,l)=>{e({event:{startPosition:i.clone(),endPosition:n.clone()},pick:r,hovering:l})};x(b.MOUSE_MOVE,({startPosition:r,endPosition:i})=>{var n,l;(!r.equals((n=t.value)==null?void 0:n.startPosition)||!i.equals((l=t.value)==null?void 0:l.endPosition))&&(t.value={startPosition:r.clone(),endPosition:i.clone()})}),R([o,t],([r,i])=>{if(r&&i){const{startPosition:n,endPosition:l}=i;a(r,n,l,!0)}}),R(o,(r,i)=>{if(i&&t.value){const{startPosition:n,endPosition:l}=t.value;a(i,n,l,!1)}})}const bt={LEFT_DOWN:b.LEFT_DOWN,LEFT_UP:b.LEFT_UP,LEFT_CLICK:b.LEFT_CLICK,LEFT_DOUBLE_CLICK:b.LEFT_DOUBLE_CLICK,RIGHT_DOWN:b.RIGHT_DOWN,RIGHT_UP:b.RIGHT_UP,RIGHT_CLICK:b.RIGHT_CLICK,MIDDLE_DOWN:b.MIDDLE_DOWN,MIDDLE_UP:b.MIDDLE_UP,MIDDLE_CLICK:b.MIDDLE_CLICK};function St(e,t){const o=bt[e],a=w();x(o,r=>{var i;const n=r.position,l=(i=a.value)==null?void 0:i.scene.pick(n);l&&n&&t({event:{position:n},pick:l})})}const k=Symbol("GLOBAL_GRAPHIC_SYMBOL"),Dt=["LEFT_DOWN","LEFT_UP","LEFT_CLICK","LEFT_DOUBLE_CLICK","RIGHT_DOWN","RIGHT_UP","RIGHT_CLICK","MIDDLE_DOWN","MIDDLE_UP","MIDDLE_CLICK"];function At(){const e=new WeakMap,t=new WeakMap,o=new WeakMap,a=(c,s,f)=>{var v,u,d,g,E,m,_,p,C,D,A,ie,ae,ce,ue,se,ve,de,fe;const P=c==="global"?k:c;(u=(v=e?.get(P))==null?void 0:v.get(s))==null||u.delete(f),(g=(d=t?.get(P))==null?void 0:d.get(s))==null||g.delete(f),((m=(E=e?.get(P))==null?void 0:E.get(s))==null?void 0:m.size)===0&&e.get(P).delete(s),((_=e.get(P))==null?void 0:_.size)===0&&e.delete(P),(C=(p=t?.get(P))==null?void 0:p.get(s))==null||C.delete(f),((A=(D=t?.get(P))==null?void 0:D.get(s))==null?void 0:A.size)===0&&((ie=t?.get(P))==null||ie.delete(s)),((ae=t?.get(P))==null?void 0:ae.size)===0&&t?.delete(P),(ue=(ce=o?.get(P))==null?void 0:ce.get(s))==null||ue.delete(f),((ve=(se=o?.get(P))==null?void 0:se.get(s))==null?void 0:ve.size)===0&&((de=o?.get(P))==null||de.delete(s)),((fe=o?.get(P))==null?void 0:fe.size)===0&&o?.delete(P)},r=(c,s,f,v={})=>{const u=c==="global"?k:c;e.get(u)??e.set(u,new Map);const d=e.get(u);d.get(s)??d.set(s,new Set),d.get(s).add(f);let{cursor:E="pointer",dragCursor:m}=v;if(U(E)){const _=T(E)?E:()=>E;t.get(u)??t.set(u,new Map),t.get(u).get(s)??t.get(u).set(s,new Map),t.get(u).get(s).set(f,_)}if(s==="DRAG"&&(m??(m=_=>_?.dragging?"crosshair":void 0)),U(m)){const _=T(m)?m:()=>m;o.get(u)??o.set(u,new Map),o.get(u).get(s)??o.get(u).set(s,new Map),o.get(u).get(s).set(f,_)}return()=>a(c,s,f)},i=(c,s)=>{var f,v,u,d,g,E;const m=c==="global"?k:c;if(s==="all"){e.delete(m),t.delete(m),o.delete(m);return}(f=e.get(m))==null||f.delete(s),((v=e.get(m))==null?void 0:v.size)===0&&e.delete(m),(u=t?.get(m))==null||u.delete(s),(d=o?.get(m))==null||d.delete(s),((g=t?.get(m))==null?void 0:g.size)===0&&t?.delete(m),((E=o?.get(m))==null?void 0:E.size)===0&&o?.delete(m)};for(const c of Dt)St(c,s=>{H(s.pick).concat(k).forEach(v=>{var u,d;(d=(u=e.get(v))==null?void 0:u.get(c))==null||d.forEach(g=>{var E;return(E=W(g))==null?void 0:E(s)})})});const n=z(!1),l=w();return Pt(c=>{H(c.pick).concat(k).forEach(f=>{var v,u,d;(u=(v=e.get(f))==null?void 0:v.get("HOVER"))==null||u.forEach(g=>{var E;return(E=W(g))==null?void 0:E(c)}),n.value||(d=t.get(f))==null||d.forEach(g=>{g.forEach(E=>{var m,_;const p=c.hovering?W(E)(c):"";(_=(m=l.value)==null?void 0:m.canvas.style)==null||_.setProperty("cursor",p)})})})}),Ct(c=>{const s=H(c.pick).concat(k);n.value=c.dragging,s.forEach(f=>{var v,u,d;(u=(v=e.get(f))==null?void 0:v.get("DRAG"))==null||u.forEach(g=>W(g)(c)),(d=o.get(f))==null||d.forEach(g=>{g.forEach(E=>{var m,_;const p=c.dragging?W(E)(c):"";(_=(m=l.value)==null?void 0:m.canvas.style)==null||_.setProperty("cursor",p)})})})}),{addGraphicEvent:r,removeGraphicEvent:a,clearGraphicEvent:i}}function Lt(e,t={}){const{destroyOnRemove:o,collection:a,isActive:r=!0,evaluating:i}=t,n=G(()=>O(e),[],{evaluating:i}),l=w();return S(c=>{var s;if(y(r)){const v=Array.isArray(n.value)?[...n.value]:[n.value],u=a??((s=l.value)==null?void 0:s.imageryLayers);if(a?.isDestroyed())return;v.forEach(d=>{if(!d){console.warn("ImageryLayer is undefined");return}if(d?.isDestroyed()){console.warn("ImageryLayer is destroyed");return}u?.add(d)}),c(()=>{const d=y(o);v.forEach(g=>g&&u?.remove(g,d))})}}),n}function Tt(e={}){const{collection:t,destroyOnRemove:o}=e,a=w(),r=h(()=>{var u;return y(t)??((u=a.value)==null?void 0:u.imageryLayers)}),i=(u,d)=>{if(!r.value)throw new Error("collection is not defined");return r.value.add(u,d),u},n=(u,d)=>{var g;return!!((g=r.value)!=null&&g.remove(u,d))},{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}=M(i,n,[o]);return{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}}function It(e,t={}){const{collection:o,isActive:a=!0,evaluating:r}=t,i=G(()=>O(e),void 0,{evaluating:r}),n=w();return S(l=>{if(!n.value)return;if(y(a)){const s=Array.isArray(i.value)?[...i.value]:[i.value],f=o??n.value.scene.postProcessStages;s.forEach(v=>v&&f.add(v)),l(()=>{s.forEach(v=>v&&f.remove(v))})}}),i}function Rt(e={}){const{collection:t}=e,o=w(),a=h(()=>{var v;return y(t)??((v=o.value)==null?void 0:v.postProcessStages)}),r=v=>{if(!a.value)throw new Error("collection is not defined");return a.value.add(v)},i=v=>{var u;return!!((u=a.value)!=null&&u.remove(v))},{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}=M(r,i,[]);return{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}}function Wt(e,t={}){const{collection:o,isActive:a=!0,evaluating:r}=t,i=G(()=>O(e),void 0,{evaluating:r}),n=w();return S(l=>{var c,s;if(y(a)){const v=Array.isArray(i.value)?[...i.value]:[i.value],u=o==="ground"?(c=n.value)==null?void 0:c.scene.groundPrimitives:o??((s=n.value)==null?void 0:s.scene.primitives);v.forEach(d=>d&&u?.add(d)),l(()=>{!u?.isDestroyed()&&v.forEach(d=>d&&u?.remove(d))})}}),i}function Ot(e={}){const{collection:t}=e,o=w(),a=h(()=>{var v;return y(t)??((v=o.value)==null?void 0:v.scene.primitives)}),r=v=>{if(!a.value)throw new Error("collection is not defined");return a.value.add(v)},i=v=>{var u;return!!((u=a.value)!=null&&u.remove(v))},{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}=M(r,i,[]);return{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}}const Mt=[.01,.05,.1,.5,1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7,2e7,3e7,5e7].reverse();function xt(e={}){const{maxPixel:t=80,delay:o=8}=e,a=h(()=>y(t)),r=w(),i=Re(()=>{var v;return(v=r.value)==null?void 0:v.canvas}),n=z(),l=async()=>{var v;await pe();const u=(v=r.value)==null?void 0:v.scene;if(!u)return;const d=u.camera.getPickRay(new J(Math.floor(i.width.value/2),i.height.value-1)),g=u.camera.getPickRay(new J(Math.floor(1+i.width.value/2),i.height.value-1));if(!d||!g)return;const E=u.globe.pick(d,u),m=u.globe.pick(g,u);if(!E||!m)return;const _=u.globe.ellipsoid.cartesianToCartographic(E),p=u.globe.ellipsoid.cartesianToCartographic(m),C=new ke(_,p);n.value=C.surfaceDistance};We(r,()=>l()),B(()=>{var v;return(v=r.value)==null?void 0:v.camera.changed},re(l,o));const c=h(()=>{if(n.value)return Mt.find(v=>n.value*a.value>v)}),s=h(()=>c.value&&n.value?c.value/n.value:0),f=h(()=>{if(c.value)return c.value>1e3?`${c.value/1e3||0}km`:`${c.value||0}m`});return{pixelDistance:Ee(n),width:s,distance:c,distanceText:f}}function kt(e,t={}){const{width:o=3,height:a=3,limit:r,throttled:i=8,isActive:n=!0}=t,l=w(),c=j(h(()=>y(e)),i,!1,!0);return h(()=>{var f;if(c.value&&y(n))return(f=l.value)==null?void 0:f.scene.drillPick(c.value,y(r),y(o),y(a))})}export{Z as CREATE_VIEWER_COLLECTION,X as CREATE_VIEWER_INJECTION_KEY,nt as CesiumMaterial,rt as addMaterialCache,st as arrayDiff,Je as assertError,Ze as canvasCoordToCartesian,Ce as cartesianToCanvasCoord,Qe as cesiumEquals,be as createCesiumAttribute,ct as createCesiumProperty,at as createPropertyField,$e as createViewer,et as degreesToDms,ne as dmsDecode,te as dmsEncode,tt as dmsToDegrees,ot as getMaterialCache,qe as isArray,Ye as isBase64,ze as isBoolean,Xe as isCesiumConstant,U as isDef,je as isElement,T as isFunction,He as isNumber,Be as isObject,ee as isPromise,K as isProperty,Ke as isString,Ue as isWindow,lt as pickHitGraphic,H as resolvePick,re as throttle,Se as toCartesian3,ut as toCartographic,Pe as toCoord,O as toPromiseValue,oe as toProperty,it as toPropertyValue,W as tryRun,vt as useCameraState,B as useCesiumEventListener,ht as useCesiumFps,M as useCollectionScope,mt as useDataSource,yt as useDataSourceScope,Et as useElementOverlay,pt as useEntity,wt as useEntityScope,At as useGraphicEvent,Lt as useImageryLayer,Tt as useImageryLayerScope,It as usePostProcessStage,Rt as usePostProcessStageScope,Wt as usePrimitive,Ot as usePrimitiveScope,xt as useScaleBar,kt as useSceneDrillPick,le as useScenePick,x as useScreenSpaceEventHandler,w as useViewer};
1
+ import{useMutationObserver as Le,tryOnScopeDispose as F,promiseTimeout as Te,refThrottled as j,watchThrottled as Ie,computedAsync as G,useElementBounding as ge,useElementSize as Re,watchImmediate as We}from"@vueuse/core";import{Viewer as _e,Ellipsoid as V,Cartesian3 as N,Math as I,Cartographic as $,defined as q,Material as Y,CallbackProperty as Oe,ConstantProperty as Me,Cartesian2 as J,ScreenSpaceEventHandler as xe,ScreenSpaceEventType as b,EllipsoidGeodesic as ke}from"cesium";import{shallowRef as L,shallowReadonly as he,provide as Fe,getCurrentScope as me,computed as h,watchEffect as S,toRaw as ye,toValue as y,markRaw as Ge,toRef as Q,inject as Ve,watch as R,ref as z,readonly as Ee,shallowReactive as Ne,nextTick as pe}from"vue";const X=Symbol("CREATE_VIEWER_INJECTION_KEY"),Z=new WeakMap;function $e(...e){const t=L(),o=he(t);Fe(X,o);const a=me();a&&Z.set(a,o);const r=h(()=>{var i;return(i=t.value)==null?void 0:i.canvas});return Le(document?.body,()=>{r.value&&!document?.body.contains(r.value)&&(t.value=void 0)},{childList:!0,subtree:!0}),S(i=>{const[n,l]=e,c=ye(y(n));if(c instanceof _e)t.value=Ge(c);else if(c){const s=c,f=l;t.value=new _e(s,f),i(()=>{var v,u;return!((v=t.value)!=null&&v.isDestroyed())&&((u=t.value)==null?void 0:u.destroy())})}else t.value=void 0}),F(()=>{t.value=void 0}),h(()=>{var i;return(i=t.value)!=null&&i.isDestroyed()?void 0:t.value})}function ze(e,t){const o=new Set(t),a=e.filter(n=>!o.has(n)),r=new Set(e),i=t?.filter(n=>!r.has(n))??[];return{added:a,removed:i}}function He(e,t,o="auto"){if(o==="pickPosition")return t.pickPosition(e);if(o==="globePick"){const a=t.camera.getPickRay(e);return a&&t.globe.pick(a,t)}else{if(t.globe.depthTestAgainstTerrain)return t.pickPosition(e);const a=t.pickPosition(e),r=t.camera.getPickRay(e),i=r&&t.globe.pick(r,t);if(!a)return i;const n=(a&&V.WGS84.cartesianToCartographic(a).height)??0,l=(i&&V.WGS84.cartesianToCartographic(i).height)??0;return n<l?a:i}}function we(e,t){return t.cartesianToCanvasCoordinates(e)}const Ce=Object.prototype.toString;function U(e){return typeof e<"u"}function Ke(e){return typeof e=="boolean"}function T(e){return typeof e=="function"}function Be(e){return typeof e=="number"}function Ue(e){return typeof e=="string"}function je(e){return Ce.call(e)==="[object Object]"}function qe(e){return typeof window<"u"&&Ce.call(e)==="[object Window]"}function ee(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Ye(e){return!!(e&&e.nodeName&&e.nodeType===1)}const Je=Array.isArray;function Qe(e){return/^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i.test(e)}function Xe(e,t){if(e)throw new Error(t)}function Ze(e,t){return e===t||T(e?.equals)&&e.equals(t)||T(t?.equals)&&t.equals(e)}function Pe(e,t={}){if(!e)return;const{type:o="Array",alt:a=!1}=t;let r,i,n;if(e instanceof N){const l=V.WGS84.cartesianToCartographic(e);r=I.toDegrees(l.longitude),i=I.toDegrees(l.latitude),n=l.height}else if(e instanceof $){const l=e;r=I.toDegrees(l.longitude),i=I.toDegrees(l.latitude),n=l.height}else Array.isArray(e)?(r=I.toDegrees(e[0]),i=I.toDegrees(e[1]),n=e[2]):(r=e.longitude,i=e.latitude,n=e.height);return o==="Array"?a?[r,i,n]:[r,i]:a?{longitude:r,latitude:i,height:n}:{longitude:r,latitude:i}}function te(e,t=3){const o=`${e}`;let a=o.indexOf(".");const r=a<0?o:o.slice(0,Math.max(0,a));let i="0",n="0";return a>0&&(i=`0${o.slice(Math.max(0,a))}`,i=`${+i*60}`,a=i.indexOf("."),a>0&&(n=`0${i.slice(Math.max(0,a))}`,i=i.slice(0,Math.max(0,a)),n=`${+n*60}`,a=n.indexOf("."),n=n.slice(0,Math.max(0,a+4)),n=(+n).toFixed(t))),`${Math.abs(+r)}\xB0${+i}\u2032${+n}\u2033`}function ne(e){const[t,o]=e.split("\xB0")??[],[a,r]=o?.split("\u2032")??[],i=r?.split("\u2033")[0],n=Number(t)||0,l=(Number(a)||0)/60,c=(Number(i)||0)/60/60,s=n+l+c;if(s===0)return 0;{let f=s;return["W","w","S","s"].includes(e[e.length-1])&&(f=-f),f}}function et(e,t=3){const o=Pe(e,{alt:!0});if(!o)return;const[a,r,i]=o,n=te(a,t),l=te(r,t);return[`${n}${a>0?"E":"W"}`,`${l}${r>0?"N":"S"}`,i]}function tt(e){const[t,o,a]=e,r=ne(t),i=ne(o);return[r,i,Number(a)||0]}function nt(e){return!q(e)||!!e.isConstant}class ot extends Y{constructor(t){super(t)}}function rt(e){return Y._materialCache.getMaterial(e)}function lt(e,t){return Y._materialCache.addMaterial(e,t)}function H(e={}){const{primitive:t,id:o,primitiveCollection:a,collection:r}=e,i=o&&o.entityCollection||null,n=i&&i.owner||null;return[...Array.isArray(o)?o:[o].filter(Boolean),t,a,r,i,n].filter(c=>!!c)}function it(e,t){if(!Array.isArray(t)||!t.length)return!1;const o=H(e);return o.length?o.some(a=>t.includes(a)):!1}function K(e){return e&&T(e.getValue)}function at(e,t){return K(e)?e.getValue(t):e}function oe(e,t=!1){return K(e)?e:T(e)?new Oe(e,t):new Me(e)}function ct(e,t,o,a){let r;const i=c=>{var s;r?.(),q(c?.definitionChanged)&&(r=(s=c?.definitionChanged)==null?void 0:s.addEventListener(()=>{e.definitionChanged.raiseEvent(e,t,c,c)}))},n=`_${t}`,l=oe(o);e[n]=l,i(l),a?Object.defineProperty(e,t,{get(){return e[n]}}):Object.defineProperty(e,t,{get(){return e[n]},set(c){const s=e[n];e[n]!==c&&(e[n]=c,i(c),q(e.definitionChanged)&&e.definitionChanged.raiseEvent(e,t,c,s))}})}function be(e,t,o,a={}){const r=!!a.toProperty,i=!!a.shallowClone,n=a.changedEventKey||"definitionChanged",l=Reflect.get(e,n),c=`_${String(t)}`,s=r?oe(o):o;Reflect.set(e,c,s);const f={get(){const d=Reflect.get(e,c);return i?Array.isArray(d)?[...d]:{...d}:d}};let v;const u=(d,g)=>{var E;v?.(),v=(E=d?.definitionChanged)==null?void 0:E.addEventListener(()=>{l?.raiseEvent.bind(l)(e,t,d,g)})};a.readonly||(r&&K(o)&&u(o),f.set=d=>{if(r&&!K(d))throw new Error(`The value of ${String(t)} must be a Cesium.Property object`);const g=Reflect.get(e,c);g!==d&&(Reflect.set(e,c,d),l?.raiseEvent.bind(l)(e,t,d,g),r&&u(d))}),Object.defineProperty(e,t,f)}function ut(e,t,o,a={}){return be(e,t,o,{...a,toProperty:!0})}function re(e,t=100,o=!0,a=!1){const r=[];let i=!1;const n=async()=>{if(await Te(t),i=!1,a)try{e(...r[0])}catch(l){console.error(l)}if(o&&(!a||r.length>1))try{e(...r[r.length-1])}catch(l){console.error(l)}r.length=0};return(...l)=>{r.length<2?r.push(l):r[1]=l,i||(i=!0,n())}}function Se(e){if(e)return e instanceof N?e.clone():e instanceof $?V.WGS84.cartographicToCartesian(e):Array.isArray(e)?N.fromDegrees(e[0],e[1],e[2]):N.fromDegrees(e.longitude,e.latitude,e.height)}function st(e){if(e)return e instanceof N?V.WGS84.cartesianToCartographic(e):e instanceof $?e.clone():Array.isArray(e)?$.fromDegrees(e[0],e[1],e[2]):$.fromDegrees(e.longitude,e.latitude,e.height)}function W(e){return(...t)=>{try{return e?.(...t)}catch(o){console.error(o)}}}async function O(e,t={}){try{const{raw:o=!0}=t;let a;if(T(e))a=await e();else{const r=y(e);a=ee(r)?await r:r}return o?ye(a):a}catch(o){throw console.error(o),o}}function B(e,t,o={}){const a=Q(o.isActive??!0),r=S(i=>{const n=y(e),l=Array.isArray(n)?n:[n];if(l&&l.length&&a.value){const c=l.map(s=>{const f=y(s);return f?.addEventListener(t,f)});i(()=>c.forEach(s=>s?.()))}});return F(r.stop),r.stop}function w(){const e=me(),t=e?Z.get(e):void 0;if(t)return t;{const o=Ve(X);if(!o)throw new Error("The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?");return o}}function vt(e={}){let t=e.camera;if(!t){const n=w();t=()=>{var l;return(l=n.value)==null?void 0:l.scene.camera}}const o=h(()=>y(t)),a=h(()=>{var n;const l=y(e.event)||"changed";return(n=o.value)==null?void 0:n[l]}),r=j(L(Symbol("camera change")),e.delay??8,!0,!1),i=()=>{r.value=Symbol("camera change")};return R(o,()=>i()),B(a,()=>i()),{camera:o,position:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.position)==null?void 0:l.clone():void 0}),direction:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.direction)==null?void 0:l.clone():void 0}),up:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.up)==null?void 0:l.clone():void 0}),right:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.right)==null?void 0:l.clone():void 0}),positionCartographic:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.positionCartographic)==null?void 0:l.clone():void 0}),positionWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.positionWC)==null?void 0:l.clone():void 0}),directionWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.directionWC)==null?void 0:l.clone():void 0}),upWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.directionWC)==null?void 0:l.clone():void 0}),rightWC:h(()=>{var n,l;return r.value?(l=(n=o.value)==null?void 0:n.directionWC)==null?void 0:l.clone():void 0}),viewRectangle:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.computeViewRectangle():void 0}),heading:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.heading:void 0}),pitch:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.pitch:void 0}),roll:h(()=>{var n;return r.value?(n=o.value)==null?void 0:n.roll:void 0}),level:h(()=>{var n,l;return r.value&&((l=(n=o.value)==null?void 0:n.positionCartographic)!=null&&l.height)?_t(o.value.positionCartographic.height):void 0})}}const dt=40487.57,ft=7096758e-11,gt=91610.74,De=-40467.74;function _t(e){return De+(dt-De)/(1+(e/gt)**ft)}function ht(e={}){const{delay:t=100}=e,o=w(),a=L(performance.now());B(()=>{var n;return(n=o.value)==null?void 0:n.scene.postRender},()=>a.value=performance.now());const r=z(0);Ie(a,(n,l)=>{r.value=n-l},{throttle:t});const i=h(()=>1e3/r.value);return{interval:Ee(r),fps:i}}function M(e,t,o){const a=Ne(new Set),r=(c,...s)=>{const f=e(c,...s);return ee(f)?new Promise((v,u)=>{f.then(d=>{a.add(d),v(d)}).catch(d=>u(d))}):(a.add(f),f)},i=(c,...s)=>(a.delete(c),t(c,...s)),n=(c,...s)=>{a.forEach(f=>{c(f)&&i(f,...s)})},l=(...c)=>{a.forEach(s=>{i(s,...c)})};return F(()=>l(...o)),{scope:he(a),add:r,remove:i,removeWhere:n,removeScope:l}}function mt(e,t={}){const{destroyOnRemove:o,collection:a,isActive:r=!0,evaluating:i}=t,n=G(()=>O(e),void 0,{evaluating:i}),l=w();return S(c=>{var s;if(y(r)){const v=Array.isArray(n.value)?[...n.value]:[n.value],u=a??((s=l.value)==null?void 0:s.dataSources);v.forEach(d=>d&&u?.add(d)),c(()=>{const d=y(o);!u?.isDestroyed()&&v.forEach(g=>g&&u?.remove(g,d))})}}),n}function yt(e={}){const{collection:t,destroyOnRemove:o}=e,a=w(),r=h(()=>{var u;return y(t)??((u=a.value)==null?void 0:u.dataSources)}),i=u=>{if(!r.value)throw new Error("collection is not defined");return r.value.add(u)},n=(u,d)=>{var g;return!!((g=r.value)!=null&&g.remove(u,d))},{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}=M(i,n,[o]);return{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}}function Et(e,t,o={}){const{referenceWindow:a,horizontal:r="center",vertical:i="bottom",offset:n={x:0,y:0}}=o,l=h(()=>Se(y(t))),c=w(),s=L();B(()=>{var _;return(_=c.value)==null?void 0:_.scene.postRender},()=>{var _;if((_=c.value)!=null&&_.scene)if(!l.value)s.value=void 0;else{const p=we(l.value,c.value.scene);s.value=J.equals(p,s.value)?s.value:p}});const f=ge(()=>{var _;return(_=c.value)==null?void 0:_.canvas.parentElement}),v=ge(e),u=h(()=>{const _=y(n);let p=_?.x??0;const C=y(r);C==="center"?p-=v.width.value/2:C==="right"&&(p-=v.width.value);let D=_?.y??0;const A=y(i);return A==="center"?D-=v.height.value/2:A==="bottom"&&(D-=v.height.value),{x:p,y:D}}),d=h(()=>{var _,p;const C={x:((_=s.value)==null?void 0:_.x)??0,y:((p=s.value)==null?void 0:p.y)??0};return y(a)&&(C.x+=f.x.value,C.y+=f.y.value),{x:u.value.x+C.x,y:u.value.y+C.y}}),g=h(()=>d.value.x),E=h(()=>d.value.y),m=h(()=>{var _,p;return{left:`${(_=g.value)==null?void 0:_.toFixed(2)}px`,top:`${(p=E.value)==null?void 0:p.toFixed(2)}px`}});return S(()=>{var _,p,C,D;const A=y(e);A&&y(o.applyStyle??!0)&&((p=(_=A.style)==null?void 0:_.setProperty)==null||p.call(_,"left",m.value.left),(D=(C=A.style)==null?void 0:C.setProperty)==null||D.call(C,"top",m.value.top))}),{x:g,y:E,style:m}}function pt(e,t={}){const{collection:o,isActive:a=!0,evaluating:r}=t,i=G(()=>O(e),[],{evaluating:r}),n=w();return S(l=>{var c;if(y(a)){const f=Array.isArray(i.value)?[...i.value]:[i.value],v=o??((c=n.value)==null?void 0:c.entities);f.forEach(u=>u&&v?.add(u)),l(()=>{f.forEach(u=>u&&v?.remove(u))})}}),i}function wt(e={}){const{collection:t}=e,o=w(),a=h(()=>{var v;return y(t)??((v=o.value)==null?void 0:v.entities)}),r=v=>{if(!a.value)throw new Error("collection is not defined");return a.value.contains(v)||a.value.add(v),v},i=v=>{var u;return!!((u=a.value)!=null&&u.remove(v))},{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}=M(r,i,[]);return{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}}const Ae=new WeakMap;function le(e,t={}){const{width:o=3,height:a=3,throttled:r=8}=t,i=Q(t.isActive??!0),n=w(),l=j(h(()=>{var s;return(s=y(e))==null?void 0:s.clone()}),r,!1,!0),c=L();return S(()=>{var s;if(n.value&&l.value&&i.value){const f=Ae.get(n.value);f&&f[0].equals(l.value)?c.value=f[1]:(Ae.set(n.value,[l.value.clone(),c.value]),c.value=(s=n.value)==null?void 0:s.scene.pick(l.value,y(o),y(a)))}}),c}function x(e,t,o={}){const{modifier:a}=o,r=w(),i=Q(o.isActive??!0),n=h(()=>{var f,v;if((v=(f=r.value)==null?void 0:f.cesiumWidget)!=null&&v.canvas)return new xe(r.value.cesiumWidget.canvas)}),l=R(n,(f,v)=>{var u;(u=r.value)!=null&&u.cesiumWidget&&v?.destroy()}),c=S(f=>{const v=y(e),u=y(a),d=y(n);!d||!i.value||!t||U(v)&&(d.setInputAction(t,v,u),f(()=>d.removeInputAction(v,u)))}),s=()=>{l(),c()};return F(s),s}function Ct(e){const t=L(),o=le(t),a=L(),r=z(!1),i=w(),n=z(!1);R(n,d=>{i.value&&(i.value.scene.screenSpaceCameraController.enableRotate=!d)});const l=()=>{n.value=!0},c=(d,g,E)=>{e({event:{startPosition:g.clone(),endPosition:E.clone()},pick:d,dragging:r.value,lockCamera:l}),pe(()=>{!r.value&&n.value&&(n.value=!1)})},s=x(b.LEFT_DOWN,d=>{r.value=!0,t.value=d.position.clone()}),f=x(b.MOUSE_MOVE,re(({startPosition:d,endPosition:g})=>{var E;a.value={startPosition:((E=a.value)==null?void 0:E.endPosition.clone())||d.clone(),endPosition:g.clone()}},8,!1,!0));R([o,a],([d,g])=>{if(d&&g){const{startPosition:E,endPosition:m}=g;r.value&&c(d,E,m)}});const v=x(b.LEFT_UP,d=>{r.value=!1,o.value&&a.value&&c(o.value,a.value.endPosition,d.position),t.value=void 0,a.value=void 0}),u=()=>{s(),f(),v()};return F(u),u}function Pt(e){const t=L(),o=le(()=>{var r;return(r=t.value)==null?void 0:r.endPosition}),a=(r,i,n,l)=>{e({event:{startPosition:i.clone(),endPosition:n.clone()},pick:r,hovering:l})};x(b.MOUSE_MOVE,({startPosition:r,endPosition:i})=>{var n,l;(!r.equals((n=t.value)==null?void 0:n.startPosition)||!i.equals((l=t.value)==null?void 0:l.endPosition))&&(t.value={startPosition:r.clone(),endPosition:i.clone()})}),R([o,t],([r,i])=>{if(r&&i){const{startPosition:n,endPosition:l}=i;a(r,n,l,!0)}}),R(o,(r,i)=>{if(i&&t.value){const{startPosition:n,endPosition:l}=t.value;a(i,n,l,!1)}})}const bt={LEFT_DOWN:b.LEFT_DOWN,LEFT_UP:b.LEFT_UP,LEFT_CLICK:b.LEFT_CLICK,LEFT_DOUBLE_CLICK:b.LEFT_DOUBLE_CLICK,RIGHT_DOWN:b.RIGHT_DOWN,RIGHT_UP:b.RIGHT_UP,RIGHT_CLICK:b.RIGHT_CLICK,MIDDLE_DOWN:b.MIDDLE_DOWN,MIDDLE_UP:b.MIDDLE_UP,MIDDLE_CLICK:b.MIDDLE_CLICK};function St(e,t){const o=bt[e],a=w();x(o,r=>{var i;const n=r.position,l=(i=a.value)==null?void 0:i.scene.pick(n);l&&n&&t({event:{position:n},pick:l})})}const k=Symbol("GLOBAL_GRAPHIC_SYMBOL"),Dt=["LEFT_DOWN","LEFT_UP","LEFT_CLICK","LEFT_DOUBLE_CLICK","RIGHT_DOWN","RIGHT_UP","RIGHT_CLICK","MIDDLE_DOWN","MIDDLE_UP","MIDDLE_CLICK"];function At(){const e=new WeakMap,t=new WeakMap,o=new WeakMap,a=(c,s,f)=>{var v,u,d,g,E,m,_,p,C,D,A,ie,ae,ce,ue,se,ve,de,fe;const P=c==="global"?k:c;(u=(v=e?.get(P))==null?void 0:v.get(s))==null||u.delete(f),(g=(d=t?.get(P))==null?void 0:d.get(s))==null||g.delete(f),((m=(E=e?.get(P))==null?void 0:E.get(s))==null?void 0:m.size)===0&&e.get(P).delete(s),((_=e.get(P))==null?void 0:_.size)===0&&e.delete(P),(C=(p=t?.get(P))==null?void 0:p.get(s))==null||C.delete(f),((A=(D=t?.get(P))==null?void 0:D.get(s))==null?void 0:A.size)===0&&((ie=t?.get(P))==null||ie.delete(s)),((ae=t?.get(P))==null?void 0:ae.size)===0&&t?.delete(P),(ue=(ce=o?.get(P))==null?void 0:ce.get(s))==null||ue.delete(f),((ve=(se=o?.get(P))==null?void 0:se.get(s))==null?void 0:ve.size)===0&&((de=o?.get(P))==null||de.delete(s)),((fe=o?.get(P))==null?void 0:fe.size)===0&&o?.delete(P)},r=(c,s,f,v={})=>{const u=c==="global"?k:c;e.get(u)??e.set(u,new Map);const d=e.get(u);d.get(s)??d.set(s,new Set),d.get(s).add(f);let{cursor:E="pointer",dragCursor:m}=v;if(U(E)){const _=T(E)?E:()=>E;t.get(u)??t.set(u,new Map),t.get(u).get(s)??t.get(u).set(s,new Map),t.get(u).get(s).set(f,_)}if(s==="DRAG"&&(m??(m=_=>_?.dragging?"crosshair":void 0)),U(m)){const _=T(m)?m:()=>m;o.get(u)??o.set(u,new Map),o.get(u).get(s)??o.get(u).set(s,new Map),o.get(u).get(s).set(f,_)}return()=>a(c,s,f)},i=(c,s)=>{var f,v,u,d,g,E;const m=c==="global"?k:c;if(s==="all"){e.delete(m),t.delete(m),o.delete(m);return}(f=e.get(m))==null||f.delete(s),((v=e.get(m))==null?void 0:v.size)===0&&e.delete(m),(u=t?.get(m))==null||u.delete(s),(d=o?.get(m))==null||d.delete(s),((g=t?.get(m))==null?void 0:g.size)===0&&t?.delete(m),((E=o?.get(m))==null?void 0:E.size)===0&&o?.delete(m)};for(const c of Dt)St(c,s=>{H(s.pick).concat(k).forEach(v=>{var u,d;(d=(u=e.get(v))==null?void 0:u.get(c))==null||d.forEach(g=>{var E;return(E=W(g))==null?void 0:E(s)})})});const n=z(!1),l=w();return Pt(c=>{H(c.pick).concat(k).forEach(f=>{var v,u,d;(u=(v=e.get(f))==null?void 0:v.get("HOVER"))==null||u.forEach(g=>{var E;return(E=W(g))==null?void 0:E(c)}),n.value||(d=t.get(f))==null||d.forEach(g=>{g.forEach(E=>{var m,_;const p=c.hovering?W(E)(c):"";(_=(m=l.value)==null?void 0:m.canvas.style)==null||_.setProperty("cursor",p)})})})}),Ct(c=>{const s=H(c.pick).concat(k);n.value=c.dragging,s.forEach(f=>{var v,u,d;(u=(v=e.get(f))==null?void 0:v.get("DRAG"))==null||u.forEach(g=>W(g)(c)),(d=o.get(f))==null||d.forEach(g=>{g.forEach(E=>{var m,_;const p=c.dragging?W(E)(c):"";(_=(m=l.value)==null?void 0:m.canvas.style)==null||_.setProperty("cursor",p)})})})}),{addGraphicEvent:r,removeGraphicEvent:a,clearGraphicEvent:i}}function Lt(e,t={}){const{destroyOnRemove:o,collection:a,isActive:r=!0,evaluating:i}=t,n=G(()=>O(e),[],{evaluating:i}),l=w();return S(c=>{var s;if(y(r)){const v=Array.isArray(n.value)?[...n.value]:[n.value],u=a??((s=l.value)==null?void 0:s.imageryLayers);if(a?.isDestroyed())return;v.forEach(d=>{if(!d){console.warn("ImageryLayer is undefined");return}if(d?.isDestroyed()){console.warn("ImageryLayer is destroyed");return}u?.add(d)}),c(()=>{const d=y(o);v.forEach(g=>g&&u?.remove(g,d))})}}),n}function Tt(e={}){const{collection:t,destroyOnRemove:o}=e,a=w(),r=h(()=>{var u;return y(t)??((u=a.value)==null?void 0:u.imageryLayers)}),i=(u,d)=>{if(!r.value)throw new Error("collection is not defined");return r.value.add(u,d),u},n=(u,d)=>{var g;return!!((g=r.value)!=null&&g.remove(u,d))},{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}=M(i,n,[o]);return{scope:l,add:c,remove:s,removeWhere:f,removeScope:v}}function It(e,t={}){const{collection:o,isActive:a=!0,evaluating:r}=t,i=G(()=>O(e),void 0,{evaluating:r}),n=w();return S(l=>{if(!n.value)return;if(y(a)){const s=Array.isArray(i.value)?[...i.value]:[i.value],f=o??n.value.scene.postProcessStages;s.forEach(v=>v&&f.add(v)),l(()=>{s.forEach(v=>v&&f.remove(v))})}}),i}function Rt(e={}){const{collection:t}=e,o=w(),a=h(()=>{var v;return y(t)??((v=o.value)==null?void 0:v.postProcessStages)}),r=v=>{if(!a.value)throw new Error("collection is not defined");return a.value.add(v)},i=v=>{var u;return!!((u=a.value)!=null&&u.remove(v))},{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}=M(r,i,[]);return{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}}function Wt(e,t={}){const{collection:o,isActive:a=!0,evaluating:r}=t,i=G(()=>O(e),void 0,{evaluating:r}),n=w();return S(l=>{var c,s;if(y(a)){const v=Array.isArray(i.value)?[...i.value]:[i.value],u=o==="ground"?(c=n.value)==null?void 0:c.scene.groundPrimitives:o??((s=n.value)==null?void 0:s.scene.primitives);v.forEach(d=>d&&u?.add(d)),l(()=>{!u?.isDestroyed()&&v.forEach(d=>d&&u?.remove(d))})}}),i}function Ot(e={}){const{collection:t}=e,o=w(),a=h(()=>{var v;return y(t)??((v=o.value)==null?void 0:v.scene.primitives)}),r=v=>{if(!a.value)throw new Error("collection is not defined");return a.value.add(v)},i=v=>{var u;return!!((u=a.value)!=null&&u.remove(v))},{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}=M(r,i,[]);return{scope:n,add:l,remove:c,removeWhere:s,removeScope:f}}const Mt=[.01,.05,.1,.5,1,2,3,5,10,20,30,50,100,200,300,500,1e3,2e3,3e3,5e3,1e4,2e4,3e4,5e4,1e5,2e5,3e5,5e5,1e6,2e6,3e6,5e6,1e7,2e7,3e7,5e7].reverse();function xt(e={}){const{maxPixel:t=80,delay:o=8}=e,a=h(()=>y(t)),r=w(),i=Re(()=>{var v;return(v=r.value)==null?void 0:v.canvas}),n=z(),l=async()=>{var v;await pe();const u=(v=r.value)==null?void 0:v.scene;if(!u)return;const d=u.camera.getPickRay(new J(Math.floor(i.width.value/2),i.height.value-1)),g=u.camera.getPickRay(new J(Math.floor(1+i.width.value/2),i.height.value-1));if(!d||!g)return;const E=u.globe.pick(d,u),m=u.globe.pick(g,u);if(!E||!m)return;const _=u.globe.ellipsoid.cartesianToCartographic(E),p=u.globe.ellipsoid.cartesianToCartographic(m),C=new ke(_,p);n.value=C.surfaceDistance};We(r,()=>l()),B(()=>{var v;return(v=r.value)==null?void 0:v.camera.changed},re(l,o));const c=h(()=>{if(n.value)return Mt.find(v=>n.value*a.value>v)}),s=h(()=>c.value&&n.value?c.value/n.value:0),f=h(()=>{if(c.value)return c.value>1e3?`${c.value/1e3||0}km`:`${c.value||0}m`});return{pixelDistance:Ee(n),width:s,distance:c,distanceText:f}}function kt(e,t={}){const{width:o=3,height:a=3,limit:r,throttled:i=8,isActive:n=!0}=t,l=w(),c=j(h(()=>y(e)),i,!1,!0);return h(()=>{var f;if(c.value&&y(n))return(f=l.value)==null?void 0:f.scene.drillPick(c.value,y(r),y(o),y(a))})}export{Z as CREATE_VIEWER_COLLECTION,X as CREATE_VIEWER_INJECTION_KEY,ot as CesiumMaterial,lt as addMaterialCache,ze as arrayDiff,Xe as assertError,He as canvasCoordToCartesian,we as cartesianToCanvasCoord,Ze as cesiumEquals,be as createCesiumAttribute,ut as createCesiumProperty,ct as createPropertyField,$e as createViewer,et as degreesToDms,ne as dmsDecode,te as dmsEncode,tt as dmsToDegrees,rt as getMaterialCache,Je as isArray,Qe as isBase64,Ke as isBoolean,nt as isCesiumConstant,U as isDef,Ye as isElement,T as isFunction,Be as isNumber,je as isObject,ee as isPromise,K as isProperty,Ue as isString,qe as isWindow,it as pickHitGraphic,H as resolvePick,re as throttle,Se as toCartesian3,st as toCartographic,Pe as toCoord,O as toPromiseValue,oe as toProperty,at as toPropertyValue,W as tryRun,vt as useCameraState,B as useCesiumEventListener,ht as useCesiumFps,M as useCollectionScope,mt as useDataSource,yt as useDataSourceScope,Et as useElementOverlay,pt as useEntity,wt as useEntityScope,At as useGraphicEvent,Lt as useImageryLayer,Tt as useImageryLayerScope,It as usePostProcessStage,Rt as usePostProcessStageScope,Wt as usePrimitive,Ot as usePrimitiveScope,xt as useScaleBar,kt as useSceneDrillPick,le as useScenePick,x as useScreenSpaceEventHandler,w as useViewer};
2
2
  //# sourceMappingURL=index.min.mjs.map