@loaders.gl/tiles 5.0.0-alpha.13 → 5.0.0-alpha.14
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.
- package/dist/dist.dev.js +665 -472
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +9 -6
- package/dist/index.cjs.map +2 -2
- package/dist/mlt/index.cjs +9 -11
- package/dist/mlt/index.cjs.map +1 -1
- package/dist/mlt/mlt-loader.js +1 -1
- package/dist/mlt/mlt-writer.js +1 -1
- package/dist/mvt/arrow-table-tile-source-loader-types.js +1 -1
- package/dist/mvt/arrow-table-tile-source-loader.cjs +8 -10
- package/dist/mvt/arrow-table-tile-source-loader.cjs.map +1 -1
- package/dist/mvt/dist.dev.js +15 -20
- package/dist/mvt/dist.min.js +19 -19
- package/dist/mvt/index.cjs +14 -24
- package/dist/mvt/index.cjs.map +3 -3
- package/dist/mvt/lib/mvt-worker-transport.d.ts.map +1 -1
- package/dist/mvt/lib/mvt-worker-transport.js +1 -1
- package/dist/mvt/lib/mvt-worker-transport.js.map +1 -1
- package/dist/mvt/map-style-loader.js +1 -1
- package/dist/mvt/mvt-geojson-loader-types.js +1 -1
- package/dist/mvt/mvt-geojson-loader.cjs +1 -1
- package/dist/mvt/mvt-loader.js +1 -1
- package/dist/mvt/mvt-writer.js +1 -1
- package/dist/mvt/tilejson-loader.js +1 -1
- package/dist/mvt-worker-node.js +69 -27
- package/dist/mvt-worker-node.js.map +4 -4
- package/dist/mvt-worker.js +68 -27
- package/dist/pmtiles/dist.dev.js +18 -23
- package/dist/pmtiles/dist.min.js +15 -15
- package/dist/pmtiles/geoarrow.cjs +7 -9
- package/dist/pmtiles/geoarrow.cjs.map +1 -1
- package/dist/pmtiles/index.cjs +13 -23
- package/dist/pmtiles/index.cjs.map +3 -3
- package/dist/pmtiles/lib/version.js +1 -1
- package/dist/pmtiles/pmtiles-writer.js +1 -1
- package/dist/pmtiles/raster.cjs.map +1 -1
- package/package.json +9 -9
- package/src/mvt/lib/mvt-worker-transport.ts +5 -2
package/dist/dist.min.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var ii=Object.create;var zt=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var ci=Object.getPrototypeOf,li=Object.prototype.hasOwnProperty;var C=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var hi=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},mr=(e,t)=>{for(var r in t)zt(e,r,{get:t[r],enumerable:!0})},vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ai(t))!li.call(e,s)&&s!==r&&zt(e,s,{get:()=>t[s],enumerable:!(n=oi(t,s))||n.enumerable});return e},Dt=(e,t,r)=>(vt(e,t,"default"),r&&vt(r,t,"default")),fi=(e,t,r)=>(r=e!=null?ii(ci(e)):{},vt(t||!e||!e.__esModule?zt(r,"default",{value:e,enumerable:!0}):r,e)),ui=e=>vt(zt({},"__esModule",{value:!0}),e);var xr=hi((_a,pr)=>{pr.exports=globalThis.loaders});function qt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var gr=C(()=>{"use strict"});function pt(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var me=C(()=>{});var it,pe=C(()=>{me();it=class{constructor(t,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=pt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(pt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var W,Tr=C(()=>{pe();W=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let r of Object.values(this.stats))t(r)}getTable(){let t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){let{name:r,type:n}=t,s=this.stats[r];return s||(t instanceof it?s=t:s=new it(r,n),this.stats[r]=s),s}}});var Ft=C(()=>{Tr();pe();me()});var mi,pi,xi,gi,Ti,Si,j,Sr=C(()=>{"use strict";Ft();mi="Queued Requests",pi="Active Requests",xi="Cancelled Requests",gi="Queued Requests Ever",Ti="Active Requests Ever",Si={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},j=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...Si,...t},this.stats=new W({id:this.props.id}),this.stats.get(mi),this.stats.get(pi),this.stats.get(xi),this.stats.get(gi),this.stats.get(Ti)}setProps(t){t.throttleRequests!==void 0&&(this.props.throttleRequests=t.throttleRequests),t.maxRequests!==void 0&&(this.props.maxRequests=t.maxRequests),t.debounceTime!==void 0&&(this.props.debounceTime=t.debounceTime)}scheduleRequest(t,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let n={handle:t,priority:0,getPriority:r},s=new Promise(i=>(n.resolve=i,n));return this.requestQueue.push(n),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){let{handle:r,resolve:n}=t,s=!1,i=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:i}):Promise.resolve({done:i})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let r=0;r<t;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let n=t[r];this._updateRequest(n)||(t.splice(r,1),this.requestMap.delete(n.handle),r--)}t.sort((r,n)=>r.priority-n.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}}});function _r(e,t){return t?t.aborted?(e.catch(()=>{}),Promise.reject(t.reason)):new Promise((r,n)=>{let s=()=>{t.removeEventListener("abort",s),n(t.reason)};t.addEventListener("abort",s,{once:!0}),e.then(i=>{t.removeEventListener("abort",s),r(i)},i=>{t.removeEventListener("abort",s),n(i)})}):e}function kt(e,t){let r=new AbortController,n=[],s=()=>{for(let[i,o]of n)i.removeEventListener("abort",o)};for(let i of t){if(!i)continue;let o=()=>r.abort(i.reason);n.push([i,o]),i.addEventListener("abort",o,{once:!0}),i.aborted&&o()}try{return r.signal.throwIfAborted(),_r(e(r.signal),r.signal).catch(i=>{throw r.abort(i),i}).finally(s)}catch(i){return r.abort(i),s(),Promise.reject(i)}}var Mr=C(()=>{"use strict"});function Ut(e={}){if(e.coordinateEpoch!==void 0&&!Number.isFinite(e.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:Er(e.crs||{state:"absent",provenance:"unknown"}),vertical:e.vertical?Er(e.vertical):void 0,coordinateEpoch:e.coordinateEpoch,coordinateFrame:e.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...e.coordinateOrder||[]]),units:e.units?Object.freeze([...e.units]):void 0})}function ot(e){if(typeof e=="object")return"projjson";let t=e.trim();return/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(t)?"wkt":/(?:^|\s)\+?proj=/i.test(t)?"proj-string":/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(t)||/^urn:ogc:def:crs:/i.test(t)||/^https?:\/\//i.test(t)||/^[A-Z][A-Z0-9._-]*$/i.test(t)?"identifier":"opaque"}function Er(e){return e.state==="explicit"||e.state==="default"?Object.freeze({...e,definition:Rr(e.definition),alternatives:e.alternatives?Object.freeze(e.alternatives.map(t=>Object.freeze({...t,definition:Rr(t.definition)}))):void 0}):Object.freeze({...e})}function Rr(e){return typeof e=="string"?e:xe(e)}function xe(e){return Array.isArray(e)?Object.freeze(e.map(t=>xe(t))):e&&typeof e=="object"?Object.freeze(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,xe(r)]))):e}var yr=C(()=>{});function Se(e,t){let n={type:"wkt-crs",root:new ge(e).parse()};if(t?.strict){let s=Ar(n,{profile:t.profile,allowExtensions:!1});if(s.length>0)throw new Gt(s)}return n}function Ar(e,t){if(!e||e.type!=="wkt-crs"||e.root?.type!=="node")throw new TypeError("validateWKTCRS expects a WKTCRSAst");let r=bi(e.root.keyword,t?.profile||"auto"),n=Ai[r],s=Ii[r],i=[],o=e.root.keyword.toUpperCase();return n.has(o)||i.push({code:"invalid-root",message:`${e.root.keyword} is not a ${r} root keyword`,path:[],keyword:e.root.keyword}),Ir(e.root,[],a=>{let c=a.node.keyword.toUpperCase();!t?.allowExtensions&&!s.has(c)&&i.push({code:"unknown-keyword",message:`${a.node.keyword} is not defined by the ${r} profile`,path:a.path,keyword:a.node.keyword}),a.node.values.length===0&&i.push({code:"empty-node",message:`${a.node.keyword} must contain at least one value`,path:a.path,keyword:a.node.keyword});let l=Ni(a.node);l&&i.push({code:"invalid-value",message:l,path:a.path,keyword:a.node.keyword})}),i}function bi(e,t){return t!=="auto"?t:xt.has(e.toUpperCase())?"wkt1":"wkt2:2019"}function Ni(e){let t=e.keyword.toUpperCase(),r=e.values,n=(i,...o)=>!!(r[i]&&o.includes(r[i].type)),s=(i,...o)=>r.length===i&&o.every((a,c)=>n(c,a));if(["ANGLEUNIT","LENGTHUNIT","PARAMETRICUNIT","SCALEUNIT","TIMEUNIT","TEMPORALQUANTITY","UNIT"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${e.keyword} must start with a quoted name and numeric conversion factor`;if(t==="CS"&&!s(2,"enumeration","number"))return`${e.keyword} must contain a coordinate-system type and dimension`;if(t==="BBOX"&&!s(4,"number","number","number","number"))return`${e.keyword} must contain four numeric bounds`;if(["ENSEMBLEACCURACY","EPOCH","COORDEPOCH","FRAMEEPOCH","OPERATIONACCURACY","ORDER"].includes(t)&&!s(1,"number"))return`${e.keyword} must contain one number`;if(["ANCHOR","AREA","CALENDAR","CITATION","REMARK","SCOPE","URI","VERSION"].includes(t)&&!s(1,"string"))return`${e.keyword} must contain one quoted string`;if(["ELLIPSOID","SPHEROID","TRIAXIAL"].includes(t)&&!(r.length>=3&&n(0,"string")&&n(1,"number")&&n(2,"number")))return`${e.keyword} must start with a quoted name and numeric ellipsoid axes`;if(["PARAMETER"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${e.keyword} must start with a quoted name and numeric value`;if(t==="PARAMETERFILE"&&!s(2,"string","string"))return`${e.keyword} must contain a quoted name and file name`;if(["AUTHORITY","ID"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"string","number")))return`${e.keyword} must start with a quoted authority and identifier`;if(["AXIS"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"enumeration")))return`${e.keyword} must start with a quoted name and axis direction`;if(["METHOD","PROJECTION"].includes(t)&&!(r.length>=1&&n(0,"string")))return`${e.keyword} must start with a quoted name`;if(t==="TIMEEXTENT"){let i=o=>n(o,"enumeration","string");if(r.length!==2||!i(0)||!i(1))return`${e.keyword} must contain two date-time or quoted values`}if(t==="VERTICALEXTENT"&&(r.length<2||r.length>3||!n(0,"number")||!n(1,"number")||r.length===3&&!n(2,"node")))return`${e.keyword} must contain two numeric bounds and an optional unit`;if(t==="COORDINATEMETADATA"&&(r.length<1||r.length>2||!n(0,"node")||r.length===2&&(!n(1,"node")||!["EPOCH","COORDEPOCH"].includes(r[1].keyword.toUpperCase()))))return`${e.keyword} must contain a CRS and an optional coordinate epoch`;if(t==="BOUNDCRS"){let i=r.slice(0,3).map(o=>o.type==="node"?o.keyword.toUpperCase():"");if(i[0]!=="SOURCECRS"||i[1]!=="TARGETCRS"||i[2]!=="ABRIDGEDTRANSFORMATION")return`${e.keyword} must start with SOURCECRS, TARGETCRS, and ABRIDGEDTRANSFORMATION`}return["COMPOUNDCRS","CONCATENATEDOPERATION","COORDINATEOPERATION","DERIVEDPROJCRS","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","GEOGCRS","GEOGRAPHICCRS","PARAMETRICCRS","POINTMOTIONOPERATION","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"].includes(t)&&!n(0,"string")?`${e.keyword} must start with a quoted name`:null}function Ir(e,t,r){r({node:e,path:t});for(let n=0;n<e.values.length;n++){let s=e.values[n];s.type==="node"&&Ir(s,[...t,n],r)}}function Pi(e,t){let r=1,n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
|
|
8
|
-
`?(r++,n=1):n++;return{line:r,column:n}}var
|
|
9
|
-
`?(r++,n=1):n++;return{line:r,column:n}}var H,Li,Nr=C(()=>{H=class extends SyntaxError{constructor(t,r,n){let s=qi(r,n);super(`${t} at ${s.line}:${s.column}`),this.name="PROJStringSyntaxError",this.offset=n,this.line=s.line,this.column=s.column}};Li=/^[+-]?\d+(?:\.\d*)?d(?:\d+(?:\.\d*)?'(?:\d+(?:\.\d*)?")?)?[NSEW]?$/i});var Me=C(()=>{yr();br();Nr()});var K={};mr(K,{EPSILON1:()=>Fi,EPSILON10:()=>Zi,EPSILON11:()=>ji,EPSILON12:()=>Hi,EPSILON13:()=>Ki,EPSILON14:()=>Xi,EPSILON15:()=>Ji,EPSILON16:()=>Qi,EPSILON17:()=>to,EPSILON18:()=>eo,EPSILON19:()=>ro,EPSILON2:()=>ki,EPSILON20:()=>no,EPSILON3:()=>Ui,EPSILON4:()=>Bi,EPSILON5:()=>Gi,EPSILON6:()=>Vi,EPSILON7:()=>Wi,EPSILON8:()=>Yi,EPSILON9:()=>$i,PI:()=>ao,PI_OVER_FOUR:()=>io,PI_OVER_SIX:()=>oo,PI_OVER_TWO:()=>so,TWO_PI:()=>co});var Fi,ki,Ui,Bi,Gi,Vi,Wi,Yi,$i,Zi,ji,Hi,Ki,Xi,Ji,Qi,to,eo,ro,no,so,io,oo,ao,co,Pr=C(()=>{Fi=.1,ki=.01,Ui=.001,Bi=1e-4,Gi=1e-5,Vi=1e-6,Wi=1e-7,Yi=1e-8,$i=1e-9,Zi=1e-10,ji=1e-11,Hi=1e-12,Ki=1e-13,Xi=1e-14,Ji=1e-15,Qi=1e-16,to=1e-17,eo=1e-18,ro=1e-19,no=1e-20,so=Math.PI/2,io=Math.PI/4,oo=Math.PI/6,ao=Math.PI,co=Math.PI*2});function Ee(e,{precision:t=L.precision}={}){return e=uo(e),`${parseFloat(e.toPrecision(t))}`}function Y(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Re(e){return Lr(e)}function ye(e){return vr(e)}function Lr(e,t){return Ce(e,r=>r*ho,t)}function vr(e,t){return Ce(e,r=>r*lo,t)}function gt(e,t,r){return Ce(e,n=>Math.max(t,Math.min(r,n)))}function U(e,t,r){let n=L.EPSILON;r&&(L.EPSILON=r);try{if(e===t)return!0;if(Y(e)&&Y(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!U(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=L.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{L.EPSILON=n}}function uo(e){return Math.round(e/L.EPSILON)*L.EPSILON}function mo(e){return e.clone?e.clone():new Array(e.length)}function Ce(e,t,r){if(Y(e)){let n=e;r=r||mo(n);for(let s=0;s<r.length&&s<n.length;++s){let i=typeof e=="number"?e:e[s];r[s]=t(i,s,r)}return r}return t(e)}var lo,ho,fo,L,ct=C(()=>{lo=1/Math.PI*180,ho=1/180*Math.PI,fo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...fo}};L=globalThis.mathgl.config});var et,Vt=C(()=>{ct();et=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Y(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(L)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Ee(this[n],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!U(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof r=="number"?r:r[s];this[s]=i+n*(o-i)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(L.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}}});function po(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function v(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Wt(e,t,r=""){if(L.debug&&!po(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}var lt=C(()=>{ct()});var Yt,zr=C(()=>{Vt();lt();ct();Yt=class extends et{toString(){let t="[";if(L.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=v(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[n+s];return r}setColumn(t,r){let n=t*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=r[s];return this}}});function D(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var we=C(()=>{});var $t,Dr=C(()=>{Vt();lt();we();$t=class extends et{get x(){return this[0]}set x(t){this[0]=v(t)}get y(){return this[1]}set y(t){this[1]=v(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let s=this[n]-t[n];r+=s*s}return v(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return v(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return D(t>=0&&t<this.ELEMENTS,"index is out of range"),v(this[t])}setComponent(t,r){return D(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n]*r;return this.check()}}});var Zt,sc,qr=C(()=>{Zt=typeof Float32Array<"u"?Float32Array:Array,sc=Math.PI/180});function Fr(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[4]*s+r[12],e[1]=r[1]*n+r[5]*s+r[13],e}var kr=C(()=>{});function Ur(e,t,r){let n=t[0],s=t[1],i=r[3]*n+r[7]*s||1;return e[0]=(r[0]*n+r[4]*s)/i,e[1]=(r[1]*n+r[5]*s)/i,e}function jt(e,t,r){let n=t[0],s=t[1],i=t[2],o=r[3]*n+r[7]*s+r[11]*i||1;return e[0]=(r[0]*n+r[4]*s+r[8]*i)/o,e[1]=(r[1]*n+r[5]*s+r[9]*i)/o,e[2]=(r[2]*n+r[6]*s+r[10]*i)/o,e}function Br(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e[2]=t[2],e}var Oe=C(()=>{});function Gr(){let e=new Zt(3);return Zt!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Ae(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function Ie(e,t,r){let n=new Zt(3);return n[0]=e,n[1]=t,n[2]=r,n}function Vr(e,t){let r=t[0],n=t[1],s=t[2],i=r*r+n*n+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function St(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ht(e,t,r){let n=t[0],s=t[1],i=t[2],o=r[0],a=r[1],c=r[2];return e[0]=s*c-i*a,e[1]=i*o-n*c,e[2]=n*a-s*o,e}function Ht(e,t,r){let n=t[0],s=t[1],i=t[2],o=r[3]*n+r[7]*s+r[11]*i+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*s+r[8]*i+r[12])/o,e[1]=(r[1]*n+r[5]*s+r[9]*i+r[13])/o,e[2]=(r[2]*n+r[6]*s+r[10]*i+r[14])/o,e}function Wr(e,t,r){let n=t[0],s=t[1],i=t[2];return e[0]=n*r[0]+s*r[3]+i*r[6],e[1]=n*r[1]+s*r[4]+i*r[7],e[2]=n*r[2]+s*r[5]+i*r[8],e}function Yr(e,t,r){let n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],c=t[1],l=t[2],h=s*l-i*c,f=i*a-n*l,u=n*c-s*a,d=s*u-i*f,m=i*h-n*u,p=n*f-s*h,g=o*2;return h*=g,f*=g,u*=g,d*=2,m*=2,p*=2,e[0]=a+h+d,e[1]=c+f+m,e[2]=l+u+p,e}function $r(e,t,r,n){let s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Zr(e,t,r,n){let s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function jr(e,t,r,n){let s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Hr(e,t){let r=e[0],n=e[1],s=e[2],i=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+n*n+s*s)*(i*i+o*o+a*a)),l=c&&St(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var Kr,_t=C(()=>{qr();Kr=Ae});var be,Kt,x,Xr=C(()=>{Dr();ct();lt();_t();Oe();be=[0,0,0],x=class e extends $t{static get ZERO(){return Kt||(Kt=new e(0,0,0),Object.freeze(Kt)),Kt}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Y(t)?this.copy(t):(L.debug&&(v(t),v(r),v(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return L.debug&&(v(t.x),v(t.y),v(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=v(t)}angle(t){return Hr(this,t)}cross(t){return ht(this,this,t),this.check()}rotateX({radians:t,origin:r=be}){return $r(this,this,r,t),this.check()}rotateY({radians:t,origin:r=be}){return Zr(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=be}){return jr(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ht(this,this,t),this.check()}transformAsVector(t){return jt(this,this,t),this.check()}transformByMatrix3(t){return Wr(this,this,t),this.check()}transformByMatrix2(t){return Br(this,this,t),this.check()}transformByQuaternion(t){return Yr(this,this,t),this.check()}}});function To(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Jr(e,t){if(e===t){let r=t[1],n=t[2],s=t[3],i=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Qr(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],f=t[9],u=t[10],d=t[11],m=t[12],p=t[13],g=t[14],T=t[15],R=r*a-n*o,_=r*c-s*o,M=r*l-i*o,S=n*c-s*a,E=n*l-i*a,O=s*l-i*c,I=h*p-f*m,w=h*g-u*m,y=h*T-d*m,b=f*g-u*p,N=f*T-d*p,P=u*T-d*g,A=R*P-_*N+M*b+S*y-E*w+O*I;return A?(A=1/A,e[0]=(a*P-c*N+l*b)*A,e[1]=(s*N-n*P-i*b)*A,e[2]=(p*O-g*E+T*S)*A,e[3]=(u*E-f*O-d*S)*A,e[4]=(c*y-o*P-l*w)*A,e[5]=(r*P-s*y+i*w)*A,e[6]=(g*M-m*O-T*_)*A,e[7]=(h*O-u*M+d*_)*A,e[8]=(o*N-a*y+l*I)*A,e[9]=(n*y-r*N-i*I)*A,e[10]=(m*E-p*M+T*R)*A,e[11]=(f*M-h*E-d*R)*A,e[12]=(a*w-o*b-c*I)*A,e[13]=(r*b-n*w+s*I)*A,e[14]=(p*_-m*S-g*R)*A,e[15]=(h*S-f*_+u*R)*A,e):null}function tn(e){let t=e[0],r=e[1],n=e[2],s=e[3],i=e[4],o=e[5],a=e[6],c=e[7],l=e[8],h=e[9],f=e[10],u=e[11],d=e[12],m=e[13],p=e[14],g=e[15],T=t*o-r*i,R=t*a-n*i,_=r*a-n*o,M=l*m-h*d,S=l*p-f*d,E=h*p-f*m,O=t*E-r*S+n*M,I=i*E-o*S+a*M,w=l*_-h*R+f*T,y=d*_-m*R+p*T;return c*O-s*I+g*w-u*y}function Ne(e,t,r){let n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],f=t[8],u=t[9],d=t[10],m=t[11],p=t[12],g=t[13],T=t[14],R=t[15],_=r[0],M=r[1],S=r[2],E=r[3];return e[0]=_*n+M*a+S*f+E*p,e[1]=_*s+M*c+S*u+E*g,e[2]=_*i+M*l+S*d+E*T,e[3]=_*o+M*h+S*m+E*R,_=r[4],M=r[5],S=r[6],E=r[7],e[4]=_*n+M*a+S*f+E*p,e[5]=_*s+M*c+S*u+E*g,e[6]=_*i+M*l+S*d+E*T,e[7]=_*o+M*h+S*m+E*R,_=r[8],M=r[9],S=r[10],E=r[11],e[8]=_*n+M*a+S*f+E*p,e[9]=_*s+M*c+S*u+E*g,e[10]=_*i+M*l+S*d+E*T,e[11]=_*o+M*h+S*m+E*R,_=r[12],M=r[13],S=r[14],E=r[15],e[12]=_*n+M*a+S*f+E*p,e[13]=_*s+M*c+S*u+E*g,e[14]=_*i+M*l+S*d+E*T,e[15]=_*o+M*h+S*m+E*R,e}function en(e,t,r){let n=r[0],s=r[1],i=r[2],o,a,c,l,h,f,u,d,m,p,g,T;return t===e?(e[12]=t[0]*n+t[4]*s+t[8]*i+t[12],e[13]=t[1]*n+t[5]*s+t[9]*i+t[13],e[14]=t[2]*n+t[6]*s+t[10]*i+t[14],e[15]=t[3]*n+t[7]*s+t[11]*i+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],h=t[4],f=t[5],u=t[6],d=t[7],m=t[8],p=t[9],g=t[10],T=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=h,e[5]=f,e[6]=u,e[7]=d,e[8]=m,e[9]=p,e[10]=g,e[11]=T,e[12]=o*n+h*s+m*i+t[12],e[13]=a*n+f*s+p*i+t[13],e[14]=c*n+u*s+g*i+t[14],e[15]=l*n+d*s+T*i+t[15]),e}function rn(e,t,r){let n=r[0],s=r[1],i=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function nn(e,t,r,n){let s=n[0],i=n[1],o=n[2],a=Math.sqrt(s*s+i*i+o*o),c,l,h,f,u,d,m,p,g,T,R,_,M,S,E,O,I,w,y,b,N,P,A,q;return a<1e-6?null:(a=1/a,s*=a,i*=a,o*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,f=t[0],u=t[1],d=t[2],m=t[3],p=t[4],g=t[5],T=t[6],R=t[7],_=t[8],M=t[9],S=t[10],E=t[11],O=s*s*h+c,I=i*s*h+o*l,w=o*s*h-i*l,y=s*i*h-o*l,b=i*i*h+c,N=o*i*h+s*l,P=s*o*h+i*l,A=i*o*h-s*l,q=o*o*h+c,e[0]=f*O+p*I+_*w,e[1]=u*O+g*I+M*w,e[2]=d*O+T*I+S*w,e[3]=m*O+R*I+E*w,e[4]=f*y+p*b+_*N,e[5]=u*y+g*b+M*N,e[6]=d*y+T*b+S*N,e[7]=m*y+R*b+E*N,e[8]=f*P+p*A+_*q,e[9]=u*P+g*A+M*q,e[10]=d*P+T*A+S*q,e[11]=m*P+R*A+E*q,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function sn(e,t,r){let n=Math.sin(r),s=Math.cos(r),i=t[4],o=t[5],a=t[6],c=t[7],l=t[8],h=t[9],f=t[10],u=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+l*n,e[5]=o*s+h*n,e[6]=a*s+f*n,e[7]=c*s+u*n,e[8]=l*s-i*n,e[9]=h*s-o*n,e[10]=f*s-a*n,e[11]=u*s-c*n,e}function on(e,t,r){let n=Math.sin(r),s=Math.cos(r),i=t[0],o=t[1],a=t[2],c=t[3],l=t[8],h=t[9],f=t[10],u=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-l*n,e[1]=o*s-h*n,e[2]=a*s-f*n,e[3]=c*s-u*n,e[8]=i*n+l*s,e[9]=o*n+h*s,e[10]=a*n+f*s,e[11]=c*n+u*s,e}function an(e,t,r){let n=Math.sin(r),s=Math.cos(r),i=t[0],o=t[1],a=t[2],c=t[3],l=t[4],h=t[5],f=t[6],u=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+l*n,e[1]=o*s+h*n,e[2]=a*s+f*n,e[3]=c*s+u*n,e[4]=l*s-i*n,e[5]=h*s-o*n,e[6]=f*s-a*n,e[7]=u*s-c*n,e}function cn(e,t){let r=t[0],n=t[1],s=t[2],i=t[4],o=t[5],a=t[6],c=t[8],l=t[9],h=t[10];return e[0]=Math.sqrt(r*r+n*n+s*s),e[1]=Math.sqrt(i*i+o*o+a*a),e[2]=Math.sqrt(c*c+l*l+h*h),e}function ln(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=r+r,a=n+n,c=s+s,l=r*o,h=n*o,f=n*a,u=s*o,d=s*a,m=s*c,p=i*o,g=i*a,T=i*c;return e[0]=1-f-m,e[1]=h+T,e[2]=u-g,e[3]=0,e[4]=h-T,e[5]=1-l-m,e[6]=d+p,e[7]=0,e[8]=u+g,e[9]=d-p,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function hn(e,t,r,n,s,i,o){let a=1/(r-t),c=1/(s-n),l=1/(i-o);return e[0]=i*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(s+n)*c,e[10]=(o+i)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*l,e[15]=0,e}function So(e,t,r,n,s){let i=1/Math.tan(t/2);if(e[0]=i/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(n-s);e[10]=(s+n)*o,e[14]=2*s*n*o}else e[10]=-1,e[14]=-2*n;return e}function _o(e,t,r,n,s,i,o){let a=1/(t-r),c=1/(n-s),l=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*c,e[14]=(o+i)*l,e[15]=1,e}function dn(e,t,r,n){let s,i,o,a,c,l,h,f,u,d,m=t[0],p=t[1],g=t[2],T=n[0],R=n[1],_=n[2],M=r[0],S=r[1],E=r[2];return Math.abs(m-M)<1e-6&&Math.abs(p-S)<1e-6&&Math.abs(g-E)<1e-6?To(e):(f=m-M,u=p-S,d=g-E,s=1/Math.sqrt(f*f+u*u+d*d),f*=s,u*=s,d*=s,i=R*d-_*u,o=_*f-T*d,a=T*u-R*f,s=Math.sqrt(i*i+o*o+a*a),s?(s=1/s,i*=s,o*=s,a*=s):(i=0,o=0,a=0),c=u*a-d*o,l=d*i-f*a,h=f*o-u*i,s=Math.sqrt(c*c+l*l+h*h),s?(s=1/s,c*=s,l*=s,h*=s):(c=0,l=0,h=0),e[0]=i,e[1]=c,e[2]=f,e[3]=0,e[4]=o,e[5]=l,e[6]=u,e[7]=0,e[8]=a,e[9]=h,e[10]=d,e[11]=0,e[12]=-(i*m+o*p+a*g),e[13]=-(c*m+l*p+h*g),e[14]=-(f*m+u*p+d*g),e[15]=1,e)}var fn,un,Pe=C(()=>{fn=So;un=_o});function mn(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function pn(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function xn(e){let t=e[0],r=e[1],n=e[2],s=e[3];return Math.sqrt(t*t+r*r+n*n+s*s)}function gn(e){let t=e[0],r=e[1],n=e[2],s=e[3];return t*t+r*r+n*n+s*s}function Tn(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=s*o,e[3]=i*o,e}function Sn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function _n(e,t,r,n){let s=t[0],i=t[1],o=t[2],a=t[3];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function Mn(e,t,r){let n=t[0],s=t[1],i=t[2],o=t[3];return e[0]=r[0]*n+r[4]*s+r[8]*i+r[12]*o,e[1]=r[1]*n+r[5]*s+r[9]*i+r[13]*o,e[2]=r[2]*n+r[6]*s+r[10]*i+r[14]*o,e[3]=r[3]*n+r[7]*s+r[11]*i+r[15]*o,e}var Le=C(()=>{});function Co(){return Xt||(Xt=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Xt)),Xt}function wo(){return Jt||(Jt=new z,Object.freeze(Jt)),Jt}function En(e){if(e>Math.PI*2)throw Error("expected radians")}function Oo(e,t,r,n,s,i){let o=2*i/(r-t),a=2*i/(s-n),c=(r+t)/(r-t),l=(s+n)/(s-n),h=-1,f=-1,u=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=h,e[11]=f,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}var De,Eo,Ro,ve,ze,yo,z,Xt,Jt,Rn=C(()=>{zr();lt();Oe();Pe();kr();_t();Le();(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(De||(De={}));Eo=45*Math.PI/180,Ro=1,ve=.1,ze=500,yo=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends Yt{static get IDENTITY(){return wo()}static get ZERO(){return Co()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return De}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,s,i,o,a,c,l,h,f,u,d,m,p,g){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=h,this[10]=f,this[11]=u,this[12]=d,this[13]=m,this[14]=p,this[15]=g,this.check()}setRowMajor(t,r,n,s,i,o,a,c,l,h,f,u,d,m,p,g){return this[0]=t,this[1]=i,this[2]=l,this[3]=d,this[4]=r,this[5]=o,this[6]=h,this[7]=m,this[8]=n,this[9]=a,this[10]=f,this[11]=p,this[12]=s,this[13]=c,this[14]=u,this[15]=g,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(yo)}fromObject(t){return this.check()}fromQuaternion(t){return ln(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:r,right:n,bottom:s,top:i,near:o=ve,far:a=ze}=t;return a===1/0?Oo(this,r,n,s,i,o):hn(this,r,n,s,i,o,a),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:s=[0,1,0]}=t;return dn(this,r,n,s),this.check()}ortho(t){let{left:r,right:n,bottom:s,top:i,near:o=ve,far:a=ze}=t;return un(this,r,n,s,i,o,a),this.check()}orthographic(t){let{fovy:r=Eo,aspect:n=Ro,focalDistance:s=1,near:i=ve,far:o=ze}=t;En(r);let a=r/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:s=.1,far:i=500}=t;return En(r),fn(this,r,n,s,i),this.check()}determinant(){return tn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],i=1/n[1],o=1/n[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],i=1/n[1],o=1/n[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return Jr(this,this),this.check()}invert(){return Qr(this,this),this.check()}multiplyLeft(t){return Ne(this,t,this),this.check()}multiplyRight(t){return Ne(this,this,t),this.check()}rotateX(t){return sn(this,this,t),this.check()}rotateY(t){return on(this,this,t),this.check()}rotateZ(t){return an(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return nn(this,this,t,r),this.check()}scale(t){return rn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return en(this,this,t),this.check()}transform(t,r){return t.length===4?(r=Mn(r||[-0,-0,-0,-0],t,this),Wt(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,s;switch(n){case 2:s=Fr(r||[-0,-0],t,this);break;case 3:s=Ht(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Wt(s,t.length),s}transformAsVector(t,r){let n;switch(t.length){case 2:n=Ur(r||[-0,-0],t,this);break;case 3:n=jt(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Wt(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}}});function yn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function qe(e,t,r){r=r*.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function Fe(e,t,r){let n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],c=r[1],l=r[2],h=r[3];return e[0]=n*h+o*a+s*l-i*c,e[1]=s*h+o*c+i*a-n*l,e[2]=i*h+o*l+n*c-s*a,e[3]=o*h-n*a-s*c-i*l,e}function Cn(e,t,r){r*=.5;let n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+o*a,e[1]=s*c+i*a,e[2]=i*c-s*a,e[3]=o*c-n*a,e}function wn(e,t,r){r*=.5;let n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c-i*a,e[1]=s*c+o*a,e[2]=i*c+n*a,e[3]=o*c-s*a,e}function On(e,t,r){r*=.5;let n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+s*a,e[1]=s*c-n*a,e[2]=i*c+o*a,e[3]=o*c-i*a,e}function An(e,t){let r=t[0],n=t[1],s=t[2];return e[0]=r,e[1]=n,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),e}function In(e,t,r,n){let s=t[0],i=t[1],o=t[2],a=t[3],c=r[0],l=r[1],h=r[2],f=r[3],u,d,m,p,g;return u=s*c+i*l+o*h+a*f,u<0&&(u=-u,c=-c,l=-l,h=-h,f=-f),1-u>1e-6?(d=Math.acos(u),g=Math.sin(d),m=Math.sin((1-n)*d)/g,p=Math.sin(n*d)/g):(m=1-n,p=n),e[0]=m*s+p*c,e[1]=m*i+p*l,e[2]=m*o+p*h,e[3]=m*a+p*f,e}function bn(e,t){let r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i,a=o?1/o:0;return e[0]=-r*a,e[1]=-n*a,e[2]=-s*a,e[3]=i*a,e}function Nn(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Pn(e,t){let r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;n=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*n,n=.5/n,e[3]=(t[i*3+o]-t[o*3+i])*n,e[i]=(t[i*3+s]+t[s*3+i])*n,e[o]=(t[o*3+s]+t[s*3+o])*n}return e}var Ln,vn,zn,Dn,qn,Fn,Ao,kn,Un=C(()=>{_t();Le();Ln=mn,vn=pn,zn=Sn,Dn=_n,qn=xn,Fn=gn,Ao=Tn,kn=(function(){let e=Gr(),t=Ie(1,0,0),r=Ie(0,1,0);return function(n,s,i){let o=St(s,i);return o<-.999999?(ht(e,t,s),Kr(e)<1e-6&&ht(e,r,s),Vr(e,e),qe(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(ht(e,s,i),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,Ao(n,n))}})()});var Mt,Bn=C(()=>{Vt();lt();Un();Mt=class extends et{constructor(t=0,r=0,n=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,n,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,n,s){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Pn(this,t),this.check()}fromEuler(t){switch(this.identity(),t.order){case"xyz":return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z);case"yxz":return this.rotateY(t.y).rotateX(t.x).rotateZ(t.z);case"zxy":return this.rotateZ(t.z).rotateX(t.x).rotateY(t.y);case"zyx":return this.rotateZ(t.z).rotateY(t.y).rotateX(t.x);case"yzx":return this.rotateY(t.y).rotateZ(t.z).rotateX(t.x);case"xzy":return this.rotateX(t.x).rotateZ(t.z).rotateY(t.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(t,r){return qe(this,t,r),this.check()}identity(){return yn(this),this.check()}setAxisAngle(t,r){return this.fromAxisRotation(t,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=v(t)}get y(){return this[1]}set y(t){this[1]=v(t)}get z(){return this[2]}set z(t){this[2]=v(t)}get w(){return this[3]}set w(t){this[3]=v(t)}len(){return qn(this)}lengthSquared(){return Fn(this)}dot(t){return zn(this,t)}rotationTo(t,r){return kn(this,t,r),this.check()}add(t){return Ln(this,this,t),this.check()}calculateW(){return An(this,this),this.check()}conjugate(){return Nn(this,this),this.check()}invert(){return bn(this,this),this.check()}lerp(t,r,n){return n===void 0?this.lerp(this,t,r):(Dn(this,t,r,n),this.check())}multiplyRight(t){return Fe(this,this,t),this.check()}multiplyLeft(t){return Fe(this,t,this),this.check()}normalize(){let t=this.len(),r=t>0?1/t:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,t===0&&(this[3]=1),this.check()}rotateX(t){return Cn(this,this,t),this.check()}rotateY(t){return wn(this,this,t),this.check()}rotateZ(t){return On(this,this,t),this.check()}scale(t){return vn(this,this,t),this.check()}slerp(t,r,n){let s,i,o;return arguments.length===2?(s=this,i=t,o=r):(s=t,i=r,o=n),In(this,s,i,o),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,r){return this.setAxisAngle(t,r)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}}});var B=C(()=>{Xr();Rn();Bn();Pr();we();ct()});function Vn(e,t,r=e){let n=e.x,s=e.y,i=e.z,{semiMajorAxis:o,semiMinorAxis:a,eccentricitySquared:c}=t,l=Math.sin(s),h=Math.cos(s),f=a/o,u=c<.9?o/Math.sqrt(1-c*l*l):o/Math.hypot(h,f*l),d=(u+i)*h*Math.cos(n),m=(u+i)*h*Math.sin(n),p=(u*(c<.9?1-c:f*f)+i)*l;return nt(r,d,m,p)}function Wn(e,t,r=e){let n=e.x,s=e.y,i=e.z,{semiMajorAxis:o,semiMinorAxis:a,eccentricitySquared:c}=t,l=Math.hypot(n,s),h=Math.hypot(n,s,i);if(!(h>0)||!Number.isFinite(h))return!1;if(c===0)return nt(r,l===0?0:Math.atan2(s,n),Math.atan2(i,l),h-o);if(l===0)return nt(r,0,Math.sign(i)*Math.PI/2,Math.abs(i)-a);let f=l/o,u=i/a;if(f*f+u*u<1-16*Number.EPSILON)return Io(n,s,i,l,o,a,r);if(c>=.9)return Gn(n,s,i,l,o,a,r);let d=i/h,m=l/h,p=1/Math.sqrt(1-c*(2-c)*m*m),g=m*(1-c)*p,T=d*p;for(let R=0;R<30;R++){let _=o/Math.sqrt(1-c*T*T),M=l*g+i*T-_*(1-c*T*T),S=c*_/(_+M);p=1/Math.sqrt(1-S*(2-S)*m*m);let E=m*(1-S)*p,O=d*p;if(Math.abs(O*g-E*T)<=1e-12){if(!Number.isFinite(M)||!Number.isFinite(O)||!Number.isFinite(E))break;return nt(r,Math.atan2(s,n),Math.atan2(O,Math.abs(E)),M)}g=E,T=O}return Gn(n,s,i,l,o,a,r)}function Io(e,t,r,n,s,i,o){let a=i/s,c=a*a,l=n/s,h=r/s,f=1-c;if(!(c>0)||a>1)return!1;if(r===0)return l<f?!1:nt(o,Math.atan2(t,e),0,n-s);let u=s*s,d=i*i,m=Number.isFinite(u)&&u>0?(d-c*u+rt(i,i,d)-c*rt(s,s,u)-rt(c,u,c*u))/u:0,p=n*n,g=e*e,T=t*t,R=g+T,_=Number.isFinite(p)&&p>0?(R-p+ke(g,T,R)+rt(e,e,g)+rt(t,t,T)-rt(n,n,p))/(2*n):0,M=s*c,S=n-s+M,E=_+ke(n-s,M,S)+rt(s,c,M)+s*m,O=Math.abs(h)*a;if(!(O>0))return!1;let I=0,w=c,y=Math.max(O,l-f);y>I&&y<w||(y=w/2);for(let b=0;b<128;b++){let N=f+y,P=l/N,A=O/y,q=s*y,$=S-q,Lt=($+(ke(S,-q,$)+E-rt(s,y,q)))/(s*N)*(P+1),mt=Lt+A*A;if(Math.abs(mt)<=4*Number.EPSILON*(Math.abs(Lt)+A*A)||w-I<=4*Number.EPSILON*y){let Z=Math.atan2(h/y,l/N),ur=Math.sin(Z),dr=Math.cos(Z);return nt(o,Math.atan2(t,e),Z,n*dr+r*ur-s*Math.hypot(dr,a*ur))}mt>0?I=y:w=y;let hr=-2*(P*P/N+A*A/y),Q=y-mt/hr,fr=Number.isFinite(Q)&&Q>I&&Q<w?Q:I+(w-I)/2;if(fr===y){let Z=Math.atan2(h/y,l/N);return nt(o,Math.atan2(t,e),Z,n*Math.cos(Z)+r*Math.sin(Z)-s*Math.hypot(Math.cos(Z),a*Math.sin(Z)))}y=fr}return!1}function ke(e,t,r){let n=r-e;return e-(r-n)+(t-n)}function rt(e,t,r){let n=134217729*e,s=134217729*t;if(!Number.isFinite(n)||!Number.isFinite(s))return 0;let i=n-(n-e),o=s-(s-t),a=e-i,c=t-o;return i*o-r+i*c+a*o+a*c}function Gn(e,t,r,n,s,i,o){let a=i/s,c=a*a,l=n/s,h=r/s,f=Math.hypot(l,r/i);if(!Number.isFinite(f)||f<1-8*Number.EPSILON||!(c>0))return!1;let u=0,d=Math.hypot(l,h*a);if(!Number.isFinite(d))return!1;let m=f<=1+8*Number.EPSILON?0:d/2;for(let p=0;p<96;p++){let g=1+m,T=c+m,R=l/g,_=h*a/T,M=Math.hypot(R,_),S=M-1;if(Math.abs(S)<=4*Number.EPSILON){let I=Math.atan2(h/T,l/g),w=Math.sin(I),y=Math.cos(I),b=n*y+r*w-s*Math.hypot(y,a*w);return nt(o,Math.atan2(t,e),I,b)}S>0?u=m:d=m;let E=-(R*R/g+_*_/T)/M,O=m-S/E;m=Number.isFinite(O)&&O>u&&O<d?O:(u+d)/2}return!1}function nt(e,t,r,n){return!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(n)?!1:(e.x=t,e.y=r,e.z=n,!0)}var Yn=C(()=>{});var $n=C(()=>{_t()});var X,Hc,Zn=C(()=>{X=6356752314245179e-9,Hc={radii:[6378137,6378137,X],radiiSquared:[6378137*6378137,6378137*6378137,X*X],oneOverRadii:[1/6378137,1/6378137,1/X],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(X*X)],maximumRadius:Math.max(6378137,6378137,X),centerToleranceSquared:.1}});function Ue(e){return e}function No(e,t=[],r=Ue){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function Be(e,t=[]){return No(e,t,L._cartographicRadians?Ue:Re)}function Ge(e,t,r,n){let s=L._cartographicRadians?Ue:ye,i=s(e),o=s(t);return"longitude"in n?(n.longitude=i,n.latitude=o,n.height=r):"x"in n?(n.x=i,n.y=o,n.z=r):(n[0]=i,n[1]=o,n[2]=r),n}var Jc,jn=C(()=>{B();Jc=new x});function Hn(){return{eastX:0,eastY:1,northZ:1,upX:1,upY:0,upZ:0}}function Kn(e,t,r){let n=e.x,s=e.y,i=e.z,o=t.x,a=t.y,c=t.z;return i!==0?!1:Po(r,n,s,o*s-a*n,o,a,c)}function Xn(e,t,r,n,s,i){let o=Ve(r),a=Ve(n),c=Ve(s),l=Math.abs(o),h=Math.abs(a),f=Math.abs(c);if(!l||!h||!f||l===h||l===f||h===f||(l%3+1===h?1:-1)*Math.sign(o*a*c)!==1||!Array.isArray(i)&&i.length<16)return!1;let d=e.eastX,m=e.eastY,p=e.northZ,g=e.upX,T=e.upY,R=e.upZ,_=-R*m,M=R*d,S=t.x,E=t.y,O=t.z,I=(l===1?d:l===2?_:g)*Math.sign(o),w=(l===1?m:l===2?M:T)*Math.sign(o),y=(l===1?0:l===2?p:R)*Math.sign(o),b=(h===1?d:h===2?_:g)*Math.sign(a),N=(h===1?m:h===2?M:T)*Math.sign(a),P=(h===1?0:h===2?p:R)*Math.sign(a),A=(f===1?d:f===2?_:g)*Math.sign(c),q=(f===1?m:f===2?M:T)*Math.sign(c),$=(f===1?0:f===2?p:R)*Math.sign(c);return!Number.isFinite(I)||!Number.isFinite(w)||!Number.isFinite(y)||!Number.isFinite(b)||!Number.isFinite(N)||!Number.isFinite(P)||!Number.isFinite(A)||!Number.isFinite(q)||!Number.isFinite($)||!Number.isFinite(S)||!Number.isFinite(E)||!Number.isFinite(O)||i instanceof Float32Array&&(!Number.isFinite(Math.fround(I))||!Number.isFinite(Math.fround(w))||!Number.isFinite(Math.fround(y))||!Number.isFinite(Math.fround(b))||!Number.isFinite(Math.fround(N))||!Number.isFinite(Math.fround(P))||!Number.isFinite(Math.fround(A))||!Number.isFinite(Math.fround(q))||!Number.isFinite(Math.fround($))||!Number.isFinite(Math.fround(S))||!Number.isFinite(Math.fround(E))||!Number.isFinite(Math.fround(O)))?!1:(i[0]=I,i[1]=w,i[2]=y,i[3]=0,i[4]=b,i[5]=N,i[6]=P,i[7]=0,i[8]=A,i[9]=q,i[10]=$,i[11]=0,i[12]=S,i[13]=E,i[14]=O,i[15]=1,!0)}function Ve(e){switch(e){case"east":return 1;case"west":return-1;case"north":return 2;case"south":return-2;case"up":return 3;case"down":return-3;default:return 0}}function Po(e,t,r,n,s,i,o){return!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(o)?!1:(e.eastX=t,e.eastY=r,e.northZ=n,e.upX=s,e.upY=i,e.upZ=o,!0)}var Jn=C(()=>{});function Ye(e,t,r,n,s,i){let o=es[t]&&es[t][r];D(o&&(!n||n===o));let a,c,l,h=Lo.copy(s),f=U(h.x,0,Qn)&&U(h.y,0,Qn),u=e.radii;if(u.x===u.y&&u.x>0&&u.z>0&&u.z<=u.x&&(!f||h.z!==0)){let{east:w,up:y}=ft;if(f?(w.set(0,1,0),y.set(0,0,Math.sign(h.z))):(w.set(-h.y,h.x,0).normalize(),e.geodeticSurfaceNormal(h,y)),!Kn(w,y,ts)||!Xn(ts,h,t,r,n,i))throw new Error("Unsupported local frame");return i}if(f){let w=Math.sign(h.z);a=vo.fromArray(We[t]),t!=="east"&&t!=="west"&&a.scale(w),c=zo.fromArray(We[r]),r!=="east"&&r!=="west"&&c.scale(w),l=Do.fromArray(We[n]),n!=="east"&&n!=="west"&&l.scale(w)}else{let{up:w,east:y,north:b}=ft;y.set(-h.y,h.x,0).normalize(),e.geodeticSurfaceNormal(h,w),b.copy(w).cross(y);let{down:N,west:P,south:A}=ft;N.copy(w).scale(-1),P.copy(y).scale(-1),A.copy(b).scale(-1),a=ft[t],c=ft[r],l=ft[n]}let d=a.x,m=a.y,p=a.z,g=c.x,T=c.y,R=c.z,_=l.x,M=l.y,S=l.z,E=h.x,O=h.y,I=h.z;return i[0]=d,i[1]=m,i[2]=p,i[3]=0,i[4]=g,i[5]=T,i[6]=R,i[7]=0,i[8]=_,i[9]=M,i[10]=S,i[11]=0,i[12]=E,i[13]=O,i[14]=I,i[15]=1,i}var Qn,Lo,ts,es,We,ft,vo,zo,Do,rs=C(()=>{B();Jn();Qn=1e-14,Lo=new x,ts=Hn(),es={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},We={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},ft={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x},vo=new x,zo=new x,Do=new x});function ss(e,t,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:s,centerToleranceSquared:i}=t,o=e,a="x"in e?o.x:e[0],c="x"in e?o.y:e[1],l="x"in e?o.z:e[2];if(!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(l))return;ns.set(a,c,l);let h=n.x,f=n.y,u=n.z,d=a*a*h*h,m=c*c*f*f,p=l*l*u*u,g=d+m+p,T=Math.sqrt(1/g);if(!Number.isFinite(T)||!Number.isFinite(g))return;let R=qo;if(R.set(a,c,l).scale(T),g<i)return Qt(r,R.x,R.y,R.z);let _=s.x,M=s.y,S=s.z,E=Fo;E.set(R.x*_*2,R.y*M*2,R.z*S*2);let O=(1-T)*ns.len()/(.5*E.len()),I=0,w,y,b,N;for(let P=0;P<64;P++){O-=I,w=1/(1+O*_),y=1/(1+O*M),b=1/(1+O*S);let A=w*w,q=y*y,$=b*b,lr=A*w,Lt=q*y,mt=$*b;if(N=d*A+m*q+p*$-1,!Number.isFinite(N))return;if(Math.abs(N)<=K.EPSILON12)return Qt(r,a*w,c*y,l*b);let Q=-2*(d*lr*_+m*Lt*M+p*mt*S);if(!Number.isFinite(Q)||Q===0||(I=N/Q,!Number.isFinite(I)))return}}function Qt(e,t,r,n){if(Y(e))e[0]=t,e[1]=r,e[2]=n;else{let s=e;s.x=t,s.y=r,s.z=n}return e}var ns,qo,Fo,is=C(()=>{B();ns=new x,qo=new x,Fo=new x});function as(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0||t>e)throw new Error("Spheroid requires finite positive axes with semiMinorAxis <= semiMajorAxis")}var F,te,os,Bo,V,Go,Et,k,cs=C(()=>{B();Yn();$n();Zn();jn();rs();is();F={x:0,y:0,z:0},te=new x,os=new x,Bo=new x,V=new x,Go=new x,Et=new x,k=class e{static fromSpheroid(t){let{semiMajorAxis:r,semiMinorAxis:n}=t;return as(r,n),new e(r,r,n)}constructor(t=0,r=0,n=0){this.centerToleranceSquared=K.EPSILON1,D(t>=0),D(r>=0),D(n>=0),this.radii=new x(t,r,n),this.radiiSquared=new x(t*t,r*r,n*n),this.radiiToTheFourth=new x(t*t*t*t,r*r*r*r,n*n*n*n),this.oneOverRadii=new x(t===0?0:1/t,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new x(t===0?0:1/(t*t),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,r,n),this.maximumRadius=Math.max(t,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),t===r&&n>0&&n<=t&&Number.isFinite(this.radiiSquared.x)&&this.radiiSquared.z>0&&(this.spheroidGeometry=Object.freeze({semiMajorAxis:t,semiMinorAxis:n,eccentricitySquared:1-this.radiiSquared.z/this.radiiSquared.x})),Object.freeze(this)}toSpheroid(){let{x:t,y:r,z:n}=this.radii;if(t!==r)throw new Error("Spheroid requires equal X/Y radii");return as(t,n),Object.freeze({semiMajorAxis:t,semiMinorAxis:n})}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){if(this.spheroidGeometry){let a=Be(t,Et);return F.x=a[0],F.y=a[1],F.z=a[2],Vn(F,this.spheroidGeometry)?Qt(r,F.x,F.y,F.z):void 0}let n=os,s=Bo,[,,i]=t;this.geodeticSurfaceNormalCartographic(t,n),s.copy(this.radiiSquared).scale(n);let o=Math.sqrt(n.dot(s));return s.scale(1/o),n.scale(i),s.add(n),s.to(r)}cartesianToCartographic(t,r=[0,0,0]){let n=t,s="x"in t?n.x:t[0],i="x"in t?n.y:t[1],o="x"in t?n.z:t[2];if(!Number.isFinite(s)||!Number.isFinite(i)||!Number.isFinite(o))return;if(this.spheroidGeometry&&Number.isFinite(s*s+i*i+o*o)&&Number.isFinite(this.oneOverRadiiSquared.x)&&Number.isFinite(this.oneOverRadiiSquared.z)){if(F.x=s,F.y=i,F.z=o,!Wn(F,this.spheroidGeometry))return;let d=s===0&&i===0?Math.atan2(i,s):F.x;return Ge(d,F.y,F.z,r)}Et.set(s,i,o);let a=this.scaleToGeodeticSurface(Et,V);if(!a)return;let c=this.geodeticSurfaceNormal(a,os),l=Go;l.copy(Et).subtract(a);let h=Math.atan2(c.y,c.x),f=Math.atan2(c.z,Math.hypot(c.x,c.y)),u=Math.sign(St(l,Et))*Ae(l);return Ge(h,f,u,r)}eastNorthUpToFixedFrame(t,r=new z){return Ye(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,n,s,i=new z){return Ye(this,t,r,n,s,i)}geocentricSurfaceNormal(t,r=[0,0,0]){return te.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let n=Be(t),s=n[0],i=n[1],o=Math.cos(i);return te.set(o*Math.cos(s),o*Math.sin(s),Math.sin(i)).normalize(),te.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return te.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return ss(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){V.from(t);let n=V.x,s=V.y,i=V.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*o.x+s*s*o.y+i*i*o.z);return V.multiplyByScalar(a).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return V.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return V.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,n=[0,0,0]){D(U(this.radii.x,this.radii.y,K.EPSILON15)),D(this.radii.z>0),V.from(t);let s=V.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-r))return V.set(0,0,s).to(n)}};k.WGS84=new k(6378137,6378137,X)});var ls=C(()=>{Pe()});var Rt,hs,yt,fs=C(()=>{B();ls();Rt=new x,hs=new x,yt=class e{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new x,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=Rt.from(r),this.center=new x().from(t).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new e(this.center,this.radius)}union(t){let r=this.center,n=this.radius,s=t.center,i=t.radius,o=Rt.copy(s).subtract(r),a=o.magnitude();if(n>=a+i)return this.clone();if(i>=a+n)return t.clone();let c=(n+a+i)*.5;return hs.copy(o).scale((-n+c)/a).add(r),this.center.copy(hs),this.radius=c,this}expand(t){let n=Rt.from(t).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(t){this.center.transform(t);let r=cn(Rt,t);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(t){let r=this.distanceTo(t);return r*r}distanceTo(t){let n=Rt.from(t).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(t){let r=this.center,n=this.radius,i=t.normal.dot(r)+t.distance;return i<-n?"outside":i<n?"intersecting":"inside"}}});var us,ds,G,$e=C(()=>{B();us=new x,ds=new x,G=class e{constructor(t=[0,0,1],r=0){this.normal=new x,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return D(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=us.from(t),this.normal.from(r).normalize();let n=-this.normal.dot(t);return this.distance=n,this}fromCoefficients(t,r,n,s){return this.normal.set(t,r,n),D(U(this.normal.len(),1)),this.distance=s,this}clone(){return new e(this.normal,this.distance)}equals(t){return U(this.distance,t.distance)&&U(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=ds.copy(this.normal).transformAsVector(t).normalize(),n=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(n,r)}projectPointOntoPlane(t,r=[0,0,0]){let n=us.from(t),s=this.getPointDistance(n),i=ds.copy(this.normal).scale(s);return n.subtract(i).to(r)}intersectWithRay(t,r=new x){let n=t.origin,s=t.direction,i=this.normal,o=i.dot(s);if(Math.abs(o)<K.EPSILON15)return;let a=(-this.distance-i.dot(n))/o;if(!(a<0))return r.copy(s).multiplyByScalar(a).add(n)}}});var ms,ps,Wo,st,xs=C(()=>{B();$e();ms=[new x([1,0,0]),new x([0,1,0]),new x([0,0,1])],ps=new x,Wo=new x,st=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*ms.length;let r=t.center,n=t.radius,s=0;for(let i of ms){let o=this.planes[s],a=this.planes[s+1];o||(o=this.planes[s]=new G),a||(a=this.planes[s+1]=new G);let c=ps.copy(i).scale(-n).add(r);o.fromPointNormal(c,i);let l=ps.copy(i).scale(n).add(r),h=Wo.copy(i).negate();a.fromPointNormal(l,h),s+=2}return this}computeVisibility(t){let r="inside";for(let n of this.planes)switch(t.intersectPlane(n)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(D(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let n=e.MASK_INSIDE,s=this.planes;for(let i=0;i<this.planes.length;++i){let o=i<31?1<<i:0;if(i<31&&(r&o)===0)continue;let a=s[i],c=t.intersectPlane(a);if(c==="outside")return e.MASK_OUTSIDE;c==="intersecting"&&(n|=o)}return n}};st.MASK_OUTSIDE=4294967295;st.MASK_INSIDE=0;st.MASK_INDETERMINATE=2147483647});var Ze=C(()=>{fs();xs();$e()});var gs=C(()=>{cs()});var Ts=C(()=>{});function He(e){Yo(e)}function Yo(e){if(typeof e.id!="string"||!e.id||e.origin.length!==2||e.tileSize.length!==2||e.matrixSize.length!==2||!Number.isFinite(e.resolution)||e.resolution<=0||e.resolutionY!==void 0&&(!Number.isFinite(e.resolutionY)||e.resolutionY<=0)||!e.origin.every(Number.isFinite)||![...e.tileSize,...e.matrixSize].every(n=>Number.isSafeInteger(n)&&n>0)||!["topLeft","bottomLeft"].includes(e.cornerOfOrigin))throw new RangeError("Invalid tile matrix geometry");let t=[...e.variableMatrixWidths??[]].sort((n,s)=>n.minTileRow-s.minTileRow),r=-1;for(let n of t){if(!Number.isSafeInteger(n.coalesce)||n.coalesce<=1||e.matrixSize[0]%n.coalesce!==0||!Number.isSafeInteger(n.minTileRow)||!Number.isSafeInteger(n.maxTileRow)||n.minTileRow<=r||n.maxTileRow<n.minTileRow||n.maxTileRow>=e.matrixSize[1])throw new RangeError("Invalid variable matrix width");r=n.maxTileRow}for(let n=0;n<2;n++){let i=(n===1?e.resolutionY??e.resolution:e.resolution)*e.tileSize[n],o=i*e.matrixSize[n],a=n===1&&e.cornerOfOrigin==="topLeft"?-1:1,c=e.origin[n]+a*o;if(!Number.isFinite(o)||o<=0||!Number.isFinite(c)||e.origin[n]+a*i===e.origin[n]||c-a*i===c)throw new RangeError("Tile matrix extent must be finite")}return t}function Ke(e,t,r,n){return He(e),n&&Ms(e,n),Number.isSafeInteger(t)&&Number.isSafeInteger(r)&&t>=0&&r>=0&&t<e.matrixSize[0]&&r<e.matrixSize[1]&&(!n||t>=n.minTileColumn&&t<=n.maxTileColumn&&r>=n.minTileRow&&r<=n.maxTileRow)}function _s(e,t,r){if(!Ke(e,t,r))throw new RangeError("Tile index outside matrix");let n=e.resolution*e.tileSize[0],s=(e.resolutionY??e.resolution)*e.tileSize[1],i=Ho(e,r),o=Math.floor(t/i)*i,a=e.origin[0]+o*n,c=e.cornerOfOrigin==="topLeft"?e.origin[1]-(r+1)*s:e.origin[1]+r*s;return[a,c,e.origin[0]+(o+i)*n,e.cornerOfOrigin==="topLeft"?e.origin[1]-r*s:e.origin[1]+(r+1)*s]}function $o(e,t,r,n,s,i=1){let o=e+t*(n*r);return(t===1?s<e||s>=o:s>e||s<=o)?null:(je(e,t,r,n,s,!1,i)-1)*i}function je(e,t,r,n,s,i,o=1){let a=0,c=n/o;for(;a<c;){let l=a+Math.floor((c-a)/2),h=e+t*(l*o*r);(t===1?i?h<s:h<=s:i?h>s:h>=s)?a=l+1:c=l}return a}function Ms(e,t){if(![t.minTileColumn,t.maxTileColumn,t.minTileRow,t.maxTileRow].every(n=>Number.isSafeInteger(n)&&n>=0)||t.minTileColumn>t.maxTileColumn||t.minTileRow>t.maxTileRow||t.maxTileColumn>=e.matrixSize[0]||t.maxTileRow>=e.matrixSize[1])throw new RangeError("Invalid tile matrix limits")}function Zo(e,t,r){jo(t);let n=Ss(e.origin[0],1,e.resolution*e.tileSize[0],e.matrixSize[0],t[0],t[2]),s=e.cornerOfOrigin==="topLeft",i=Ss(e.origin[1],s?-1:1,(e.resolutionY??e.resolution)*e.tileSize[1],e.matrixSize[1],s?t[3]:t[1],s?t[1]:t[3]);if(!n||!i)return null;let o={minTileColumn:Math.max(n[0],r?.minTileColumn??0),maxTileColumn:Math.min(n[1],r?.maxTileColumn??e.matrixSize[0]-1),minTileRow:Math.max(i[0],r?.minTileRow??0),maxTileRow:Math.min(i[1],r?.maxTileRow??e.matrixSize[1]-1)};return o.minTileColumn>o.maxTileColumn||o.minTileRow>o.maxTileRow?null:o}function jo(e){if(e.length!==4||!e.every(Number.isFinite)||e[0]>e[2]||e[1]>e[3])throw new RangeError("Tile query bounds must be finite and ordered")}function Es(e,t,r){if(He(e),e.variableMatrixWidths?.length)throw new RangeError("Use getTileRanges for variable-width matrices");return r&&Ms(e,r),Zo(e,t,r)}function Ho(e,t){return e.variableMatrixWidths?.find(r=>t>=r.minTileRow&&t<=r.maxTileRow)?.coalesce??1}function Ss(e,t,r,n,s,i,o=1){if(s===i){let h=$o(e,t,r,n,s,o);return h===null?null:[h,h]}let a=e+t*(n*r),c=t===1?Math.max(s,e):Math.min(s,e),l=t===1?Math.min(i,a):Math.max(i,a);return(t===1?c>=l:c<=l)?null:[(je(e,t,r,n,c,!1,o)-1)*o,(je(e,t,r,n,l,!0,o)-1)*o]}function Rs(e,t){if(!Number.isFinite(t)||t<=0)throw new RangeError("Target resolution must be positive and finite");let r=null,n=null,s=-1/0,i=1/0,o=new Set;for(let a of e.matrices){if(He(a),o.has(a.id))throw new RangeError("Tile matrix identifiers must be unique");o.add(a.id);let c=Math.max(a.resolution,a.resolutionY??a.resolution);(!n||c<i)&&(n=a,i=c),c<=t&&(!r||c>s)&&(r=a,s=c)}return r??n}var ys=C(()=>{});var Cs=C(()=>{});var ee=C(()=>{gs();Ts();Cs()});var Ct=C(()=>{"use strict";gr();Sr();Mr()});var Pt={};mr(Pt,{ImageSet:()=>ie,LOD_METRIC_TYPE:()=>bt,RasterSet:()=>oe,STRATEGY_DEFAULT:()=>dt,STRATEGY_NEVER:()=>re,STRATEGY_REPLACE:()=>ne,SharedTile2DHeader:()=>tt,TILESET_TYPE:()=>J,TILE_TYPE:()=>It,Tileset2D:()=>ut,Tileset3D:()=>Nt,selectTileMatrixTiles:()=>si});Dt(Pt,fi(xr(),1));var tt=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(t){this.index=t,this.parent=null,this.children=[],this.content=null,this.error=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.bottom]])}get data(){let t=this._loader;return!this._isCancelled&&t!==void 0?t.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get hasError(){return!!this.error}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let t=this.content?this.content.byteLength:0;return Number.isFinite(t)?t:0}async _loadData({getData:t,requestScheduler:r,onLoad:n,onError:s}){let i=(g,T,R)=>{if(!(R!==this._loaderId||this._isCancelled)){if(this._loader=void 0,this.content=g,this.error=T?di(T):null,this._isLoaded=!0,this._isCancelled=!1,T){s(T,this);return}n(this)}},{index:o,id:a,bbox:c,userData:l,zoom:h}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:u}=this._abortController,d=await r.scheduleRequest({tile:this,loaderId:f},()=>f===this._loaderId&&!this._isCancelled?1:-1);if(this._isCancelled||f!==this._loaderId){d?.done();return}if(!d){this._isCancelled=!0;return}let m=null,p;try{m=await t({index:o,id:a,bbox:c,userData:l,zoom:h,signal:u})}catch(g){p=g||!0}finally{d.done()}i(m,p,f)}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._loaderId++,this._loader=void 0,this._abortController?.abort())}};function di(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}Ct();Ft();var re="never",ne="no-overlap",dt="best-available",ws={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:dt,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},ut=class e{stats;sourceMetadata=null;opts;_requestScheduler;_cache;_dirty;_tiles;_cacheByteSize;_unloadedTileCount;_listeners=new Set;_consumers=new Map;_explicitOptionKeys=new Set;_baseOpts={};_sourceMetadataOverrides={};_maxZoom;_minZoom;_lastTileContext=null;_statsUpdateScheduled=!1;_lifecycleVersion=0;constructor(t){if(this.stats=new W({id:"Tileset2D",stats:[{name:"Tiles In Cache"},{name:"Cache Size"},{name:"Visible Tiles"},{name:"Selected Tiles"},{name:"Loading Tiles"},{name:"Unloaded Tiles"},{name:"Consumers"}]}),this.opts={...ws,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new j({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._unloadedTileCount=0,!this.opts.tileSource&&!t.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(t),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(t,r={}){return new e({...r,tileSource:t})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let t=this._getVisibleTilesUnion();for(let r of this._getSelectedTilesUnion())t.add(r);return Array.from(t)}get loadingTiles(){return Array.from(this._cache.values()).filter(t=>t.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(t=>!t.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||dt}get adapter(){return this.opts.adapter}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}attachConsumer(t){this._consumers.set(t,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(t){this._consumers.delete(t),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(t){this._rememberExplicitOptions(t),this._baseOpts={...this._baseOpts,...t};let r=this.opts.maxRequests,n=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||n!==this.opts.debounceTime)&&(this._requestScheduler=new j({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){this._lifecycleVersion++;for(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let t=this._getSelectedTilesUnion(),r=this._getVisibleTilesUnion();for(let n of this._cache.keys()){let s=this._cache.get(n);s&&!t.has(s)&&!r.has(s)?(this._cache.delete(n),this._handleTileUnload(s),this._dirty=!0):s&&s.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,r,n){this._consumers.set(t,{selectedTiles:new Set(r),visibleTiles:new Set(n)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:r,minZoom:n,zRange:s,modelMatrix:i,modelMatrixInverse:o}){let{adapter:a,tileSize:c,extent:l,zoomOffset:h}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:t,tileSize:c},a.getTileIndices({viewState:t,maxZoom:r,minZoom:n,zRange:s,tileSize:c,extent:Ko(l),modelMatrix:i,modelMatrixInverse:o,zoomOffset:h})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){if(!this._lastTileContext)throw new Error("Tileset2D metadata requested before traversal context was set.");if(!this.opts.adapter)throw new Error("Tileset2D requires an adapter before tile metadata can be derived.");return{bbox:this.opts.adapter.getTileBoundingBox(this._lastTileContext,t)}}getParentIndex(t){return{x:Math.floor(t.x/2),y:Math.floor(t.y/2),z:t.z-1}}getTile(t,r){let n=this.getTileId(t),s=this._cache.get(n),i=!1;if(!s&&r?(s=new tt(t),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:n,zoom:this.getTileZoom(s.index)}),i=!0,this._cache.set(n,s),this._dirty=!0,this._setStatCount("Tiles In Cache",this._cache.size),this._scheduleStatsUpdate()):s&&s.needsReload&&(i=!0),s&&this._touchTile(n,s),s&&i&&r){let o=s.isLoading;s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),o||this.stats.get("Loading Tiles").incrementCount(),this._scheduleStatsUpdate()}return s}async _initializeTileSource(t){let r=this._lifecycleVersion;try{let n=await t.getMetadata();if(r!==this._lifecycleVersion)return;this.sourceMetadata=n,this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(n){if(r!==this._lifecycleVersion)return;let s=n instanceof Error?n:new Error(`TileSource metadata error: ${String(n)}`);this._notifyError(s)}}_rememberExplicitOptions(t){for(let r of Object.keys(t))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let t={...ws,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let r=t.tileSource;t.getTileData=n=>r.getTileData(n)}this.opts=t,this._maxZoom=typeof this.opts.maxZoom=="number"&&Number.isFinite(this.opts.maxZoom)?Math.floor(this.opts.maxZoom):void 0,this._minZoom=typeof this.opts.minZoom=="number"&&Number.isFinite(this.opts.minZoom)?Math.ceil(this.opts.minZoom):void 0}_getMetadataOverrides(t){if(!t)return{};let r={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(r.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(r.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(r.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),r}_handleTileLoad(t){let r=this._lifecycleVersion;if(this._cache.get(t.id)===t&&(this.opts.onTileLoad?.(t),this._cache.get(t.id)===t)){this._cacheByteSize=this._getCacheByteSize(),this._resizeCache(),this._updateStats();for(let n of this._listeners){if(r!==this._lifecycleVersion)return;n.onTileLoad?.(t)}}}_handleTileError(t,r){let n=this._lifecycleVersion;if(this._cache.get(r.id)===r&&(this.opts.onTileError?.(t,r),this._cache.get(r.id)===r)){this._cacheByteSize=this._getCacheByteSize(),this._resizeCache(),this._updateStats();for(let s of this._listeners){if(n!==this._lifecycleVersion)return;s.onTileError?.(t,r)}}}_handleTileUnload(t){t.abort(),this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let r of this._listeners)r.onTileUnload?.(t)}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let r of this._listeners)r.onError?.(t)}_scheduleStatsUpdate(){this._statsUpdateScheduled||(this._statsUpdateScheduled=!0,queueMicrotask(()=>{this._statsUpdateScheduled&&this._updateStats()}))}_updateStats(){this._statsUpdateScheduled=!1,this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let t of this._listeners)t.onStatsChange?.(this.stats)}_setStatCount(t,r){this.stats.get(t).reset().addCount(r)}_getSelectedTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let n of r.selectedTiles)t.add(n);return t}_getVisibleTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let n of r.visibleTiles)t.add(n);return t}_touchTile(t,r){this._cache.delete(t),this._cache.set(t,r)}_getCacheByteSize(){let t=0;for(let r of this._cache.values())t+=r.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,r=this._getSelectedTilesUnion(),n=this._getVisibleTilesUnion(),s=[],i=0;for(let o of this._cache.values())o.isLoading&&(i++,!r.has(o)&&!n.has(o)&&s.push(o));for(;t>0&&i>t&&s.length>0;){let o=s.shift();o&&o.abort(),i--}}_rebuildTree(){for(let t of this._cache.values())t.parent=null,t.children&&(t.children.length=0);for(let t of this._cache.values()){let r=this._getNearestAncestor(t);t.parent=r,r?.children&&r.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,r)=>t.zoom-r.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,r=this.opts.maxCacheByteSize??1/0,n=this._getVisibleTilesUnion(),s=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>r){for(let[o,a]of this._cache)if(!n.has(a)&&!s.has(a)&&(this._cache.delete(o),this._cacheByteSize-=a.byteLength,this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=r)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:r=0}=this,n=t.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let s=this._cache.get(this.getTileId(n));if(s)return s}return null}};function Ko(e){return e&&e.length===4?e:void 0}var se={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},ie=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.imageSource&&(!t.getImage||!t.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(t,r={}){return new e({...r,imageSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.imageSource,n=this._normalizeOptions({...this._opts,...t}),s=r!==n.imageSource||this._opts.getImage!==n.getImage||this._opts.getMetadata!==n.getMetadata;this._opts=n,s&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let r of this._listeners)r.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let r=Os(t,"Image metadata request failed");if(!this._finalized)for(let n of this._listeners)n.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(t,r=this._opts.debounceTime){let n=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(n,t)},r):this._loadImage(n,t),n}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,r){if(!this._finalized){this._startLoading();for(let n of this._listeners)n.onImageLoadStart?.(t,r);try{let n=new AbortController;this._abortController=n;let s=await this._opts.getImage({...r,signal:n.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,image:s};for(let i of this._listeners)i.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(n){if(Xo(n))return;let s=Os(n,"Image request failed");if(!this._finalized)for(let i of this._listeners)i.onImageLoadError?.(t,s,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let r=t.imageSource||null;return{...se,...t,imageSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():se.getMetadata()),getImage:t.getImage||(n=>r?r.getImage(n):se.getImage(n)),debounceTime:t.debounceTime??se.debounceTime}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(t){for(let r of this._listeners)r.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function Xo(e){return e instanceof Error&&e.name==="AbortError"}function Os(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}Ct();var wt={getMetadata:async()=>({width:0,height:0,bandCount:0,dtype:"uint8"}),getRaster:async()=>({data:new Uint8Array(0),width:0,height:0,bandCount:0,dtype:"uint8"}),debounceTime:0,shouldRefetch:()=>!0},oe=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_metadataAbortController=null;_finalized=!1;_sourceGeneration=0;_metadataRequestId=0;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.rasterSource&&(!t.getRaster||!t.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(t,r={}){return new e({...r,rasterSource:t})}static fromCallbacks(t){return new e(t)}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get raster(){return this._currentRequest?.raster||null}get currentRequest(){return this._currentRequest}get rasterSource(){return this._opts.rasterSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.rasterSource,n={...this._opts,...t};t.rasterSource&&t.rasterSource!==r&&(n.getRaster=t.getRaster,n.getMetadata=t.getMetadata);let s=this._normalizeOptions(n),i=r!==s.rasterSource||this._opts.getRaster!==s.getRaster||this._opts.getMetadata!==s.getMetadata;this._opts=s,i&&(this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._sourceGeneration++,this.metadata=null,this._currentRequest=null,this._emitUpdate())}async loadMetadata(t={}){if(this._finalized)throw new Error("RasterSet is finalized");t.signal?.throwIfAborted(),this._metadataAbortController?.abort();let r=new AbortController;this._metadataAbortController=r;let n=()=>r.abort(t.signal?.reason);t.signal?.addEventListener("abort",n,{once:!0});let s=++this._metadataRequestId,i=this._sourceGeneration;try{this._startLoading(),r.signal.throwIfAborted();let o=await kt(a=>this._opts.getMetadata({signal:a}),[r.signal]);if(r.signal.throwIfAborted(),this._finalized||i!==this._sourceGeneration||s!==this._metadataRequestId)return o;this.metadata=o;for(let a of this._listeners)a.onMetadataLoad?.(o);return this._emitUpdate(),o}catch(o){if(r.signal.aborted)throw r.signal.reason;if(Is(o))throw o;let a=As(o,"Raster metadata request failed");if(!this._finalized&&i===this._sourceGeneration&&s===this._metadataRequestId)for(let c of this._listeners)c.onMetadataLoadError?.(a);throw a}finally{t.signal?.removeEventListener("abort",n),this._metadataAbortController===r&&(this._metadataAbortController=null),this._finishLoading()}}requestRaster(t,r=this._opts.debounceTime){if(this._finalized)return-1;if(!this.shouldRefetchRaster(t))return this._cancelScheduledRaster(),this._abortActiveRequest(),this._nextRequestId++,this._currentRequest?.requestId??-1;let n=this._nextRequestId++;return this._cancelScheduledRaster(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(n,t)},r):this._loadRaster(n,t),n}shouldRefetchRaster(t){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:t})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._metadataAbortController=null,this._loadCounter=0,this._listeners.clear()}async _loadRaster(t,r){if(this._finalized)return;let n=r.signal;if(n?.aborted)return;let s=new AbortController;this._abortController=s;let i=()=>s.abort(n?.reason);n?.addEventListener("abort",i,{once:!0}),this._startLoading();try{s.signal.throwIfAborted();for(let a of this._listeners)a.onRasterLoadStart?.(t,r);s.signal.throwIfAborted();let o=await kt(a=>this._opts.getRaster(Jo(r,a)),[s.signal]);if(this._finalized||s.signal.aborted||t!==this._nextRequestId-1)return;this._currentRequest={requestId:t,parameters:r,raster:o};for(let a of this._listeners)a.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(o){if(s.signal.aborted||Is(o))return;let a=As(o,"Raster request failed");if(!this._finalized&&t===this._nextRequestId-1)for(let c of this._listeners)c.onRasterLoadError?.(t,a,r)}finally{n?.removeEventListener("abort",i),this._abortController===s&&(this._abortController=null),this._finishLoading()}}_normalizeOptions(t){let r=t.rasterSource||null;return{...wt,...t,rasterSource:r,getMetadata:t.getMetadata||(n=>r?r.getMetadata(n):wt.getMetadata()),getRaster:t.getRaster||(n=>r?r.getRaster(n):wt.getRaster(n)),debounceTime:t.debounceTime??wt.debounceTime,shouldRefetch:t.shouldRefetch||(n=>wt.shouldRefetch(n))}}_emitUpdate(){if(!this._finalized)for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){if(!this._finalized)for(let r of this._listeners)r.onLoadingStateChange?.(t)}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function Jo(e,t){let r=Object.getOwnPropertyDescriptors(e);delete r.signal;let n=Array.isArray(e)?Object.defineProperties(e.slice(),r):Object.create(Object.getPrototypeOf(e),r);return Object.defineProperty(n,"signal",{configurable:!0,enumerable:!0,value:t,writable:!0}),n}function As(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function Is(e){return e instanceof Error&&e.name==="AbortError"}B();ee();Ft();Ct();var ae=class{item;previous;next;constructor(t,r,n){this.item=t,this.previous=r,this.next=n}};var ce=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new ae(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){let n=t.next;t.next=r,this.tail===t?this.tail=r:n.previous=r,r.next=n,r.previous=t,++this._length}};var le=class{_list;_sentinel;_trimTiles;constructor(){this._list=new ce,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(t,r))}unloadTile(t,r,n){let s=r._cacheNode;s&&(this._list.remove(s),r._cacheNode=null,n&&n(t,r))}unloadTiles(t,r){let n=this._trimTiles;this._trimTiles=!1;let s=this._list,i=this._sentinel,o=s.head;for(;o!==i&&(t.gpuMemoryUsageInBytes>t.cacheBytes||n);){let a=o.item;o=o.next,this.unloadTile(t,a,r)}}trim(){this._trimTiles=!0}};ee();B();Ct();function bs(e,t){qt(e),qt(t);let{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:s,boundingVolume:{center:i}}=e,o=new z(s);switch(r&&o.translate(r),n){case"Z":break;case"Y":let u=new z().rotateX(Math.PI/2);o=o.multiplyRight(u);break;case"X":let d=new z().rotateY(-Math.PI/2);o=o.multiplyRight(d);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new x(i);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let c=k.WGS84.cartesianToCartographic(a,new x),h=k.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=h.multiplyRight(o),t.cartographicOrigin=c;let f=ta(t);f&&(t.cartesianModelMatrix=new z(o).multiplyRight(f.matrix),t.cartographicModelMatrix.multiplyRight(f.matrix),f.matrix=z.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Qo=1e6**2;function ta(e){let t=e.gltf;if(!t)return null;let r=typeof t.scene=="number"?t.scene:0,s=t.scenes?.[r]?.nodes?.[0];if(!s?.matrix)return null;let i=s.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Qo?null:s}B();Ze();ee();var Ns=new x,Xe=new x,ea=1e-5,ra=1e-7,Je=new st([new G,new G,new G,new G,new G,new G]);function Ps(e,t,r={}){let{cameraUp:n,height:s}=e,i=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=Ot(e,e.center),c=k.WGS84.eastNorthUpToFixedFrame(a),l=e.unprojectPosition(e.cameraPosition),h=k.WGS84.cartographicToCartesian(l,new x),f;if(i)f=new x(c.transformAsVector(new x(i).scale(o))).normalize();else{let E=e.getFrustumPlanes().near,O=Qe(E,e.cameraPosition),I=Ot(e,O);f=new x(I).subtract(h).normalize()}let u=new x(c.transformAsVector(new x(n).scale(o))).normalize();na(e);let d=e.constructor,{longitude:m,latitude:p,width:g,bearing:T,zoom:R,position:_}=e,M=new d({longitude:m,latitude:p,height:s,width:g,bearing:T,zoom:R,position:_,pitch:0}),S=Number.isFinite(e.fovy)&&Number(e.fovy)>0&&Number(e.fovy)<180?Number(e.fovy)*Math.PI/180:Math.PI/3;return{camera:{position:h,direction:f,up:u,cartographicPosition:l,verticalFieldOfView:S,timeSinceMovement:r.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:e,topDownViewport:M,height:s,cullingVolume:Je,clippingPlanes:e.clippingPlanes,frameNumber:t,sseDenominator:2*Math.tan(S/2),dynamicScreenSpaceErrorDensity:0}}function Ls(e,t,r,n){let s=Array.from(t),i=Array.from(r),o=e?s.length!==e.position.length||s.some((l,h)=>Math.abs(l-e.position[h])>ea):!1,a=e?i.length!==e.direction.length||i.some((l,h)=>Math.abs(l-e.direction[h])>ra):!1,c=o||a?n:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:s,direction:i,lastMovementTime:c},timeSinceMovement:Math.max((n-c)/1e3,0)}}function vs(e,t,r){if(r===0||e.length<=r)return[e,[]];let n=[],{longitude:s,latitude:i}=t.viewport;for(let[l,h]of e.entries()){let[f,u]=h.header.mbs,d=Math.abs(s-f),m=Math.abs(i-u),p=Math.sqrt(m*m+d*d);n.push([l,p])}let o=n.sort((l,h)=>l[1]-h[1]),a=[];for(let l=0;l<r;l++)a.push(e[o[l][0]]);let c=[];for(let l=r;l<o.length;l++)c.push(e[o[l][0]]);return[a,c]}function na(e){let t=e.getFrustumPlanes(),r=Qe(t.near,e.cameraPosition),n=Ot(e,r),s=Ot(e,e.cameraPosition,Xe),i=0;Je.planes[i++].fromPointNormal(n,Ns.copy(n).subtract(s));for(let o in t){if(o==="near")continue;let a=t[o],c=Qe(a,r,Xe),l=Ot(e,c,Xe);Je.planes[i++].fromPointNormal(l,Ns.copy(n).subtract(l))}}function Qe(e,t,r=new x){let n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function Ot(e,t,r=new x){let n=e.unprojectPosition(t);return k.WGS84.cartographicToCartesian(n,r)}B();var ks=new x,sa=new x,at=new x,zs=new x,At=new x,Ds=new x,qs=new x,Fs=new x,he=new Mt,ia=new x(0,0,1);function Us(e,t){e._updateTransform(t)}function Bs(e,t,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let n=oa(e),s=n.region?aa(n.region,t):ca(e,n,t);if(!s)return 0;let i=gt(r.dynamicScreenSpaceErrorHeightFalloff,0,1),o=s.minimumHeight+(s.maximumHeight-s.minimumHeight)*i,a=s.maximumHeight-o,c=a>0?gt((s.cameraHeight-o)/a,0,1):s.cameraHeight>=s.maximumHeight?1:0,h=(1-gt(Math.abs(s.cameraDirection.dot(s.upDirection)),0,1))*(1-c);return r.dynamicScreenSpaceErrorDensity*h}function oa(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function aa(e,t){let r=ks.copy(t.camera.position).normalize(),n=At.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:n,upDirection:r}}function ca(e,t,r){let n=la(t,at);if(n===null)return null;let s=new z(e.computedTransform).invert(),i=e.tileset.ellipsoid;if(Math.hypot(at[0],at[1],at[2])>i.minimumRadius){let a=i.cartesianToCartographic(at,sa),c=ks.copy(r.camera.position).normalize(),l=At.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:l,upDirection:c}}return s.transformAsPoint(r.camera.position,zs),s.transformAsVector(r.camera.direction,At),At.normalize(),{cameraHeight:zs[2],minimumHeight:at[2]-n,maximumHeight:at[2]+n,cameraDirection:At,upDirection:ia}}function la(e,t){if(e.box){let r=e.box;return t.set(r[0],r[1],r[2]),ha(r)}if(e.sphere){let r=e.sphere;return t.set(r[0],r[1],r[2]),r[3]}return null}function ha(e){return e.length===10?(he.fromArray(e,6),Ds.set(e[3],0,0).transformByQuaternion(he),qs.set(0,e[4],0).transformByQuaternion(he),Fs.set(0,0,e[5]).transformByQuaternion(he),Math.abs(Ds[2])+Math.abs(qs[2])+Math.abs(Fs[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}B();Ze();var tr;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(tr||(tr={}));var It;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(It||(It={}));var J;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(J||(J={}));var bt;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(bt||(bt={}));var mh=new yt,ph=new x,xh=new x,gh=new x,Th=new x;function Gs(e,t,r){return e+(t-e)*r}Me();Me();var Vs="EPSG:4326",Ws="EPSG:4978";function Ys(e){let t=e.trim().toUpperCase(),r=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:t}function fe(e){if(typeof e=="string"){let r=ot(e);return r==="wkt"?ua(e):r==="proj-string"?da(e):fa(e)||"projected"}let t=e;return t.type==="BoundCRS"&&t.source_crs?fe(t.source_crs):t.type==="CompoundCRS"&&t.components?.[0]?fe(t.components[0]):String(t.type).includes("Projected")?"projected":String(t.type).includes("Geographic")?"geographic":String(t.type).includes("Geodetic")?t.coordinate_system?.subtype==="Cartesian"?"geocentric":"geographic":"unknown"}function fa(e){if(typeof e!="string")return;let t=Ys(e);if(t===Ws)return"geocentric";if(t===Vs||t==="OGC:CRS84")return"geographic";let r=/^EPSG:(\d+)$/.exec(t);if(!r)return;let n=Number(r[1]);if(n===7789)return"geocentric";if(n===4490||n===4979)return"geographic";if(n===3857||n>=32601&&n<=32660||n>=32701&&n<=32760)return"projected"}function ua(e){let t;try{t=Se(e).root}catch{return"unknown"}switch(t.keyword.toUpperCase()){case"GEOCCS":return"geocentric";case"GEOGCS":case"GEOGCRS":case"GEOGRAPHICCRS":case"GEOGRAPHIC2DCRS":case"GEOGRAPHIC3DCRS":return"geographic";case"PROJCS":case"PROJCRS":case"PROJECTEDCRS":return"projected";case"GEODCRS":case"GEODETICCRS":{let n=t.values.find(s=>s.type==="node"&&s.keyword.toUpperCase()==="CS")?.values[0];return n?.type!=="enumeration"&&n?.type!=="string"?"unknown":n.value.toUpperCase()==="CARTESIAN"?"geocentric":n.value.toUpperCase()==="ELLIPSOIDAL"?"geographic":"unknown"}default:return"unknown"}}function da(e){try{let t=_e(e).parameters.find(r=>r.name.toLowerCase()==="proj")?.value;switch(t?.toLowerCase()){case"longlat":case"latlong":return"geographic";case"geocent":return"geocentric";default:return t?"projected":"unknown"}}catch{return"unknown"}}function rr(e,t={}){let r=t.sourceCrs!==void 0,n=t.sourceCrs||e.sourceCrs,s=t.outputCoordinates||"auto",i=t.targetCrs||(s==="ecef"?"EPSG:4978":void 0),o=t.targetHeightReference||"native",a=e.verticalUnitScale??1,c=e.elevationUnitScale??1,l=e.elevationOffset||0,h=e.elevationMode==="onTheGround"||e.elevationMode==="relativeToGround"||e.elevationMode==="relativeToScene",f=e.elevationMode==="relativeToScene"?!!t.sceneElevationProvider:!h||!!t.terrainElevationProvider,u=a!==1||c!==1||e.elevationMode!==void 0&&(h||e.elevationMode==="absoluteHeight"&&l!==0),d=o!=="native"&&o!==e.heightReference,m=!!i||o!=="native"||s!=="auto"||u,p=s!=="target-crs"||!!i,g=!d||(e.heightReference||"unknown")!=="unknown",T=Number.isFinite(a)&&a>0&&Number.isFinite(c)&&c>0,R=!!n&&m&&p&&g&&T&&f&&s!=="local-enu",_=r?"caller-override":e.provenance||"unknown",M=r&&n?fe(n):e.coordinateFrame,S=r?"explicit":e.sourceCrsState||(n?_==="format-default"?"default":"explicit":"absent"),E=Ut({crs:n?{state:S==="default"?"default":"explicit",definition:n,representation:!r&&e.sourceCrsRepresentation||ot(n),provenance:_,alternatives:r?void 0:e.sourceCrsAlternatives}:{state:S==="unknown"?"unknown":"absent",provenance:_},vertical:e.verticalCrs?{state:"explicit",definition:e.verticalCrs,representation:ot(e.verticalCrs),provenance:e.provenance||"metadata"}:void 0,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,coordinateFrame:M,coordinateOrder:pa(e.axisOrder),units:r?void 0:e.units}),O=er(E.crs),I=E.vertical?er(E.vertical):void 0,w=i?ma(i):void 0;return Object.freeze({...E,sourceCrs:O,verticalCrs:I,verticalUnitScale:a,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,heightReference:e.heightReference||"unknown",elevationMode:e.elevationMode,elevationOffset:e.elevationOffset,elevationUnit:e.elevationUnit,elevationUnitScale:c,coordinateFrame:M||"unknown",axisOrder:e.axisOrder||"unknown",provenance:_,targetCrs:w,targetHeightReference:o,outputCoordinates:s,status:m?R?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function nr(e,t={}){return rr({sourceCrs:e?.sourceCrs,sourceCrsState:e?.crs.state,sourceCrsRepresentation:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.representation:void 0,sourceCrsAlternatives:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.alternatives:void 0,verticalCrs:e?.verticalCrs,units:e?.units,verticalUnitScale:e?.verticalUnitScale,coordinateEpoch:e?.coordinateEpoch,heightReference:e?.heightReference,elevationMode:e?.elevationMode,elevationOffset:e?.elevationOffset,elevationUnit:e?.elevationUnit,elevationUnitScale:e?.elevationUnitScale,coordinateFrame:e?.coordinateFrame,axisOrder:e?.axisOrder,provenance:e?.provenance,warnings:e?.warnings},t)}function er(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function ma(e){let t=Ut({crs:{state:"explicit",definition:e,representation:ot(e),provenance:"caller-override"}}),r=er(t.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function pa(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function $s(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var de=1024*1024,ri=512*de,ni=512*de,xa=32*de,ga=de;function ue(e,t){if(!Number.isFinite(e)||e<0)throw new Error(`${t} must be a finite number greater than or equal to 0`);return e}function Zs(e,t){let r=e.cacheBytes??t;return ue(r,"cacheBytes")}function js(e,t){let r=e.maximumCacheOverflowBytes??t;return ue(r,"maximumCacheOverflowBytes")}var sr={description:"",ellipsoid:k.WGS84,modelMatrix:new z,throttleRequests:!0,maxRequests:64,cacheBytes:ri,maximumCacheOverflowBytes:ni,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:Gs,foveatedTimeDelay:.2,maximumScreenSpaceError:8,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{},spatial:{}},ir="Tiles In Tileset(s)",or="Tiles In Memory",Hs="Tiles In View",Ks="Tiles To Render",Xs="Tiles Loaded",ar="Tiles Loading",Js="Tiles Unloaded",Qs="Failed Tile Loads",ti="Points/Vertices",cr="Tile Memory Use",ei="Maximum Screen Space Error",Nt=class{options;loadOptions;source;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};schema=null;schemaUri=null;groups=[];metadata=null;statistics=null;spatialReference=rr({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=ri;_maximumCacheOverflowBytes=ni;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new le;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,r){if(!$s(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let n=r||{},s=t.type===J.TILES3D,i=s?sr.cacheBytes:xa,o=s?sr.maximumCacheOverflowBytes:ga,a=Zs(n,i),c=js(n,o);this.options={...sr,...n,cacheBytes:a,maximumCacheOverflowBytes:c,skipLevelOfDetail:n.skipLevelOfDetail??t.type===J.TILES3D,memoryAdjustedScreenSpaceError:n.memoryAdjustedScreenSpaceError??s},this.loadOptions=this.options.loadOptions||{},this.source=t,this.tileset=null,this.loader=this.source.loader,this.type=this.source.type,this.url=this.source.url,this.basePath=this.source.basePath,this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType="",this.lodMetricValue=0,this.refine="",this.contentFormats=this.source.contentFormats,this._traverser=this._initializeTraverser(),this._requestScheduler=new j({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=c;let l=this._getSourceMetadata();l&&(this.spatialReference=nr(l.spatialReference,this.options.spatial)),this.stats=new W({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet()}destroy(){this._clearDeferredTraversal(),this.source.destroy?.(),this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get requestedTiles(){return this._requestedTiles.slice()}get emptyTiles(){return this._emptyTiles.slice()}get cacheBytes(){return this._cacheBytes}set cacheBytes(t){this._cacheBytes=ue(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=ue(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes}get queryParams(){let t=this.source.getTileUrl(this.url),r=t.indexOf("?");return r>=0?t.slice(r+1):""}setProps(t){let r=Zs(t,this.cacheBytes),n=js(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:r,maximumCacheOverflowBytes:n},this._cacheBytes=r,this._maximumCacheOverflowBytes=n}getTileUrl(t){return this.source.getTileUrl(t)}hasExtension(t){return!!this.source.hasExtension?.(t)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=t instanceof Array?t:[t],n=new Set(r.map(a=>a.id));for(let a of Object.keys(this.frameStateData))n.has(a)||delete this.frameStateData[a];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let s=Date.now(),i=Number.POSITIVE_INFINITY,o=[];for(let a of r){let c=a.id;this._needTraverse(c)?o.push(c):this.traverseCounter--}for(let a of r){let c=a.id;if(this.roots[c]||(this.roots[c]=this._initializeTileHeaders(this.tileset,null)),!o.includes(c))continue;let l=Ps(a,this._frameNumber),h=this.roots[c],f=Ls(this._cameraMotionStates[c],l.camera.position,l.camera.direction,s);this._cameraMotionStates[c]=f.state,l.camera.timeSinceMovement=f.timeSinceMovement,Us(h,this.modelMatrix),l.dynamicScreenSpaceErrorDensity=this.type===J.TILES3D&&this.options.dynamicScreenSpaceError&&!l.viewport.orthographic?Bs(h,l,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=l.dynamicScreenSpaceErrorDensity,this._traverser.traverse(h,l,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(i=Math.min(i,Math.max(this.options.foveatedTimeDelay-f.timeSinceMovement,0)))}Number.isFinite(i)?this._scheduleDeferredTraversal(i):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let n=r instanceof Error?r:new Error(String(r));this._onTilesetError(n)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){let r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],s=Object.values(this._traverser.selectedTiles),[i,o]=vs(s,t,this.options.maximumTilesSelected);n.selectedTiles=i;for(let a of o)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let t=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let i in this.frameStateData){let o=this.frameStateData[i];this.selectedTiles=this.selectedTiles.concat(o.selectedTiles),this._requestedTiles=this._requestedTiles.concat(o._requestedTiles),this._emptyTiles=this._emptyTiles.concat(o._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles),n=this.selectedTiles.some(i=>!i.tileDrawn),s=0;if(n){let i=new Set(Object.keys(this.frameStateData).map(a=>this.roots[a])),o=new Map;for(let a of this.selectedTiles)for(let c=a.parent;c;c=c.parent)o.set(c,(o.get(c)??!0)&&a.tileDrawn);for(let a of t)a.tileDrawn&&this._heldTiles.add(a);for(let a of this._heldTiles){let c=a;for(;c.parent;)c=c.parent;if(!i.has(c)){this._heldTiles.delete(a);continue}r.has(a)||(a.contentAvailable&&!this._hasDrawnReplacement(a,r,o)?(a._selectedFrame=this._frameNumber,this.selectedTiles.push(a),s++):this._heldTiles.delete(a))}}else this._heldTiles=r;s>0&&setTimeout(()=>{this.selectTiles()},0);for(let i of this.selectedTiles)this._tiles[i.id]=i;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(t,this.selectedTiles)&&this.options.onUpdate()}_hasDrawnReplacement(t,r,n){for(let s=t.parent;s;s=s.parent)if(r.has(s))return s.tileDrawn;return n.get(t)===!0}_tilesChanged(t,r){if(t.length!==r.length)return!0;let n=new Set(t.map(o=>o.id)),s=new Set(r.map(o=>o.id)),i=t.some(o=>!s.has(o.id));return i=i||r.some(o=>!n.has(o.id)),i}_loadTiles(){this._requestedTiles.sort((t,r)=>t._priority-r._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,r=0;for(let n of this.selectedTiles)if(n.contentAvailable&&n.content){t++;let s=n.contents.length?n.contents:[n.content];for(let i of s)i.pointCount?r+=i.pointCount:r+=i.vertexCount||0}this.stats.get(Hs).count=this.selectedTiles.length,this.stats.get(Ks).count=t,this.stats.get(ti).count=r,this.stats.get(ei).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),r=this._getSourceMetadata();r&&this._syncSourceState(r),r?.tileset?.root&&typeof r.tileset.root.then!="function"&&(!this.source.prepareTileset||this.spatialReference?.status==="native")&&(this.root=this._initializeTileHeaders(r.tileset,null),this._applyViewState()),await t;let n=this.source.getMetadata();this._syncSourceState(n),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(n.tileset,null)),this._applyViewState()}catch(t){let r=t instanceof Error?t:new Error(String(t));throw this._onSourceError(r,this.root),this._onTilesetError(r),r}}_initializeStats(){this.stats.get(ir),this.stats.get(ar),this.stats.get(or),this.stats.get(Hs),this.stats.get(Ks),this.stats.get(Xs),this.stats.get(Js),this.stats.get(Qs),this.stats.get(ti),this.stats.get(cr,"memory"),this.stats.get(ei)}_initializeTileHeaders(t,r){return this.source.initializeTileHeaders(this,t,r)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r=null;try{this._onStartTileLoading(),r=await t.loadContent()}catch(n){let s=n instanceof Error?n:new Error("load failed");this._onSourceError(s,t),this._onTileLoadError(t,s)}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}async _loadTileChildren(t,r){try{this._onStartTileLoading(),await t.loadChildren(r)}catch(n){let s=n instanceof Error?n:new Error("subtree load failed");this._onSourceError(s,t),this._onTileLoadError(t,s)}finally{this._onEndTileLoading()}}_onTileLoadError(t,r){this.stats.get(Qs).incrementCount();let n=r.message||r.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,s)}_onSourceError(t,r=null){this.options.onSourceError(t,this.source,r)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,r){if(!r?.loaded)return;t.content&&bs(t,t.content),this.source.onTileLoaded?.(this,t,r),this._syncSourceState(this.source.getMetadata());let n=this.source.getTilesTotalCount?.();n&&(this.stats.get(ir).reset(),this.stats.get(ir).addCount(n)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(ar).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(ar).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(Xs).incrementCount(),this.stats.get(or).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(cr).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(or).decrementCount(),this.stats.get(Js).incrementCount(),this.stats.get(cr).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let r=t.pop();for(let n of r.children)t.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,n=[r];for(;n.length>0;){t=n.pop();for(let s of t.children)n.push(s);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_syncSourceState(t){this.tileset=t.tileset,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let r=t.tileset;this.schema=r.schema||null,this.schemaUri=r.schemaUri||null,this.groups=r.groups||[],this.metadata=r.metadata||null,this.statistics=r.statistics??null;let n=nr(t.spatialReference,this.options.spatial);this.spatialReference=Ta(this.spatialReference,n),this.properties=this.source.properties??this.properties,this.extras=this.source.extras??this.extras,this.options.attributions?.length?this.credits={attributions:this.options.attributions}:this.credits=this.source.credits||this.credits}_applyViewState(){let t=this.source.getViewState(this.root);this.asset=t.asset||this.source.asset||{},this.properties=t.properties??this.source.properties,this.extras=t.extras??this.source.extras??null,this.credits=t.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=t.description||this.options.description||"",this.boundingVolume=t.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=t.cartographicCenter||new x,this.cartesianCenter=t.cartesianCenter||null,this.zoom=t.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};function Ta(e,t){return e?.status==="transformed"&&e.sourceCrs===t.sourceCrs&&e.targetCrs===t.targetCrs&&e.targetHeightReference===t.targetHeightReference&&e.outputCoordinates===t.outputCoordinates?e:t}ys();function si(e,t,r={}){let n=e.tileMatrixSet;if(!n||!n.crs||t.crs!==n.crs)throw new Error("Tile selection requires complete geometry and a frame in the exact grid CRS.");if(t.extent.length!==4||!t.extent.every(Number.isFinite)||t.extent[0]>t.extent[2]||t.extent[1]>t.extent[3])throw new RangeError("Tile frame extent must be finite and ordered.");let s=r.maximumTileCount??4096;if(!Number.isSafeInteger(s)||s<0)throw new RangeError("maximumTileCount must be a nonnegative safe integer.");for(let u of n.matrices){let d=u.variableMatrixWidths;if(d!==void 0&&(!Array.isArray(d)||d.length>0))throw new Error("Regular-grid selection does not support variable-width rows.")}let i=Rs(n,t.resolution),o=new Map;for(let u of e.limits??[]){let d=n.matrices.find(m=>m.id===u.tileMatrix);if(!d||o.has(u.tileMatrix))throw new RangeError("Tile coverage must reference unique, known matrix ids.");Ke(d,u.minTileColumn,u.minTileRow,u),o.set(u.tileMatrix,u)}if(!i||e.limits!==void 0&&!o.has(i.id))return[];let a=Es(i,t.extent,o.get(i.id));if(!a)return[];let c=a.maxTileColumn-a.minTileColumn+1,l=a.maxTileRow-a.minTileRow+1;if(c>s/l)throw new RangeError("Tile selection exceeds maximumTileCount.");let h=n.matrices.indexOf(i),f=[];for(let u=a.minTileRow;u<=a.maxTileRow;u++)for(let d=a.minTileColumn;d<=a.maxTileColumn;d++){let[m,p,g,T]=_s(i,d,u);f.push({index:{x:d,y:u,z:h},tileMatrix:i.id,id:JSON.stringify([n.crs,i.id,d,u]),bbox:{left:m,bottom:p,right:g,top:T},crs:n.crs,tileSize:[i.tileSize[0],i.tileSize[1]]})}return f}return ui(Pt);})();
|
|
7
|
+
"use strict";var __exports__=(()=>{var Rs=Object.create;var Yt=Object.defineProperty;var Es=Object.getOwnPropertyDescriptor;var ys=Object.getOwnPropertyNames;var Cs=Object.getPrototypeOf,ws=Object.prototype.hasOwnProperty;var I=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var Os=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Nr=(e,t)=>{for(var r in t)Yt(e,r,{get:t[r],enumerable:!0})},Wt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ys(t))!ws.call(e,i)&&i!==r&&Yt(e,i,{get:()=>t[i],enumerable:!(n=Es(t,i))||n.enumerable});return e},$t=(e,t,r)=>(Wt(e,t,"default"),r&&Wt(r,t,"default")),As=(e,t,r)=>(r=e!=null?Rs(Cs(e)):{},Wt(t||!e||!e.__esModule?Yt(r,"default",{value:e,enumerable:!0}):r,e)),bs=e=>Wt(Yt({},"__esModule",{value:!0}),e);var Lr=Os((za,Pr)=>{Pr.exports=globalThis.loaders});function jt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var vr=I(()=>{"use strict"});function At(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var ve=I(()=>{});var mt,ze=I(()=>{ve();mt=class{constructor(t,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=At(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(At()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var j,zr=I(()=>{ze();j=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let r of Object.values(this.stats))t(r)}getTable(){let t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){let{name:r,type:n}=t,i=this.stats[r];return i||(t instanceof mt?i=t:i=new mt(r,n),this.stats[r]=i),i}}});var Zt=I(()=>{zr();ze();ve()});var Ns,Ps,Ls,vs,zs,Ds,Q,Dr=I(()=>{"use strict";Zt();Ns="Queued Requests",Ps="Active Requests",Ls="Cancelled Requests",vs="Queued Requests Ever",zs="Active Requests Ever",Ds={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Q=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...Ds,...t},this.stats=new j({id:this.props.id}),this.stats.get(Ns),this.stats.get(Ps),this.stats.get(Ls),this.stats.get(vs),this.stats.get(zs)}setProps(t){t.throttleRequests!==void 0&&(this.props.throttleRequests=t.throttleRequests),t.maxRequests!==void 0&&(this.props.maxRequests=t.maxRequests),t.debounceTime!==void 0&&(this.props.debounceTime=t.debounceTime)}scheduleRequest(t,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let n={handle:t,priority:0,getPriority:r},i=new Promise(s=>(n.resolve=s,n));return this.requestQueue.push(n),this.requestMap.set(t,i),this._issueNewRequests(),i}_issueRequest(t){let{handle:r,resolve:n}=t,i=!1,s=()=>{i||(i=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:s}):Promise.resolve({done:s})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let r=0;r<t;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let n=t[r];this._updateRequest(n)||(t.splice(r,1),this.requestMap.delete(n.handle),r--)}t.sort((r,n)=>r.priority-n.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}}});function qr(e,t){return t?t.aborted?(e.catch(()=>{}),Promise.reject(t.reason)):new Promise((r,n)=>{let i=()=>{t.removeEventListener("abort",i),n(t.reason)};t.addEventListener("abort",i,{once:!0}),e.then(s=>{t.removeEventListener("abort",i),r(s)},s=>{t.removeEventListener("abort",i),n(s)})}):e}function Ht(e,t){let r=new AbortController,n=[],i=()=>{for(let[s,o]of n)s.removeEventListener("abort",o)};for(let s of t){if(!s)continue;let o=()=>r.abort(s.reason);n.push([s,o]),s.addEventListener("abort",o,{once:!0}),s.aborted&&o()}try{return r.signal.throwIfAborted(),qr(e(r.signal),r.signal).catch(s=>{throw r.abort(s),s}).finally(i)}catch(s){return r.abort(s),i(),Promise.reject(s)}}var Fr=I(()=>{"use strict"});function Kt(e={}){if(e.coordinateEpoch!==void 0&&!Number.isFinite(e.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:kr(e.crs||{state:"absent",provenance:"unknown"}),vertical:e.vertical?kr(e.vertical):void 0,coordinateEpoch:e.coordinateEpoch,coordinateFrame:e.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...e.coordinateOrder||[]]),units:e.units?Object.freeze([...e.units]):void 0})}function pt(e){if(typeof e=="object")return"projjson";let t=e.trim();return/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(t)?"wkt":/(?:^|\s)\+?proj=/i.test(t)?"proj-string":/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(t)||/^urn:ogc:def:crs:/i.test(t)||/^https?:\/\//i.test(t)||/^[A-Z][A-Z0-9._-]*$/i.test(t)?"identifier":"opaque"}function kr(e){return e.state==="explicit"||e.state==="default"?Object.freeze({...e,definition:Ur(e.definition),alternatives:e.alternatives?Object.freeze(e.alternatives.map(t=>Object.freeze({...t,definition:Ur(t.definition)}))):void 0}):Object.freeze({...e})}function Ur(e){return typeof e=="string"?e:De(e)}function De(e){return Array.isArray(e)?Object.freeze(e.map(t=>De(t))):e&&typeof e=="object"?Object.freeze(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,De(r)]))):e}var Br=I(()=>{});function ke(e,t){let n={type:"wkt-crs",root:new qe(e).parse()};if(t?.strict){let i=Yr(n,{profile:t.profile,allowExtensions:!1});if(i.length>0)throw new Jt(i)}return n}function Yr(e,t){if(!e||e.type!=="wkt-crs"||e.root?.type!=="node")throw new TypeError("validateWKTCRS expects a WKTCRSAst");let r=js(e.root.keyword,t?.profile||"auto"),n=Ys[r],i=$s[r],s=[],o=e.root.keyword.toUpperCase();return n.has(o)||s.push({code:"invalid-root",message:`${e.root.keyword} is not a ${r} root keyword`,path:[],keyword:e.root.keyword}),$r(e.root,[],a=>{let c=a.node.keyword.toUpperCase();!t?.allowExtensions&&!i.has(c)&&s.push({code:"unknown-keyword",message:`${a.node.keyword} is not defined by the ${r} profile`,path:a.path,keyword:a.node.keyword}),a.node.values.length===0&&s.push({code:"empty-node",message:`${a.node.keyword} must contain at least one value`,path:a.path,keyword:a.node.keyword});let h=Zs(a.node);h&&s.push({code:"invalid-value",message:h,path:a.path,keyword:a.node.keyword})}),s}function js(e,t){return t!=="auto"?t:bt.has(e.toUpperCase())?"wkt1":"wkt2:2019"}function Zs(e){let t=e.keyword.toUpperCase(),r=e.values,n=(s,...o)=>!!(r[s]&&o.includes(r[s].type)),i=(s,...o)=>r.length===s&&o.every((a,c)=>n(c,a));if(["ANGLEUNIT","LENGTHUNIT","PARAMETRICUNIT","SCALEUNIT","TIMEUNIT","TEMPORALQUANTITY","UNIT"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${e.keyword} must start with a quoted name and numeric conversion factor`;if(t==="CS"&&!i(2,"enumeration","number"))return`${e.keyword} must contain a coordinate-system type and dimension`;if(t==="BBOX"&&!i(4,"number","number","number","number"))return`${e.keyword} must contain four numeric bounds`;if(["ENSEMBLEACCURACY","EPOCH","COORDEPOCH","FRAMEEPOCH","OPERATIONACCURACY","ORDER"].includes(t)&&!i(1,"number"))return`${e.keyword} must contain one number`;if(["ANCHOR","AREA","CALENDAR","CITATION","REMARK","SCOPE","URI","VERSION"].includes(t)&&!i(1,"string"))return`${e.keyword} must contain one quoted string`;if(["ELLIPSOID","SPHEROID","TRIAXIAL"].includes(t)&&!(r.length>=3&&n(0,"string")&&n(1,"number")&&n(2,"number")))return`${e.keyword} must start with a quoted name and numeric ellipsoid axes`;if(["PARAMETER"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${e.keyword} must start with a quoted name and numeric value`;if(t==="PARAMETERFILE"&&!i(2,"string","string"))return`${e.keyword} must contain a quoted name and file name`;if(["AUTHORITY","ID"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"string","number")))return`${e.keyword} must start with a quoted authority and identifier`;if(["AXIS"].includes(t)&&!(r.length>=2&&n(0,"string")&&n(1,"enumeration")))return`${e.keyword} must start with a quoted name and axis direction`;if(["METHOD","PROJECTION"].includes(t)&&!(r.length>=1&&n(0,"string")))return`${e.keyword} must start with a quoted name`;if(t==="TIMEEXTENT"){let s=o=>n(o,"enumeration","string");if(r.length!==2||!s(0)||!s(1))return`${e.keyword} must contain two date-time or quoted values`}if(t==="VERTICALEXTENT"&&(r.length<2||r.length>3||!n(0,"number")||!n(1,"number")||r.length===3&&!n(2,"node")))return`${e.keyword} must contain two numeric bounds and an optional unit`;if(t==="COORDINATEMETADATA"&&(r.length<1||r.length>2||!n(0,"node")||r.length===2&&(!n(1,"node")||!["EPOCH","COORDEPOCH"].includes(r[1].keyword.toUpperCase()))))return`${e.keyword} must contain a CRS and an optional coordinate epoch`;if(t==="BOUNDCRS"){let s=r.slice(0,3).map(o=>o.type==="node"?o.keyword.toUpperCase():"");if(s[0]!=="SOURCECRS"||s[1]!=="TARGETCRS"||s[2]!=="ABRIDGEDTRANSFORMATION")return`${e.keyword} must start with SOURCECRS, TARGETCRS, and ABRIDGEDTRANSFORMATION`}return["COMPOUNDCRS","CONCATENATEDOPERATION","COORDINATEOPERATION","DERIVEDPROJCRS","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","GEOGCRS","GEOGRAPHICCRS","PARAMETRICCRS","POINTMOTIONOPERATION","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"].includes(t)&&!n(0,"string")?`${e.keyword} must start with a quoted name`:null}function $r(e,t,r){r({node:e,path:t});for(let n=0;n<e.values.length;n++){let i=e.values[n];i.type==="node"&&$r(i,[...t,n],r)}}function Hs(e,t){let r=1,n=1;for(let i=0;i<t&&i<e.length;i++)e[i]===`
|
|
8
|
+
`?(r++,n=1):n++;return{line:r,column:n}}var Xt,Jt,qs,Fs,bt,Fe,ks,Us,Bs,Gs,Gr,Vr,Wr,Vs,Ws,Ys,$s,qe,jr=I(()=>{Xt=class extends SyntaxError{constructor(t,r,n){let i=Hs(r,n);super(`${t} at ${i.line}:${i.column}`),this.name="WKTCRSSyntaxError",this.offset=n,this.line=i.line,this.column=i.column}},Jt=class extends Error{constructor(t){super(t[0]?.message||"WKT validation failed"),this.name="WKTCRSValidationError",this.issues=t}},qs=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?$/,Fs=/^[A-Za-z][A-Za-z0-9_]*/,bt=new Set(["COMPD_CS","CONCAT_MT","FITTED_CS","GEOCCS","GEOGCS","INVERSE_MT","LOCAL_CS","PARAM_MT","PASSTHROUGH_MT","PROJCS","VERT_CS"]),Fe=new Set([...bt,"AUTHORITY","AXIS","CONCAT_MT","DATUM","INVERSE_MT","LOCAL_DATUM","PARAMETER","PARAM_MT","PASSTHROUGH_MT","PRIMEM","PROJECTION","SPHEROID","TOWGS84","UNIT","VERT_DATUM"]),ks=new Set(bt),Us=new Set([...Fe,"EXTENSION"]),Bs=new Set([...bt,"COMPDCS","LOCALCS","VERTCS"]),Gs=new Set([...Fe,"COMPDCS","LOCALCS","VDATUM","VERTCS"]),Gr=new Set(["BOUNDCRS","COMPOUNDCRS","COORDINATEOPERATION","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","PARAMETRICCRS","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"]),Vr=new Set([...Gr,"CONCATENATEDOPERATION","COORDINATEMETADATA","DERIVEDPROJCRS","GEOGCRS","GEOGRAPHICCRS","POINTMOTIONOPERATION"]),Wr=new Set([...Vr,"ABRIDGEDTRANSFORMATION","ANCHOR","ANGLEUNIT","AREA","AXIS","BASEENGCRS","BASEGEODCRS","BASEGEOGCRS","BASEPARAMCRS","BASEPROJCRS","BASETIMECRS","BASEVERTCRS","BBOX","BEARING","CALENDAR","CITATION","CONVERSION","COORDEPOCH","CS","DATUM","DERIVINGCONVERSION","DYNAMIC","EDATUM","ELLIPSOID","ENGINEERINGDATUM","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEODETICDATUM","GEOIDMODEL","ID","INTERPOLATIONCRS","LENGTHUNIT","MEMBER","MERIDIAN","METHOD","MODEL","OPERATIONACCURACY","ORDER","PARAMETER","PARAMETERFILE","PARAMETRICDATUM","PARAMETRICUNIT","PDATUM","PRIMEM","PRIMEMERIDIAN","REMARK","SCALEUNIT","SCOPE","SOURCECRS","STEP","TARGETCRS","TDATUM","TEMPORALQUANTITY","TIMEEXTENT","TIMEORIGIN","TIMEUNIT","TIMEDATUM","TRIAXIAL","TRF","URI","USAGE","VDATUM","VERSION","VERTICALDATUM","VERTICALEXTENT","VELOCITYGRID","VRF"]),Vs=new Set(["BASEGEOGCRS","CALENDAR","CONCATENATEDOPERATION","COORDEPOCH","COORDINATEMETADATA","DERIVEDPROJCRS","DYNAMIC","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEOGCRS","GEOGRAPHICCRS","GEOIDMODEL","MEMBER","MODEL","POINTMOTIONOPERATION","STEP","TEMPORALQUANTITY","TRF","TRIAXIAL","VELOCITYGRID","VRF"]),Ws=new Set([...Wr].filter(e=>!Vs.has(e))),Ys={wkt1:bt,gdal:ks,esri:Bs,"wkt2:2015":Gr,"wkt2:2019":Vr},$s={wkt1:Fe,gdal:Us,esri:Gs,"wkt2:2015":Ws,"wkt2:2019":Wr};qe=class{constructor(t){this.offset=0,this.source=t}parse(){this.skipWhitespace();let t=this.parseNode();return this.skipWhitespace(),this.offset!==this.source.length&&this.fail("Unexpected content after WKT root"),t}parseNode(){let t=this.parseKeyword();return this.parseNodeAfterKeyword(t)}parseNodeAfterKeyword(t){this.skipWhitespace();let r=this.source[this.offset];r!=="["&&r!=="("&&this.fail(`Expected '[' or '(' after ${t}`),this.offset++;let n=r==="["?"bracket":"parenthesis",i=r==="["?"]":")",s=[];if(this.skipWhitespace(),this.source[this.offset]===i)return this.offset++,{type:"node",keyword:t,delimiter:n,values:s};for(;this.offset<this.source.length;){s.push(this.parseValue()),this.skipWhitespace();let o=this.source[this.offset];if(o===","){this.offset++,this.skipWhitespace(),this.source[this.offset]===i&&this.fail("Expected a WKT value after comma");continue}if(o===i)return this.offset++,{type:"node",keyword:t,delimiter:n,values:s};(o==="]"||o===")")&&this.fail(`Expected '${i}' to close ${t}`),this.fail(`Expected ',' or '${i}' in ${t}`)}this.fail(`Unterminated ${t} node`)}parseValue(){if(this.skipWhitespace(),this.source[this.offset]==='"')return this.parseString();let r=this.offset;for(;this.offset<this.source.length&&!/[\s,\[\]()"]/.test(this.source[this.offset]);)this.offset++;r===this.offset&&this.fail("Expected a WKT value");let n=this.source.slice(r,this.offset);return this.source[this.offset]==='"'&&this.fail("Unexpected quote in unquoted WKT value"),this.skipWhitespace(),this.source[this.offset]==="["||this.source[this.offset]==="("?(/^[A-Za-z][A-Za-z0-9_]*$/.test(n)||this.fail(`Invalid WKT keyword '${n}'`),this.parseNodeAfterKeyword(n)):qs.test(n)?{type:"number",value:Number(n),raw:n}:{type:"enumeration",value:n}}parseKeyword(){let t=this.source.slice(this.offset).match(Fs);return t||this.fail("Expected a WKT keyword"),this.offset+=t[0].length,t[0]}parseString(){this.offset++;let t="";for(;this.offset<this.source.length;){let r=this.source[this.offset++];if(r==='"'){if(this.source[this.offset]==='"'){t+='"',this.offset++;continue}return{type:"string",value:t}}t+=r}this.fail("Unterminated WKT string")}skipWhitespace(){for(;this.offset<this.source.length&&/\s/.test(this.source[this.offset]);)this.offset++}fail(t){throw new Xt(t,this.source,this.offset)}}});function Ue(e){let t=Js(e);if(t.length===0)throw new tt("PROJ string is empty",e,0);return{type:"proj-string",parameters:t.map(n=>Xs(n.raw,n.offset,e))}}function Xs(e,t,r){let n=e.startsWith("+")?e.slice(1):e;if(!n)throw new tt("Expected a parameter after '+'",r,t);let i=n.indexOf("="),s=i<0?n:n.slice(0,i);if(!s||/[\s+=]/.test(s))throw new tt(`Invalid PROJ parameter name '${s}'`,r,t);if(i<0)return{type:"parameter",name:s};let o=n.slice(i+1),a=Qs(o,r,t+i+1);return{type:"parameter",name:s,value:a,rawValue:o}}function Js(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;let n=r,i=null,s=!1;for(;r<e.length;){let o=e[r];if(s){s=!1,r++;continue}if(o==="\\"&&i){s=!0,r++;continue}if(i){o===i&&(i=null),r++;continue}if((o==='"'||o==="'")&&e[r-1]==="="){i=o,r++;continue}if(/\s/.test(o))break;r++}if(i)throw new tt("Unterminated quoted PROJ value",e,n);t.push({raw:e.slice(n,r),offset:n})}return t}function Qs(e,t,r){if(!e)return"";let n=e[0];if(n!=='"'&&n!=="'"){if((e.includes('"')||e.includes("'"))&&!Ks.test(e))throw new tt("Quote must begin a PROJ parameter value",t,r);return e}if(e[e.length-1]!==n)throw new tt("Unterminated quoted PROJ value",t,r);let i="";for(let s=1;s<e.length-1;s++){let o=e[s];o==="\\"&&s+1<e.length-1?i+=e[++s]:i+=o}return i}function to(e,t){let r=1,n=1;for(let i=0;i<t&&i<e.length;i++)e[i]===`
|
|
9
|
+
`?(r++,n=1):n++;return{line:r,column:n}}var tt,Ks,Zr=I(()=>{tt=class extends SyntaxError{constructor(t,r,n){let i=to(r,n);super(`${t} at ${i.line}:${i.column}`),this.name="PROJStringSyntaxError",this.offset=n,this.line=i.line,this.column=i.column}};Ks=/^[+-]?\d+(?:\.\d*)?d(?:\d+(?:\.\d*)?'(?:\d+(?:\.\d*)?")?)?[NSEW]?$/i});var Be=I(()=>{Br();jr();Zr()});var St={};Nr(St,{EPSILON1:()=>eo,EPSILON10:()=>lo,EPSILON11:()=>fo,EPSILON12:()=>uo,EPSILON13:()=>mo,EPSILON14:()=>po,EPSILON15:()=>xo,EPSILON16:()=>go,EPSILON17:()=>To,EPSILON18:()=>So,EPSILON19:()=>Mo,EPSILON2:()=>ro,EPSILON20:()=>_o,EPSILON3:()=>no,EPSILON4:()=>io,EPSILON5:()=>so,EPSILON6:()=>oo,EPSILON7:()=>ao,EPSILON8:()=>co,EPSILON9:()=>ho,PI:()=>Co,PI_OVER_FOUR:()=>Eo,PI_OVER_SIX:()=>yo,PI_OVER_TWO:()=>Ro,TWO_PI:()=>wo});var eo,ro,no,io,so,oo,ao,co,ho,lo,fo,uo,mo,po,xo,go,To,So,Mo,_o,Ro,Eo,yo,Co,wo,Hr=I(()=>{eo=.1,ro=.01,no=.001,io=1e-4,so=1e-5,oo=1e-6,ao=1e-7,co=1e-8,ho=1e-9,lo=1e-10,fo=1e-11,uo=1e-12,mo=1e-13,po=1e-14,xo=1e-15,go=1e-16,To=1e-17,So=1e-18,Mo=1e-19,_o=1e-20,Ro=Math.PI/2,Eo=Math.PI/4,yo=Math.PI/6,Co=Math.PI,wo=Math.PI*2});function Ge(e,{precision:t=v.precision}={}){return e=Io(e),`${parseFloat(e.toPrecision(t))}`}function Z(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ve(e){return Kr(e)}function We(e){return Xr(e)}function Kr(e,t){return Ye(e,r=>r*Ao,t)}function Xr(e,t){return Ye(e,r=>r*Oo,t)}function It(e,t,r){return Ye(e,n=>Math.max(t,Math.min(r,n)))}function ct(e,t,r){let n=v.EPSILON;r&&(v.EPSILON=r);try{if(e===t)return!0;if(Z(e)&&Z(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!ct(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=v.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{v.EPSILON=n}}function Io(e){return Math.round(e/v.EPSILON)*v.EPSILON}function No(e){return e.clone?e.clone():new Array(e.length)}function Ye(e,t,r){if(Z(e)){let n=e;r=r||No(n);for(let i=0;i<r.length&&i<n.length;++i){let s=typeof e=="number"?e:e[i];r[i]=t(s,i,r)}return r}return t(e)}var Oo,Ao,bo,v,Mt=I(()=>{Oo=1/Math.PI*180,Ao=1/180*Math.PI,bo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...bo}};v=globalThis.mathgl.config});var ht,Qt=I(()=>{Mt();ht=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Z(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(v)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Ge(this[n],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!ct(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let i=0;i<this.ELEMENTS;++i){let s=t[i],o=typeof r=="number"?r:r[i];this[i]=s+n*(o-s)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(v.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}}});function Po(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function z(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function te(e,t,r=""){if(v.debug&&!Po(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}var _t=I(()=>{Mt()});var ee,Jr=I(()=>{Qt();_t();Mt();ee=class extends ht{toString(){let t="[";if(v.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=z(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[n+i];return r}setColumn(t,r){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=r[i];return this}}});function F(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var $e=I(()=>{});var re,Qr=I(()=>{Qt();_t();$e();re=class extends ht{get x(){return this[0]}set x(t){this[0]=z(t)}get y(){return this[1]}set y(t){this[1]=z(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-t[n];r+=i*i}return z(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return z(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return F(t>=0&&t<this.ELEMENTS,"index is out of range"),z(this[t])}setComponent(t,r){return F(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n]*r;return this.check()}}});var ne,Sc,tn=I(()=>{ne=typeof Float32Array<"u"?Float32Array:Array,Sc=Math.PI/180});function en(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e}var rn=I(()=>{});function nn(e,t,r){let n=t[0],i=t[1],s=r[3]*n+r[7]*i||1;return e[0]=(r[0]*n+r[4]*i)/s,e[1]=(r[1]*n+r[5]*i)/s,e}function ie(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s||1;return e[0]=(r[0]*n+r[4]*i+r[8]*s)/o,e[1]=(r[1]*n+r[5]*i+r[9]*s)/o,e[2]=(r[2]*n+r[6]*i+r[10]*s)/o,e}function sn(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2],e}var je=I(()=>{});function on(){let e=new ne(3);return ne!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function vo(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function Ze(e,t,r){let n=new ne(3);return n[0]=e,n[1]=t,n[2]=r,n}function an(e,t){let r=t[0],n=t[1],i=t[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function He(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Rt(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2];return e[0]=i*c-s*a,e[1]=s*o-n*c,e[2]=n*a-i*o,e}function se(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,e}function cn(e,t,r){let n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function hn(e,t,r){let n=r[0],i=r[1],s=r[2],o=r[3],a=t[0],c=t[1],h=t[2],l=i*h-s*c,f=s*a-n*h,d=n*c-i*a,u=i*d-s*f,m=s*l-n*d,p=n*f-i*l,x=o*2;return l*=x,f*=x,d*=x,u*=2,m*=2,p*=2,e[0]=a+l+u,e[1]=c+f+m,e[2]=h+d+p,e}function ln(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function fn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function un(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function dn(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+n*n+i*i)*(s*s+o*o+a*a)),h=c&&He(e,t)/c;return Math.acos(Math.min(Math.max(h,-1),1))}var mn,oe=I(()=>{tn();mn=vo});var Ke,ae,T,pn=I(()=>{Qr();Mt();_t();oe();je();Ke=[0,0,0],T=class e extends re{static get ZERO(){return ae||(ae=new e(0,0,0),Object.freeze(ae)),ae}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Z(t)?this.copy(t):(v.debug&&(z(t),z(r),z(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return v.debug&&(z(t.x),z(t.y),z(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=z(t)}angle(t){return dn(this,t)}cross(t){return Rt(this,this,t),this.check()}rotateX({radians:t,origin:r=Ke}){return ln(this,this,r,t),this.check()}rotateY({radians:t,origin:r=Ke}){return fn(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=Ke}){return un(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return se(this,this,t),this.check()}transformAsVector(t){return ie(this,this,t),this.check()}transformByMatrix3(t){return cn(this,this,t),this.check()}transformByMatrix2(t){return sn(this,this,t),this.check()}transformByQuaternion(t){return hn(this,this,t),this.check()}}});function Do(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function xn(e,t){if(e===t){let r=t[1],n=t[2],i=t[3],s=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=i,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function gn(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],f=t[9],d=t[10],u=t[11],m=t[12],p=t[13],x=t[14],R=t[15],w=r*a-n*o,_=r*c-i*o,S=r*h-s*o,M=n*c-i*a,E=n*h-s*a,g=i*h-s*c,C=l*p-f*m,N=l*x-d*m,A=l*R-u*m,O=f*x-d*p,y=f*R-u*p,P=d*R-u*x,b=w*P-_*y+S*O+M*A-E*N+g*C;return b?(b=1/b,e[0]=(a*P-c*y+h*O)*b,e[1]=(i*y-n*P-s*O)*b,e[2]=(p*g-x*E+R*M)*b,e[3]=(d*E-f*g-u*M)*b,e[4]=(c*A-o*P-h*N)*b,e[5]=(r*P-i*A+s*N)*b,e[6]=(x*S-m*g-R*_)*b,e[7]=(l*g-d*S+u*_)*b,e[8]=(o*y-a*A+h*C)*b,e[9]=(n*A-r*y-s*C)*b,e[10]=(m*E-p*S+R*w)*b,e[11]=(f*S-l*E-u*w)*b,e[12]=(a*N-o*O-c*C)*b,e[13]=(r*O-n*N+i*C)*b,e[14]=(p*_-m*M-x*w)*b,e[15]=(l*M-f*_+d*w)*b,e):null}function Tn(e){let t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=e[6],c=e[7],h=e[8],l=e[9],f=e[10],d=e[11],u=e[12],m=e[13],p=e[14],x=e[15],R=t*o-r*s,w=t*a-n*s,_=r*a-n*o,S=h*m-l*u,M=h*p-f*u,E=l*p-f*m,g=t*E-r*M+n*S,C=s*E-o*M+a*S,N=h*_-l*w+f*R,A=u*_-m*w+p*R;return c*g-i*C+x*N-d*A}function Xe(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],f=t[8],d=t[9],u=t[10],m=t[11],p=t[12],x=t[13],R=t[14],w=t[15],_=r[0],S=r[1],M=r[2],E=r[3];return e[0]=_*n+S*a+M*f+E*p,e[1]=_*i+S*c+M*d+E*x,e[2]=_*s+S*h+M*u+E*R,e[3]=_*o+S*l+M*m+E*w,_=r[4],S=r[5],M=r[6],E=r[7],e[4]=_*n+S*a+M*f+E*p,e[5]=_*i+S*c+M*d+E*x,e[6]=_*s+S*h+M*u+E*R,e[7]=_*o+S*l+M*m+E*w,_=r[8],S=r[9],M=r[10],E=r[11],e[8]=_*n+S*a+M*f+E*p,e[9]=_*i+S*c+M*d+E*x,e[10]=_*s+S*h+M*u+E*R,e[11]=_*o+S*l+M*m+E*w,_=r[12],S=r[13],M=r[14],E=r[15],e[12]=_*n+S*a+M*f+E*p,e[13]=_*i+S*c+M*d+E*x,e[14]=_*s+S*h+M*u+E*R,e[15]=_*o+S*l+M*m+E*w,e}function Sn(e,t,r){let n=r[0],i=r[1],s=r[2],o,a,c,h,l,f,d,u,m,p,x,R;return t===e?(e[12]=t[0]*n+t[4]*i+t[8]*s+t[12],e[13]=t[1]*n+t[5]*i+t[9]*s+t[13],e[14]=t[2]*n+t[6]*i+t[10]*s+t[14],e[15]=t[3]*n+t[7]*i+t[11]*s+t[15]):(o=t[0],a=t[1],c=t[2],h=t[3],l=t[4],f=t[5],d=t[6],u=t[7],m=t[8],p=t[9],x=t[10],R=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=h,e[4]=l,e[5]=f,e[6]=d,e[7]=u,e[8]=m,e[9]=p,e[10]=x,e[11]=R,e[12]=o*n+l*i+m*s+t[12],e[13]=a*n+f*i+p*s+t[13],e[14]=c*n+d*i+x*s+t[14],e[15]=h*n+u*i+R*s+t[15]),e}function Mn(e,t,r){let n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function _n(e,t,r,n){let i=n[0],s=n[1],o=n[2],a=Math.sqrt(i*i+s*s+o*o),c,h,l,f,d,u,m,p,x,R,w,_,S,M,E,g,C,N,A,O,y,P,b,L;return a<1e-6?null:(a=1/a,i*=a,s*=a,o*=a,h=Math.sin(r),c=Math.cos(r),l=1-c,f=t[0],d=t[1],u=t[2],m=t[3],p=t[4],x=t[5],R=t[6],w=t[7],_=t[8],S=t[9],M=t[10],E=t[11],g=i*i*l+c,C=s*i*l+o*h,N=o*i*l-s*h,A=i*s*l-o*h,O=s*s*l+c,y=o*s*l+i*h,P=i*o*l+s*h,b=s*o*l-i*h,L=o*o*l+c,e[0]=f*g+p*C+_*N,e[1]=d*g+x*C+S*N,e[2]=u*g+R*C+M*N,e[3]=m*g+w*C+E*N,e[4]=f*A+p*O+_*y,e[5]=d*A+x*O+S*y,e[6]=u*A+R*O+M*y,e[7]=m*A+w*O+E*y,e[8]=f*P+p*b+_*L,e[9]=d*P+x*b+S*L,e[10]=u*P+R*b+M*L,e[11]=m*P+w*b+E*L,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Rn(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],f=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+h*n,e[5]=o*i+l*n,e[6]=a*i+f*n,e[7]=c*i+d*n,e[8]=h*i-s*n,e[9]=l*i-o*n,e[10]=f*i-a*n,e[11]=d*i-c*n,e}function En(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],c=t[3],h=t[8],l=t[9],f=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-h*n,e[1]=o*i-l*n,e[2]=a*i-f*n,e[3]=c*i-d*n,e[8]=s*n+h*i,e[9]=o*n+l*i,e[10]=a*n+f*i,e[11]=c*n+d*i,e}function yn(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],c=t[3],h=t[4],l=t[5],f=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i+h*n,e[1]=o*i+l*n,e[2]=a*i+f*n,e[3]=c*i+d*n,e[4]=h*i-s*n,e[5]=l*i-o*n,e[6]=f*i-a*n,e[7]=d*i-c*n,e}function Cn(e,t){let r=t[0],n=t[1],i=t[2],s=t[4],o=t[5],a=t[6],c=t[8],h=t[9],l=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(s*s+o*o+a*a),e[2]=Math.sqrt(c*c+h*h+l*l),e}function wn(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r+r,a=n+n,c=i+i,h=r*o,l=n*o,f=n*a,d=i*o,u=i*a,m=i*c,p=s*o,x=s*a,R=s*c;return e[0]=1-f-m,e[1]=l+R,e[2]=d-x,e[3]=0,e[4]=l-R,e[5]=1-h-m,e[6]=u+p,e[7]=0,e[8]=d+x,e[9]=u-p,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function On(e,t,r,n,i,s,o){let a=1/(r-t),c=1/(i-n),h=1/(s-o);return e[0]=s*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(i+n)*c,e[10]=(o+s)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*s*2*h,e[15]=0,e}function qo(e,t,r,n,i){let s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(n-i);e[10]=(i+n)*o,e[14]=2*i*n*o}else e[10]=-1,e[14]=-2*n;return e}function Fo(e,t,r,n,i,s,o){let a=1/(t-r),c=1/(n-i),h=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*c,e[14]=(o+s)*h,e[15]=1,e}function In(e,t,r,n){let i,s,o,a,c,h,l,f,d,u,m=t[0],p=t[1],x=t[2],R=n[0],w=n[1],_=n[2],S=r[0],M=r[1],E=r[2];return Math.abs(m-S)<1e-6&&Math.abs(p-M)<1e-6&&Math.abs(x-E)<1e-6?Do(e):(f=m-S,d=p-M,u=x-E,i=1/Math.sqrt(f*f+d*d+u*u),f*=i,d*=i,u*=i,s=w*u-_*d,o=_*f-R*u,a=R*d-w*f,i=Math.sqrt(s*s+o*o+a*a),i?(i=1/i,s*=i,o*=i,a*=i):(s=0,o=0,a=0),c=d*a-u*o,h=u*s-f*a,l=f*o-d*s,i=Math.sqrt(c*c+h*h+l*l),i?(i=1/i,c*=i,h*=i,l*=i):(c=0,h=0,l=0),e[0]=s,e[1]=c,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=d,e[7]=0,e[8]=a,e[9]=l,e[10]=u,e[11]=0,e[12]=-(s*m+o*p+a*x),e[13]=-(c*m+h*p+l*x),e[14]=-(f*m+d*p+u*x),e[15]=1,e)}var An,bn,Je=I(()=>{An=qo;bn=Fo});function Nn(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Pn(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function Ln(e){let t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)}function vn(e){let t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i}function zn(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r*r+n*n+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=s*o,e}function Dn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function qn(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function Fn(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*o,e}var Qe=I(()=>{});function Vo(){return ce||(ce=new q([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ce)),ce}function Wo(){return he||(he=new q,Object.freeze(he)),he}function kn(e){if(e>Math.PI*2)throw Error("expected radians")}function Yo(e,t,r,n,i,s){let o=2*s/(r-t),a=2*s/(i-n),c=(r+t)/(r-t),h=(i+n)/(i-n),l=-1,f=-1,d=-2*s;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=h,e[10]=l,e[11]=f,e[12]=0,e[13]=0,e[14]=d,e[15]=0,e}var rr,Uo,Bo,tr,er,Go,q,ce,he,Un=I(()=>{Jr();_t();je();Je();rn();oe();Qe();(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(rr||(rr={}));Uo=45*Math.PI/180,Bo=1,tr=.1,er=500,Go=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),q=class extends ee{static get IDENTITY(){return Wo()}static get ZERO(){return Vo()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return rr}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,i,s,o,a,c,h,l,f,d,u,m,p,x){return this[0]=t,this[1]=r,this[2]=n,this[3]=i,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=h,this[9]=l,this[10]=f,this[11]=d,this[12]=u,this[13]=m,this[14]=p,this[15]=x,this.check()}setRowMajor(t,r,n,i,s,o,a,c,h,l,f,d,u,m,p,x){return this[0]=t,this[1]=s,this[2]=h,this[3]=u,this[4]=r,this[5]=o,this[6]=l,this[7]=m,this[8]=n,this[9]=a,this[10]=f,this[11]=p,this[12]=i,this[13]=c,this[14]=d,this[15]=x,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Go)}fromObject(t){return this.check()}fromQuaternion(t){return wn(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:r,right:n,bottom:i,top:s,near:o=tr,far:a=er}=t;return a===1/0?Yo(this,r,n,i,s,o):On(this,r,n,i,s,o,a),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:i=[0,1,0]}=t;return In(this,r,n,i),this.check()}ortho(t){let{left:r,right:n,bottom:i,top:s,near:o=tr,far:a=er}=t;return bn(this,r,n,i,s,o,a),this.check()}orthographic(t){let{fovy:r=Uo,aspect:n=Bo,focalDistance:i=1,near:s=tr,far:o=er}=t;kn(r);let a=r/2,c=i*Math.tan(a),h=c*n;return this.ortho({left:-h,right:h,bottom:-c,top:c,near:s,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:i=.1,far:s=500}=t;return kn(r),An(this,r,n,i,s),this.check()}determinant(){return Tn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],s=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*s,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*s,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*s,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],s=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*s,t[2]=this[2]*o,t[3]=this[4]*i,t[4]=this[5]*s,t[5]=this[6]*o,t[6]=this[8]*i,t[7]=this[9]*s,t[8]=this[10]*o,t}transpose(){return xn(this,this),this.check()}invert(){return gn(this,this),this.check()}multiplyLeft(t){return Xe(this,t,this),this.check()}multiplyRight(t){return Xe(this,this,t),this.check()}rotateX(t){return Rn(this,this,t),this.check()}rotateY(t){return En(this,this,t),this.check()}rotateZ(t){return yn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return _n(this,this,t,r),this.check()}scale(t){return Mn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Sn(this,this,t),this.check()}transform(t,r){return t.length===4?(r=Fn(r||[-0,-0,-0,-0],t,this),te(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,i;switch(n){case 2:i=en(r||[-0,-0],t,this);break;case 3:i=se(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return te(i,t.length),i}transformAsVector(t,r){let n;switch(t.length){case 2:n=nn(r||[-0,-0],t,this);break;case 3:n=ie(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return te(n,t.length),n}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}}});function Bn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function nr(e,t,r){r=r*.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function ir(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3],a=r[0],c=r[1],h=r[2],l=r[3];return e[0]=n*l+o*a+i*h-s*c,e[1]=i*l+o*c+s*a-n*h,e[2]=s*l+o*h+n*c-i*a,e[3]=o*l-n*a-i*c-s*h,e}function Gn(e,t,r){r*=.5;let n=t[0],i=t[1],s=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+o*a,e[1]=i*c+s*a,e[2]=s*c-i*a,e[3]=o*c-n*a,e}function Vn(e,t,r){r*=.5;let n=t[0],i=t[1],s=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c-s*a,e[1]=i*c+o*a,e[2]=s*c+n*a,e[3]=o*c-i*a,e}function Wn(e,t,r){r*=.5;let n=t[0],i=t[1],s=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+i*a,e[1]=i*c-n*a,e[2]=s*c+o*a,e[3]=o*c-s*a,e}function Yn(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e}function $n(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=t[3],c=r[0],h=r[1],l=r[2],f=r[3],d,u,m,p,x;return d=i*c+s*h+o*l+a*f,d<0&&(d=-d,c=-c,h=-h,l=-l,f=-f),1-d>1e-6?(u=Math.acos(d),x=Math.sin(u),m=Math.sin((1-n)*u)/x,p=Math.sin(n*u)/x):(m=1-n,p=n),e[0]=m*i+p*c,e[1]=m*s+p*h,e[2]=m*o+p*l,e[3]=m*a+p*f,e}function jn(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r*r+n*n+i*i+s*s,a=o?1/o:0;return e[0]=-r*a,e[1]=-n*a,e[2]=-i*a,e[3]=s*a,e}function Zn(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Hn(e,t){let r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);let s=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[i*3+i]-t[s*3+s]-t[o*3+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[s*3+o]-t[o*3+s])*n,e[s]=(t[s*3+i]+t[i*3+s])*n,e[o]=(t[o*3+i]+t[i*3+o])*n}return e}var Kn,Xn,Jn,Qn,ti,ei,$o,ri,ni=I(()=>{oe();Qe();Kn=Nn,Xn=Pn,Jn=Dn,Qn=qn,ti=Ln,ei=vn,$o=zn,ri=(function(){let e=on(),t=Ze(1,0,0),r=Ze(0,1,0);return function(n,i,s){let o=He(i,s);return o<-.999999?(Rt(e,t,i),mn(e)<1e-6&&Rt(e,r,i),an(e,e),nr(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Rt(e,i,s),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,$o(n,n))}})()});var Pt,ii=I(()=>{Qt();_t();ni();Pt=class extends ht{constructor(t=0,r=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,n,i)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,n,i){return this[0]=t,this[1]=r,this[2]=n,this[3]=i,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Hn(this,t),this.check()}fromEuler(t){switch(this.identity(),t.order){case"xyz":return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z);case"yxz":return this.rotateY(t.y).rotateX(t.x).rotateZ(t.z);case"zxy":return this.rotateZ(t.z).rotateX(t.x).rotateY(t.y);case"zyx":return this.rotateZ(t.z).rotateY(t.y).rotateX(t.x);case"yzx":return this.rotateY(t.y).rotateZ(t.z).rotateX(t.x);case"xzy":return this.rotateX(t.x).rotateZ(t.z).rotateY(t.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(t,r){return nr(this,t,r),this.check()}identity(){return Bn(this),this.check()}setAxisAngle(t,r){return this.fromAxisRotation(t,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=z(t)}get y(){return this[1]}set y(t){this[1]=z(t)}get z(){return this[2]}set z(t){this[2]=z(t)}get w(){return this[3]}set w(t){this[3]=z(t)}len(){return ti(this)}lengthSquared(){return ei(this)}dot(t){return Jn(this,t)}rotationTo(t,r){return ri(this,t,r),this.check()}add(t){return Kn(this,this,t),this.check()}calculateW(){return Yn(this,this),this.check()}conjugate(){return Zn(this,this),this.check()}invert(){return jn(this,this),this.check()}lerp(t,r,n){return n===void 0?this.lerp(this,t,r):(Qn(this,t,r,n),this.check())}multiplyRight(t){return ir(this,this,t),this.check()}multiplyLeft(t){return ir(this,t,this),this.check()}normalize(){let t=this.len(),r=t>0?1/t:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,t===0&&(this[3]=1),this.check()}rotateX(t){return Gn(this,this,t),this.check()}rotateY(t){return Vn(this,this,t),this.check()}rotateZ(t){return Wn(this,this,t),this.check()}scale(t){return Xn(this,this,t),this.check()}slerp(t,r,n){let i,s,o;return arguments.length===2?(i=this,s=t,o=r):(i=t,s=r,o=n),$n(this,i,s,o),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,r){return this.setAxisAngle(t,r)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}}});var U=I(()=>{pn();Un();ii();Hr();$e();Mt()});function si(e,t,r=e){let n=e.x,i=e.y,s=e.z,{semiMajorAxis:o,semiMinorAxis:a,eccentricitySquared:c}=t,h=Math.sin(i),l=Math.abs(i)===Math.PI/2?0:Math.cos(i),f=a/o,d=c<.9?o/Math.sqrt(1-c*h*h):o/Math.hypot(l,f*h),u=(d+s)*l*Math.cos(n),m=(d+s)*l*Math.sin(n),p=(d*(c<.9?1-c:f*f)+s)*h;return Et(r,u,m,p)}function oi(e,t,r=e){let n=e.x,i=e.y,s=e.z,{semiMajorAxis:o,semiMinorAxis:a,eccentricitySquared:c}=t,h=Math.atan2(i,n),l=Math.hypot(n,i),f=Math.hypot(n,i,s);if(!(f>0)||!Number.isFinite(f))return!1;if(c===0)return Et(r,l===0?0:h,Math.atan2(s,l),f-o);if(l===0)return Et(r,0,Math.sign(s)*Math.PI/2,Math.abs(s)-a);let d=l/o,u=s/a;if(d*d+u*u<1-16*fe||c>=.9)return sr(n,i,s,l,o,a,r);let m=s/f,p=l/f,x=1/Math.sqrt(1-c*(2-c)*p*p),R=p*(1-c)*x,w=m*x;for(let _=0;_<30;_++){let S=o/Math.sqrt(1-c*w*w),M=l*R+s*w-S*(1-c*w*w),E=c*S/(S+M);x=1/Math.sqrt(1-E*(2-E)*p*p);let g=p*(1-E)*x,C=m*x;if(Math.abs(C*R-g*w)<=1e-12){if(!Number.isFinite(M))break;return Et(r,h,Math.atan2(C,Math.abs(g)),M)}R=g,w=C}return sr(n,i,s,l,o,a,r)}function sr(e,t,r,n,i,s,o){let a=Math.atan2(t,e),c=s/i,h=c*c,l=n/i,f=r/i,d=1-h;if(!(h>0)||c>1)return!1;let u=i*i,m=s*s,p=Number.isFinite(u)&&u>0?(m-h*u+lt(s,s,m)-h*lt(i,i,u)-lt(h,u,h*u))/u:0,x=n*n,R=e*e,w=t*t,_=R+w,S=Number.isFinite(x)&&x>0?(_-x+le(R,w,_)+lt(e,e,R)+lt(t,t,w)-lt(n,n,x))/(2*n):0,M=i*h,E=n-i,g=E+M,C=S+le(n,-i,E)+le(E,M,g)+lt(i,h,M)+i*p;if(r===0)return g+C<0?!1:Et(o,a,0,E);let N=Math.abs(f)*c,A=0,O=h+Math.hypot(l,f*c);if(!Number.isFinite(O))return!1;let y=Math.max(N,l-d);y>A&&y<O||(y=O/2);let P=-(g+C)/i,b=Math.sqrt(P*(l+d))/d,L=P>0&&Math.abs(r)/b/i*c<=fe*P?Math.atan2(Math.sign(r)*b/c,l/d):void 0;for(let D=0;D<1024&&L===void 0;D++){let ut=d+y,st=l/ut,Tt=r/y/i,k=Tt*c,W=i*y,$=g-W,X=($+(le(g,-W,$)+C-lt(i,y,W)))/(i*ut)*(st+1),J=X+k*k;if(!Number.isFinite(J))return!1;J>0?A=y:O=y;let Ie=-2*(st*st/ut+k*k/y),ot=y-J/Ie,Ot=ot>A&&ot<O?ot:A+(O-A)/2;if(Math.abs(J)<=4*fe*(Math.abs(X)+k*k)||O-A<=4*fe*y){L=Math.atan2(Tt,st);break}y=Ot}return L!==void 0&&jo(o,a,L,n,r,i,c)}function le(e,t,r){let n=r-e;return e-(r-n)+(t-n)}function lt(e,t,r){let n=134217729*e,i=134217729*t;if(!Number.isFinite(n)||!Number.isFinite(i))return 0;let s=n-(n-e),o=i-(i-t),a=e-s,c=t-o;return s*o-r+s*c+a*o+a*c}function jo(e,t,r,n,i,s,o){let a=Math.sin(r),c=Math.cos(r);return Et(e,t,r,n*c+i*a-s*Math.hypot(c,o*a))}function Et(e,t,r,n){return!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(n)?!1:(e.x=t,e.y=r,e.z=n,!0)}var fe,ai=I(()=>{fe=Number.EPSILON});var et,hh,ci=I(()=>{et=6356752314245179e-9,hh={radii:[6378137,6378137,et],radiiSquared:[6378137*6378137,6378137*6378137,et*et],oneOverRadii:[1/6378137,1/6378137,1/et],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(et*et)],maximumRadius:Math.max(6378137,6378137,et),centerToleranceSquared:.1}});function or(e){return e}function rt(e,t=[],r=or){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function hi(e,t=[]){return rt(e,t,v._cartographicRadians?or:Ve)}function ar(e,t,r,n){let i=v._cartographicRadians?or:We,s=i(e),o=i(t);return"longitude"in n?(n.longitude=s,n.latitude=o,n.height=r):"x"in n?(n.x=s,n.y=o,n.z=r):(n[0]=s,n[1]=o,n[2]=r),n}var uh,li=I(()=>{U();uh=new T});function H(e,t,r,n,i,s,o){let c=[n,i,s,Math.abs(e),Math.abs(t),Math.abs(r)].map(g=>{let C=g.toString(2),N=C.indexOf(".");return{integer:BigInt("0b"+C.replace(".","")),exponent:N<0?0:N+1-C.length}}),h=Math.min(...c.filter(g=>g.integer!==0n).map(g=>g.exponent)),l=c.map(g=>g.integer<<BigInt(g.exponent-h)),f=l.slice(0,3).map(g=>g*g),d=f.reduce((g,C)=>g<C?g:C),u=f.map(g=>g-d),m=f.map((g,C)=>l[C]*l[C+3]),p=64;if(!m.some((g,C)=>u[C]===0n&&g!==0n)){let g=-1n,C=1n;for(let O=0;O<3;O++){if(u[O]===0n)continue;let y=u[O]*u[O];g=g*y+m[O]*m[O]*C,C*=y}if(g<0n)return!1;if(g===0n)return E(0n,1n);let A=u.filter(O=>O>0n).reduce((O,y)=>O<y?O:y);p=Math.max(64,(2n*(C+g)).toString(2).length-(g*A).toString(2).length+128)}let x=1n<<BigInt(p),R=u.map(g=>g*x),w=m.map(g=>g*x),_=w.map(g=>g*g),S=0n,M=w.reduce((g,C)=>g+C,0n);if(M===0n)return!1;for(let g=0;g<4096;g++){let C=S+M>>1n;if(C===S)return!1;let N=R[0]+C,A=R[1]+C,O=R[2]+C,y=N*N,P=A*A,b=O*O,L=_[0]*P*b+_[1]*y*b+_[2]*y*P-y*P*b;if(L===0n)return E(C,x);if(L>0n?S=C:M=C,S>0n&&M-S<=S>>60n)return E(S+M>>1n,x)}return!1;function E(g,C){let N=f.map((P,b)=>{let L=u[b]*C+g;return L===0n?0:Zo(P*l[b+3]*C,L,h)});if(!N.every(Number.isFinite))return!1;let A=Math.sign(e)*N[0],O=Math.sign(t)*N[1],y=Math.sign(r)*N[2];return o.x=A,o.y=O,o.z=y,!0}}function Zo(e,t,r){if(e===0n)return 0;let n=52-(e.toString(2).length-t.toString(2).length),i=n>=0?e<<BigInt(n):e,s=n>=0?t:t<<BigInt(-n),o=i/s,a=i%s;(2n*a>s||2n*a===s&&o&1n)&&o++;let c=r-n,h=Math.max(-1022,Math.min(1023,c));return Number(o)*2**h*2**(c-h)}var fi=I(()=>{});function ui(e,t,r,n,i,s,o){let a=Math.min(n,i,s),c=a*a,h=n*n,l=i*i,f=s*s;if(!(a>0)||!(c>0)||!Number.isFinite(Math.max(h,l,f)))return!1;let d=xt(a,a,c),u=h-c,m=l-c,p=f-c,x=nt(h,-c,u)+xt(n,n,h)-d,R=nt(l,-c,m)+xt(i,i,l)-d,w=nt(f,-c,p)+xt(s,s,f)-d,_=n*Math.abs(e),S=i*Math.abs(t),M=s*Math.abs(r);if(c<2**-1022||e!==0&&_<2**-1022||t!==0&&S<2**-1022||r!==0&&M<2**-1022)return H(e,t,r,n,i,s,o);let E=xt(n,Math.abs(e),_),g=xt(i,Math.abs(t),S),C=xt(s,Math.abs(r),M);if(Math.hypot(u===0?_===0?0:1/0:_/(u+x),m===0?S===0?0:1/0:S/(m+R),p===0?M===0?0:1/0:M/(p+w))<=1+64*Number.EPSILON)return H(e,t,r,n,i,s,o);if((e!==0?1:0)+(t!==0?1:0)+(r!==0?1:0)==1)return o.x=e===0?e:Math.sign(e)*n,o.y=t===0?t:Math.sign(t)*i,o.z=r===0?r:Math.sign(r)*s,!0;let A=Math.hypot(u===0?_:0,m===0?S:0,p===0?M:0),O=Math.hypot(_,S,M);if(!(O>0)||!Number.isFinite(O))return H(e,t,r,n,i,s,o);let y=A>0?A:O;for(let P=0;P<512;P++){let b=u+y,L=m+y,D=p+y,ut=nt(u,y,b)+x,st=nt(m,y,L)+R,Tt=nt(p,y,D)+w,k=_/b,W=S/L,$=M/D,dt,X;k>=W&&k>=$?(dt=cr(_,E,u,x,y,b)*(k+1),X=(W*(1-st/L))**2+($*(1-Tt/D))**2):W>=$?(dt=cr(S,g,m,R,y,L)*(W+1),X=(k*(1-ut/b))**2+($*(1-Tt/D))**2):(dt=cr(M,C,p,w,y,D)*($+1),X=(k*(1-ut/b))**2+(W*(1-st/L))**2);let J=-2*(k*k/b+W*W/L+$*$/D),Ie=4*Number.EPSILON*(Math.abs(dt)+X),ot=dt+X;if(!Number.isFinite(ot))return H(e,t,r,n,i,s,o);if(Math.abs(ot)<=4*Number.EPSILON*(Math.abs(dt)+X)||O-A<=4*Number.EPSILON*y){let br=Ie/Math.abs(J);if(!Number.isFinite(J)||!(Math.abs(J)>0)||br>2e-13*y)return H(e,t,r,n,i,s,o);let Ne=Math.sign(e)*n*(k*(1-ut/b)),Pe=Math.sign(t)*i*(W*(1-st/L)),Le=Math.sign(r)*s*($*(1-Tt/D)),Ir=2*br*Math.max(Math.abs(Ne/b),Math.abs(Pe/L),Math.abs(Le/D));return!Number.isFinite(Ir)||Ir>2e-13*Math.max(n,i,s)?H(e,t,r,n,i,s,o):!Number.isFinite(Ne)||!Number.isFinite(Pe)||!Number.isFinite(Le)?H(e,t,r,n,i,s,o):(o.x=Ne,o.y=Pe,o.z=Le,!0)}ot>0?A=y:O=y;let Ot=y-ot/J,Ar=Ot>A&&Ot<O?Ot:A+(O-A)/2;if(Ar===y)return H(e,t,r,n,i,s,o);y=Ar}return H(e,t,r,n,i,s,o)}function cr(e,t,r,n,i,s){let o=e-r,a=nt(e,-r,o)+t-n,c=o+a,h=nt(o,a,c),l=c-i;return(l+(nt(c,-i,l)+h))/s}function nt(e,t,r){let n=r-e;return e-(r-n)+(t-n)}function xt(e,t,r){let n=134217729*e,i=134217729*t;if(!Number.isFinite(n)||!Number.isFinite(i))return 0;let s=n-(n-e),o=i-(i-t),a=e-s,c=t-o;return s*o-r+s*c+a*o+a*c}var di=I(()=>{fi()});function mi(e,t,r=[]){let n=e,i="x"in e?n.x:e[0],s="x"in e?n.y:e[1],o="x"in e?n.z:e[2];if(!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(o)||!Number.isFinite(i*i+s*s+o*o))return;let{radii:a}=t;if(ui(i,s,o,a.x,a.y,a.z,ue))return K(r,ue.x,ue.y,ue.z)}function K(e,t,r,n){if(Z(e))e[0]=t,e[1]=r,e[2]=n;else{let i=e;i.x=t,i.y=r,i.z=n}return e}var ue,pi=I(()=>{U();di();ue={x:0,y:0,z:0}});function xi(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0||t>e)throw new Error("Spheroid requires finite positive axes with semiMinorAxis <= semiMajorAxis")}function pe(e,t,r,n){let i=Math.max(Math.abs(e),Math.abs(t),Math.abs(r));if(!(i>0)||!Number.isFinite(i))return;let s=e/i,o=t/i,a=r/i,c=Math.hypot(s,o,a);return K(n,s/c,o/c,a/c)}var B,de,Xo,Y,me,G,gi=I(()=>{U();ai();ci();li();pi();B={x:0,y:0,z:0},de=new T,Xo=new T,Y=new T,me=new T,G=class e{static fromSpheroid(t){let{semiMajorAxis:r,semiMinorAxis:n}=t;return xi(r,n),new e(r,r,n)}constructor(t=0,r=0,n=0){this.centerToleranceSquared=St.EPSILON1,F(Number.isFinite(t)&&t>=0),F(Number.isFinite(r)&&r>=0),F(Number.isFinite(n)&&n>=0),this.radii=new T(t,r,n),this.radiiSquared=new T(t*t,r*r,n*n),this.radiiToTheFourth=new T(t*t*t*t,r*r*r*r,n*n*n*n),this.oneOverRadii=new T(t===0?0:1/t,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new T(t===0?0:1/(t*t),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,r,n),this.maximumRadius=Math.max(t,r,n),n!==0&&(this.squaredXOverSquaredZ=(t/n)**2),t===r&&n>0&&n<=t&&Number.isFinite(this.radiiSquared.x)&&this.radiiSquared.z>0&&(this.spheroidGeometry=Object.freeze({semiMajorAxis:t,semiMinorAxis:n,eccentricitySquared:1-(n/t)**2})),Object.freeze(this.radii),Object.freeze(this.radiiSquared),Object.freeze(this.radiiToTheFourth),Object.freeze(this.oneOverRadii),Object.freeze(this.oneOverRadiiSquared),Object.freeze(this)}toSpheroid(){let{x:t,y:r,z:n}=this.radii;if(t!==r)throw new Error("Spheroid requires equal X/Y radii");return xi(t,n),Object.freeze({semiMajorAxis:t,semiMinorAxis:n})}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){let n=hi(t,me),i=n[0],s=n[1],o=n[2];if(!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(o)||!(this.minimumRadius>0)||!Number.isFinite(this.maximumRadius*this.maximumRadius))return;if(this.spheroidGeometry&&(v._cartographicRadians||Math.abs(s)<=Math.PI/4))return B.x=i,B.y=s,B.z=o,si(B,this.spheroidGeometry)?K(r,B.x,B.y,B.z):void 0;let a=Xo;this.geodeticSurfaceNormalCartographic(t,a);let c=a.x,h=a.y,l=a.z,f=this.radii.x,d=this.radii.y,u=this.radii.z,m=Math.hypot(f*c,d*h,u*l),p=f*(f*c/m)+o*c,x=d*(d*h/m)+o*h,R=u*(u*l/m)+o*l;if(!(!Number.isFinite(p)||!Number.isFinite(x)||!Number.isFinite(R)))return K(r,p,x,R)}cartesianToCartographic(t,r=[0,0,0]){let n=t,i="x"in t?n.x:t[0],s="x"in t?n.y:t[1],o="x"in t?n.z:t[2];if(!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(o))return;if(this.spheroidGeometry&&Number.isFinite(i*i+s*s+o*o)&&Number.isFinite(this.oneOverRadiiSquared.x)&&Number.isFinite(this.oneOverRadiiSquared.z)){B.x=i,B.y=s,B.z=o;let w=this.spheroidGeometry;if(!(o===0&&w.semiMinorAxis<w.semiMajorAxis&&Math.abs(Math.hypot(i,s)-w.semiMajorAxis*w.eccentricitySquared)<=64*Number.EPSILON*w.semiMajorAxis)&&oi(B,w)){let S=i===0&&s===0?Math.atan2(s,i):B.x;return ar(S,B.y,B.z,r)}}if(!(this.minimumRadius>0)||!Number.isFinite(this.maximumRadius*this.maximumRadius)||!Number.isFinite(1/(this.minimumRadius*this.minimumRadius)))return;me.set(i,s,o);let a=this.scaleToGeodeticSurface(me,Y);if(!a)return;let c=a[0]*this.oneOverRadiiSquared.x,h=a[1]*this.oneOverRadiiSquared.y,l=a[2]*this.oneOverRadiiSquared.z,f=Math.hypot(c,h,l);if(!(f>0)||!Number.isFinite(f))return;let d=c/f,u=h/f,m=l/f,p=Math.atan2(u,d),x=Math.atan2(m,Math.hypot(d,u)),R=(i-a[0])*d+(s-a[1])*u+(o-a[2])*m;return ar(p,x,R,r)}geocentricSurfaceNormal(t,r=[0,0,0]){rt(t,de);let n=de;return pe(n.x,n.y,n.z,r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let n=rt(t,me),i=v._cartographicRadians?n[0]:n[0]*Math.PI/180,s=v._cartographicRadians?n[1]:n[1]*Math.PI/180,o=!v._cartographicRadians&&Math.abs(n[1])>45,a=(90-Math.abs(n[1]))*Math.PI/180,c=o?Math.sin(a):Math.abs(s)===Math.PI/2?0:Math.cos(s),h=o?Math.sign(n[1])*Math.cos(a):Math.sin(s);return pe(c*Math.cos(i),c*Math.sin(i),h,r)}geodeticSurfaceNormal(t,r=[0,0,0]){if(!(this.minimumRadius>0))return;rt(t,de);let n=de,i=Math.max(Math.abs(n.x),Math.abs(n.y),Math.abs(n.z));if(!(i>0)||!Number.isFinite(i))return;let s=n.x/i*(this.minimumRadius/this.radii.x)**2,o=n.y/i*(this.minimumRadius/this.radii.y)**2,a=n.z/i*(this.minimumRadius/this.radii.z)**2;if((n.x===0||Math.abs(s)>=2**-1022)&&(n.y===0||Math.abs(o)>=2**-1022)&&(n.z===0||Math.abs(a)>=2**-1022))return pe(s,o,a,r);let c=n.x===0?0:Math.min(1023,Math.floor(Math.log2(Math.abs(n.x)))),h=n.y===0?0:Math.min(1023,Math.floor(Math.log2(Math.abs(n.y)))),l=n.z===0?0:Math.min(1023,Math.floor(Math.log2(Math.abs(n.z)))),f=Math.min(1023,Math.floor(Math.log2(this.radii.x))),d=Math.min(1023,Math.floor(Math.log2(this.radii.y))),u=Math.min(1023,Math.floor(Math.log2(this.radii.z))),m=Math.max(n.x===0?-1/0:c-2*f,n.y===0?-1/0:h-2*d,n.z===0?-1/0:l-2*u);return pe(n.x===0?n.x:n.x/2**c/(this.radii.x/2**f)**2*2**(c-2*f-m),n.y===0?n.y:n.y/2**h/(this.radii.y/2**d)**2*2**(h-2*d-m),n.z===0?n.z:n.z/2**l/(this.radii.z/2**u)**2*2**(l-2*u-m),r)}scaleToGeodeticSurface(t,r){return mi(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){rt(t,Y);let n=Y,i=Math.max(Math.abs(n.x),Math.abs(n.y),Math.abs(n.z));if(!(this.minimumRadius>0)||!(i>0)||!Number.isFinite(i))return;let s=n.x*n.x*this.oneOverRadiiSquared.x+n.y*n.y*this.oneOverRadiiSquared.y+n.z*n.z*this.oneOverRadiiSquared.z;if(s>=2**-1022&&Number.isFinite(s)&&i*i>=2**-1022&&Number.isFinite(i*i)){let l=1/Math.sqrt(s);return K(r,n.x*l,n.y*l,n.z*l)}let o=n.x/i,a=n.y/i,c=n.z/i,h=Math.hypot(o/this.radii.x,a/this.radii.y,c/this.radii.z);if(!(!(h>0)||!Number.isFinite(h)))return K(r,o/h,a/h,c/h)}transformPositionToScaledSpace(t,r=[0,0,0]){rt(t,Y);let n=Y.scale(this.oneOverRadii);return K(r,n.x,n.y,n.z)}transformPositionFromScaledSpace(t,r=[0,0,0]){rt(t,Y);let n=Y.scale(this.radii);return K(r,n.x,n.y,n.z)}getSurfaceNormalIntersectionWithZAxis(t,r=0,n=[0,0,0]){if(F(this.radii.x===this.radii.y&&this.minimumRadius>0),rt(t,Y),!Number.isFinite(Y.x)||!Number.isFinite(Y.y)||!Number.isFinite(Y.z)||!Number.isFinite(r))return;let i=Y.z*(1-this.squaredXOverSquaredZ);if(Number.isFinite(i)&&!(Math.abs(i)>=this.radii.z-r))return K(n,0,0,i)}};G.WGS84=new G(6378137,6378137,et)});var Ti=I(()=>{Je()});var Lt,Si,vt,Mi=I(()=>{U();Ti();Lt=new T,Si=new T,vt=class e{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new T,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=Lt.from(r),this.center=new T().from(t).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new e(this.center,this.radius)}union(t){let r=this.center,n=this.radius,i=t.center,s=t.radius,o=Lt.copy(i).subtract(r),a=o.magnitude();if(n>=a+s)return this.clone();if(s>=a+n)return t.clone();let c=(n+a+s)*.5;return Si.copy(o).scale((-n+c)/a).add(r),this.center.copy(Si),this.radius=c,this}expand(t){let n=Lt.from(t).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(t){this.center.transform(t);let r=Cn(Lt,t);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(t){let r=this.distanceTo(t);return r*r}distanceTo(t){let n=Lt.from(t).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(t){let r=this.center,n=this.radius,s=t.normal.dot(r)+t.distance;return s<-n?"outside":s<n?"intersecting":"inside"}}});var _i,Ri,V,hr=I(()=>{U();_i=new T,Ri=new T,V=class e{constructor(t=[0,0,1],r=0){this.normal=new T,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return F(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=_i.from(t),this.normal.from(r).normalize();let n=-this.normal.dot(t);return this.distance=n,this}fromCoefficients(t,r,n,i){return this.normal.set(t,r,n),F(ct(this.normal.len(),1)),this.distance=i,this}clone(){return new e(this.normal,this.distance)}equals(t){return ct(this.distance,t.distance)&&ct(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=Ri.copy(this.normal).transformAsVector(t).normalize(),n=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(n,r)}projectPointOntoPlane(t,r=[0,0,0]){let n=_i.from(t),i=this.getPointDistance(n),s=Ri.copy(this.normal).scale(i);return n.subtract(s).to(r)}intersectWithRay(t,r=new T){let n=t.origin,i=t.direction,s=this.normal,o=s.dot(i);if(Math.abs(o)<St.EPSILON15)return;let a=(-this.distance-s.dot(n))/o;if(!(a<0))return r.copy(i).multiplyByScalar(a).add(n)}}});var Ei,yi,Qo,ft,Ci=I(()=>{U();hr();Ei=[new T([1,0,0]),new T([0,1,0]),new T([0,0,1])],yi=new T,Qo=new T,ft=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Ei.length;let r=t.center,n=t.radius,i=0;for(let s of Ei){let o=this.planes[i],a=this.planes[i+1];o||(o=this.planes[i]=new V),a||(a=this.planes[i+1]=new V);let c=yi.copy(s).scale(-n).add(r);o.fromPointNormal(c,s);let h=yi.copy(s).scale(n).add(r),l=Qo.copy(s).negate();a.fromPointNormal(h,l),i+=2}return this}computeVisibility(t){let r="inside";for(let n of this.planes)switch(t.intersectPlane(n)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(F(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let n=e.MASK_INSIDE,i=this.planes;for(let s=0;s<this.planes.length;++s){let o=s<31?1<<s:0;if(s<31&&(r&o)===0)continue;let a=i[s],c=t.intersectPlane(a);if(c==="outside")return e.MASK_OUTSIDE;c==="intersecting"&&(n|=o)}return n}};ft.MASK_OUTSIDE=4294967295;ft.MASK_INSIDE=0;ft.MASK_INDETERMINATE=2147483647});var lr=I(()=>{Mi();Ci();hr()});function wi(){return{eastX:0,eastY:1,northZ:1,upX:1,upY:0,upZ:0}}function Oi(e,t,r){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return s!==0?!1:ta(r,n,i,o*i-a*n,o,a,c)}function Ai(e,t,r,n,i,s){let o=fr(r),a=fr(n),c=fr(i),h=Math.abs(o),l=Math.abs(a),f=Math.abs(c);if(!h||!l||!f||h===l||h===f||l===f||(h%3+1===l?1:-1)*Math.sign(o*a*c)!==1||!Array.isArray(s)&&s.length<16)return!1;let u=e.eastX,m=e.eastY,p=e.northZ,x=e.upX,R=e.upY,w=e.upZ,_=-w*m,S=w*u,M=t.x,E=t.y,g=t.z,C=(h===1?u:h===2?_:x)*Math.sign(o),N=(h===1?m:h===2?S:R)*Math.sign(o),A=(h===1?0:h===2?p:w)*Math.sign(o),O=(l===1?u:l===2?_:x)*Math.sign(a),y=(l===1?m:l===2?S:R)*Math.sign(a),P=(l===1?0:l===2?p:w)*Math.sign(a),b=(f===1?u:f===2?_:x)*Math.sign(c),L=(f===1?m:f===2?S:R)*Math.sign(c),D=(f===1?0:f===2?p:w)*Math.sign(c);return!Number.isFinite(C)||!Number.isFinite(N)||!Number.isFinite(A)||!Number.isFinite(O)||!Number.isFinite(y)||!Number.isFinite(P)||!Number.isFinite(b)||!Number.isFinite(L)||!Number.isFinite(D)||!Number.isFinite(M)||!Number.isFinite(E)||!Number.isFinite(g)||s instanceof Float32Array&&(!Number.isFinite(Math.fround(C))||!Number.isFinite(Math.fround(N))||!Number.isFinite(Math.fround(A))||!Number.isFinite(Math.fround(O))||!Number.isFinite(Math.fround(y))||!Number.isFinite(Math.fround(P))||!Number.isFinite(Math.fround(b))||!Number.isFinite(Math.fround(L))||!Number.isFinite(Math.fround(D))||!Number.isFinite(Math.fround(M))||!Number.isFinite(Math.fround(E))||!Number.isFinite(Math.fround(g)))?!1:(s[0]=C,s[1]=N,s[2]=A,s[3]=0,s[4]=O,s[5]=y,s[6]=P,s[7]=0,s[8]=b,s[9]=L,s[10]=D,s[11]=0,s[12]=M,s[13]=E,s[14]=g,s[15]=1,!0)}function fr(e){switch(e){case"east":return 1;case"west":return-1;case"north":return 2;case"south":return-2;case"up":return 3;case"down":return-3;default:return 0}}function ta(e,t,r,n,i,s,o){return!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(o)?!1:(e.eastX=t,e.eastY=r,e.northZ=n,e.upX=i,e.upY=s,e.upZ=o,!0)}var bi=I(()=>{});function Pi(e,t,r,n,i,s){let o=Ni[t]&&Ni[t][r];F(o&&(!n||n===o));let a,c,h,l=ra.copy(i);if(!Number.isFinite(l.x)||!Number.isFinite(l.y)||!Number.isFinite(l.z)||!Array.isArray(s)&&s.length<16)throw new Error("Unsupported local frame");let f=ea*Math.min(1,e.maximumRadius),d=Math.abs(l.x)<=f&&Math.abs(l.y)<=f,u=e.radii;if(u.x===u.y&&u.x>0&&u.z>0&&u.z<=u.x&&(!d||l.z!==0)){let{east:A,up:O}=yt;if(d)A.set(0,1,0),O.set(0,0,Math.sign(l.z));else{let y=Math.max(Math.abs(l.x),Math.abs(l.y));A.set(-l.y/y,l.x/y,0).normalize(),e.geodeticSurfaceNormal(l,O)}if(!Oi(A,O,Ii)||!Ai(Ii,l,t,r,n,s))throw new Error("Unsupported local frame");return s}if(d){let A=Math.sign(l.z);a=na.fromArray(ur[t]),t!=="east"&&t!=="west"&&a.scale(A),c=ia.fromArray(ur[r]),r!=="east"&&r!=="west"&&c.scale(A),h=sa.fromArray(ur[n]),n!=="east"&&n!=="west"&&h.scale(A)}else{let{up:A,east:O,north:y}=yt,P=Math.max(Math.abs(l.x),Math.abs(l.y));O.set(-l.y/P,l.x/P,0).normalize(),e.geodeticSurfaceNormal(l,A),y.copy(A).cross(O);let{down:b,west:L,south:D}=yt;b.copy(A).scale(-1),L.copy(O).scale(-1),D.copy(y).scale(-1),a=yt[t],c=yt[r],h=yt[n]}let m=a.x,p=a.y,x=a.z,R=c.x,w=c.y,_=c.z,S=h.x,M=h.y,E=h.z,g=l.x,C=l.y,N=l.z;return s[0]=m,s[1]=p,s[2]=x,s[3]=0,s[4]=R,s[5]=w,s[6]=_,s[7]=0,s[8]=S,s[9]=M,s[10]=E,s[11]=0,s[12]=g,s[13]=C,s[14]=N,s[15]=1,s}var ea,ra,Ii,Ni,ur,yt,na,ia,sa,Li=I(()=>{U();bi();ea=1e-14,ra=new T,Ii=wi(),Ni={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},ur={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},yt={east:new T,north:new T,up:new T,west:new T,south:new T,down:new T},na=new T,ia=new T,sa=new T});function zt(e,t,r=new q){return Pi(e,"east","north","up",t,r)}var vi=I(()=>{U();Li()});var xe=I(()=>{gi();vi()});var zi=I(()=>{});function mr(e){oa(e)}function oa(e){if(typeof e.id!="string"||!e.id||e.origin.length!==2||e.tileSize.length!==2||e.matrixSize.length!==2||!Number.isFinite(e.resolution)||e.resolution<=0||e.resolutionY!==void 0&&(!Number.isFinite(e.resolutionY)||e.resolutionY<=0)||!e.origin.every(Number.isFinite)||![...e.tileSize,...e.matrixSize].every(n=>Number.isSafeInteger(n)&&n>0)||!["topLeft","bottomLeft"].includes(e.cornerOfOrigin))throw new RangeError("Invalid tile matrix geometry");let t=[...e.variableMatrixWidths??[]].sort((n,i)=>n.minTileRow-i.minTileRow),r=-1;for(let n of t){if(!Number.isSafeInteger(n.coalesce)||n.coalesce<=1||e.matrixSize[0]%n.coalesce!==0||!Number.isSafeInteger(n.minTileRow)||!Number.isSafeInteger(n.maxTileRow)||n.minTileRow<=r||n.maxTileRow<n.minTileRow||n.maxTileRow>=e.matrixSize[1])throw new RangeError("Invalid variable matrix width");r=n.maxTileRow}for(let n=0;n<2;n++){let s=(n===1?e.resolutionY??e.resolution:e.resolution)*e.tileSize[n],o=s*e.matrixSize[n],a=n===1&&e.cornerOfOrigin==="topLeft"?-1:1,c=e.origin[n]+a*o;if(!Number.isFinite(o)||o<=0||!Number.isFinite(c)||e.origin[n]+a*s===e.origin[n]||c-a*s===c)throw new RangeError("Tile matrix extent must be finite")}return t}function pr(e,t,r,n){return mr(e),n&&Fi(e,n),Number.isSafeInteger(t)&&Number.isSafeInteger(r)&&t>=0&&r>=0&&t<e.matrixSize[0]&&r<e.matrixSize[1]&&(!n||t>=n.minTileColumn&&t<=n.maxTileColumn&&r>=n.minTileRow&&r<=n.maxTileRow)}function qi(e,t,r){if(!pr(e,t,r))throw new RangeError("Tile index outside matrix");let n=e.resolution*e.tileSize[0],i=(e.resolutionY??e.resolution)*e.tileSize[1],s=la(e,r),o=Math.floor(t/s)*s,a=e.origin[0]+o*n,c=e.cornerOfOrigin==="topLeft"?e.origin[1]-(r+1)*i:e.origin[1]+r*i;return[a,c,e.origin[0]+(o+s)*n,e.cornerOfOrigin==="topLeft"?e.origin[1]-r*i:e.origin[1]+(r+1)*i]}function aa(e,t,r,n,i,s=1){let o=e+t*(n*r);return(t===1?i<e||i>=o:i>e||i<=o)?null:(dr(e,t,r,n,i,!1,s)-1)*s}function dr(e,t,r,n,i,s,o=1){let a=0,c=n/o;for(;a<c;){let h=a+Math.floor((c-a)/2),l=e+t*(h*o*r);(t===1?s?l<i:l<=i:s?l>i:l>=i)?a=h+1:c=h}return a}function Fi(e,t){if(![t.minTileColumn,t.maxTileColumn,t.minTileRow,t.maxTileRow].every(n=>Number.isSafeInteger(n)&&n>=0)||t.minTileColumn>t.maxTileColumn||t.minTileRow>t.maxTileRow||t.maxTileColumn>=e.matrixSize[0]||t.maxTileRow>=e.matrixSize[1])throw new RangeError("Invalid tile matrix limits")}function ca(e,t,r){ha(t);let n=Di(e.origin[0],1,e.resolution*e.tileSize[0],e.matrixSize[0],t[0],t[2]),i=e.cornerOfOrigin==="topLeft",s=Di(e.origin[1],i?-1:1,(e.resolutionY??e.resolution)*e.tileSize[1],e.matrixSize[1],i?t[3]:t[1],i?t[1]:t[3]);if(!n||!s)return null;let o={minTileColumn:Math.max(n[0],r?.minTileColumn??0),maxTileColumn:Math.min(n[1],r?.maxTileColumn??e.matrixSize[0]-1),minTileRow:Math.max(s[0],r?.minTileRow??0),maxTileRow:Math.min(s[1],r?.maxTileRow??e.matrixSize[1]-1)};return o.minTileColumn>o.maxTileColumn||o.minTileRow>o.maxTileRow?null:o}function ha(e){if(e.length!==4||!e.every(Number.isFinite)||e[0]>e[2]||e[1]>e[3])throw new RangeError("Tile query bounds must be finite and ordered")}function ki(e,t,r){if(mr(e),e.variableMatrixWidths?.length)throw new RangeError("Use getTileRanges for variable-width matrices");return r&&Fi(e,r),ca(e,t,r)}function la(e,t){return e.variableMatrixWidths?.find(r=>t>=r.minTileRow&&t<=r.maxTileRow)?.coalesce??1}function Di(e,t,r,n,i,s,o=1){if(i===s){let l=aa(e,t,r,n,i,o);return l===null?null:[l,l]}let a=e+t*(n*r),c=t===1?Math.max(i,e):Math.min(i,e),h=t===1?Math.min(s,a):Math.max(s,a);return(t===1?c>=h:c<=h)?null:[(dr(e,t,r,n,c,!1,o)-1)*o,(dr(e,t,r,n,h,!0,o)-1)*o]}function Ui(e,t){if(!Number.isFinite(t)||t<=0)throw new RangeError("Target resolution must be positive and finite");let r=null,n=null,i=-1/0,s=1/0,o=new Set;for(let a of e.matrices){if(mr(a),o.has(a.id))throw new RangeError("Tile matrix identifiers must be unique");o.add(a.id);let c=Math.max(a.resolution,a.resolutionY??a.resolution);(!n||c<s)&&(n=a,s=c),c<=t&&(!r||c>i)&&(r=a,i=c)}return r??n}var Bi=I(()=>{});var Gi=I(()=>{});var ge=I(()=>{xe();zi();Gi()});var Dt=I(()=>{"use strict";vr();Dr();Fr()});var Vt={};Nr(Vt,{ImageSet:()=>_e,LOD_METRIC_TYPE:()=>Bt,RasterSet:()=>Re,STRATEGY_DEFAULT:()=>wt,STRATEGY_NEVER:()=>Te,STRATEGY_REPLACE:()=>Se,SharedTile2DHeader:()=>at,TILESET_TYPE:()=>it,TILE_TYPE:()=>Ut,Tileset2D:()=>Ct,Tileset3D:()=>Gt,selectTileMatrixTiles:()=>_s});$t(Vt,As(Lr(),1));var at=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(t){this.index=t,this.parent=null,this.children=[],this.content=null,this.error=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.bottom]])}get data(){let t=this._loader;return!this._isCancelled&&t!==void 0?t.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get hasError(){return!!this.error}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let t=this.content?this.content.byteLength:0;return Number.isFinite(t)?t:0}async _loadData({getData:t,requestScheduler:r,onLoad:n,onError:i}){let s=(x,R,w)=>{if(!(w!==this._loaderId||this._isCancelled)){if(this._loader=void 0,this.content=x,this.error=R?Is(R):null,this._isLoaded=!0,this._isCancelled=!1,R){i(R,this);return}n(this)}},{index:o,id:a,bbox:c,userData:h,zoom:l}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:d}=this._abortController,u=await r.scheduleRequest({tile:this,loaderId:f},()=>f===this._loaderId&&!this._isCancelled?1:-1);if(this._isCancelled||f!==this._loaderId){u?.done();return}if(!u){this._isCancelled=!0;return}let m=null,p;try{m=await t({index:o,id:a,bbox:c,userData:h,zoom:l,signal:d})}catch(x){p=x||!0}finally{u.done()}s(m,p,f)}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._loaderId++,this._loader=void 0,this._abortController?.abort())}};function Is(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}Dt();Zt();var Te="never",Se="no-overlap",wt="best-available",Vi={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:wt,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},Ct=class e{stats;sourceMetadata=null;opts;_requestScheduler;_cache;_dirty;_tiles;_cacheByteSize;_unloadedTileCount;_listeners=new Set;_consumers=new Map;_explicitOptionKeys=new Set;_baseOpts={};_sourceMetadataOverrides={};_maxZoom;_minZoom;_lastTileContext=null;_statsUpdateScheduled=!1;_lifecycleVersion=0;constructor(t){if(this.stats=new j({id:"Tileset2D",stats:[{name:"Tiles In Cache"},{name:"Cache Size"},{name:"Visible Tiles"},{name:"Selected Tiles"},{name:"Loading Tiles"},{name:"Unloaded Tiles"},{name:"Consumers"}]}),this.opts={...Vi,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new Q({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._unloadedTileCount=0,!this.opts.tileSource&&!t.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(t),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(t,r={}){return new e({...r,tileSource:t})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let t=this._getVisibleTilesUnion();for(let r of this._getSelectedTilesUnion())t.add(r);return Array.from(t)}get loadingTiles(){return Array.from(this._cache.values()).filter(t=>t.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(t=>!t.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||wt}get adapter(){return this.opts.adapter}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}attachConsumer(t){this._consumers.set(t,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(t){this._consumers.delete(t),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(t){this._rememberExplicitOptions(t),this._baseOpts={...this._baseOpts,...t};let r=this.opts.maxRequests,n=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||n!==this.opts.debounceTime)&&(this._requestScheduler=new Q({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){this._lifecycleVersion++;for(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let t=this._getSelectedTilesUnion(),r=this._getVisibleTilesUnion();for(let n of this._cache.keys()){let i=this._cache.get(n);i&&!t.has(i)&&!r.has(i)?(this._cache.delete(n),this._handleTileUnload(i),this._dirty=!0):i&&i.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,r,n){this._consumers.set(t,{selectedTiles:new Set(r),visibleTiles:new Set(n)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:r,minZoom:n,zRange:i,modelMatrix:s,modelMatrixInverse:o}){let{adapter:a,tileSize:c,extent:h,zoomOffset:l}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:t,tileSize:c},a.getTileIndices({viewState:t,maxZoom:r,minZoom:n,zRange:i,tileSize:c,extent:fa(h),modelMatrix:s,modelMatrixInverse:o,zoomOffset:l})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){if(!this._lastTileContext)throw new Error("Tileset2D metadata requested before traversal context was set.");if(!this.opts.adapter)throw new Error("Tileset2D requires an adapter before tile metadata can be derived.");return{bbox:this.opts.adapter.getTileBoundingBox(this._lastTileContext,t)}}getParentIndex(t){return{x:Math.floor(t.x/2),y:Math.floor(t.y/2),z:t.z-1}}getTile(t,r){let n=this.getTileId(t),i=this._cache.get(n),s=!1;if(!i&&r?(i=new at(t),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:n,zoom:this.getTileZoom(i.index)}),s=!0,this._cache.set(n,i),this._dirty=!0,this._setStatCount("Tiles In Cache",this._cache.size),this._scheduleStatsUpdate()):i&&i.needsReload&&(s=!0),i&&this._touchTile(n,i),i&&s&&r){let o=i.isLoading;i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),o||this.stats.get("Loading Tiles").incrementCount(),this._scheduleStatsUpdate()}return i}async _initializeTileSource(t){let r=this._lifecycleVersion;try{let n=await t.getMetadata();if(r!==this._lifecycleVersion)return;this.sourceMetadata=n,this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(n){if(r!==this._lifecycleVersion)return;let i=n instanceof Error?n:new Error(`TileSource metadata error: ${String(n)}`);this._notifyError(i)}}_rememberExplicitOptions(t){for(let r of Object.keys(t))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let t={...Vi,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let r=t.tileSource;t.getTileData=n=>r.getTileData(n)}this.opts=t,this._maxZoom=typeof this.opts.maxZoom=="number"&&Number.isFinite(this.opts.maxZoom)?Math.floor(this.opts.maxZoom):void 0,this._minZoom=typeof this.opts.minZoom=="number"&&Number.isFinite(this.opts.minZoom)?Math.ceil(this.opts.minZoom):void 0}_getMetadataOverrides(t){if(!t)return{};let r={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(r.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(r.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(r.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),r}_handleTileLoad(t){let r=this._lifecycleVersion;if(this._cache.get(t.id)===t&&(this.opts.onTileLoad?.(t),this._cache.get(t.id)===t)){this._cacheByteSize=this._getCacheByteSize(),this._resizeCache(),this._updateStats();for(let n of this._listeners){if(r!==this._lifecycleVersion)return;n.onTileLoad?.(t)}}}_handleTileError(t,r){let n=this._lifecycleVersion;if(this._cache.get(r.id)===r&&(this.opts.onTileError?.(t,r),this._cache.get(r.id)===r)){this._cacheByteSize=this._getCacheByteSize(),this._resizeCache(),this._updateStats();for(let i of this._listeners){if(n!==this._lifecycleVersion)return;i.onTileError?.(t,r)}}}_handleTileUnload(t){t.abort(),this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let r of this._listeners)r.onTileUnload?.(t)}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let r of this._listeners)r.onError?.(t)}_scheduleStatsUpdate(){this._statsUpdateScheduled||(this._statsUpdateScheduled=!0,queueMicrotask(()=>{this._statsUpdateScheduled&&this._updateStats()}))}_updateStats(){this._statsUpdateScheduled=!1,this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let t of this._listeners)t.onStatsChange?.(this.stats)}_setStatCount(t,r){this.stats.get(t).reset().addCount(r)}_getSelectedTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let n of r.selectedTiles)t.add(n);return t}_getVisibleTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let n of r.visibleTiles)t.add(n);return t}_touchTile(t,r){this._cache.delete(t),this._cache.set(t,r)}_getCacheByteSize(){let t=0;for(let r of this._cache.values())t+=r.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,r=this._getSelectedTilesUnion(),n=this._getVisibleTilesUnion(),i=[],s=0;for(let o of this._cache.values())o.isLoading&&(s++,!r.has(o)&&!n.has(o)&&i.push(o));for(;t>0&&s>t&&i.length>0;){let o=i.shift();o&&o.abort(),s--}}_rebuildTree(){for(let t of this._cache.values())t.parent=null,t.children&&(t.children.length=0);for(let t of this._cache.values()){let r=this._getNearestAncestor(t);t.parent=r,r?.children&&r.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,r)=>t.zoom-r.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,r=this.opts.maxCacheByteSize??1/0,n=this._getVisibleTilesUnion(),i=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>r){for(let[o,a]of this._cache)if(!n.has(a)&&!i.has(a)&&(this._cache.delete(o),this._cacheByteSize-=a.byteLength,this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=r)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:r=0}=this,n=t.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let i=this._cache.get(this.getTileId(n));if(i)return i}return null}};function fa(e){return e&&e.length===4?e:void 0}var Me={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},_e=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.imageSource&&(!t.getImage||!t.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(t,r={}){return new e({...r,imageSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.imageSource,n=this._normalizeOptions({...this._opts,...t}),i=r!==n.imageSource||this._opts.getImage!==n.getImage||this._opts.getMetadata!==n.getMetadata;this._opts=n,i&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let r of this._listeners)r.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let r=Wi(t,"Image metadata request failed");if(!this._finalized)for(let n of this._listeners)n.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(t,r=this._opts.debounceTime){let n=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(n,t)},r):this._loadImage(n,t),n}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,r){if(!this._finalized){this._startLoading();for(let n of this._listeners)n.onImageLoadStart?.(t,r);try{let n=new AbortController;this._abortController=n;let i=await this._opts.getImage({...r,signal:n.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,image:i};for(let s of this._listeners)s.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(n){if(ua(n))return;let i=Wi(n,"Image request failed");if(!this._finalized)for(let s of this._listeners)s.onImageLoadError?.(t,i,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let r=t.imageSource||null;return{...Me,...t,imageSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():Me.getMetadata()),getImage:t.getImage||(n=>r?r.getImage(n):Me.getImage(n)),debounceTime:t.debounceTime??Me.debounceTime}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(t){for(let r of this._listeners)r.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function ua(e){return e instanceof Error&&e.name==="AbortError"}function Wi(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}Dt();var qt={getMetadata:async()=>({width:0,height:0,bandCount:0,dtype:"uint8"}),getRaster:async()=>({data:new Uint8Array(0),width:0,height:0,bandCount:0,dtype:"uint8"}),debounceTime:0,shouldRefetch:()=>!0},Re=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_metadataAbortController=null;_finalized=!1;_sourceGeneration=0;_metadataRequestId=0;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.rasterSource&&(!t.getRaster||!t.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(t,r={}){return new e({...r,rasterSource:t})}static fromCallbacks(t){return new e(t)}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get raster(){return this._currentRequest?.raster||null}get currentRequest(){return this._currentRequest}get rasterSource(){return this._opts.rasterSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.rasterSource,n={...this._opts,...t};t.rasterSource&&t.rasterSource!==r&&(n.getRaster=t.getRaster,n.getMetadata=t.getMetadata);let i=this._normalizeOptions(n),s=r!==i.rasterSource||this._opts.getRaster!==i.getRaster||this._opts.getMetadata!==i.getMetadata;this._opts=i,s&&(this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._sourceGeneration++,this.metadata=null,this._currentRequest=null,this._emitUpdate())}async loadMetadata(t={}){if(this._finalized)throw new Error("RasterSet is finalized");t.signal?.throwIfAborted(),this._metadataAbortController?.abort();let r=new AbortController;this._metadataAbortController=r;let n=()=>r.abort(t.signal?.reason);t.signal?.addEventListener("abort",n,{once:!0});let i=++this._metadataRequestId,s=this._sourceGeneration;try{this._startLoading(),r.signal.throwIfAborted();let o=await Ht(a=>this._opts.getMetadata({signal:a}),[r.signal]);if(r.signal.throwIfAborted(),this._finalized||s!==this._sourceGeneration||i!==this._metadataRequestId)return o;this.metadata=o;for(let a of this._listeners)a.onMetadataLoad?.(o);return this._emitUpdate(),o}catch(o){if(r.signal.aborted)throw r.signal.reason;if($i(o))throw o;let a=Yi(o,"Raster metadata request failed");if(!this._finalized&&s===this._sourceGeneration&&i===this._metadataRequestId)for(let c of this._listeners)c.onMetadataLoadError?.(a);throw a}finally{t.signal?.removeEventListener("abort",n),this._metadataAbortController===r&&(this._metadataAbortController=null),this._finishLoading()}}requestRaster(t,r=this._opts.debounceTime){if(this._finalized)return-1;if(!this.shouldRefetchRaster(t))return this._cancelScheduledRaster(),this._abortActiveRequest(),this._nextRequestId++,this._currentRequest?.requestId??-1;let n=this._nextRequestId++;return this._cancelScheduledRaster(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(n,t)},r):this._loadRaster(n,t),n}shouldRefetchRaster(t){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:t})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._metadataAbortController?.abort(),this._metadataAbortController=null,this._loadCounter=0,this._listeners.clear()}async _loadRaster(t,r){if(this._finalized)return;let n=r.signal;if(n?.aborted)return;let i=new AbortController;this._abortController=i;let s=()=>i.abort(n?.reason);n?.addEventListener("abort",s,{once:!0}),this._startLoading();try{i.signal.throwIfAborted();for(let a of this._listeners)a.onRasterLoadStart?.(t,r);i.signal.throwIfAborted();let o=await Ht(a=>this._opts.getRaster(da(r,a)),[i.signal]);if(this._finalized||i.signal.aborted||t!==this._nextRequestId-1)return;this._currentRequest={requestId:t,parameters:r,raster:o};for(let a of this._listeners)a.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(o){if(i.signal.aborted||$i(o))return;let a=Yi(o,"Raster request failed");if(!this._finalized&&t===this._nextRequestId-1)for(let c of this._listeners)c.onRasterLoadError?.(t,a,r)}finally{n?.removeEventListener("abort",s),this._abortController===i&&(this._abortController=null),this._finishLoading()}}_normalizeOptions(t){let r=t.rasterSource||null;return{...qt,...t,rasterSource:r,getMetadata:t.getMetadata||(n=>r?r.getMetadata(n):qt.getMetadata()),getRaster:t.getRaster||(n=>r?r.getRaster(n):qt.getRaster(n)),debounceTime:t.debounceTime??qt.debounceTime,shouldRefetch:t.shouldRefetch||(n=>qt.shouldRefetch(n))}}_emitUpdate(){if(!this._finalized)for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){if(!this._finalized)for(let r of this._listeners)r.onLoadingStateChange?.(t)}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function da(e,t){let r=Object.getOwnPropertyDescriptors(e);delete r.signal;let n=Array.isArray(e)?Object.defineProperties(e.slice(),r):Object.create(Object.getPrototypeOf(e),r);return Object.defineProperty(n,"signal",{configurable:!0,enumerable:!0,value:t,writable:!0}),n}function Yi(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function $i(e){return e instanceof Error&&e.name==="AbortError"}U();ge();Zt();Dt();var Ee=class{item;previous;next;constructor(t,r,n){this.item=t,this.previous=r,this.next=n}};var ye=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new Ee(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){let n=t.next;t.next=r,this.tail===t?this.tail=r:n.previous=r,r.next=n,r.previous=t,++this._length}};var Ce=class{_list;_sentinel;_trimTiles;constructor(){this._list=new ye,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(t,r))}unloadTile(t,r,n){let i=r._cacheNode;i&&(this._list.remove(i),r._cacheNode=null,n&&n(t,r))}unloadTiles(t,r){let n=this._trimTiles;this._trimTiles=!1;let i=this._list,s=this._sentinel,o=i.head;for(;o!==s&&(t.gpuMemoryUsageInBytes>t.cacheBytes||n);){let a=o.item;o=o.next,this.unloadTile(t,a,r)}}trim(){this._trimTiles=!0}};ge();xe();U();Dt();function ji(e,t){jt(e),jt(t);let{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:i,boundingVolume:{center:s}}=e,o=new q(i);switch(r&&o.translate(r),n){case"Z":break;case"Y":let d=new q().rotateX(Math.PI/2);o=o.multiplyRight(d);break;case"X":let u=new q().rotateY(-Math.PI/2);o=o.multiplyRight(u);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new T(s);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let c=G.WGS84.cartesianToCartographic(a,new T),l=zt(G.WGS84,a).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=c;let f=pa(t);f&&(t.cartesianModelMatrix=new q(o).multiplyRight(f.matrix),t.cartographicModelMatrix.multiplyRight(f.matrix),f.matrix=q.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var ma=1e6**2;function pa(e){let t=e.gltf?.json;if(!t)return null;let r=typeof t.scene=="number"?t.scene:0,i=t.scenes?.[r]?.nodes?.[0],s=i===void 0?void 0:t.nodes?.[i];if(!s?.matrix)return null;let o=s.matrix;return o[12]*o[12]+o[13]*o[13]+o[14]*o[14]<=ma?null:s}U();lr();ge();xe();var Zi=new T,xr=new T,xa=1e-5,ga=1e-7,gr=new ft([new V,new V,new V,new V,new V,new V]);function Hi(e,t,r={}){let{cameraUp:n,height:i}=e,s=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=Ft(e,e.center),c=zt(G.WGS84,a),h=e.unprojectPosition(e.cameraPosition),l=G.WGS84.cartographicToCartesian(h,new T),f;if(s)f=new T(c.transformAsVector(new T(s).scale(o))).normalize();else{let E=e.getFrustumPlanes().near,g=Tr(E,e.cameraPosition),C=Ft(e,g);f=new T(C).subtract(l).normalize()}let d=new T(c.transformAsVector(new T(n).scale(o))).normalize();Ta(e);let u=e.constructor,{longitude:m,latitude:p,width:x,bearing:R,zoom:w,position:_}=e,S=new u({longitude:m,latitude:p,height:i,width:x,bearing:R,zoom:w,position:_,pitch:0}),M=Number.isFinite(e.fovy)&&Number(e.fovy)>0&&Number(e.fovy)<180?Number(e.fovy)*Math.PI/180:Math.PI/3;return{camera:{position:l,direction:f,up:d,cartographicPosition:h,verticalFieldOfView:M,timeSinceMovement:r.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:e,topDownViewport:S,height:i,cullingVolume:gr,clippingPlanes:e.clippingPlanes,frameNumber:t,sseDenominator:2*Math.tan(M/2),dynamicScreenSpaceErrorDensity:0}}function Ki(e,t,r,n){let i=Array.from(t),s=Array.from(r),o=e?i.length!==e.position.length||i.some((h,l)=>Math.abs(h-e.position[l])>xa):!1,a=e?s.length!==e.direction.length||s.some((h,l)=>Math.abs(h-e.direction[l])>ga):!1,c=o||a?n:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:i,direction:s,lastMovementTime:c},timeSinceMovement:Math.max((n-c)/1e3,0)}}function Xi(e,t,r){if(r===0||e.length<=r)return[e,[]];let n=[],{longitude:i,latitude:s}=t.viewport;for(let[h,l]of e.entries()){let[f,d]=l.header.mbs,u=Math.abs(i-f),m=Math.abs(s-d),p=Math.sqrt(m*m+u*u);n.push([h,p])}let o=n.sort((h,l)=>h[1]-l[1]),a=[];for(let h=0;h<r;h++)a.push(e[o[h][0]]);let c=[];for(let h=r;h<o.length;h++)c.push(e[o[h][0]]);return[a,c]}function Ta(e){let t=e.getFrustumPlanes(),r=Tr(t.near,e.cameraPosition),n=Ft(e,r),i=Ft(e,e.cameraPosition,xr),s=0;gr.planes[s++].fromPointNormal(n,Zi.copy(n).subtract(i));for(let o in t){if(o==="near")continue;let a=t[o],c=Tr(a,r,xr),h=Ft(e,c,xr);gr.planes[s++].fromPointNormal(h,Zi.copy(n).subtract(h))}}function Tr(e,t,r=new T){let n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function Ft(e,t,r=new T){let n=e.unprojectPosition(t);return G.WGS84.cartographicToCartesian(n,r)}U();var rs=new T,Sa=new T,gt=new T,Ji=new T,kt=new T,Qi=new T,ts=new T,es=new T,we=new Pt,Ma=new T(0,0,1);function ns(e,t){e._updateTransform(t)}function is(e,t,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let n=_a(e),i=n.region?Ra(n.region,t):Ea(e,n,t);if(!i)return 0;let s=It(r.dynamicScreenSpaceErrorHeightFalloff,0,1),o=i.minimumHeight+(i.maximumHeight-i.minimumHeight)*s,a=i.maximumHeight-o,c=a>0?It((i.cameraHeight-o)/a,0,1):i.cameraHeight>=i.maximumHeight?1:0,l=(1-It(Math.abs(i.cameraDirection.dot(i.upDirection)),0,1))*(1-c);return r.dynamicScreenSpaceErrorDensity*l}function _a(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function Ra(e,t){let r=rs.copy(t.camera.position).normalize(),n=kt.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:n,upDirection:r}}function Ea(e,t,r){let n=ya(t,gt);if(n===null)return null;let i=new q(e.computedTransform).invert(),s=e.tileset.ellipsoid;if(Math.hypot(gt[0],gt[1],gt[2])>s.minimumRadius){let a=s.cartesianToCartographic(gt,Sa),c=rs.copy(r.camera.position).normalize(),h=kt.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:h,upDirection:c}}return i.transformAsPoint(r.camera.position,Ji),i.transformAsVector(r.camera.direction,kt),kt.normalize(),{cameraHeight:Ji[2],minimumHeight:gt[2]-n,maximumHeight:gt[2]+n,cameraDirection:kt,upDirection:Ma}}function ya(e,t){if(e.box){let r=e.box;return t.set(r[0],r[1],r[2]),Ca(r)}if(e.sphere){let r=e.sphere;return t.set(r[0],r[1],r[2]),r[3]}return null}function Ca(e){return e.length===10?(we.fromArray(e,6),Qi.set(e[3],0,0).transformByQuaternion(we),ts.set(0,e[4],0).transformByQuaternion(we),es.set(0,0,e[5]).transformByQuaternion(we),Math.abs(Qi[2])+Math.abs(ts[2])+Math.abs(es[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}U();lr();var Sr;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(Sr||(Sr={}));var Ut;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Ut||(Ut={}));var it;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(it||(it={}));var Bt;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Bt||(Bt={}));var Fl=new vt,kl=new T,Ul=new T,Bl=new T,Gl=new T;function ss(e,t,r){return e+(t-e)*r}Be();Be();var os="EPSG:4326",as="EPSG:4978";function cs(e){let t=e.trim().toUpperCase(),r=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:t}function Oe(e){if(typeof e=="string"){let r=pt(e);return r==="wkt"?Oa(e):r==="proj-string"?Aa(e):wa(e)||"projected"}let t=e;return t.type==="BoundCRS"&&t.source_crs?Oe(t.source_crs):t.type==="CompoundCRS"&&t.components?.[0]?Oe(t.components[0]):String(t.type).includes("Projected")?"projected":String(t.type).includes("Geographic")?"geographic":String(t.type).includes("Geodetic")?t.coordinate_system?.subtype==="Cartesian"?"geocentric":"geographic":"unknown"}function wa(e){if(typeof e!="string")return;let t=cs(e);if(t===as)return"geocentric";if(t===os||t==="OGC:CRS84")return"geographic";let r=/^EPSG:(\d+)$/.exec(t);if(!r)return;let n=Number(r[1]);if(n===7789)return"geocentric";if(n===4490||n===4979)return"geographic";if(n===3857||n>=32601&&n<=32660||n>=32701&&n<=32760)return"projected"}function Oa(e){let t;try{t=ke(e).root}catch{return"unknown"}switch(t.keyword.toUpperCase()){case"GEOCCS":return"geocentric";case"GEOGCS":case"GEOGCRS":case"GEOGRAPHICCRS":case"GEOGRAPHIC2DCRS":case"GEOGRAPHIC3DCRS":return"geographic";case"PROJCS":case"PROJCRS":case"PROJECTEDCRS":return"projected";case"GEODCRS":case"GEODETICCRS":{let n=t.values.find(i=>i.type==="node"&&i.keyword.toUpperCase()==="CS")?.values[0];return n?.type!=="enumeration"&&n?.type!=="string"?"unknown":n.value.toUpperCase()==="CARTESIAN"?"geocentric":n.value.toUpperCase()==="ELLIPSOIDAL"?"geographic":"unknown"}default:return"unknown"}}function Aa(e){try{let t=Ue(e).parameters.find(r=>r.name.toLowerCase()==="proj")?.value;switch(t?.toLowerCase()){case"longlat":case"latlong":return"geographic";case"geocent":return"geocentric";default:return t?"projected":"unknown"}}catch{return"unknown"}}function _r(e,t={}){let r=t.sourceCrs!==void 0,n=t.sourceCrs||e.sourceCrs,i=t.outputCoordinates||"auto",s=t.targetCrs||(i==="ecef"?"EPSG:4978":void 0),o=t.targetHeightReference||"native",a=e.verticalUnitScale??1,c=e.elevationUnitScale??1,h=e.elevationOffset||0,l=e.elevationMode==="onTheGround"||e.elevationMode==="relativeToGround"||e.elevationMode==="relativeToScene",f=e.elevationMode==="relativeToScene"?!!t.sceneElevationProvider:!l||!!t.terrainElevationProvider,d=a!==1||c!==1||e.elevationMode!==void 0&&(l||e.elevationMode==="absoluteHeight"&&h!==0),u=o!=="native"&&o!==e.heightReference,m=!!s||o!=="native"||i!=="auto"||d,p=i!=="target-crs"||!!s,x=!u||(e.heightReference||"unknown")!=="unknown",R=Number.isFinite(a)&&a>0&&Number.isFinite(c)&&c>0,w=!!n&&m&&p&&x&&R&&f&&i!=="local-enu",_=r?"caller-override":e.provenance||"unknown",S=r&&n?Oe(n):e.coordinateFrame,M=r?"explicit":e.sourceCrsState||(n?_==="format-default"?"default":"explicit":"absent"),E=Kt({crs:n?{state:M==="default"?"default":"explicit",definition:n,representation:!r&&e.sourceCrsRepresentation||pt(n),provenance:_,alternatives:r?void 0:e.sourceCrsAlternatives}:{state:M==="unknown"?"unknown":"absent",provenance:_},vertical:e.verticalCrs?{state:"explicit",definition:e.verticalCrs,representation:pt(e.verticalCrs),provenance:e.provenance||"metadata"}:void 0,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,coordinateFrame:S,coordinateOrder:Ia(e.axisOrder),units:r?void 0:e.units}),g=Mr(E.crs),C=E.vertical?Mr(E.vertical):void 0,N=s?ba(s):void 0;return Object.freeze({...E,sourceCrs:g,verticalCrs:C,verticalUnitScale:a,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,heightReference:e.heightReference||"unknown",elevationMode:e.elevationMode,elevationOffset:e.elevationOffset,elevationUnit:e.elevationUnit,elevationUnitScale:c,coordinateFrame:S||"unknown",axisOrder:e.axisOrder||"unknown",provenance:_,targetCrs:N,targetHeightReference:o,outputCoordinates:i,status:m?w?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function Rr(e,t={}){return _r({sourceCrs:e?.sourceCrs,sourceCrsState:e?.crs.state,sourceCrsRepresentation:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.representation:void 0,sourceCrsAlternatives:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.alternatives:void 0,verticalCrs:e?.verticalCrs,units:e?.units,verticalUnitScale:e?.verticalUnitScale,coordinateEpoch:e?.coordinateEpoch,heightReference:e?.heightReference,elevationMode:e?.elevationMode,elevationOffset:e?.elevationOffset,elevationUnit:e?.elevationUnit,elevationUnitScale:e?.elevationUnitScale,coordinateFrame:e?.coordinateFrame,axisOrder:e?.axisOrder,provenance:e?.provenance,warnings:e?.warnings},t)}function Mr(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function ba(e){let t=Kt({crs:{state:"explicit",definition:e,representation:pt(e),provenance:"caller-override"}}),r=Mr(t.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function Ia(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function hs(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var be=1024*1024,Ss=512*be,Ms=512*be,Na=32*be,Pa=be;function Ae(e,t){if(!Number.isFinite(e)||e<0)throw new Error(`${t} must be a finite number greater than or equal to 0`);return e}function ls(e,t){let r=e.cacheBytes??t;return Ae(r,"cacheBytes")}function fs(e,t){let r=e.maximumCacheOverflowBytes??t;return Ae(r,"maximumCacheOverflowBytes")}var Er={description:"",ellipsoid:G.WGS84,modelMatrix:new q,throttleRequests:!0,maxRequests:64,cacheBytes:Ss,maximumCacheOverflowBytes:Ms,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:ss,foveatedTimeDelay:.2,maximumScreenSpaceError:8,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{},spatial:{}},yr="Tiles In Tileset(s)",Cr="Tiles In Memory",us="Tiles In View",ds="Tiles To Render",ms="Tiles Loaded",wr="Tiles Loading",ps="Tiles Unloaded",xs="Failed Tile Loads",gs="Points/Vertices",Or="Tile Memory Use",Ts="Maximum Screen Space Error",Gt=class{options;loadOptions;source;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};schema=null;schemaUri=null;groups=[];metadata=null;statistics=null;spatialReference=_r({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=Ss;_maximumCacheOverflowBytes=Ms;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new Ce;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,r){if(!hs(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let n=r||{},i=t.type===it.TILES3D,s=i?Er.cacheBytes:Na,o=i?Er.maximumCacheOverflowBytes:Pa,a=ls(n,s),c=fs(n,o);this.options={...Er,...n,cacheBytes:a,maximumCacheOverflowBytes:c,skipLevelOfDetail:n.skipLevelOfDetail??t.type===it.TILES3D,memoryAdjustedScreenSpaceError:n.memoryAdjustedScreenSpaceError??i},this.loadOptions=this.options.loadOptions||{},this.source=t,this.tileset=null,this.loader=this.source.loader,this.type=this.source.type,this.url=this.source.url,this.basePath=this.source.basePath,this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType="",this.lodMetricValue=0,this.refine="",this.contentFormats=this.source.contentFormats,this._traverser=this._initializeTraverser(),this._requestScheduler=new Q({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=c;let h=this._getSourceMetadata();h&&(this.spatialReference=Rr(h.spatialReference,this.options.spatial)),this.stats=new j({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet()}destroy(){this._clearDeferredTraversal(),this.source.destroy?.(),this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get requestedTiles(){return this._requestedTiles.slice()}get emptyTiles(){return this._emptyTiles.slice()}get cacheBytes(){return this._cacheBytes}set cacheBytes(t){this._cacheBytes=Ae(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=Ae(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes}get queryParams(){let t=this.source.getTileUrl(this.url),r=t.indexOf("?");return r>=0?t.slice(r+1):""}setProps(t){let r=ls(t,this.cacheBytes),n=fs(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:r,maximumCacheOverflowBytes:n},this._cacheBytes=r,this._maximumCacheOverflowBytes=n}getTileUrl(t){return this.source.getTileUrl(t)}hasExtension(t){return!!this.source.hasExtension?.(t)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=t instanceof Array?t:[t],n=new Set(r.map(a=>a.id));for(let a of Object.keys(this.frameStateData))n.has(a)||delete this.frameStateData[a];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let i=Date.now(),s=Number.POSITIVE_INFINITY,o=[];for(let a of r){let c=a.id;this._needTraverse(c)?o.push(c):this.traverseCounter--}for(let a of r){let c=a.id;if(this.roots[c]||(this.roots[c]=this._initializeTileHeaders(this.tileset,null)),!o.includes(c))continue;let h=Hi(a,this._frameNumber),l=this.roots[c],f=Ki(this._cameraMotionStates[c],h.camera.position,h.camera.direction,i);this._cameraMotionStates[c]=f.state,h.camera.timeSinceMovement=f.timeSinceMovement,ns(l,this.modelMatrix),h.dynamicScreenSpaceErrorDensity=this.type===it.TILES3D&&this.options.dynamicScreenSpaceError&&!h.viewport.orthographic?is(l,h,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=h.dynamicScreenSpaceErrorDensity,this._traverser.traverse(l,h,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(s=Math.min(s,Math.max(this.options.foveatedTimeDelay-f.timeSinceMovement,0)))}Number.isFinite(s)?this._scheduleDeferredTraversal(s):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let n=r instanceof Error?r:new Error(String(r));this._onTilesetError(n)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){let r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],i=Object.values(this._traverser.selectedTiles),[s,o]=Xi(i,t,this.options.maximumTilesSelected);n.selectedTiles=s;for(let a of o)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let t=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let s in this.frameStateData){let o=this.frameStateData[s];this.selectedTiles=this.selectedTiles.concat(o.selectedTiles),this._requestedTiles=this._requestedTiles.concat(o._requestedTiles),this._emptyTiles=this._emptyTiles.concat(o._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles),n=this.selectedTiles.some(s=>!s.tileDrawn),i=0;if(n){let s=new Set(Object.keys(this.frameStateData).map(a=>this.roots[a])),o=new Map;for(let a of this.selectedTiles)for(let c=a.parent;c;c=c.parent)o.set(c,(o.get(c)??!0)&&a.tileDrawn);for(let a of t)a.tileDrawn&&this._heldTiles.add(a);for(let a of this._heldTiles){let c=a;for(;c.parent;)c=c.parent;if(!s.has(c)){this._heldTiles.delete(a);continue}r.has(a)||(a.contentAvailable&&!this._hasDrawnReplacement(a,r,o)?(a._selectedFrame=this._frameNumber,this.selectedTiles.push(a),i++):this._heldTiles.delete(a))}}else this._heldTiles=r;i>0&&setTimeout(()=>{this.selectTiles()},0);for(let s of this.selectedTiles)this._tiles[s.id]=s;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(t,this.selectedTiles)&&this.options.onUpdate()}_hasDrawnReplacement(t,r,n){for(let i=t.parent;i;i=i.parent)if(r.has(i))return i.tileDrawn;return n.get(t)===!0}_tilesChanged(t,r){if(t.length!==r.length)return!0;let n=new Set(t.map(o=>o.id)),i=new Set(r.map(o=>o.id)),s=t.some(o=>!i.has(o.id));return s=s||r.some(o=>!n.has(o.id)),s}_loadTiles(){this._requestedTiles.sort((t,r)=>t._priority-r._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,r=0;for(let n of this.selectedTiles)if(n.contentAvailable&&n.content){t++;let i=n.contents.length?n.contents:[n.content];for(let s of i)s.pointCount?r+=s.pointCount:r+=s.vertexCount||0}this.stats.get(us).count=this.selectedTiles.length,this.stats.get(ds).count=t,this.stats.get(gs).count=r,this.stats.get(Ts).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),r=this._getSourceMetadata();r&&this._syncSourceState(r),r?.tileset?.root&&typeof r.tileset.root.then!="function"&&(!this.source.prepareTileset||this.spatialReference?.status==="native")&&(this.root=this._initializeTileHeaders(r.tileset,null),this._applyViewState()),await t;let n=this.source.getMetadata();this._syncSourceState(n),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(n.tileset,null)),this._applyViewState()}catch(t){let r=t instanceof Error?t:new Error(String(t));throw this._onSourceError(r,this.root),this._onTilesetError(r),r}}_initializeStats(){this.stats.get(yr),this.stats.get(wr),this.stats.get(Cr),this.stats.get(us),this.stats.get(ds),this.stats.get(ms),this.stats.get(ps),this.stats.get(xs),this.stats.get(gs),this.stats.get(Or,"memory"),this.stats.get(Ts)}_initializeTileHeaders(t,r){return this.source.initializeTileHeaders(this,t,r)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r=null;try{this._onStartTileLoading(),r=await t.loadContent()}catch(n){let i=n instanceof Error?n:new Error("load failed");this._onSourceError(i,t),this._onTileLoadError(t,i)}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}async _loadTileChildren(t,r){try{this._onStartTileLoading(),await t.loadChildren(r)}catch(n){let i=n instanceof Error?n:new Error("subtree load failed");this._onSourceError(i,t),this._onTileLoadError(t,i)}finally{this._onEndTileLoading()}}_onTileLoadError(t,r){this.stats.get(xs).incrementCount();let n=r.message||r.toString(),i=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,i)}_onSourceError(t,r=null){this.options.onSourceError(t,this.source,r)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,r){if(!r?.loaded)return;t.content&&ji(t,t.content),this.source.onTileLoaded?.(this,t,r),this._syncSourceState(this.source.getMetadata());let n=this.source.getTilesTotalCount?.();n&&(this.stats.get(yr).reset(),this.stats.get(yr).addCount(n)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(wr).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(wr).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(ms).incrementCount(),this.stats.get(Cr).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Or).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(Cr).decrementCount(),this.stats.get(ps).incrementCount(),this.stats.get(Or).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let r=t.pop();for(let n of r.children)t.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,n=[r];for(;n.length>0;){t=n.pop();for(let i of t.children)n.push(i);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_syncSourceState(t){this.tileset=t.tileset,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let r=t.tileset;this.schema=r.schema||null,this.schemaUri=r.schemaUri||null,this.groups=r.groups||[],this.metadata=r.metadata||null,this.statistics=r.statistics??null;let n=Rr(t.spatialReference,this.options.spatial);this.spatialReference=La(this.spatialReference,n),this.properties=this.source.properties??this.properties,this.extras=this.source.extras??this.extras,this.options.attributions?.length?this.credits={attributions:this.options.attributions}:this.credits=this.source.credits||this.credits}_applyViewState(){let t=this.source.getViewState(this.root);this.asset=t.asset||this.source.asset||{},this.properties=t.properties??this.source.properties,this.extras=t.extras??this.source.extras??null,this.credits=t.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=t.description||this.options.description||"",this.boundingVolume=t.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=t.cartographicCenter||new T,this.cartesianCenter=t.cartesianCenter||null,this.zoom=t.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};function La(e,t){return e?.status==="transformed"&&e.sourceCrs===t.sourceCrs&&e.targetCrs===t.targetCrs&&e.targetHeightReference===t.targetHeightReference&&e.outputCoordinates===t.outputCoordinates?e:t}Bi();function _s(e,t,r={}){let n=e.tileMatrixSet;if(!n||!n.crs||t.crs!==n.crs)throw new Error("Tile selection requires complete geometry and a frame in the exact grid CRS.");if(t.extent.length!==4||!t.extent.every(Number.isFinite)||t.extent[0]>t.extent[2]||t.extent[1]>t.extent[3])throw new RangeError("Tile frame extent must be finite and ordered.");let i=r.maximumTileCount??4096;if(!Number.isSafeInteger(i)||i<0)throw new RangeError("maximumTileCount must be a nonnegative safe integer.");for(let d of n.matrices){let u=d.variableMatrixWidths;if(u!==void 0&&(!Array.isArray(u)||u.length>0))throw new Error("Regular-grid selection does not support variable-width rows.")}let s=Ui(n,t.resolution),o=new Map;for(let d of e.limits??[]){let u=n.matrices.find(m=>m.id===d.tileMatrix);if(!u||o.has(d.tileMatrix))throw new RangeError("Tile coverage must reference unique, known matrix ids.");pr(u,d.minTileColumn,d.minTileRow,d),o.set(d.tileMatrix,d)}if(!s||e.limits!==void 0&&!o.has(s.id))return[];let a=ki(s,t.extent,o.get(s.id));if(!a)return[];let c=a.maxTileColumn-a.minTileColumn+1,h=a.maxTileRow-a.minTileRow+1;if(c>i/h)throw new RangeError("Tile selection exceeds maximumTileCount.");let l=n.matrices.indexOf(s),f=[];for(let d=a.minTileRow;d<=a.maxTileRow;d++)for(let u=a.minTileColumn;u<=a.maxTileColumn;u++){let[m,p,x,R]=qi(s,u,d);f.push({index:{x:u,y:d,z:l},tileMatrix:s.id,id:JSON.stringify([n.crs,s.id,u,d]),bbox:{left:m,bottom:p,right:x,top:R},crs:n.crs,tileSize:[s.tileSize[0],s.tileSize[1]]})}return f}return bs(Vt);})();
|
|
10
10
|
return __exports__;
|
|
11
11
|
});
|