@vesium/plot 1.0.1-beta.37 → 1.0.1-beta.39

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
- var VesiumPlot=function(P,r,I,_,C){"use strict";var ce=Object.defineProperty,de=(i,e,t)=>e in i?ce(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,w=(i,e,t)=>de(i,typeof e!="symbol"?e+"":e,t);const ve=Symbol("CREATE_VIEWER_INJECTION_KEY"),ue=new WeakMap;async function Q(i,e={}){try{const{raw:t=!0}=e;let o;if(C.isFunction(i))o=await i();else{const n=_.toValue(i);o=C.isPromise(n)?await n:n}return t?_.toRaw(o):o}catch(t){throw console.error(t),t}}function H(i,e,t={}){const o=_.toRef(t.isActive??!0),n=_.watchEffect(l=>{const v=_.toValue(i),d=Array.isArray(v)?v:[v];if(d&&d.length&&o.value){const u=d.map(a=>{const p=_.toValue(a);return p?.addEventListener(e,p)});l(()=>u.forEach(a=>a?.()))}});return I.tryOnScopeDispose(n.stop),n.stop}function b(){const i=_.getCurrentScope(),e=i?ue.get(i):void 0;if(e)return e;{const t=_.inject(ve);if(!t)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 t}}function X(i,e,t){const o=_.shallowReactive(new Set),n=(u,...a)=>{const p=i(u,...a);return C.isPromise(p)?new Promise((h,s)=>{p.then(c=>{o.add(c),h(c)}).catch(c=>s(c))}):(o.add(p),p)},l=(u,...a)=>(o.delete(u),e(u,...a)),v=(u,...a)=>{o.forEach(p=>{u(p)&&l(p,...a)})},d=(...u)=>{o.forEach(a=>{l(a,...u)})};return I.tryOnScopeDispose(()=>d(...t)),{scope:_.shallowReadonly(o),add:n,remove:l,removeWhere:v,removeScope:d}}function Z(i,e={}){const{destroyOnRemove:t,collection:o,isActive:n=!0,evaluating:l}=e,v=I.computedAsync(()=>Q(i),void 0,{evaluating:l}),d=b();return _.watchEffect(u=>{var a;if(_.toValue(n)){const h=Array.isArray(v.value)?[...v.value]:[v.value],s=o??((a=d.value)==null?void 0:a.dataSources);h.forEach(c=>c&&s?.add(c)),u(()=>{const c=_.toValue(t);!s?.isDestroyed()&&h.forEach(g=>g&&s?.remove(g,c))})}}),v}function ee(i={}){const{collection:e}=i,t=b(),o=_.computed(()=>{var h;return _.toValue(e)??((h=t.value)==null?void 0:h.entities)}),n=h=>{if(!o.value)throw new Error("collection is not defined");return o.value.contains(h)||o.value.add(h),h},l=h=>{var s;return!!((s=o.value)!=null&&s.remove(h))},{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}=X(n,l,[]);return{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}}const te=new WeakMap;function j(i,e={}){const{width:t=3,height:o=3,throttled:n=8}=e,l=_.toRef(e.isActive??!0),v=b(),d=I.refThrottled(_.computed(()=>{var a;return(a=_.toValue(i))==null?void 0:a.clone()}),n,!1,!0),u=_.shallowRef();return _.watchEffect(()=>{var a;if(v.value&&d.value&&l.value){const p=te.get(v.value);p&&p[0].equals(d.value)?u.value=p[1]:(te.set(v.value,[d.value.clone(),u.value]),u.value=(a=v.value)==null?void 0:a.scene.pick(d.value,_.toValue(t),_.toValue(o)))}},{flush:"post"}),u}function A(i,e,t={}){const{modifier:o}=t,n=b(),l=_.toRef(t.isActive??!0),v=_.computed(()=>{var p,h;if((h=(p=n.value)==null?void 0:p.cesiumWidget)!=null&&h.canvas)return new r.ScreenSpaceEventHandler(n.value.cesiumWidget.canvas)}),d=_.watch(v,(p,h)=>{var s;(s=n.value)!=null&&s.cesiumWidget&&h?.destroy()}),u=_.watchEffect(p=>{const h=_.toValue(i),s=_.toValue(o),c=_.toValue(v);!c||!l.value||!e||C.isDef(h)&&(c.setInputAction(e,h,s),p(()=>c.removeInputAction(h,s)))}),a=()=>{d(),u()};return I.tryOnScopeDispose(a),a}function he(i){const e=_.shallowRef(),t=j(e),o=_.shallowRef(),n=_.ref(!1),l=b(),v=_.ref(!1);_.watch(v,c=>{l.value&&(l.value.scene.screenSpaceCameraController.enableRotate=!c)});const d=()=>{v.value=!0},u=(c,g,f)=>{i({event:{startPosition:g.clone(),endPosition:f.clone()},pick:c,dragging:n.value,lockCamera:d}),_.nextTick(()=>{!n.value&&v.value&&(v.value=!1)})},a=A(r.ScreenSpaceEventType.LEFT_DOWN,c=>{n.value=!0,e.value=c.position.clone()}),p=A(r.ScreenSpaceEventType.MOUSE_MOVE,C.throttle(({startPosition:c,endPosition:g})=>{var f;o.value={startPosition:((f=o.value)==null?void 0:f.endPosition.clone())||c.clone(),endPosition:g.clone()}},8,!1,!0));_.watch([t,o],([c,g])=>{if(c&&g){const{startPosition:f,endPosition:m}=g;n.value&&u(c,f,m)}});const h=A(r.ScreenSpaceEventType.LEFT_UP,c=>{n.value=!1,t.value&&o.value&&u(t.value,o.value.endPosition,c.position),e.value=void 0,o.value=void 0}),s=()=>{a(),p(),h()};return I.tryOnScopeDispose(s),s}function fe(i){const e=_.shallowRef(),t=j(()=>{var n;return(n=e.value)==null?void 0:n.endPosition}),o=(n,l,v,d)=>{i({event:{startPosition:l.clone(),endPosition:v.clone()},pick:n,hovering:d})};A(r.ScreenSpaceEventType.MOUSE_MOVE,({startPosition:n,endPosition:l})=>{var v,d;(!n.equals((v=e.value)==null?void 0:v.startPosition)||!l.equals((d=e.value)==null?void 0:d.endPosition))&&(e.value={startPosition:n.clone(),endPosition:l.clone()})}),_.watch([t,e],([n,l])=>{if(n&&l){const{startPosition:v,endPosition:d}=l;o(n,v,d,!0)}}),_.watch(t,(n,l)=>{if(l&&e.value){const{startPosition:v,endPosition:d}=e.value;o(l,v,d,!1)}})}const pe={LEFT_DOWN:r.ScreenSpaceEventType.LEFT_DOWN,LEFT_UP:r.ScreenSpaceEventType.LEFT_UP,LEFT_CLICK:r.ScreenSpaceEventType.LEFT_CLICK,LEFT_DOUBLE_CLICK:r.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,RIGHT_DOWN:r.ScreenSpaceEventType.RIGHT_DOWN,RIGHT_UP:r.ScreenSpaceEventType.RIGHT_UP,RIGHT_CLICK:r.ScreenSpaceEventType.RIGHT_CLICK,MIDDLE_DOWN:r.ScreenSpaceEventType.MIDDLE_DOWN,MIDDLE_UP:r.ScreenSpaceEventType.MIDDLE_UP,MIDDLE_CLICK:r.ScreenSpaceEventType.MIDDLE_CLICK};function ge(i,e){const t=pe[i],o=_.shallowRef(),n=j(o);A(t,l=>{o.value=l.position.clone()}),_.watch([o,n],([l,v])=>{v&&l&&e({event:{position:l},pick:v})})}const W=Symbol("GLOBAL_GRAPHIC_SYMBOL"),_e=["LEFT_DOWN","LEFT_UP","LEFT_CLICK","LEFT_DOUBLE_CLICK","RIGHT_DOWN","RIGHT_UP","RIGHT_CLICK","MIDDLE_DOWN","MIDDLE_UP","MIDDLE_CLICK"];function me(){const i=new WeakMap,e=new WeakMap,t=new WeakMap,o=(u,a,p)=>{var h,s,c,g,f,m,E,y,T,R,K,M,B,N,Y,L,z,F,O;const S=u==="global"?W:u;(s=(h=i?.get(S))==null?void 0:h.get(a))==null||s.delete(p),(g=(c=e?.get(S))==null?void 0:c.get(a))==null||g.delete(p),((m=(f=i?.get(S))==null?void 0:f.get(a))==null?void 0:m.size)===0&&i.get(S).delete(a),((E=i.get(S))==null?void 0:E.size)===0&&i.delete(S),(T=(y=e?.get(S))==null?void 0:y.get(a))==null||T.delete(p),((K=(R=e?.get(S))==null?void 0:R.get(a))==null?void 0:K.size)===0&&((M=e?.get(S))==null||M.delete(a)),((B=e?.get(S))==null?void 0:B.size)===0&&e?.delete(S),(Y=(N=t?.get(S))==null?void 0:N.get(a))==null||Y.delete(p),((z=(L=t?.get(S))==null?void 0:L.get(a))==null?void 0:z.size)===0&&((F=t?.get(S))==null||F.delete(a)),((O=t?.get(S))==null?void 0:O.size)===0&&t?.delete(S)},n=(u,a,p,h={})=>{const s=u==="global"?W:u;i.get(s)??i.set(s,new Map);const c=i.get(s);c.get(a)??c.set(a,new Set),c.get(a).add(p);let{cursor:f="pointer",dragCursor:m}=h;if(C.isDef(f)){const E=C.isFunction(f)?f:()=>f;e.get(s)??e.set(s,new Map),e.get(s).get(a)??e.get(s).set(a,new Map),e.get(s).get(a).set(p,E)}if(a==="DRAG"&&(m??(m=E=>E?.dragging?"crosshair":void 0)),C.isDef(m)){const E=C.isFunction(m)?m:()=>m;t.get(s)??t.set(s,new Map),t.get(s).get(a)??t.get(s).set(a,new Map),t.get(s).get(a).set(p,E)}return()=>o(u,a,p)},l=(u,a)=>{var p,h,s,c,g,f;const m=u==="global"?W:u;if(a==="all"){i.delete(m),e.delete(m),t.delete(m);return}(p=i.get(m))==null||p.delete(a),((h=i.get(m))==null?void 0:h.size)===0&&i.delete(m),(s=e?.get(m))==null||s.delete(a),(c=t?.get(m))==null||c.delete(a),((g=e?.get(m))==null?void 0:g.size)===0&&e?.delete(m),((f=t?.get(m))==null?void 0:f.size)===0&&t?.delete(m)};for(const u of _e)ge(u,a=>{C.resolvePick(a.pick).concat(W).forEach(h=>{var s,c;(c=(s=i.get(h))==null?void 0:s.get(u))==null||c.forEach(g=>{var f;return(f=C.tryRun(g))==null?void 0:f(a)})})});const v=_.ref(!1),d=b();return fe(u=>{C.resolvePick(u.pick).concat(W).forEach(p=>{var h,s,c;(s=(h=i.get(p))==null?void 0:h.get("HOVER"))==null||s.forEach(g=>{var f;return(f=C.tryRun(g))==null?void 0:f(u)}),v.value||(c=e.get(p))==null||c.forEach(g=>{g.forEach(f=>{var m,E;const y=u.hovering?C.tryRun(f)(u):"";(E=(m=d.value)==null?void 0:m.canvas.style)==null||E.setProperty("cursor",y)})})})}),he(u=>{const a=C.resolvePick(u.pick).concat(W);v.value=u.dragging,a.forEach(p=>{var h,s,c;(s=(h=i.get(p))==null?void 0:h.get("DRAG"))==null||s.forEach(g=>C.tryRun(g)(u)),(c=t.get(p))==null||c.forEach(g=>{g.forEach(f=>{var m,E;const y=u.dragging?C.tryRun(f)(u):"";(E=(m=d.value)==null?void 0:m.canvas.style)==null||E.setProperty("cursor",y)})})})}),{addGraphicEvent:n,removeGraphicEvent:o,clearGraphicEvent:l}}function ie(i,e={}){const{collection:t,isActive:o=!0,evaluating:n}=e,l=I.computedAsync(()=>Q(i),void 0,{evaluating:n}),v=b();return _.watchEffect(d=>{var u,a;if(_.toValue(o)){const h=Array.isArray(l.value)?[...l.value]:[l.value],s=t==="ground"?(u=v.value)==null?void 0:u.scene.groundPrimitives:t??((a=v.value)==null?void 0:a.scene.primitives);h.forEach(c=>c&&s?.add(c)),d(()=>{!s?.isDestroyed()&&h.forEach(c=>c&&s?.remove(c))})}}),l}function ne(i={}){const{collection:e}=i,t=b(),o=_.computed(()=>{var h;return _.toValue(e)??((h=t.value)==null?void 0:h.scene.primitives)}),n=h=>{if(!o.value)throw new Error("collection is not defined");return o.value.add(h)},l=h=>{var s;return!!((s=o.value)!=null&&s.remove(h))},{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}=X(n,l,[]);return{scope:v,add:d,remove:u,removeWhere:a,removeScope:p}}const oe=class G{constructor(e){w(this,"type"),w(this,"complete"),w(this,"forceComplete"),w(this,"definingCursor"),w(this,"skeletons"),w(this,"initEntites"),w(this,"initPrimitives"),w(this,"initGroundPrimitives"),w(this,"render");var t;this.type=e.type,this.complete=e.complete,this.forceComplete=e.forceComplete,this.definingCursor=e.definingCursor??"crosshair",this.skeletons=((t=e.skeletons)==null?void 0:t.map(o=>o()))??[],this.initEntites=e.initEntites,this.initPrimitives=e.initPrimitives,this.initGroundPrimitives=e.initGroundPrimitives,this.render=e.render}static getCacheTypes(){return[...this._record.keys()]}static getCache(e){return G._record.get(e)}static setCache(e){C.assertError(!e.type,"`scheme.type` is required"),G._record.set(e.type,e)}static resolve(e){if(typeof e=="string"){const t=G.getCache(e);return I.assert(!!t,`scheme ${e} not found`),t}else return e instanceof G?e:new G(e)}};w(oe,"_record",new Map);let k=oe;var se=(i=>(i[i.NEAR=0]="NEAR",i[i.CYCLE=1]="CYCLE",i[i.STRICT=2]="STRICT",i))(se||{});const Ee=(i,e,t,o)=>{var n,l,v;return o===0?{time:i,positions:(n=e.positions)==null?void 0:n.map(d=>d.clone()),derivative:e.derivative}:o===1?{time:i,positions:(l=t.positions)==null?void 0:l.map(d=>d.clone()),derivative:e.derivative}:{time:i,positions:(v=t.positions)==null?void 0:v.map((d,u)=>{var a;const p=(a=e.positions)==null?void 0:a[u];return p?r.Cartesian3.lerp(p,d,o,new r.Cartesian3):d}),derivative:e.derivative}},le=class ae{constructor(e){w(this,"strategy"),w(this,"interpolationAlgorithm"),w(this,"_times",[]),w(this,"_sampleds",[]),w(this,"_derivatives",[]),w(this,"_definitionChanged",new r.Event);var t;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(t=e?.packables)==null||t.forEach(o=>this.setSample(o)),this._times.length||this.setSample({time:r.JulianDate.now(),positions:[],derivative:void 0})}get isConstant(){return this._times.length===0}get definitionChanged(){return this._definitionChanged}getTimes(){return this._times.map(e=>e.clone())}getIndexScope(e){if(!this._times.length)return;const t=this._times[0],o=this._times[this._times.length-1];if(r.JulianDate.lessThan(e,t)||r.JulianDate.greaterThan(e,o))switch(this.strategy){case 2:return;case 0:{e=r.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break}case 1:{const a=r.JulianDate.toDate(this._times[0]).getTime(),h=r.JulianDate.toDate(this._times[this._times.length-1]).getTime()-a,c=(r.JulianDate.toDate(e).getTime()-a)%h,g=new Date(a+c);e=r.JulianDate.fromDate(g);break}}const n=this._times.findIndex(a=>r.JulianDate.lessThanOrEquals(e,a)),l=Math.min(n,this._times.length-1),v=r.JulianDate.toDate(this._times[n]).getTime(),d=r.JulianDate.toDate(this._times[l]).getTime(),u=r.JulianDate.toDate(e).getTime();return{prevIndex:n,nextIndex:l,proportion:(u-v)/(d-v)||0}}getValue(e,t){var o,n;if(t??(t={time:e}),Object.assign(t,{time:e.clone(),positions:void 0,derivative:void 0}),!e)return t.time=(o=this._times[0])==null?void 0:o.clone(),t.positions=(n=this._sampleds[0])==null?void 0:n.map(s=>s.clone(s)),t.derivative=this._derivatives[0],t;const l=this.getIndexScope(e);if(!l)return t;t.time=e;const{prevIndex:v,nextIndex:d,proportion:u}=l,a={time:this._times[v],positions:this._sampleds[v],derivative:this._derivatives[v]},p={time:this._times[d],positions:this._sampleds[d],derivative:this._derivatives[d]},h=(this.interpolationAlgorithm||ae.defaultInterpolationAlgorithm)(e,a,p,u);return Object.assign(t,h),t}setSample(e){var t;const o=e.time.clone(),n=((t=e.positions)==null?void 0:t.map(d=>d.clone()))??[],l=e.derivative,v=this._times.findIndex(d=>r.JulianDate.equals(o,d));v!==-1?(this._times[v]=o,this._sampleds[v]=n,this._derivatives[v]=e.derivative):this._times.length===0?(this._times[0]=o,this._sampleds[0]=n,this._derivatives[0]=e.derivative):r.JulianDate.lessThan(o,this._times[0])?(this._times.splice(0,0,o),this._sampleds.splice(0,0,n),this._derivatives.splice(0,0,l)):r.JulianDate.greaterThan(o,this._times[this._times.length-1])&&(this._times.push(o),this._sampleds.push(n),this._derivatives.push(l)),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(t=>this.setSample(t))}removeSample(e){const t=this._times.findIndex(o=>o.equals(e));return t!==-1&&(this._sampleds.splice(t,1),this._derivatives.splice(t,1),this._times.splice(t,1).length)?(this._definitionChanged.raiseEvent(this),!0):!1}removeSamples(e){for(let t=0;t<this._times.length;t++){const o=this._times[t];r.TimeInterval.contains(e,o)&&this.removeSample(o)}}equals(e){return e===this}};w(le,"defaultInterpolationAlgorithm",Ee);let q=le;class V{constructor(e){w(this,"_id"),w(this,"_scheme"),w(this,"_definitionChanged"),w(this,"_defining"),w(this,"_disabled"),w(this,"_sampled"),w(this,"_entities"),w(this,"_primitives"),w(this,"_groundPrimitives"),w(this,"_skeletons");var t,o,n,l,v,d;const{id:u,disabled:a=!1,sampled:p}=e;this._id=u||r.createGuid(),this._scheme=k.resolve(e.scheme),this._definitionChanged=new r.Event,this._defining=!0,this._disabled=a,this._sampled=p instanceof q?p:new q(p),this._sampled.definitionChanged.addEventListener(h=>this._definitionChanged.raiseEvent(this,"sampled",h,h),this),this._entities=[...((o=(t=this._scheme).initEntites)==null?void 0:o.call(t))??[]],this._primitives=[...((l=(n=this._scheme).initPrimitives)==null?void 0:l.call(n))??[]],this._groundPrimitives=[...((d=(v=this._scheme).initGroundPrimitives)==null?void 0:d.call(v))??[]],this._skeletons=[]}get id(){return this._id}get scheme(){return this._scheme}get definitionChanged(){return this._definitionChanged}get defining(){return this._defining}static setDefining(e,t){e._defining!==t&&(e._definitionChanged.raiseEvent(e,"defining",t,e._defining),e._defining=t)}get disabled(){return this._disabled}set disabled(e){this.disabled=e}get sampled(){return this._sampled}get entities(){return this._entities}set entities(e){this._definitionChanged.raiseEvent(this,"entities",e,this._entities),this._entities=e}get primitives(){return this._primitives}set primitives(e){this._definitionChanged.raiseEvent(this,"primitives",e,this._primitives),this._primitives=e}get groundPrimitives(){return this._groundPrimitives}set groundPrimitives(e){this._definitionChanged.raiseEvent(this,"groundPrimitives",e,this._groundPrimitives),this._groundPrimitives=e}get skeletons(){return this._skeletons}set skeletons(e){this._definitionChanged.raiseEvent(this,"skeletons",e,this._skeletons),this._skeletons=e}}class Ce{constructor(e={}){w(this,"_id"),w(this,"_isDestroyed");const{id:t}=e;this._id=t||r.createGuid(),this._isDestroyed=!1}get id(){return this._id}get collectionChanged(){return this._collectionChanged}get values(){return Array.from(this._values)}add(e){if(this._isDestroyed)throw new Error("PlotFeatureCollection is isDestroyed");return this._values.has(e)?!1:!!this._values.add(e)}remove(e){return this._values.delete(e)}get entities(){return this._dataSource.entities}get primitives(){return this._primitives}get groundPrimitives(){return this._groundPrimitives}get skeletons(){return this._skeletonDataSource.entities}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._viewer.dataSources.remove(this._dataSource),this._viewer.dataSources.remove(this._skeletonDataSource),this._viewer.scene.primitives.remove(this._primitives),this._viewer.scene.groundPrimitives.remove(this._groundPrimitives),this._viewer.dataSources.remove(this._skeletonDataSource),this._isDestroyed=!0)}}var D=(i=>(i[i.IDLE=0]="IDLE",i[i.HOVER=1]="HOVER",i[i.ACTIVE=2]="ACTIVE",i))(D||{});class U extends r.Entity{constructor(e){super(e)}}function we(i,e,t){const o=b(),n=ie(new r.PrimitiveCollection),l=ie(new r.PrimitiveCollection,{collection:"ground"}),v=Z(new r.CustomDataSource),d=ee({collection:()=>v.value.entities}),u=ne({collection:()=>n.value}),a=ne({collection:()=>l.value}),p=_.shallowRef();A(r.ScreenSpaceEventType.MOUSE_MOVE,s=>{p.value=C.canvasCoordToCartesian(s?.endPosition,o.value.scene)}),I.watchArray(i,(s,c,g,f=[])=>{f.forEach(m=>{d.removeWhere(E=>m.entities.includes(E)),u.removeWhere(E=>m.primitives.includes(E)),a.removeWhere(E=>m.groundPrimitives.includes(E))}),g.forEach(m=>{m.entities.forEach(E=>d.add(E)),m.primitives.forEach(E=>u.add(E)),m.groundPrimitives.forEach(E=>a.add(E))})},{immediate:!0,flush:"post"}),H(()=>i.value.map(s=>s.definitionChanged),(s,c,g,f)=>{if(c==="entities"){const{added:m,removed:E}=C.arrayDiff(g,f);m.forEach(y=>d.add(y)),E.forEach(y=>d.remove(y))}else if(c==="primitives"){const{added:m,removed:E}=C.arrayDiff(g,f);m.forEach(y=>u.add(y)),E.forEach(y=>u.remove(y))}else if(c==="groundPrimitives"){const{added:m,removed:E}=C.arrayDiff(g,f);m.forEach(y=>a.add(y)),E.forEach(y=>a.remove(y))}});const h=async s=>{var c,g;const f=await((g=(c=s.scheme).render)==null?void 0:g.call(c,{packable:s.sampled.getValue(t()),mouse:s.defining?p.value:void 0,defining:s.defining,previous:{entities:s.entities,primitives:s.primitives,groundPrimitives:s.groundPrimitives}}));s.entities=f?.entities??[],s.primitives=f?.primitives??[],s.groundPrimitives=f?.groundPrimitives??[]};return _.watch(e,(s,c)=>{c&&h(c)}),H(()=>i.value.map(s=>s.definitionChanged),(s,c)=>{["disabled","defining","scheme","sampled","time"].includes(c)&&h(s)}),_.watch(p,()=>{i.value.forEach(s=>s.defining&&h(s))}),{primitives:_.computed(()=>Array.from(u.scope)),groundPrimitives:_.computed(()=>Array.from(u.scope)),entities:_.computed(()=>Array.from(d.scope))}}function ye(i,e){const t=b(),o=_.ref(!1),n=_.computed(()=>{var d;return(d=i.value)==null?void 0:d.sampled.getValue(e())});A(r.ScreenSpaceEventType.LEFT_CLICK,async d=>{var u,a;if(await I.promiseTimeout(1),!i.value||!n.value||o.value)return;const{scheme:p,defining:h,sampled:s}=i.value;if(!h)return;const c=C.canvasCoordToCartesian(d.position,t.value.scene);if(!c)return;(u=n.value).positions??(u.positions=[]),n.value.positions.push(c),s.setSample(n.value),((a=p.complete)==null?void 0:a.call(p,n.value))&&V.setDefining(i.value,!1)}),A(r.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async d=>{var u;if(!i.value||!n.value)return;o.value=!0,await I.promiseTimeout(2),o.value=!1;const{scheme:a,defining:p}=i.value;if(!p||!C.canvasCoordToCartesian(d.position,t.value.scene))return;((u=a.forceComplete)==null?void 0:u.call(a,n.value))&&V.setDefining(i.value,!1)}),A(r.ScreenSpaceEventType.RIGHT_CLICK,async()=>{var d;if(!i.value||!n.value)return;const{defining:u,sampled:a}=i.value;u&&((d=n.value).positions??(d.positions=[]),n.value.positions.length!==0&&(n.value.positions.splice(n.value.positions.length-1,1),a.setSample(n.value)))});const l=_.ref(),v=()=>{var d,u;if(!((d=i.value)!=null&&d.defining))l.value&&(l.value=void 0,t.value.container.parentElement.style.removeProperty("cursor"));else{const a=i.value.scheme.definingCursor;l.value=C.isFunction(a)?a(n.value):a,l.value&&((u=t.value)==null||u.container.parentElement.style.setProperty("cursor",l.value))}};H(()=>{var d;return(d=i.value)==null?void 0:d.definitionChanged},(d,u)=>{(u==="defining"||u==="sampled")&&v()}),_.watch(i,()=>v())}function Pe(i,e,t){const o=b(),n=Z(new r.CustomDataSource),l=ee({collection:()=>n.value.entities}),v=_.shallowRef(),d=_.shallowRef(),u=h=>{var s,c;return h?((s=d.value)==null?void 0:s.id)===h.id?D.ACTIVE:((c=v.value)==null?void 0:c.id)===h.id?D.HOVER:D.IDLE:D.IDLE},a=C.throttle((h,s)=>{const c=h.skeletons,g=[];if(s||h.disabled)h.skeletons=[];else{const f=h.sampled.getValue(t()),m=h.defining,E=e.value===h;h.scheme.skeletons.forEach(T=>{var R;if(C.isFunction(T.disabled)?T.disabled({active:E,defining:m}):T.disabled)return;const M=((R=T.format)==null?void 0:R.call(T,f))??f?.positions??[];M.forEach((B,N)=>{var Y;let L=c.find(O=>O.index===N&&O.skeleton===T);const z=(Y=T.render)==null?void 0:Y.call(T,{defining:m,active:E,index:N,packable:f,positions:M,position:B,action:u(L)}),F=new U(z??{});L?F.propertyNames.forEach(O=>{O!=="id"&&(L[O]=F[O])}):L=F,L.plot=h,L.skeleton=T,L.index=N,g.push(L)})})}h.skeletons=g},1),{addGraphicEvent:p}=me();return _.watchEffect(h=>{const s=p("global","DRAG",({event:c,pick:g,dragging:f,lockCamera:m})=>{var E;if(g.id instanceof U&&l.scope.has(g.id)){const y=g.id,T=y.plot;if(T.defining)return;d.value=y;const R=y.skeleton,K=y.index,M=T.sampled.getValue(t());(E=R.onDrag)==null||E.call(R,{viewer:o.value,sampled:T.sampled,packable:M,active:e.value===T,index:K,event:c,dragging:f,lockCamera:m})}else d.value=void 0},{cursor:({pick:c})=>{var g;if(!((g=e.value)!=null&&g.defining)&&l.scope.has(c.id)){const f=c.id.skeleton;return C.isFunction(f?.cursor)?f.cursor(c):_.toValue(f?.cursor)}},dragCursor:({pick:c})=>{var g;if(!((g=e.value)!=null&&g.defining)&&l.scope.has(c.id)){const f=c.id.skeleton;return C.isFunction(f?.dragCursor)?f.dragCursor(c):_.toValue(f?.dragCursor)}}});h(s)}),I.onKeyStroke(h=>{var s;if(d.value){const c=d.value,g=c.plot,f=c.skeleton,m=c.index,E=g.sampled.getValue(t());(s=f.onKeyPressed)==null||s.call(f,{viewer:o.value,sampled:g.sampled,packable:E,index:m,keyEvent:h})}}),_.watchEffect(h=>{const s=p("global","HOVER",({hovering:c,pick:g})=>{if(c&&g.id instanceof U&&l.scope.has(g.id)){const f=g.id;v.value=f}else v.value=void 0});h(s)}),_.watchEffect(h=>{const s=p("global","LEFT_CLICK",({event:c,pick:g})=>{var f;if(g.id instanceof U&&l.scope.has(g.id)){const m=g.id;d.value=m;const E=m.plot,y=m.skeleton,T=m.index,R=E.sampled.getValue(t());(f=y.onLeftClick)==null||f.call(y,{viewer:o.value,sampled:E.sampled,packable:R,active:e.value===E,defining:E.defining,index:T,event:c})}else d.value=void 0});h(s)}),I.watchArray(i,(h,s,c,g=[])=>{c.forEach(f=>a(f)),g.forEach(f=>a(f,!0))}),H(()=>i.value.map(h=>h.definitionChanged),(h,s,c,g)=>{if(["disabled","defining","scheme","sampled","time"].includes(s)&&a(h),s==="skeletons"){const{added:f,removed:m}=C.arrayDiff(c,g);f.forEach(E=>l.add(E)),m.forEach(E=>l.remove(E))}}),_.watch(e,(h,s)=>{h&&a(h),s&&a(s)}),{dataSource:n}}function Te(i){const e=i?.time||_.shallowRef(),t=b(),o=()=>{var s,c,g;return((s=e.value)==null?void 0:s.clone())||((g=(c=t.value)==null?void 0:c.clock.currentTime)==null?void 0:g.clone())||r.JulianDate.now()},n=_.shallowReactive(new Set),l=_.computed(()=>Array.from(n)),v=_.shallowRef(),d=_.shallowRef();H([()=>{var s;return(s=v.value)==null?void 0:s.sampled.definitionChanged}],()=>{var s;d.value=(s=v.value)==null?void 0:s.sampled.getValue(o())}),ye(v,o),we(l,v,o),Pe(l,v,o),A(r.ScreenSpaceEventType.LEFT_CLICK,s=>{var c,g,f;if((c=v.value)!=null&&c.defining)return;const m=(g=t.value)==null?void 0:g.scene.pick(s.position.clone());if(!(((f=m?.id)==null?void 0:f.plot)instanceof V)){if(!m){v.value=void 0;return}v.value=l.value.find(E=>C.pickHitGraphic(m,[...E.entities,...E.primitives,...E.groundPrimitives]))}});let u,a;return _.watch(v,(s,c)=>{var g,f;if(c&&c.defining){const m=c.sampled.getValue(o());((f=(g=c.scheme).forceComplete)==null?void 0:f.call(g,m))?(V.setDefining(c,!1),u?.(c)):n.delete(c)}}),{plots:l,time:e,operate:async s=>new Promise((c,g)=>{u=c,a=g;const f=s instanceof V?s:new V(s);return n.has(f)||n.add(f),v.value=f,c(f)}),remove:s=>(s===v.value&&(v.value=void 0),n.has(s)?(n.delete(s),!0):!1),cancel:a}}function J(){return{disabled:({active:i})=>!i,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:i,sampled:e,packable:t,event:o,index:n,lockCamera:l}){l();const v=C.canvasCoordToCartesian(o.endPosition,i.scene);if(v){const d=[...t.positions??[]];d[n]=v,e.setSample({time:t.time,derivative:t.derivative,positions:d})}},onKeyPressed({viewer:i,keyEvent:e,sampled:t,packable:o,index:n}){var l;const v=(l=C.toCartographic(i.camera.position))==null?void 0:l.height;if(!v||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let d=0;switch(e.key){case"ArrowRight":d=Math.PI/2;break;case"ArrowDown":d=Math.PI;break;case"ArrowLeft":d=-Math.PI/2;break;case"ArrowUp":d=0;break}const u=(i.camera.heading+d)%(2*Math.PI),a=[...o.positions??[]],p=C.toCartographic(a[n]),s=v/1e5*Math.PI/180/1e3;p.latitude+=s*Math.cos(u),p.longitude+=s*Math.sin(u),a[n]=C.toCartesian3(p),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:i,action:e})=>{const t={[D.IDLE]:r.Color.BLUE.withAlpha(.4),[D.HOVER]:r.Color.BLUE.withAlpha(.6),[D.ACTIVE]:r.Color.AQUA.withAlpha(1)};return{position:i,point:{pixelSize:8,color:t[e],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:r.Color.WHITE.withAlpha(.4)}}}}}function $(){let i=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:"pointer",dragCursor:"crosshair",format(e){const t=e.positions??[];return t.length<2?[]:t.map((o,n)=>{const l=n===t.length-1?t[0]:t[n+1];return r.Cartesian3.midpoint(o,l,new r.Cartesian3)})},onDrag({viewer:e,sampled:t,packable:o,event:n,index:l,lockCamera:v,dragging:d}){v();const u=C.canvasCoordToCartesian(n.endPosition,e.scene);if(!u)return;const a=[...o.positions??[]];i===-1?(i=l,a.splice(l+1,0,u)):a[i+1]=u,d||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:e,action:t,active:o})=>{if(!o)return;const n={[D.IDLE]:r.Color.GREEN.withAlpha(.4),[D.HOVER]:r.Color.GREEN.withAlpha(.6),[D.ACTIVE]:r.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:n[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:r.Color.WHITE.withAlpha(.4)}}}}}function re(){let i=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:"pointer",dragCursor:"crosshair",format(e){const t=e.positions??[];if(t.length<2)return[];const o=[];for(let n=0;n<t.length-1;n++)o.push(r.Cartesian3.midpoint(t[n],t[n+1],new r.Cartesian3));return o},onDrag({viewer:e,sampled:t,packable:o,event:n,index:l,lockCamera:v,dragging:d}){v();const u=C.canvasCoordToCartesian(n.endPosition,e.scene);if(!u)return;const a=[...o.positions??[]];i===-1?(i=l,a.splice(l+1,0,u)):a[i+1]=u,d||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:e,action:t})=>{const o={[D.IDLE]:r.Color.GREEN.withAlpha(.4),[D.HOVER]:r.Color.GREEN.withAlpha(.6),[D.ACTIVE]:r.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:o[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:r.Color.WHITE.withAlpha(.4)}}}}}const De=`data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6"/></svg>')}`;function x(){return{disabled:({active:i,defining:e})=>!i||e,cursor:"pointer",dragCursor:"crosshair",format(i){const e=i.positions??[];if(e.length===0)return[];if(e.length===1)return[e[0]];{const t=r.Rectangle.center(r.Rectangle.fromCartesianArray(e));return[C.toCartesian3(t)]}},onDrag({viewer:i,sampled:e,packable:t,event:o,lockCamera:n,dragging:l}){l&&n();const v=C.canvasCoordToCartesian(o.startPosition,i.scene),d=C.canvasCoordToCartesian(o.endPosition,i.scene);if(!v||!d)return;const u=r.Cartesian3.subtract(d,v,new r.Cartesian3),a=[...t.positions??[]];e.setSample({time:t.time,derivative:t.derivative,positions:a.map(p=>r.Cartesian3.add(p,u,new r.Cartesian3))})},render:({position:i,action:e})=>{const t={[D.IDLE]:r.Color.WHITE,[D.HOVER]:r.Color.WHITE,[D.ACTIVE]:r.Color.AQUA.withAlpha(1)};return{position:i,billboard:{image:De,width:20,height:20,color:t[e],pixelOffset:new r.Cartesian3(0,-20),horizontalOrigin:r.HorizontalOrigin.CENTER,verticalOrigin:r.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}}}}}function Se(i){if(i.length<3)throw new Error("positions must >= 3");if(i.length===3)return[[i[0].clone(),i[1].clone(),i[2].clone()]];const e=r.CoplanarPolygonGeometry.createGeometry(r.CoplanarPolygonGeometry.fromPositions({positions:i,vertexFormat:r.VertexFormat.POSITION_ONLY}));if(!e)throw new Error("positions\u65E0\u6CD5\u7EC4\u6210\u6709\u6548\u7684geometry,\u68C0\u67E5\u70B9\u4F4D\u662F\u5426\u9519\u8BEF");const t=e.attributes.position.values,o=e.indices,n=[];for(let l=0;l<o.length;l+=3){const v=r.Cartesian3.unpack(t,o[l]*3,new r.Cartesian3),d=r.Cartesian3.unpack(t,o[l+1]*3,new r.Cartesian3),u=r.Cartesian3.unpack(t,o[l+2]*3,new r.Cartesian3);n.push([v,d,u])}return n}function Ie(i,e,t){const o=r.Cartesian3.subtract(i,e,new r.Cartesian3),n=r.Cartesian3.subtract(t,e,new r.Cartesian3),l=r.Cartesian3.cross(o,n,o);return r.Cartesian3.magnitude(l)*.5}function be(i){const t=r.ClassificationType.BOTH,o=Math.floor(10);return{scene:i?.scene,clampToGround:!1,classificationType:t,terrainProvider:i?.terrainProvider,density:o}}async function Le(i,e){if(i.length<2)throw new Error("positions.length must >= 2");const{density:t}=be(e);if(t<=0)throw new Error("options.density must > 0");return Se(i).reduce((n,l)=>n+=Ie(...l),0)}const Ae=new k({type:"measureArea",forceComplete:i=>i.positions.length>=3,skeletons:[J,$],initEntites:()=>[new r.Entity({label:{font:"14pt"},polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({label:{font:"14pt"},polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}}),l=[...o.positions??[]];return t&&l.push(t),l.length===2?(n.position=void 0,n.label.text=void 0,n.polygon.hierarchy=void 0,n.polyline.positions=new r.CallbackProperty(()=>l,!1)):l.length>=3?(l.push(l[0]),n.position=new r.ConstantPositionProperty(C.toCartesian3(r.Rectangle.center(r.Rectangle.fromCartesianArray(l)))),n.label.text=new r.ConstantProperty(""),Le(l).then(v=>{let d="";v/1e3/1e3>10?d=`${(v/1e3/1e3).toFixed(2)}km\xB2`:d=`${(+v).toFixed(2)}m\xB2`,n.label.text=new r.ConstantProperty(d)}),n.polyline.positions=void 0,n.polygon.hierarchy=new r.CallbackProperty(()=>l.length>=3?new r.PolygonHierarchy([...l]):void 0,!1)):(n.position=void 0,n.polygon.hierarchy=void 0,n.polyline.positions=void 0),{entities:[n]}}}),Re=new k({type:"billboard",complete:i=>i.positions.length>=1,skeletons:[x],initEntites:()=>[new r.Entity({billboard:{image:"/favicon.svg",width:32,height:32}})],render(i){var e,t;const{mouse:o,packable:n}=i,l=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({billboard:{}}),v=((t=n.positions)==null?void 0:t[0])??o;return l.position=new r.CallbackPositionProperty(()=>v,!0),{entities:[l]}}}),Oe=new k({type:"label",complete:i=>i.positions.length>=1,skeletons:[x],initEntites:()=>[new r.Entity({label:{text:"Label"}})],render(i){var e,t;const{mouse:o,packable:n}=i,l=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({label:{}}),v=((t=n.positions)==null?void 0:t[0])??o;return l.position=new r.CallbackPositionProperty(()=>v,!0),{entities:[l]}}}),ke=new k({type:"polygon",forceComplete:i=>i.positions.length>=3,skeletons:[J,$,x],initEntites:()=>[new r.Entity({polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({polyline:{material:r.Color.YELLOW.withAlpha(.5)},polygon:{material:r.Color.YELLOW.withAlpha(.5)}}),l=[...o.positions??[]];return t&&l.push(t),l.length===2?(n.polygon.hierarchy=void 0,n.polyline.positions=new r.CallbackProperty(()=>l,!1)):l.length>=3?(n.polyline.positions=void 0,n.polygon.hierarchy=new r.CallbackProperty(()=>(l.push(l[0]),l.length>=3?new r.PolygonHierarchy([...l]):void 0),!1)):(n.polygon.hierarchy=void 0,n.polyline.positions=void 0),{entities:[n]}}}),Ve=new k({type:"polyline",forceComplete:i=>i.positions.length>=2,skeletons:[J,re,x],initEntites:()=>[new r.Entity({polyline:{width:1}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new r.Entity({polyline:{}});return n.polyline.positions=new r.CallbackProperty(()=>{const l=[...o.positions??[]].concat(t?[t]:[]);return l.length>=2?l:[]},!1),{entities:[n]}}});return P.PlotAction=D,P.PlotFeature=V,P.PlotFeatureCollection=Ce,P.PlotScheme=k,P.PlotSkeletonEntity=U,P.SampledPlotProperty=q,P.SampledPlotStrategy=se,P.control=J,P.interval=$,P.intervalNonclosed=re,P.moved=x,P.schemeBillboard=Re,P.schemeLabel=Oe,P.schemeMeasureArea=Ae,P.schemePolygon=ke,P.schemePolyline=Ve,P.usePlot=Te,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({},Cesium,VueUse,Vue,VesiumShared);
1
+ var VesiumPlot=function(P,l,I,_,C){"use strict";var ce=Object.defineProperty,de=(i,e,t)=>e in i?ce(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,w=(i,e,t)=>de(i,typeof e!="symbol"?e+"":e,t);const ve=Symbol("CREATE_VIEWER_INJECTION_KEY"),ue=new WeakMap;async function $(i,e={}){try{const{raw:t=!0}=e;let o;if(C.isFunction(i))o=await i();else{const n=_.toValue(i);o=C.isPromise(n)?await n:n}return t?_.toRaw(o):o}catch(t){throw console.error(t),t}}function H(i,e,t={}){const o=_.toRef(t.isActive??!0),n=_.watchEffect(r=>{const v=_.toValue(i),c=Array.isArray(v)?v:[v];if(c&&c.length&&o.value){const u=c.map(a=>{const f=_.toValue(a);return f?.addEventListener(e,f)});r(()=>u.forEach(a=>a?.()))}});return I.tryOnScopeDispose(n.stop),n.stop}function b(){const i=_.getCurrentScope(),e=i?ue.get(i):void 0;if(e)return e;{const t=_.inject(ve);if(!t)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 t}}function Q(i,e,t){const o=_.shallowReactive(new Set),n=(u,...a)=>{const f=i(u,...a);return C.isPromise(f)?new Promise((h,s)=>{f.then(d=>{o.add(d),h(d)}).catch(d=>s(d))}):(o.add(f),f)},r=(u,...a)=>(o.delete(u),e(u,...a)),v=(u,...a)=>{o.forEach(f=>{u(f)&&r(f,...a)})},c=(...u)=>{o.forEach(a=>{r(a,...u)})};return I.tryOnScopeDispose(()=>c(...t)),{scope:_.shallowReadonly(o),add:n,remove:r,removeWhere:v,removeScope:c}}function X(i,e={}){const{destroyOnRemove:t,collection:o,isActive:n=!0,evaluating:r}=e,v=I.computedAsync(()=>$(i),void 0,{evaluating:r}),c=b();return _.watchEffect(u=>{var a;if(_.toValue(n)){const h=Array.isArray(v.value)?[...v.value]:[v.value],s=o??((a=c.value)==null?void 0:a.dataSources);h.forEach(d=>d&&s?.add(d)),u(()=>{const d=_.toValue(t);!s?.isDestroyed()&&h.forEach(g=>g&&s?.remove(g,d))})}}),v}function Z(i={}){const{collection:e}=i,t=b(),o=_.computed(()=>{var h;return _.toValue(e)??((h=t.value)==null?void 0:h.entities)}),n=h=>{if(!o.value)throw new Error("collection is not defined");return o.value.contains(h)||o.value.add(h),h},r=h=>{var s;return!!((s=o.value)!=null&&s.remove(h))},{scope:v,add:c,remove:u,removeWhere:a,removeScope:f}=Q(n,r,[]);return{scope:v,add:c,remove:u,removeWhere:a,removeScope:f}}const ee=new WeakMap;function te(i,e={}){const{width:t=3,height:o=3,throttled:n=8}=e,r=_.toRef(e.isActive??!0),v=b(),c=I.refThrottled(_.computed(()=>{var a;return(a=_.toValue(i))==null?void 0:a.clone()}),n,!1,!0),u=_.shallowRef();return _.watchEffect(()=>{var a;if(v.value&&c.value&&r.value){const f=ee.get(v.value);f&&f[0].equals(c.value)?u.value=f[1]:(ee.set(v.value,[c.value.clone(),u.value]),u.value=(a=v.value)==null?void 0:a.scene.pick(c.value,_.toValue(t),_.toValue(o)))}}),u}function A(i,e,t={}){const{modifier:o}=t,n=b(),r=_.toRef(t.isActive??!0),v=_.computed(()=>{var f,h;if((h=(f=n.value)==null?void 0:f.cesiumWidget)!=null&&h.canvas)return new l.ScreenSpaceEventHandler(n.value.cesiumWidget.canvas)}),c=_.watch(v,(f,h)=>{var s;(s=n.value)!=null&&s.cesiumWidget&&h?.destroy()}),u=_.watchEffect(f=>{const h=_.toValue(i),s=_.toValue(o),d=_.toValue(v);!d||!r.value||!e||C.isDef(h)&&(d.setInputAction(e,h,s),f(()=>d.removeInputAction(h,s)))}),a=()=>{c(),u()};return I.tryOnScopeDispose(a),a}function he(i){const e=_.shallowRef(),t=te(e),o=_.shallowRef(),n=_.ref(!1),r=b(),v=_.ref(!1);_.watch(v,d=>{r.value&&(r.value.scene.screenSpaceCameraController.enableRotate=!d)});const c=()=>{v.value=!0},u=(d,g,p)=>{i({event:{startPosition:g.clone(),endPosition:p.clone()},pick:d,dragging:n.value,lockCamera:c}),_.nextTick(()=>{!n.value&&v.value&&(v.value=!1)})},a=A(l.ScreenSpaceEventType.LEFT_DOWN,d=>{n.value=!0,e.value=d.position.clone()}),f=A(l.ScreenSpaceEventType.MOUSE_MOVE,C.throttle(({startPosition:d,endPosition:g})=>{var p;o.value={startPosition:((p=o.value)==null?void 0:p.endPosition.clone())||d.clone(),endPosition:g.clone()}},8,!1,!0));_.watch([t,o],([d,g])=>{if(d&&g){const{startPosition:p,endPosition:m}=g;n.value&&u(d,p,m)}});const h=A(l.ScreenSpaceEventType.LEFT_UP,d=>{n.value=!1,t.value&&o.value&&u(t.value,o.value.endPosition,d.position),e.value=void 0,o.value=void 0}),s=()=>{a(),f(),h()};return I.tryOnScopeDispose(s),s}function pe(i){const e=_.shallowRef(),t=te(()=>{var n;return(n=e.value)==null?void 0:n.endPosition}),o=(n,r,v,c)=>{i({event:{startPosition:r.clone(),endPosition:v.clone()},pick:n,hovering:c})};A(l.ScreenSpaceEventType.MOUSE_MOVE,({startPosition:n,endPosition:r})=>{var v,c;(!n.equals((v=e.value)==null?void 0:v.startPosition)||!r.equals((c=e.value)==null?void 0:c.endPosition))&&(e.value={startPosition:n.clone(),endPosition:r.clone()})}),_.watch([t,e],([n,r])=>{if(n&&r){const{startPosition:v,endPosition:c}=r;o(n,v,c,!0)}}),_.watch(t,(n,r)=>{if(r&&e.value){const{startPosition:v,endPosition:c}=e.value;o(r,v,c,!1)}})}const fe={LEFT_DOWN:l.ScreenSpaceEventType.LEFT_DOWN,LEFT_UP:l.ScreenSpaceEventType.LEFT_UP,LEFT_CLICK:l.ScreenSpaceEventType.LEFT_CLICK,LEFT_DOUBLE_CLICK:l.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,RIGHT_DOWN:l.ScreenSpaceEventType.RIGHT_DOWN,RIGHT_UP:l.ScreenSpaceEventType.RIGHT_UP,RIGHT_CLICK:l.ScreenSpaceEventType.RIGHT_CLICK,MIDDLE_DOWN:l.ScreenSpaceEventType.MIDDLE_DOWN,MIDDLE_UP:l.ScreenSpaceEventType.MIDDLE_UP,MIDDLE_CLICK:l.ScreenSpaceEventType.MIDDLE_CLICK};function ge(i,e){const t=fe[i],o=b();A(t,n=>{var r;const v=n.position,c=(r=o.value)==null?void 0:r.scene.pick(v);c&&v&&e({event:{position:v},pick:c})})}const W=Symbol("GLOBAL_GRAPHIC_SYMBOL"),_e=["LEFT_DOWN","LEFT_UP","LEFT_CLICK","LEFT_DOUBLE_CLICK","RIGHT_DOWN","RIGHT_UP","RIGHT_CLICK","MIDDLE_DOWN","MIDDLE_UP","MIDDLE_CLICK"];function me(){const i=new WeakMap,e=new WeakMap,t=new WeakMap,o=(u,a,f)=>{var h,s,d,g,p,m,E,y,T,R,K,M,B,N,Y,L,z,F,O;const S=u==="global"?W:u;(s=(h=i?.get(S))==null?void 0:h.get(a))==null||s.delete(f),(g=(d=e?.get(S))==null?void 0:d.get(a))==null||g.delete(f),((m=(p=i?.get(S))==null?void 0:p.get(a))==null?void 0:m.size)===0&&i.get(S).delete(a),((E=i.get(S))==null?void 0:E.size)===0&&i.delete(S),(T=(y=e?.get(S))==null?void 0:y.get(a))==null||T.delete(f),((K=(R=e?.get(S))==null?void 0:R.get(a))==null?void 0:K.size)===0&&((M=e?.get(S))==null||M.delete(a)),((B=e?.get(S))==null?void 0:B.size)===0&&e?.delete(S),(Y=(N=t?.get(S))==null?void 0:N.get(a))==null||Y.delete(f),((z=(L=t?.get(S))==null?void 0:L.get(a))==null?void 0:z.size)===0&&((F=t?.get(S))==null||F.delete(a)),((O=t?.get(S))==null?void 0:O.size)===0&&t?.delete(S)},n=(u,a,f,h={})=>{const s=u==="global"?W:u;i.get(s)??i.set(s,new Map);const d=i.get(s);d.get(a)??d.set(a,new Set),d.get(a).add(f);let{cursor:p="pointer",dragCursor:m}=h;if(C.isDef(p)){const E=C.isFunction(p)?p:()=>p;e.get(s)??e.set(s,new Map),e.get(s).get(a)??e.get(s).set(a,new Map),e.get(s).get(a).set(f,E)}if(a==="DRAG"&&(m??(m=E=>E?.dragging?"crosshair":void 0)),C.isDef(m)){const E=C.isFunction(m)?m:()=>m;t.get(s)??t.set(s,new Map),t.get(s).get(a)??t.get(s).set(a,new Map),t.get(s).get(a).set(f,E)}return()=>o(u,a,f)},r=(u,a)=>{var f,h,s,d,g,p;const m=u==="global"?W:u;if(a==="all"){i.delete(m),e.delete(m),t.delete(m);return}(f=i.get(m))==null||f.delete(a),((h=i.get(m))==null?void 0:h.size)===0&&i.delete(m),(s=e?.get(m))==null||s.delete(a),(d=t?.get(m))==null||d.delete(a),((g=e?.get(m))==null?void 0:g.size)===0&&e?.delete(m),((p=t?.get(m))==null?void 0:p.size)===0&&t?.delete(m)};for(const u of _e)ge(u,a=>{C.resolvePick(a.pick).concat(W).forEach(h=>{var s,d;(d=(s=i.get(h))==null?void 0:s.get(u))==null||d.forEach(g=>{var p;return(p=C.tryRun(g))==null?void 0:p(a)})})});const v=_.ref(!1),c=b();return pe(u=>{C.resolvePick(u.pick).concat(W).forEach(f=>{var h,s,d;(s=(h=i.get(f))==null?void 0:h.get("HOVER"))==null||s.forEach(g=>{var p;return(p=C.tryRun(g))==null?void 0:p(u)}),v.value||(d=e.get(f))==null||d.forEach(g=>{g.forEach(p=>{var m,E;const y=u.hovering?C.tryRun(p)(u):"";(E=(m=c.value)==null?void 0:m.canvas.style)==null||E.setProperty("cursor",y)})})})}),he(u=>{const a=C.resolvePick(u.pick).concat(W);v.value=u.dragging,a.forEach(f=>{var h,s,d;(s=(h=i.get(f))==null?void 0:h.get("DRAG"))==null||s.forEach(g=>C.tryRun(g)(u)),(d=t.get(f))==null||d.forEach(g=>{g.forEach(p=>{var m,E;const y=u.dragging?C.tryRun(p)(u):"";(E=(m=c.value)==null?void 0:m.canvas.style)==null||E.setProperty("cursor",y)})})})}),{addGraphicEvent:n,removeGraphicEvent:o,clearGraphicEvent:r}}function ie(i,e={}){const{collection:t,isActive:o=!0,evaluating:n}=e,r=I.computedAsync(()=>$(i),void 0,{evaluating:n}),v=b();return _.watchEffect(c=>{var u,a;if(_.toValue(o)){const h=Array.isArray(r.value)?[...r.value]:[r.value],s=t==="ground"?(u=v.value)==null?void 0:u.scene.groundPrimitives:t??((a=v.value)==null?void 0:a.scene.primitives);h.forEach(d=>d&&s?.add(d)),c(()=>{!s?.isDestroyed()&&h.forEach(d=>d&&s?.remove(d))})}}),r}function ne(i={}){const{collection:e}=i,t=b(),o=_.computed(()=>{var h;return _.toValue(e)??((h=t.value)==null?void 0:h.scene.primitives)}),n=h=>{if(!o.value)throw new Error("collection is not defined");return o.value.add(h)},r=h=>{var s;return!!((s=o.value)!=null&&s.remove(h))},{scope:v,add:c,remove:u,removeWhere:a,removeScope:f}=Q(n,r,[]);return{scope:v,add:c,remove:u,removeWhere:a,removeScope:f}}const oe=class G{constructor(e){w(this,"type"),w(this,"complete"),w(this,"forceComplete"),w(this,"definingCursor"),w(this,"skeletons"),w(this,"initEntites"),w(this,"initPrimitives"),w(this,"initGroundPrimitives"),w(this,"render");var t;this.type=e.type,this.complete=e.complete,this.forceComplete=e.forceComplete,this.definingCursor=e.definingCursor??"crosshair",this.skeletons=((t=e.skeletons)==null?void 0:t.map(o=>o()))??[],this.initEntites=e.initEntites,this.initPrimitives=e.initPrimitives,this.initGroundPrimitives=e.initGroundPrimitives,this.render=e.render}static getCacheTypes(){return[...this._record.keys()]}static getCache(e){return G._record.get(e)}static setCache(e){C.assertError(!e.type,"`scheme.type` is required"),G._record.set(e.type,e)}static resolve(e){if(typeof e=="string"){const t=G.getCache(e);return I.assert(!!t,`scheme ${e} not found`),t}else return e instanceof G?e:new G(e)}};w(oe,"_record",new Map);let k=oe;var se=(i=>(i[i.NEAR=0]="NEAR",i[i.CYCLE=1]="CYCLE",i[i.STRICT=2]="STRICT",i))(se||{});const Ee=(i,e,t,o)=>{var n,r,v;return o===0?{time:i,positions:(n=e.positions)==null?void 0:n.map(c=>c.clone()),derivative:e.derivative}:o===1?{time:i,positions:(r=t.positions)==null?void 0:r.map(c=>c.clone()),derivative:e.derivative}:{time:i,positions:(v=t.positions)==null?void 0:v.map((c,u)=>{var a;const f=(a=e.positions)==null?void 0:a[u];return f?l.Cartesian3.lerp(f,c,o,new l.Cartesian3):c}),derivative:e.derivative}},re=class ae{constructor(e){w(this,"strategy"),w(this,"interpolationAlgorithm"),w(this,"_times",[]),w(this,"_sampleds",[]),w(this,"_derivatives",[]),w(this,"_definitionChanged",new l.Event);var t;this.interpolationAlgorithm=e?.interpolationAlgorithm,this.strategy=e?.strategy??0,(t=e?.packables)==null||t.forEach(o=>this.setSample(o)),this._times.length||this.setSample({time:l.JulianDate.now(),positions:[],derivative:void 0})}get isConstant(){return this._times.length===0}get definitionChanged(){return this._definitionChanged}getTimes(){return this._times.map(e=>e.clone())}getIndexScope(e){if(!this._times.length)return;const t=this._times[0],o=this._times[this._times.length-1];if(l.JulianDate.lessThan(e,t)||l.JulianDate.greaterThan(e,o))switch(this.strategy){case 2:return;case 0:{e=l.JulianDate.lessThan(e,this._times[0])?this._times[0].clone():this._times[this._times.length-1].clone();break}case 1:{const a=l.JulianDate.toDate(this._times[0]).getTime(),h=l.JulianDate.toDate(this._times[this._times.length-1]).getTime()-a,d=(l.JulianDate.toDate(e).getTime()-a)%h,g=new Date(a+d);e=l.JulianDate.fromDate(g);break}}const n=this._times.findIndex(a=>l.JulianDate.lessThanOrEquals(e,a)),r=Math.min(n,this._times.length-1),v=l.JulianDate.toDate(this._times[n]).getTime(),c=l.JulianDate.toDate(this._times[r]).getTime(),u=l.JulianDate.toDate(e).getTime();return{prevIndex:n,nextIndex:r,proportion:(u-v)/(c-v)||0}}getValue(e,t){var o,n;if(t??(t={time:e}),Object.assign(t,{time:e.clone(),positions:void 0,derivative:void 0}),!e)return t.time=(o=this._times[0])==null?void 0:o.clone(),t.positions=(n=this._sampleds[0])==null?void 0:n.map(s=>s.clone(s)),t.derivative=this._derivatives[0],t;const r=this.getIndexScope(e);if(!r)return t;t.time=e;const{prevIndex:v,nextIndex:c,proportion:u}=r,a={time:this._times[v],positions:this._sampleds[v],derivative:this._derivatives[v]},f={time:this._times[c],positions:this._sampleds[c],derivative:this._derivatives[c]},h=(this.interpolationAlgorithm||ae.defaultInterpolationAlgorithm)(e,a,f,u);return Object.assign(t,h),t}setSample(e){var t;const o=e.time.clone(),n=((t=e.positions)==null?void 0:t.map(c=>c.clone()))??[],r=e.derivative,v=this._times.findIndex(c=>l.JulianDate.equals(o,c));v!==-1?(this._times[v]=o,this._sampleds[v]=n,this._derivatives[v]=e.derivative):this._times.length===0?(this._times[0]=o,this._sampleds[0]=n,this._derivatives[0]=e.derivative):l.JulianDate.lessThan(o,this._times[0])?(this._times.splice(0,0,o),this._sampleds.splice(0,0,n),this._derivatives.splice(0,0,r)):l.JulianDate.greaterThan(o,this._times[this._times.length-1])&&(this._times.push(o),this._sampleds.push(n),this._derivatives.push(r)),this.definitionChanged.raiseEvent(this)}setSamples(e){e.forEach(t=>this.setSample(t))}removeSample(e){const t=this._times.findIndex(o=>o.equals(e));return t!==-1&&(this._sampleds.splice(t,1),this._derivatives.splice(t,1),this._times.splice(t,1).length)?(this._definitionChanged.raiseEvent(this),!0):!1}removeSamples(e){for(let t=0;t<this._times.length;t++){const o=this._times[t];l.TimeInterval.contains(e,o)&&this.removeSample(o)}}equals(e){return e===this}};w(re,"defaultInterpolationAlgorithm",Ee);let j=re;class V{constructor(e){w(this,"_id"),w(this,"_scheme"),w(this,"_definitionChanged"),w(this,"_defining"),w(this,"_disabled"),w(this,"_sampled"),w(this,"_entities"),w(this,"_primitives"),w(this,"_groundPrimitives"),w(this,"_skeletons");var t,o,n,r,v,c;const{id:u,disabled:a=!1,sampled:f}=e;this._id=u||l.createGuid(),this._scheme=k.resolve(e.scheme),this._definitionChanged=new l.Event,this._defining=!0,this._disabled=a,this._sampled=f instanceof j?f:new j(f),this._sampled.definitionChanged.addEventListener(h=>this._definitionChanged.raiseEvent(this,"sampled",h,h),this),this._entities=[...((o=(t=this._scheme).initEntites)==null?void 0:o.call(t))??[]],this._primitives=[...((r=(n=this._scheme).initPrimitives)==null?void 0:r.call(n))??[]],this._groundPrimitives=[...((c=(v=this._scheme).initGroundPrimitives)==null?void 0:c.call(v))??[]],this._skeletons=[]}get id(){return this._id}get scheme(){return this._scheme}get definitionChanged(){return this._definitionChanged}get defining(){return this._defining}static setDefining(e,t){e._defining!==t&&(e._definitionChanged.raiseEvent(e,"defining",t,e._defining),e._defining=t)}get disabled(){return this._disabled}set disabled(e){this.disabled=e}get sampled(){return this._sampled}get entities(){return this._entities}set entities(e){this._definitionChanged.raiseEvent(this,"entities",e,this._entities),this._entities=e}get primitives(){return this._primitives}set primitives(e){this._definitionChanged.raiseEvent(this,"primitives",e,this._primitives),this._primitives=e}get groundPrimitives(){return this._groundPrimitives}set groundPrimitives(e){this._definitionChanged.raiseEvent(this,"groundPrimitives",e,this._groundPrimitives),this._groundPrimitives=e}get skeletons(){return this._skeletons}set skeletons(e){this._definitionChanged.raiseEvent(this,"skeletons",e,this._skeletons),this._skeletons=e}}class Ce{constructor(e={}){w(this,"_id"),w(this,"_isDestroyed");const{id:t}=e;this._id=t||l.createGuid(),this._isDestroyed=!1}get id(){return this._id}get collectionChanged(){return this._collectionChanged}get values(){return Array.from(this._values)}add(e){if(this._isDestroyed)throw new Error("PlotFeatureCollection is isDestroyed");return this._values.has(e)?!1:!!this._values.add(e)}remove(e){return this._values.delete(e)}get entities(){return this._dataSource.entities}get primitives(){return this._primitives}get groundPrimitives(){return this._groundPrimitives}get skeletons(){return this._skeletonDataSource.entities}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._viewer.dataSources.remove(this._dataSource),this._viewer.dataSources.remove(this._skeletonDataSource),this._viewer.scene.primitives.remove(this._primitives),this._viewer.scene.groundPrimitives.remove(this._groundPrimitives),this._viewer.dataSources.remove(this._skeletonDataSource),this._isDestroyed=!0)}}var D=(i=>(i[i.IDLE=0]="IDLE",i[i.HOVER=1]="HOVER",i[i.ACTIVE=2]="ACTIVE",i))(D||{});class U extends l.Entity{constructor(e){super(e)}}function we(i,e,t){const o=b(),n=ie(new l.PrimitiveCollection),r=ie(new l.PrimitiveCollection,{collection:"ground"}),v=X(new l.CustomDataSource),c=Z({collection:()=>v.value.entities}),u=ne({collection:()=>n.value}),a=ne({collection:()=>r.value}),f=_.shallowRef();A(l.ScreenSpaceEventType.MOUSE_MOVE,s=>{f.value=C.canvasCoordToCartesian(s?.endPosition,o.value.scene)}),I.watchArray(i,(s,d,g,p=[])=>{p.forEach(m=>{c.removeWhere(E=>m.entities.includes(E)),u.removeWhere(E=>m.primitives.includes(E)),a.removeWhere(E=>m.groundPrimitives.includes(E))}),g.forEach(m=>{m.entities.forEach(E=>c.add(E)),m.primitives.forEach(E=>u.add(E)),m.groundPrimitives.forEach(E=>a.add(E))})},{immediate:!0,flush:"post"}),H(()=>i.value.map(s=>s.definitionChanged),(s,d,g,p)=>{if(d==="entities"){const{added:m,removed:E}=C.arrayDiff(g,p);m.forEach(y=>c.add(y)),E.forEach(y=>c.remove(y))}else if(d==="primitives"){const{added:m,removed:E}=C.arrayDiff(g,p);m.forEach(y=>u.add(y)),E.forEach(y=>u.remove(y))}else if(d==="groundPrimitives"){const{added:m,removed:E}=C.arrayDiff(g,p);m.forEach(y=>a.add(y)),E.forEach(y=>a.remove(y))}});const h=async s=>{var d,g;const p=await((g=(d=s.scheme).render)==null?void 0:g.call(d,{packable:s.sampled.getValue(t()),mouse:s.defining?f.value:void 0,defining:s.defining,previous:{entities:s.entities,primitives:s.primitives,groundPrimitives:s.groundPrimitives}}));s.entities=p?.entities??[],s.primitives=p?.primitives??[],s.groundPrimitives=p?.groundPrimitives??[]};return _.watch(e,(s,d)=>{d&&h(d)}),H(()=>i.value.map(s=>s.definitionChanged),(s,d)=>{["disabled","defining","scheme","sampled","time"].includes(d)&&h(s)}),_.watch(f,()=>{i.value.forEach(s=>s.defining&&h(s))}),{primitives:_.computed(()=>Array.from(u.scope)),groundPrimitives:_.computed(()=>Array.from(u.scope)),entities:_.computed(()=>Array.from(c.scope))}}function ye(i,e){const t=b(),o=_.ref(!1),n=_.computed(()=>{var c;return(c=i.value)==null?void 0:c.sampled.getValue(e())});A(l.ScreenSpaceEventType.LEFT_CLICK,async c=>{var u,a;if(await I.promiseTimeout(1),!i.value||!n.value||o.value)return;const{scheme:f,defining:h,sampled:s}=i.value;if(!h)return;const d=C.canvasCoordToCartesian(c.position,t.value.scene);if(!d)return;(u=n.value).positions??(u.positions=[]),n.value.positions.push(d),s.setSample(n.value),((a=f.complete)==null?void 0:a.call(f,n.value))&&V.setDefining(i.value,!1)}),A(l.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,async c=>{var u;if(!i.value||!n.value)return;o.value=!0,await I.promiseTimeout(2),o.value=!1;const{scheme:a,defining:f}=i.value;if(!f||!C.canvasCoordToCartesian(c.position,t.value.scene))return;((u=a.forceComplete)==null?void 0:u.call(a,n.value))&&V.setDefining(i.value,!1)}),A(l.ScreenSpaceEventType.RIGHT_CLICK,async()=>{var c;if(!i.value||!n.value)return;const{defining:u,sampled:a}=i.value;u&&((c=n.value).positions??(c.positions=[]),n.value.positions.length!==0&&(n.value.positions.splice(n.value.positions.length-1,1),a.setSample(n.value)))});const r=_.ref(),v=()=>{var c,u;if(!((c=i.value)!=null&&c.defining))r.value&&(r.value=void 0,t.value.container.parentElement.style.removeProperty("cursor"));else{const a=i.value.scheme.definingCursor;r.value=C.isFunction(a)?a(n.value):a,r.value&&((u=t.value)==null||u.container.parentElement.style.setProperty("cursor",r.value))}};H(()=>{var c;return(c=i.value)==null?void 0:c.definitionChanged},(c,u)=>{(u==="defining"||u==="sampled")&&v()}),_.watch(i,()=>v())}function Pe(i,e,t){const o=b(),n=X(new l.CustomDataSource),r=Z({collection:()=>n.value.entities}),v=_.shallowRef(),c=_.shallowRef(),u=h=>{var s,d;return h?((s=c.value)==null?void 0:s.id)===h.id?D.ACTIVE:((d=v.value)==null?void 0:d.id)===h.id?D.HOVER:D.IDLE:D.IDLE},a=(h,s)=>{const d=h.skeletons,g=[];if(s||h.disabled)h.skeletons=[];else{const p=h.sampled.getValue(t()),m=h.defining,E=e.value===h;h.scheme.skeletons.forEach(T=>{var R;if(C.isFunction(T.disabled)?T.disabled({active:E,defining:m}):T.disabled)return;const M=((R=T.format)==null?void 0:R.call(T,p))??p?.positions??[];M.forEach((B,N)=>{var Y;let L=d.find(O=>O.index===N&&O.skeleton===T);const z=(Y=T.render)==null?void 0:Y.call(T,{defining:m,active:E,index:N,packable:p,positions:M,position:B,action:u(L)}),F=new U(z??{});L?F.propertyNames.forEach(O=>{O!=="id"&&(L[O]=F[O])}):L=F,L.plot=h,L.skeleton=T,L.index=N,g.push(L)})})}h.skeletons=g},{addGraphicEvent:f}=me();return _.watchEffect(h=>{const s=f("global","DRAG",({event:d,pick:g,dragging:p,lockCamera:m})=>{var E;if(g.id instanceof U&&r.scope.has(g.id)){const y=g.id,T=y.plot;if(T.defining)return;c.value=y;const R=y.skeleton,K=y.index,M=T.sampled.getValue(t());(E=R.onDrag)==null||E.call(R,{viewer:o.value,sampled:T.sampled,packable:M,active:e.value===T,index:K,event:d,dragging:p,lockCamera:m})}else c.value=void 0},{cursor:({pick:d})=>{var g;if(!((g=e.value)!=null&&g.defining)&&r.scope.has(d.id)){const p=d.id.skeleton;return C.isFunction(p?.cursor)?p.cursor(d):_.toValue(p?.cursor)}},dragCursor:({pick:d})=>{var g;if(!((g=e.value)!=null&&g.defining)&&r.scope.has(d.id)){const p=d.id.skeleton;return C.isFunction(p?.dragCursor)?p.dragCursor(d):_.toValue(p?.dragCursor)}}});h(s)}),I.onKeyStroke(h=>{var s;if(c.value){const d=c.value,g=d.plot,p=d.skeleton,m=d.index,E=g.sampled.getValue(t());(s=p.onKeyPressed)==null||s.call(p,{viewer:o.value,sampled:g.sampled,packable:E,index:m,keyEvent:h})}}),_.watchEffect(h=>{const s=f("global","HOVER",({hovering:d,pick:g})=>{if(d&&g.id instanceof U&&r.scope.has(g.id)){const p=g.id;v.value=p}else v.value=void 0});h(s)}),_.watchEffect(h=>{const s=f("global","LEFT_CLICK",({event:d,pick:g})=>{var p;if(g.id instanceof U&&r.scope.has(g.id)){const m=g.id;c.value=m;const E=m.plot,y=m.skeleton,T=m.index,R=E.sampled.getValue(t());(p=y.onLeftClick)==null||p.call(y,{viewer:o.value,sampled:E.sampled,packable:R,active:e.value===E,defining:E.defining,index:T,event:d})}else c.value=void 0});h(s)}),I.watchArray(i,(h,s,d,g=[])=>{d.forEach(p=>a(p)),g.forEach(p=>a(p,!0))}),H(()=>i.value.map(h=>h.definitionChanged),(h,s,d,g)=>{if(["disabled","defining","scheme","sampled","time"].includes(s))_.nextTick(()=>a(h));else if(s==="skeletons"){const{added:p,removed:m}=C.arrayDiff(d,g);p.forEach(E=>r.add(E)),m.forEach(E=>r.remove(E))}}),_.watch(e,(h,s)=>{h&&a(h),s&&a(s)}),{dataSource:n}}function Te(i){const e=i?.time||_.shallowRef(),t=b(),o=()=>{var s,d,g;return((s=e.value)==null?void 0:s.clone())||((g=(d=t.value)==null?void 0:d.clock.currentTime)==null?void 0:g.clone())||l.JulianDate.now()},n=_.shallowReactive(new Set),r=_.computed(()=>Array.from(n)),v=_.shallowRef(),c=_.shallowRef();H([()=>{var s;return(s=v.value)==null?void 0:s.sampled.definitionChanged}],()=>{var s;c.value=(s=v.value)==null?void 0:s.sampled.getValue(o())}),ye(v,o),we(r,v,o),Pe(r,v,o),A(l.ScreenSpaceEventType.LEFT_CLICK,s=>{var d,g,p;if((d=v.value)!=null&&d.defining)return;const m=(g=t.value)==null?void 0:g.scene.pick(s.position.clone());if(!(((p=m?.id)==null?void 0:p.plot)instanceof V)){if(!m){v.value=void 0;return}v.value=r.value.find(E=>C.pickHitGraphic(m,[...E.entities,...E.primitives,...E.groundPrimitives]))}});let u,a;return _.watch(v,(s,d)=>{var g,p;if(d&&d.defining){const m=d.sampled.getValue(o());((p=(g=d.scheme).forceComplete)==null?void 0:p.call(g,m))?(V.setDefining(d,!1),u?.(d)):n.delete(d)}}),{plots:r,time:e,operate:async s=>new Promise((d,g)=>{u=d,a=g;const p=s instanceof V?s:new V(s);return n.has(p)||n.add(p),v.value=p,d(p)}),remove:s=>(s===v.value&&(v.value=void 0),n.has(s)?(n.delete(s),!0):!1),cancel:a}}function J(){return{disabled:({active:i})=>!i,cursor:"pointer",dragCursor:"crosshair",onDrag({viewer:i,sampled:e,packable:t,event:o,index:n,lockCamera:r}){r();const v=C.canvasCoordToCartesian(o.endPosition,i.scene);if(v){const c=[...t.positions??[]];c[n]=v,e.setSample({time:t.time,derivative:t.derivative,positions:c})}},onKeyPressed({viewer:i,keyEvent:e,sampled:t,packable:o,index:n}){var r;const v=(r=C.toCartographic(i.camera.position))==null?void 0:r.height;if(!v||!["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"].includes(e.key))return;e.preventDefault();let c=0;switch(e.key){case"ArrowRight":c=Math.PI/2;break;case"ArrowDown":c=Math.PI;break;case"ArrowLeft":c=-Math.PI/2;break;case"ArrowUp":c=0;break}const u=(i.camera.heading+c)%(2*Math.PI),a=[...o.positions??[]],f=C.toCartographic(a[n]),s=v/1e5*Math.PI/180/1e3;f.latitude+=s*Math.cos(u),f.longitude+=s*Math.sin(u),a[n]=C.toCartesian3(f),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:i,action:e})=>{const t={[D.IDLE]:l.Color.BLUE.withAlpha(.4),[D.HOVER]:l.Color.BLUE.withAlpha(.6),[D.ACTIVE]:l.Color.AQUA.withAlpha(1)};return{position:i,point:{pixelSize:8,color:t[e],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:l.Color.WHITE.withAlpha(.4)}}}}}function q(){let i=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:"pointer",dragCursor:"crosshair",format(e){const t=e.positions??[];return t.length<2?[]:t.map((o,n)=>{const r=n===t.length-1?t[0]:t[n+1];return l.Cartesian3.midpoint(o,r,new l.Cartesian3)})},onDrag({viewer:e,sampled:t,packable:o,event:n,index:r,lockCamera:v,dragging:c}){v();const u=C.canvasCoordToCartesian(n.endPosition,e.scene);if(!u)return;const a=[...o.positions??[]];i===-1?(i=r,a.splice(r+1,0,u)):a[i+1]=u,c||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:e,action:t,active:o})=>{if(!o)return;const n={[D.IDLE]:l.Color.GREEN.withAlpha(.4),[D.HOVER]:l.Color.GREEN.withAlpha(.6),[D.ACTIVE]:l.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:n[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:l.Color.WHITE.withAlpha(.4)}}}}}function le(){let i=-1;return{disabled:({active:e,defining:t})=>!e||t,cursor:"pointer",dragCursor:"crosshair",format(e){const t=e.positions??[];if(t.length<2)return[];const o=[];for(let n=0;n<t.length-1;n++)o.push(l.Cartesian3.midpoint(t[n],t[n+1],new l.Cartesian3));return o},onDrag({viewer:e,sampled:t,packable:o,event:n,index:r,lockCamera:v,dragging:c}){v();const u=C.canvasCoordToCartesian(n.endPosition,e.scene);if(!u)return;const a=[...o.positions??[]];i===-1?(i=r,a.splice(r+1,0,u)):a[i+1]=u,c||(i=-1),t.setSample({time:o.time,derivative:o.derivative,positions:a})},render:({position:e,action:t})=>{const o={[D.IDLE]:l.Color.GREEN.withAlpha(.4),[D.HOVER]:l.Color.GREEN.withAlpha(.6),[D.ACTIVE]:l.Color.GREEN.withAlpha(1)};return{position:e,point:{pixelSize:6,color:o[t],disableDepthTestDistance:Number.POSITIVE_INFINITY,outlineWidth:1,outlineColor:l.Color.WHITE.withAlpha(.4)}}}}}const De=`data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6"/></svg>')}`;function x(){return{disabled:({active:i,defining:e})=>!i||e,cursor:"pointer",dragCursor:"crosshair",format(i){const e=i.positions??[];if(e.length===0)return[];if(e.length===1)return[e[0]];{const t=l.Rectangle.center(l.Rectangle.fromCartesianArray(e));return[C.toCartesian3(t)]}},onDrag({viewer:i,sampled:e,packable:t,event:o,lockCamera:n,dragging:r}){r&&n();const v=C.canvasCoordToCartesian(o.startPosition,i.scene),c=C.canvasCoordToCartesian(o.endPosition,i.scene);if(!v||!c)return;const u=l.Cartesian3.subtract(c,v,new l.Cartesian3),a=[...t.positions??[]];e.setSample({time:t.time,derivative:t.derivative,positions:a.map(f=>l.Cartesian3.add(f,u,new l.Cartesian3))})},render:({position:i,action:e})=>{const t={[D.IDLE]:l.Color.WHITE,[D.HOVER]:l.Color.WHITE,[D.ACTIVE]:l.Color.AQUA.withAlpha(1)};return{position:i,billboard:{image:De,width:20,height:20,color:t[e],pixelOffset:new l.Cartesian3(0,-20),horizontalOrigin:l.HorizontalOrigin.CENTER,verticalOrigin:l.VerticalOrigin.BOTTOM,disableDepthTestDistance:Number.POSITIVE_INFINITY}}}}}function Se(i){if(i.length<3)throw new Error("positions must >= 3");if(i.length===3)return[[i[0].clone(),i[1].clone(),i[2].clone()]];const e=l.CoplanarPolygonGeometry.createGeometry(l.CoplanarPolygonGeometry.fromPositions({positions:i,vertexFormat:l.VertexFormat.POSITION_ONLY}));if(!e)throw new Error("positions\u65E0\u6CD5\u7EC4\u6210\u6709\u6548\u7684geometry,\u68C0\u67E5\u70B9\u4F4D\u662F\u5426\u9519\u8BEF");const t=e.attributes.position.values,o=e.indices,n=[];for(let r=0;r<o.length;r+=3){const v=l.Cartesian3.unpack(t,o[r]*3,new l.Cartesian3),c=l.Cartesian3.unpack(t,o[r+1]*3,new l.Cartesian3),u=l.Cartesian3.unpack(t,o[r+2]*3,new l.Cartesian3);n.push([v,c,u])}return n}function Ie(i,e,t){const o=l.Cartesian3.subtract(i,e,new l.Cartesian3),n=l.Cartesian3.subtract(t,e,new l.Cartesian3),r=l.Cartesian3.cross(o,n,o);return l.Cartesian3.magnitude(r)*.5}function be(i){const t=l.ClassificationType.BOTH,o=Math.floor(10);return{scene:i?.scene,clampToGround:!1,classificationType:t,terrainProvider:i?.terrainProvider,density:o}}async function Le(i,e){if(i.length<2)throw new Error("positions.length must >= 2");const{density:t}=be(e);if(t<=0)throw new Error("options.density must > 0");return Se(i).reduce((n,r)=>n+=Ie(...r),0)}const Ae=new k({type:"measureArea",forceComplete:i=>i.positions.length>=3,skeletons:[J,q],initEntites:()=>[new l.Entity({label:{font:"14pt"},polyline:{material:l.Color.YELLOW.withAlpha(.5)},polygon:{material:l.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new l.Entity({label:{font:"14pt"},polyline:{material:l.Color.YELLOW.withAlpha(.5)},polygon:{material:l.Color.YELLOW.withAlpha(.5)}}),r=[...o.positions??[]];return t&&r.push(t),r.length===2?(n.position=void 0,n.label.text=void 0,n.polygon.hierarchy=void 0,n.polyline.positions=new l.CallbackProperty(()=>r,!1)):r.length>=3?(r.push(r[0]),n.position=new l.ConstantPositionProperty(C.toCartesian3(l.Rectangle.center(l.Rectangle.fromCartesianArray(r)))),n.label.text=new l.ConstantProperty(""),Le(r).then(v=>{let c="";v/1e3/1e3>10?c=`${(v/1e3/1e3).toFixed(2)}km\xB2`:c=`${(+v).toFixed(2)}m\xB2`,n.label.text=new l.ConstantProperty(c)}),n.polyline.positions=void 0,n.polygon.hierarchy=new l.CallbackProperty(()=>r.length>=3?new l.PolygonHierarchy([...r]):void 0,!1)):(n.position=void 0,n.polygon.hierarchy=void 0,n.polyline.positions=void 0),{entities:[n]}}}),Re=new k({type:"billboard",complete:i=>i.positions.length>=1,skeletons:[x],initEntites:()=>[new l.Entity({billboard:{image:"/favicon.svg",width:32,height:32}})],render(i){var e,t;const{mouse:o,packable:n}=i,r=((e=i.previous.entities)==null?void 0:e[0])??new l.Entity({billboard:{}}),v=((t=n.positions)==null?void 0:t[0])??o;return r.position=new l.CallbackPositionProperty(()=>v,!0),{entities:[r]}}}),Oe=new k({type:"label",complete:i=>i.positions.length>=1,skeletons:[x],initEntites:()=>[new l.Entity({label:{text:"Label"}})],render(i){var e,t;const{mouse:o,packable:n}=i,r=((e=i.previous.entities)==null?void 0:e[0])??new l.Entity({label:{}}),v=((t=n.positions)==null?void 0:t[0])??o;return r.position=new l.CallbackPositionProperty(()=>v,!0),{entities:[r]}}}),ke=new k({type:"polygon",forceComplete:i=>i.positions.length>=3,skeletons:[J,q,x],initEntites:()=>[new l.Entity({polyline:{material:l.Color.YELLOW.withAlpha(.5)},polygon:{material:l.Color.YELLOW.withAlpha(.5)}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new l.Entity({polyline:{material:l.Color.YELLOW.withAlpha(.5)},polygon:{material:l.Color.YELLOW.withAlpha(.5)}}),r=[...o.positions??[]];return t&&r.push(t),r.length===2?(n.polygon.hierarchy=void 0,n.polyline.positions=new l.CallbackProperty(()=>r,!1)):r.length>=3?(n.polyline.positions=void 0,n.polygon.hierarchy=new l.CallbackProperty(()=>(r.push(r[0]),r.length>=3?new l.PolygonHierarchy([...r]):void 0),!1)):(n.polygon.hierarchy=void 0,n.polyline.positions=void 0),{entities:[n]}}}),Ve=new k({type:"polyline",forceComplete:i=>i.positions.length>=2,skeletons:[J,le,x],initEntites:()=>[new l.Entity({polyline:{width:1}})],render(i){var e;const{mouse:t,packable:o}=i,n=((e=i.previous.entities)==null?void 0:e[0])??new l.Entity({polyline:{}});return n.polyline.positions=new l.CallbackProperty(()=>{const r=[...o.positions??[]].concat(t?[t]:[]);return r.length>=2?r:[]},!1),{entities:[n]}}});return P.PlotAction=D,P.PlotFeature=V,P.PlotFeatureCollection=Ce,P.PlotScheme=k,P.PlotSkeletonEntity=U,P.SampledPlotProperty=j,P.SampledPlotStrategy=se,P.control=J,P.interval=q,P.intervalNonclosed=le,P.moved=x,P.schemeBillboard=Re,P.schemeLabel=Oe,P.schemeMeasureArea=Ae,P.schemePolygon=ke,P.schemePolyline=Ve,P.usePlot=Te,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({},Cesium,VueUse,Vue,VesiumShared);
2
2
  //# sourceMappingURL=index.iife.min.js.map