@mapvx/web-kit 1.2.0-develop.13 → 1.2.0-develop.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/cjs/chunks/{DRACOLoader-gEI4jG0V.cjs → DRACOLoader-B1Y7vbrj.cjs} +2 -2
- package/dist/cjs/chunks/{GLTFLoader-Cd9ix-wY.cjs → GLTFLoader-DrrfQ0_F.cjs} +2 -2
- package/dist/cjs/chunks/{KTX2Loader-Dk2GlCFI.cjs → KTX2Loader-BoLi8knA.cjs} +2 -2
- package/dist/cjs/chunks/{accessibility-C9U1mv_p.cjs → accessibility-Djzp33ox.cjs} +2 -2
- package/dist/cjs/chunks/{back_arrow-tpfWrGJ9.cjs → back_arrow-BPoJQerl.cjs} +2 -2
- package/dist/cjs/chunks/{debug-hooks-xLx1YP8n.cjs → debug-hooks-CMF1BR-2.cjs} +2 -2
- package/dist/cjs/chunks/{dist-ENDZf7Zh.cjs → dist-B06OgE5W.cjs} +2 -2
- package/dist/cjs/chunks/{dist-1oZjernx.cjs → dist-DII2Jcfe.cjs} +2 -2
- package/dist/cjs/chunks/{dist-CYGLkXos.cjs → dist-_3MDeFq6.cjs} +2 -2
- package/dist/cjs/chunks/{expression-q70ZQCYv.cjs → expression-Dq2zVyIz.cjs} +2 -2
- package/dist/cjs/chunks/{globe-viewport-CIe_h8dV.cjs → globe-viewport-s9VMxxMl.cjs} +2 -2
- package/dist/cjs/chunks/{icon-origin-point-D_DBb1gM.cjs → icon-origin-point-B07J_RrC.cjs} +2 -2
- package/dist/cjs/chunks/{meshopt_decoder.module-B5j8Tze_.cjs → meshopt_decoder.module-CedN2Fs4.cjs} +2 -2
- package/dist/cjs/chunks/{repeat_icon-F6Q7hnPl.cjs → repeat_icon-BwwtBUqw.cjs} +2 -2
- package/dist/cjs/chunks/{rolldown-runtime-BOxlEPsq.cjs → rolldown-runtime-S4XI6pHy.cjs} +2 -2
- package/dist/cjs/chunks/{shader-type-decoder-B16cQ7H3.cjs → shader-type-decoder-CplMa6Zn.cjs} +2 -2
- package/dist/cjs/chunks/{styles-zP5lXn9p.cjs → styles-eVk3as0O.cjs} +2 -2
- package/dist/cjs/chunks/{three.module-BHURJnCD.cjs → three.module-TyjyfRuV.cjs} +2 -2
- package/dist/cjs/chunks/{walking-CMpmZTw3.cjs → walking-BXmnNjav.cjs} +2 -2
- package/dist/cjs/chunks/{webgl-CJbVWdD9.cjs → webgl-C3A9O7UB.cjs} +2 -2
- package/dist/cjs/chunks/{webgl-device-D7wKHxQy.cjs → webgl-device-CR_IOS1K.cjs} +2 -2
- package/dist/cjs/web-kit.cjs +5 -5
- package/dist/es/chunks/{DRACOLoader-r8VXQ8hj.js → DRACOLoader-D0vU8-Oo.js} +2 -2
- package/dist/es/chunks/{GLTFLoader-IbJ3eCNr.js → GLTFLoader-DQ80Aq6X.js} +2 -2
- package/dist/es/chunks/{KTX2Loader-DZlQyAGv.js → KTX2Loader-Dh9k32r5.js} +2 -2
- package/dist/es/chunks/{accessibility-BldDqm74.js → accessibility-BG8JCwcH.js} +2 -2
- package/dist/es/chunks/{back_arrow-BeeCYF4P.js → back_arrow-CF2VEGV0.js} +2 -2
- package/dist/es/chunks/{debug-hooks-NzJ2oy3C.js → debug-hooks-D_XQuFlb.js} +2 -2
- package/dist/es/chunks/{dist-B3-nPsaF.js → dist-B7VX6I_c.js} +2 -2
- package/dist/es/chunks/{dist-DOcsJa1u.js → dist-CQzG76mh.js} +2 -2
- package/dist/es/chunks/{dist-DNNWa2bQ.js → dist-CcWEArpE.js} +2 -2
- package/dist/es/chunks/{expression-Dpos4VqC.js → expression-C7yC7-03.js} +2 -2
- package/dist/es/chunks/{globe-viewport-BmqhgdhG.js → globe-viewport-D0Ev9_5m.js} +2 -2
- package/dist/es/chunks/{icon-origin-point-CkHTMtFu.js → icon-origin-point-C23InZ8B.js} +2 -2
- package/dist/es/chunks/{meshopt_decoder.module-YGVnWwV0.js → meshopt_decoder.module-CrrPmGGq.js} +2 -2
- package/dist/es/chunks/{repeat_icon-B_t3ecTa.js → repeat_icon-BIa50JSA.js} +2 -2
- package/dist/es/chunks/{rolldown-runtime-BSTMnvUK.js → rolldown-runtime-CDBfnOLQ.js} +2 -2
- package/dist/es/chunks/{shader-type-decoder-CFX5sij5.js → shader-type-decoder-CmsRL_mF.js} +2 -2
- package/dist/es/chunks/{styles-DTTMB3rI.js → styles-CU6-Ggto.js} +2 -2
- package/dist/es/chunks/{three.module-Cj5xe6gn.js → three.module-Df6wkceO.js} +2 -2
- package/dist/es/chunks/{walking--SMEsH_B.js → walking-BY9QNI9o.js} +2 -2
- package/dist/es/chunks/{webgl-device-KnEQ5CNv.js → webgl-device-CjfmtXLr.js} +2 -2
- package/dist/es/chunks/{webgl-ZcaUll7k.js → webgl-y_Wz0lFW.js} +2 -2
- package/dist/es/web-kit.mjs +5 -5
- package/dist/iife/web-kit.iife.js +3 -3
- package/dist/sw/mvx-tiles-sw.js +4 -19
- package/dist/types/index.d.ts +19 -19
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Web-kit v1.2.0-develop.
|
|
2
|
-
!function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f744d0d4-88f0-4731-bc5a-2bebba928117",e._sentryDebugIdIdentifier="sentry-dbid-f744d0d4-88f0-4731-bc5a-2bebba928117")}catch(e){}}();import{a as e,d as t,f as n,i as r,m as i,p as o,r as s,u as a}from"./shader-type-decoder-CFX5sij5.js";function c(e,t){if(!e)throw new Error(t||"loader assertion failed.")}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof global&&global,"undefined"!=typeof document&&document;var l=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),u="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),h=(u&&parseFloat(u[1]),"4.5.4"[0]>="0"&&"4.5.4"[0]<="9"?"v4.5.4":"");var d=function(){const e=new i({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=h,globalThis.probe||={},globalThis.probe.loaders=e,e}(),f=e=>"function"==typeof e,p=e=>null!==e&&"object"==typeof e,m=e=>p(e)&&e.constructor==={}.constructor,g=e=>"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer,b=e=>p(e)&&"number"==typeof e.byteLength&&"function"==typeof e.slice,_=e=>"undefined"!=typeof Response&&e instanceof Response||p(e)&&f(e.arrayBuffer)&&f(e.text)&&f(e.json),y=e=>"undefined"!=typeof Blob&&e instanceof Blob,v=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||p(e)&&f(e.tee)&&f(e.cancel)&&f(e.getReader))(e)||(e=>p(e)&&f(e.read)&&f(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);function w(e,t){return E(e||{},t)}function E(e,t,n=0){if(n>3)return t;const r={...e};for(const[i,o]of Object.entries(t))o&&"object"==typeof o&&!Array.isArray(o)?r[i]=E(r[i]||{},t[i],n+1):r[i]=t[i];return r}var x=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version);function T(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof global&&global,"undefined"!=typeof document&&document;var M="object"!=typeof process||"[object process]"!==String(process)||process.browser,S="function"==typeof importScripts,P="undefined"!=typeof window&&void 0!==window.orientation,O="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),A=(O&&parseFloat(O[1]),class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){T(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){T(this.isRunning),this.isRunning=!1,this._reject(e)}}),j=class{terminate(){}},L=/* @__PURE__ */new Map;function I(e){T(e.source&&!e.url||!e.source&&e.url);let t=L.get(e.source||e.url);var n;return t||(e.url&&(t=(n=e.url).startsWith("http")?C(`try {\n importScripts('${n}');\n} catch (error) {\n console.error(error);\n throw error;\n}`):n,L.set(e.url,t)),e.source&&(t=C(e.source),L.set(e.source,t))),T(t),t}function C(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function R(e,t=!0,n){const r=n||/* @__PURE__ */new Set;if(e){if($(e))r.add(e);else if($(e.buffer))r.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)R(e[i],t,r)}else;return void 0===n?Array.from(r):[]}function $(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var k=()=>{},N=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&M||void 0!==j&&!M}constructor(e){const{name:t,source:n,url:r}=e;T(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=k,this.onError=e=>console.log(e),this.worker=M?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=k,this.onError=k,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||R(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=I({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(/* @__PURE__ */new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new j(t,{eval:!1,type:n})}else{if(!this.source)throw new Error("no worker");e=new j(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}},z=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return N.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){const r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const r=new A(t.name,e);e.onMessage=e=>t.onMessage(r,e.type,e.payload),e.onError=e=>t.onError(r,e),t.onStart(r);try{await r.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!M||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new N({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return P?this.maxMobileConcurrency:this.maxConcurrency}},D={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},U=class e{props;workerPools=/* @__PURE__ */new Map;static _workerFarm;static isSupported(){return N.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}constructor(e){this.props={...D},this.setProps(e),this.workerPools=/* @__PURE__ */new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=/* @__PURE__ */new Map}setProps(e){this.props={...this.props,...e};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:n,url:r}=e;let i=this.workerPools.get(t);return i||(i=new z({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};async function W(e,t,n,r,i){const o=e.id,s=function(e,t={}){const n=t[e.id]||{},r=M?e.workerFile||`${e.id}-worker.js`:`${e.id}-worker-node.js`;let i=n.workerUrl;if(i||"compression"!==e.id||(i=t.workerUrl),"test"===(t._workerType||t?.core?._workerType)&&(i=M?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;"latest"===t&&(t="latest");const n=t?`@${t}`:"";i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return T(i),i}(e,n),a=U.getWorkerFarm(n?.core).getWorkerPool({name:o,url:s});(n=JSON.parse(JSON.stringify(n||{})))._workerLoaderId=e.id,r=JSON.parse(JSON.stringify(r||{}));const c=await a.startJob("process-on-worker",F.bind(null,i));return c.postMessage("process",{input:t,options:n,context:r}),await(await c.result).result}async function F(e,t,n,r){switch(n){case"done":t.done(r);break;case"error":t.error(new Error(r.error));break;case"process":const{id:o,input:s,options:a}=r;try{const n=await e(s,a);t.postMessage("done",{id:o,result:n})}catch(i){const e=i instanceof Error?i.message:"unknown error";t.postMessage("error",{id:o,error:e})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}function B(...e){return function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n);let i=0;for(const o of t)r.set(o,i),i+=o.byteLength;return r.buffer}(e)}function G(e,t,n){const r=void 0!==n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function V(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const{buffer:t,byteOffset:n,byteLength:r}=e;return Y(t,n,r)}return Y(e)}function Y(e,t=0,n=e.byteLength-t){const r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function X(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}var q=class{constructor(e,t){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=e,this.type=t,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(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=X(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(X()-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)}},H=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:n}=e;let r=this.stats[t];return r||(r=e instanceof q?e:new q(t,n),this.stats[t]=r),r}},Z={};function K(e){for(const t in Z)if(e.startsWith(t)){const n=Z[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}function J(e){return e&&"object"==typeof e&&e.isBuffer}function Q(e){if(J(e))return e;if(e instanceof ArrayBuffer)return e;if(g(e))return te(e);if(ArrayBuffer.isView(e)){const t=e.buffer;return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function ee(e){if(e instanceof ArrayBuffer)return e;if(g(e))return te(e);const{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&0===n&&r===t.byteLength?t:te(t,n,r)}function te(e,t=0,n=e.byteLength-t){const r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function ne(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function re(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function ie(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function oe(...e){const t=[];for(let o=0;o<e.length;o++)t[o]=e[o];let n,r="",i=!1;for(let o=t.length-1;o>=-1&&!i;o--){let e;o>=0?e=t[o]:(void 0===n&&(n=ne()),e=n),0!==e.length&&(r=`${e}/${r}`,i=e.charCodeAt(0)===se)}return r=function(e,t){let n,r="",i=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===se)break;n=se}if(n===se){if(i===a-1||1===o);else if(i!==a-1&&2===o){if(r.length<2||!s||r.charCodeAt(r.length-1)!==ae||r.charCodeAt(r.length-2)!==ae)if(r.length>2){const e=r.length-1;let t=e;for(;t>=0&&r.charCodeAt(t)!==se;--t);if(t!==e){r=-1===t?"":r.slice(0,t),i=a,o=0,s=!1;continue}}else if(2===r.length||1===r.length){r="",i=a,o=0,s=!1;continue}t&&(r.length>0?r+="/..":r="..",s=!0)}else{const t=e.slice(i+1,a);r.length>0?r+=`/${t}`:r=t,s=!1}i=a,o=0}else n===ae&&-1!==o?++o:o=-1}return r}(r,!i),i?`/${r}`:r.length>0?r:"."}var se=47,ae=46;var ce=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response},le=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ue=/^([-\w.]+\/[-\w.+]+)/;function he(e,t){return e.toLowerCase()===t.toLowerCase()}function de(e){const t=le.exec(e);return t?t[1]:""}var fe=/\?.*/;function pe(e){return e.replace(fe,"")}function me(e){return _(e)?e.url:y(e)?("name"in e?e.name:"")||"":"string"==typeof e?e:""}function ge(e){if(_(e)){const t=e.headers.get("content-type")||"",n=pe(e.url);return function(e){const t=ue.exec(e);return t?t[1]:e}(t)||de(n)}return y(e)?e.type||"":"string"==typeof e?de(e):""}async function be(e){if(_(e))return e;const t={},n=function(e){return _(e)?e.headers["content-length"]||-1:y(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);n>=0&&(t["content-length"]=String(n));const r=me(e),i=ge(e);i&&(t["content-type"]=i);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${function(e){let t="";const n=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)t+=String.fromCharCode(n[r]);return btoa(t)}(e.slice(0,t))}`:null}(e);o&&(t["x-first-bytes"]=o),"string"==typeof e&&(e=(new TextEncoder).encode(e));const s=new Response(e,{headers:t});return Object.defineProperty(s,"url",{value:r}),s}async function _e(e){if(!e.ok)throw await async function(e){const t=function(e){if(e.length<50)return e;const t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}(e.url);let n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;const r={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");r.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(i){}return new ce(n,r)}(e)}async function ye(e,t){if("string"==typeof e){const n=K(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await be(e)}var ve=new i({id:"loaders.gl"}),we=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Ee={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:l,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},xe={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"},Te=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Me(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function Se(){const e=Me();return e.globalOptions=e.globalOptions||{...Ee,core:{...Ee.core}},Oe(e.globalOptions)}function Pe(e,t,n,r){return n=n||[],function(e,t){Ae(e,null,Ee,xe,t);for(const n of t){const r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},o=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};Ae(r,n.id,i,o,t)}}(e,n=Array.isArray(n)?n:[n]),Oe(function(e,t,n){const r=e.options||{},i={...r};r.core&&(i.core={...r.core});Ie(i),null===i.core?.log&&(i.core={...i.core,log:new we});return Le(i,Oe(Se())),Le(i,Oe(t)),function(e,t){if(!t)return;void 0===e.core?.baseUrl&&(e.core||={},e.core.baseUrl=ie(pe(t)))}(i,n),function(e){const t=e.core;if(!t)return;for(const n of Te)void 0!==t[n]&&(e[n]=t[n])}(i),i}(t,e,r))}function Oe(e){const t=function(e){const t={...e};e.core&&(t.core={...e.core});return t}(e);Ie(t);for(const n of Te)t.core&&void 0!==t.core[n]&&delete t[n];return t.core&&void 0!==t.core._workerType&&delete t._worker,t}function Ae(e,t,n,r,i){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const c=!t&&p(e[a]);if(!(a in n)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in r)ve.level>0&&ve.warn(`${o} loader option '${s}${a}' no longer supported, use '${r[a]}'`)();else if(!c&&ve.level>0){const e=je(a,i);ve.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function je(e,t){const n=e.toLowerCase();let r="";for(const i of t)for(const t in i.options){if(e===t)return`Did you mean '${i.id}.${t}'?`;const o=t.toLowerCase();(n.startsWith(o)||o.startsWith(n))&&(r=r||`Did you mean '${i.id}.${t}'?`)}return r}function Le(e,t){for(const n in t)if(n in t){const r=t[n];m(r)&&m(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function Ie(e){void 0!==e.baseUri&&(e.core||={},void 0===e.core.baseUrl&&(e.core.baseUrl=e.baseUri));for(const n of Te)if(void 0!==e[n]){const t=e.core=e.core||{};void 0===t[n]&&(t[n]=e[n])}const t=e._worker;void 0!==t&&(e.core||={},void 0===e.core._workerType&&(e.core._workerType=t))}function Ce(e){return!!e&&(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions))}function Re(e){let t;return c(e,"null loader"),c(Ce(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}var $e=()=>{const e=Me();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function ke(e){const t=$e();e=Array.isArray(e)?e:[e];for(const n of e){const e=Re(n);t.find(t=>e===t)||t.unshift(e)}}var Ne=/\.([^.]+)$/;function ze(e){const t=ge(e);return Boolean(t&&(t.startsWith("text/")||"application/json"===t||t.endsWith("+json")))}function De(e,t=[],n,r){if(!Ue(e))return null;const i=Oe(n||{});if(i.core||={},t&&!Array.isArray(t))return Re(t);let o=[];t&&(o=o.concat(t)),i.core.ignoreRegisteredLoaders||o.push(...$e()),function(e){for(const t of e)Re(t)}(o);const s=function(e,t,n,r){const i=me(e),o=ge(e),s=pe(i)||r?.url;let a=null,c="";n?.core?.mimeType&&(a=Fe(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`);a=a||function(e,t){const n=t&&Ne.exec(t),r=n&&n[1];return r?function(e,t){t=t.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===t)return n;return null}(e,r):null}(t,s),c=c||(a?`matched url ${s}`:""),a=a||Fe(t,o),c=c||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(Be(t,n))return n}else if(ArrayBuffer.isView(t)){if(Ge(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&Ge(t,0,n))return n;return null}(t,e),c=c||(a?`matched initial data ${Ve(e)}`:""),n?.core?.fallbackMimeType&&(a=a||Fe(t,n?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${o}`:""));c&&d.log(1,`selectLoader selected ${a?.name}: ${c}.`);return a}(e,o,i,r);if(!s&&!i.core.nothrow)throw new Error(We(e));return s}function Ue(e){return!(e instanceof Response&&204===e.status)}function We(e){const t=me(e),n=ge(e);let r="No valid loader found (";r+=t?`${re(t)}, `:"no url provided, ",r+=`MIME type: ${n?`"${n}"`:"not provided"}, `;const i=e?Ve(e):"";return r+=i?` first bytes: "${i}"`:"first bytes: not available",r+=")",r}function Fe(e,t){for(const n of e){if(n.mimeTypes?.some(e=>he(t,e)))return n;if(he(t,`application/x.${n.id}`))return n}return null}function Be(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Ge(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(n=>function(e,t,n,r){if(b(r))return function(e,t,n){if(n=n||e.byteLength,e.byteLength<n||t.byteLength<n)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let o=0;o<r.length;++o)if(r[o]!==i[o])return!1;return!0}(r,e,r.byteLength);switch(typeof r){case"function":return r(ee(e));case"string":return r===Ye(e,t,r.length);default:return!1}}(e,t,0,n))}function Ve(e,t=5){return"string"==typeof e?e.slice(0,t):ArrayBuffer.isView(e)?Ye(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?Ye(e,0,t):""}function Ye(e,t,n){if(e.byteLength<t+n)return"";const r=new DataView(e);let i="";for(let o=0;o<n;o++)i+=String.fromCharCode(r.getUint8(t+o));return i}var Xe=262144;function qe(e,t){return l?async function*(e,t){const n=e.getReader();let r;try{for(;;){const e=r||n.read();t?._streamReadAhead&&(r=n.read());const{done:i,value:o}=await e;if(i)return;yield Q(o)}}catch(i){n.releaseLock()}}(e,t):async function*(e){for await(const t of e)yield Q(t)}(e)}function He(e,t){if("string"==typeof e)return function*(e,t){const n=t?.chunkSize||262144;let r=0;const i=new TextEncoder;for(;r<e.length;){const t=Math.min(e.length-r,n),o=e.slice(r,r+t);r+=t,yield ee(i.encode(o))}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:n=Xe}=t;let r=0;for(;r<e.byteLength;){const t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),o=new Uint8Array(e,r,t);new Uint8Array(i).set(o),r+=t,yield i}}(e,t);if(y(e))return async function*(e,t){const n=t?.chunkSize||1048576;let r=0;for(;r<e.size;){const t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}(e,t);if(v(e))return qe(e,t);if(_(e)){const n=e.body;if(!n)throw new Error("Readable stream not available on Response");return qe(n,t)}throw new Error("makeIterator")}var Ze="Cannot convert supplied data type";function Ke(e,t,n){if(t.text&&"string"==typeof e)return e;if(J(e)&&(e=e.buffer),b(e)){const n=function(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}(e);return t.text&&!t.binary?new TextDecoder("utf8").decode(n):Q(n)}throw new Error(Ze)}async function Je(e,t,n){if("string"==typeof e||b(e))return Ke(e,t);if(y(e)&&(e=await be(e)),_(e))return await _e(e),t.binary?await e.arrayBuffer():await e.text();if(v(e)&&(e=He(e,n)),r=e,Boolean(r)&&f(r[Symbol.iterator])||(e=>Boolean(e)&&f(e[Symbol.asyncIterator]))(e))return async function(e){const t=[];for await(const n of e)t.push(V(n));return B(...t)}(e);var r;throw new Error(Ze)}function Qe(e,t){const n=Se(),r=e||n,i=r.fetch??r.core?.fetch;return"function"==typeof i?i:p(i)?e=>ye(e,i):t?.fetch?t?.fetch:ye}function et(e,t,n){if(n)return n;const r={fetch:Qe(t,e),...e};if(r.url){const e=pe(r.url);r.baseUrl=e,r.queryString=function(e){const t=e.match(fe);return t&&t[0]}(r.url),r.filename=re(e),r.baseUrl=ie(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}async function tt(e,t,n,r){!t||Array.isArray(t)||Ce(t)||(r=void 0,n=t,t=void 0),n=n||{};const i=me(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}(t,r),s=await async function(e,t=[],n,r){if(!Ue(e))return null;const i=Oe(n||{});if(i.core||={},e instanceof Response&&ze(e)){const n=De(await e.clone().text(),t,{...i,core:{...i.core,nothrow:!0}},r);if(n)return n}let o=De(e,t,{...i,core:{...i.core,nothrow:!0}},r);if(o)return o;if(y(e)&&(o=De(e=await e.slice(0,10).arrayBuffer(),t,i,r)),!o&&e instanceof Response&&ze(e)&&(o=De(await e.clone().text(),t,i,r)),!o&&!i.core.nothrow)throw new Error(We(e));return o}(e,o,n);if(!s)return null;const a=Pe(n,s,o,i);return r=et({url:i,_parse:tt,loaders:o},a,r||null),await async function(e,t,n,r){if(function(e){T(e,"no worker provided");const t=e.version}(e),n=w(e.options,n),_(t)){const{ok:e,redirected:n,status:i,statusText:o,type:s,url:a}=t;r.response={headers:Object.fromEntries(t.headers.entries()),ok:e,redirected:n,status:i,statusText:o,type:s,url:a}}t=await Je(t,e,n);const i=e;if(i.parseTextSync&&"string"==typeof t)return i.parseTextSync(t,n,r);if(function(e,t){if(!U.isSupported())return!1;if(!M&&!(t?._nodeWorkers??t?.core?._nodeWorkers))return!1;const n=t?.worker??t?.core?.worker;return Boolean(e.worker&&n)}(e,n))return await W(e,t,n,r,tt);if(i.parseText&&"string"==typeof t)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw T(!i.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,a,r)}async function nt(e,t,n,r){let i,o;Array.isArray(t)||Ce(t)?(i=t,o=n):(i=[],o=t);const s=Qe(o);let a=e;return"string"==typeof e&&(a=await s(e)),y(e)&&(a=await s(e)),"string"==typeof e&&(Oe(o||{}).core?.baseUrl||(o={...o,core:{...o?.core,baseUrl:e}})),Array.isArray(i),await tt(a,i,o)}var rt=new i({id:"deck"}),it={attributeUpdateStart:-1,attributeManagerUpdateStart:-1,attributeUpdateMessages:[]},ot={};function st(e){ot=e}function at(e,t,n,r){rt.level>0&&ot[e]&&ot[e].call(null,t,n,r)}"production"!==process.env.NODE_ENV&&(ot=(e=>({"layer.changeFlag":(t,n,r)=>{e.log(3,`${t.id} ${n}: `,r[n])()},"layer.initialize":t=>{e.log(1,`Initializing ${t}`)()},"layer.update":(t,n)=>{if(n){const n=t.getChangeFlags();e.log(2,`Updating ${t} because: ${Object.keys(n).filter(e=>n[e]).join(", ")}`)()}else e.log(4,`${t} does not need update`)()},"layer.matched":(t,n)=>{n&&e.log(4,`Matched ${t}, state transfered`)()},"layer.finalize":t=>{e.log(1,`Finalizing ${t}`)()},"compositeLayer.renderLayers":(t,n,r)=>{n?e.log(2,`Composite layer rendered new subLayers ${t}`,r)():e.log(4,`Composite layer reused subLayers ${t}`,r)()},"layerManager.setLayers":(t,n,r)=>{n&&e.log(2,`Updating ${r.length} deck layers`)()},"layerManager.activateViewport":(t,n)=>{e.log(3,"Viewport changed",n)()},"attributeManager.invalidate":(t,n,r)=>{e.log(1,r?`invalidated attributes ${r} (${n}) for ${t.id}`:`invalidated all attributes for ${t.id}`)()},"attributeManager.updateStart":e=>{it.attributeUpdateMessages.length=0,it.attributeManagerUpdateStart=Date.now()},"attributeManager.updateEnd":(t,n)=>{const r=Math.round(Date.now()-it.attributeManagerUpdateStart);e.groupCollapsed(2,`Updated attributes for ${n} instances in ${t.id} in ${r}ms`)();for(const i of it.attributeUpdateMessages)e.log(3,i)();e.groupEnd(2)()},"attribute.updateStart":e=>{it.attributeUpdateStart=Date.now()},"attribute.allocate":(e,t)=>{const n=`${e.id} allocated ${t}`;it.attributeUpdateMessages.push(n)},"attribute.updateEnd":(e,t)=>{const n=Math.round(Date.now()-it.attributeUpdateStart),r=`${e.id} updated ${t} in ${n}ms`;it.attributeUpdateMessages.push(r)},"deckRenderer.renderLayers":(t,n,r)=>{const{pass:i,redrawReason:o}=r;for(const s of n){const{totalCount:n,visibleCount:r,compositeCount:a,pickableCount:c}=s,l=n-a-r;e.log(2,`RENDER #${t.renderCount} ${r} (of ${n} layers) to ${i} because ${o} (${l} hidden, ${a} composite ${c} pickable)`)()}}}))(rt));var ct="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",lt="\\s*",ut=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}@group\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${lt}@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}${ct}`,"g")],ht=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}@group\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${lt}@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}${ct}`,"g")],dt=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${lt}@group\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${lt}@binding\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g")],ft=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${ct}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ct}`,"g")];function pt(e){const t=e.split("");let n=0,r=0,i=!1,o=!1,s=!1;for(;n<e.length;){const a=e[n],c=e[n+1];if(o)s?s=!1:"\\"===a?s=!0:'"'===a&&(o=!1),n++;else if(i)"\n"===a||"\r"===a?i=!1:t[n]=" ",n++;else if(r>0){if("/"===a&&"*"===c){t[n]=" ",t[n+1]=" ",r++,n+=2;continue}if("*"===a&&"/"===c){t[n]=" ",t[n+1]=" ",r--,n+=2;continue}"\n"!==a&&"\r"!==a&&(t[n]=" "),n++}else'"'!==a?"/"!==a||"/"!==c?"/"!==a||"*"!==c?n++:(t[n]=" ",t[n+1]=" ",r=1,n+=2):(t[n]=" ",t[n+1]=" ",i=!0,n+=2):(o=!0,n++)}return t.join("")}function mt(e,t){const n=pt(e),r=[];for(const i of t){let o;for(i.lastIndex=0,o=i.exec(n);o;){const s=i===t[0],a=o.index,c=o[0].length;r.push({match:e.slice(a,a+c),index:a,length:c,bindingToken:o[s?1:2],groupToken:o[s?2:1],accessDeclaration:o[3]?.trim(),name:o[4]}),o=i.exec(n)}}return r.sort((e,t)=>e.index-t.index)}function gt(e,t,n){const r=mt(e,t);if(!r.length)return e;let i="",o=0;for(const s of r)i+=e.slice(o,s.index),i+=n(s),o=s.index+s.length;return i+=e.slice(o),i}function bt(e){return/@binding\(\s*auto\s*\)/.test(pt(e))}function _t(e,t={}){const n=yt(e),r=function(e){const t=[];let n=0;for(const r of e){if("}"===r.value&&0===n)return null;t.push(n),"{"===r.value?n++:"}"===r.value&&n--}return 0===n?t:null}(n);if(!r)return null;const i=function(e,t){const n=/* @__PURE__ */new Map;for(let r=0;r<e.length;r++){if(0!==t[r]||"alias"!==e[r].value)continue;const i=e[r+1]?.value;if(!It(i)||"="!==e[r+2]?.value||n.has(i))return null;const o=At(e,t,r+3,";");if(o<0||o===r+3)return null;n.set(i,Lt(e.slice(r+3,o))),r=o}return n}(n,r);if(!i)return null;const o=function(e,t,n){const r=[],i=/* @__PURE__ */new Set,o=/* @__PURE__ */new Set;for(let s=0;s<e.length;s++){if(0!==t[s]||"var"!==e[s].value)continue;const a=jt(e,t,s),c=e.slice(a,s),l=Tt(c,"group"),u=Tt(c,"binding");if(null===l||null===u||void 0===l!=(void 0===u))return null;if(void 0===l||void 0===u)continue;let h=s+1,d=[];if("<"===e[h]?.value){const t=Pt(e,h,"<",">");if(t<0)return null;const n=Ot(e.slice(h+1,t),",");if(!n)return null;d=n.map(Lt),h=t+1}const f=e[h]?.value;if(!It(f)||":"!==e[h+1]?.value)return null;const p=At(e,t,h+2,";");if(p<0||p===h+2)return null;const m=Et(Lt(e.slice(h+2,p)),n);if(!m)return null;const g=vt({name:f,group:l,location:u,addressSpace:d,resourceType:m}),b=`${l}:${u}`;if(!g||i.has(b)||o.has(f))return null;r.push(g),i.add(b),o.add(f),s=p}return function(e){for(const t of e){if("sampler"!==t.type||t.samplerType||!t.name.endsWith("Sampler"))continue;const n=t.name.slice(0,-7);"depth"===e.find(e=>"texture"===e.type&&e.name===n&&e.group===t.group)?.sampleType&&(t.samplerType="non-filtering")}}(r),r.sort((e,t)=>e.group-t.group||e.location-t.location||e.name.localeCompare(t.name))}(n,r,i);if(!o)return null;if(!1===t.scanVertexAttributes)return{attributes:[],bindings:o};const s=function(e,t){const n=/* @__PURE__ */new Map;for(let r=0;r<e.length;r++){if(0!==t[r]||"struct"!==e[r].value)continue;const i=e[r+1]?.value,o=r+2;if(!It(i)||n.has(i)||"{"!==e[o]?.value)return null;const s=Pt(e,o,"{","}");if(s<0)return null;n.set(i,e.slice(o+1,s)),r=s}return n}(n,r);if(!s)return null;const a=function(e,t,n,r,i){const o=function(e,t){const n=[],r=/* @__PURE__ */new Set;for(let i=0;i<e.length;i++){if(0!==t[i]||"fn"!==e[i].value)continue;const o=e[i+1]?.value,s=i+2;if(!It(o)||r.has(o)||"("!==e[s]?.value)return null;const a=Pt(e,s,"(",")");if(a<0)return null;const c=jt(e,t,i);n.push({name:o,vertex:Mt(e.slice(c,i),"vertex"),parameters:e.slice(s+1,a)}),r.add(o),i=a}return n}(e,t);if(!o)return null;const s=o.filter(e=>e.vertex),a=i?s.find(e=>e.name===i):1===s.length?s[0]:void 0;if(!a)return 0!==s.length||i?null:[];const c=Ot(a.parameters,",");if(!c)return null;const l=[],u=/* @__PURE__ */new Set,h=/* @__PURE__ */new Set,d=/* @__PURE__ */new Set;for(const f of c)if(f.length>0&&!wt({declaration:f,aliases:n,structures:r,attributes:l,attributeLocations:u,attributeNames:h,visitedStructures:d}))return null;return l.sort((e,t)=>e.location-t.location||e.name.localeCompare(t.name))}(n,r,i,s,t.vertexEntryPoint);return a?{attributes:a,bindings:o}:null}function yt(e){const t=pt(e),n=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,r=[];let i=n.exec(t);for(;i;)r.push({value:i[0],index:i.index}),i=n.exec(t);return r}function vt(e){const{name:t,group:n,location:r,addressSpace:i,resourceType:o}=e,s={name:t,group:n,location:r};if("uniform"===i[0]&&1===i.length)return{...s,type:"uniform"};if("storage"===i[0]&&i.length<=2){const e=i[1]||"read";return"read"===e?{...s,type:"read-only-storage"}:"read_write"===e?{...s,type:"storage"}:null}return i.length>0?null:"sampler"===o||"sampler_comparison"===o?{...s,type:"sampler",..."sampler_comparison"===o?{samplerType:"comparison"}:{}}:"texture_external"===o?{...s,type:"external-texture"}:function(e,t){const n=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(t);if(!n)return null;const r={read:"read-only",write:"write-only",read_write:"read-write"}[n[3]];return{...e,type:"storage",format:n[2],access:r,viewDimension:St(n[1])}}(s,o)||function(e,t){const n=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(t);if(n){if(n[1]&&"2d"!==n[2])return null;const t={f32:"float",i32:"sint",u32:"uint"}[n[3]];return{...e,type:"texture",viewDimension:St(n[2]),sampleType:t,multisampled:Boolean(n[1])}}const r=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(t);return!r||r[1]&&"2d"!==r[2]?null:{...e,type:"texture",viewDimension:St(r[2]),sampleType:"depth",multisampled:Boolean(r[1])}}(s,o)}function wt(e){const{declaration:t,aliases:n,structures:r,attributes:i,attributeLocations:o,attributeNames:s,visitedStructures:a}=e,c=function(e,t){const n=Ot(e,t);return n&&2===n.length?n[0].length:-1}(t,":");if(c<1||c===t.length-1)return!1;const l=function(e){for(let t=e.length-1;t>=0;t--)if(It(e[t].value))return e[t].value;return null}(t.slice(0,c)),u=Tt(t.slice(0,c),"location"),h=Mt(t.slice(0,c),"builtin"),d=Et(Lt(t.slice(c+1)),n);if(!l||null===u||!d||void 0!==u&&h)return!1;if(void 0!==u){const e=/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(f=d)?f:null;return!(!e||o.has(u)||s.has(l))&&(i.push({name:l,location:u,type:e}),o.add(u),s.add(l),!0)}var f;if(h)return!0;const p=r.get(d);if(!p||a.has(d))return!1;const m=Ot(p,",");if(!m)return!1;a.add(d);for(const g of m)if(g.length>0&&!wt({...e,declaration:g}))return!1;return a.delete(d),!0}function Et(e,t,n=/* @__PURE__ */new Set){const r=yt(e);let i="";for(const o of r){const e=t.get(o.value);if(!e){i+=xt(o.value);continue}if(n.has(o.value))return null;const r=new Set(n);r.add(o.value);const s=Et(e,t,r);if(!s)return null;i+=s}return i}function xt(e){const t=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(e);if(!t)return e;const n={f:"f32",i:"i32",u:"u32",h:"f16"}[t[2]];return`${t[1]}<${n}>`}function Tt(e,t){let n;for(let r=0;r<e.length;r++)if("@"===e[r].value&&e[r+1]?.value===t){if(void 0!==n||"("!==e[r+2]?.value||!/^\d+$/.test(e[r+3]?.value||"")||")"!==e[r+4]?.value)return null;n=Number(e[r+3].value)}return n}function Mt(e,t){return e.some((n,r)=>"@"===n.value&&e[r+1]?.value===t)}function St(e){return e.replace("_","-")}function Pt(e,t,n,r){let i=0;for(let o=t;o<e.length;o++)if(e[o].value===n)i++;else if(e[o].value===r&&0===--i)return o;return-1}function Ot(e,t){const n=[];let r=0;const i={"(":0,"<":0,"[":0,"{":0},o=Object.keys(i),s={")":"(",">":"<","]":"[","}":"{"};for(let a=0;a<e.length;a++){const c=e[a].value;if(c===t&&o.every(e=>0===i[e]))n.push(e.slice(r,a)),r=a+1;else if(c in i)i[c]++;else if(c in s){const e=s[c];if(i[e]--,i[e]<0)return null}}return o.every(e=>0===i[e])?(n.push(e.slice(r)),n):null}function At(e,t,n,r){for(let i=n;i<e.length;i++)if(0===t[i]&&e[i].value===r)return i;return-1}function jt(e,t,n){for(let r=n-1;r>=0;r--)if(";"===e[r].value&&0===t[r]||"}"===e[r].value&&1===t[r])return r+1;return 0}function Lt(e){return e.map(e=>e.value).join("")}function It(e){return Boolean(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}function Ct(e,t){if(!e){const e=new Error(t||"shadertools: assertion failed.");throw Error.captureStackTrace?.(e,Ct),e}}var Rt={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function $t(e){let t=kt(e);if("object"!==t)return{value:e,...Rt[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...Rt[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=kt(e.value),{...e,...Rt[t],type:t}):{type:"object",value:null};throw new Error("props")}function kt(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var Nt={vertex:"#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\n fragColor = material_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n fragColor = lighting_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_FOG\n fragColor = fog_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_PICKING\n fragColor = picking_filterHighlightColor(fragColor);\n fragColor = picking_filterPickingColor(fragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"},zt=/void\s+main\s*\([^)]*\)\s*\{\n?/,Dt=/}\n?[^{}]*$/,Ut=[],Wt="__LUMA_INJECT_DECLARATIONS__";function Ft(e){const t={vertex:{},fragment:{}};for(const n in e){let r=e[n];"string"==typeof r&&(r={order:0,injection:r}),t[Bt(n)][n]=r}return t}function Bt(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function Gt(e,t,n,r=!1,i="glsl",o={}){const s="vertex"===t;for(const a in n){const t=n[a];t.sort((e,t)=>e.order-t.order),Ut.length=t.length;for(let e=0,n=t.length;e<n;++e)Ut[e]=t[e].injection;const r=`${Ut.join("\n")}\n`;switch(a){case"vs:#decl":("wgsl"===i||s)&&(e=e.replace(Wt,r));break;case"vs:#main-start":("wgsl"===i||s)&&(e="wgsl"===i?Vt(e,"vertex",r,"start",o.vertex):e.replace(zt,e=>e+r));break;case"vs:#main-end":("wgsl"===i||s)&&(e="wgsl"===i?Vt(e,"vertex",r,"end",o.vertex):e.replace(Dt,e=>r+e));break;case"fs:#decl":"wgsl"!==i&&s||(e=e.replace(Wt,r));break;case"fs:#main-start":"wgsl"!==i&&s||(e="wgsl"===i?Vt(e,"fragment",r,"start",o.fragment):e.replace(zt,e=>e+r));break;case"fs:#main-end":"wgsl"!==i&&s||(e="wgsl"===i?Vt(e,"fragment",r,"end",o.fragment):e.replace(Dt,e=>r+e));break;default:e=e.replace(a,e=>e+r)}}return e=e.replace(Wt,""),r&&(e=e.replace(/\}\s*$/,e=>e+Nt[t])),e}function Vt(e,t,n,r,i){const o=function(e,t,n){const r="vertex"===t?"@vertex":"@fragment",i=e.indexOf(r);if(i<0)return null;const o=n?e.search(new RegExp(`\\bfn\\s+${s=n,s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`)):e.indexOf("fn",i);var s;if(o<0)return null;const a=e.indexOf("{",o);if(a<0)return null;let c=0;for(let l=a;l<e.length;l++){const t=e[l];if("{"===t)c++;else if("}"===t&&(c--,0===c))return{openBraceIndex:a,closeBraceIndex:l}}return null}(e,t,i);if(!o)return e;if("start"===r){const t=o.openBraceIndex+1;return`${e.slice(0,t)}\n${n}${e.slice(t)}`}return`${e.slice(0,o.closeBraceIndex)}${n}${e.slice(o.closeBraceIndex)}`}function Yt(e){e.map(e=>function(e){if(e.instance)return;Yt(e.dependencies||[]);const{propTypes:t={},deprecations:n=[],inject:r={}}=e,i={normalizedInjections:Ft(r),parsedDeprecations:qt(n)};t&&(i.propValidators=function(e){const t={};for(const[n,r]of Object.entries(e))t[n]=$t(r);return t}(t));e.instance=i;let o={};t&&(o=Object.entries(t).reduce((e,[t,n])=>{const r=n?.value;return r&&(e[t]=r),e},{}));e.defaultUniforms={...e.defaultUniforms,...o}}(e))}function Xt(e,t,n){e.deprecations?.forEach(e=>{e.regex?.test(t)&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function qt(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}function Ht(e){Yt(e);const t={},n={};Zt({modules:e,level:0,moduleMap:t,moduleDepth:n});const r=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return Yt(r),r}function Zt(e){const{modules:t,level:n,moduleMap:r,moduleDepth:i}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(const o of t)r[o.name]=o,(void 0===i[o.name]||i[o.name]<n)&&(i[o.name]=n);for(const o of t)o.dependencies&&Zt({modules:o.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}var Kt,Jt,Qt={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[n,r]=e.getDevicePixelSize();o.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{const[n,r]=e.getPosition();o.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>o.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>o.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:(Kt=o.get("debug"),Jt=function(){const e=globalThis.process;if(e?.env)return e.env.NODE_ENV}(),null!=Kt?Boolean(Kt):void 0!==Jt&&"production"!==Jt),debugGPUTime:!1,debugShaders:o.get("debug-shaders")||void 0,debugFramebuffers:Boolean(o.get("debug-framebuffers")),debugFactories:Boolean(o.get("debug-factories")),debugWebGL:Boolean(o.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};var en=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],tn=/* @__PURE__ */new WeakMap,nn=/* @__PURE__ */new WeakMap,rn=new class{stats=/* @__PURE__ */new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new H({id:e}));const t=this.stats.get(e);return"GPU Time and Memory"===e&&function(e,t){const n=e.stats;let r=!1;for(const c of t)n[c]||(e.get(c),r=!0);const i=Object.keys(n).length,o=tn.get(e);if(!r&&o?.orderedStatNames===t&&o.statCount===i)return;const s={};let a=nn.get(t);a||(a=new Set(t),nn.set(t,a));for(const c of t)n[c]&&(s[c]=n[c]);for(const[c,l]of Object.entries(n))a.has(c)||(s[c]=l);for(const c of Object.keys(n))delete n[c];Object.assign(n,s),tn.set(e,{orderedStatNames:t,statCount:i})}(t,en),t}};var on="texture-compression-bc",sn="texture-compression-astc",an="texture-compression-etc2",cn="texture-compression-pvrtc-webgl",ln="texture-compression-atc-webgl",un="float32-renderable-webgl",hn="float16-renderable-webgl",dn="snorm8-renderable-webgl",fn="norm16-webgl",pn="norm16-renderable-webgl",mn="snorm16-renderable-webgl",gn="float32-filterable",bn="float16-filterable-webgl",_n=19,yn=992;function vn(e){const t=wn[e];if(!t)throw new Error(`Unsupported texture format ${e}`);return t}var wn={...{r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:dn,webgpu:837},rg8snorm:{render:dn,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:dn,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:_n},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:_n},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:fn,render:pn,webgpu:yn},rg16unorm:{f:fn,render:pn,webgpu:yn},"rgb16unorm-webgl":{f:fn,render:!1},rgba16unorm:{f:fn,render:pn,webgpu:yn},r16snorm:{f:fn,render:mn,webgpu:yn},rg16snorm:{f:fn,render:mn,webgpu:yn},"rgb16snorm-webgl":{f:fn,render:!1},rgba16snorm:{f:fn,render:mn,webgpu:yn},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:_n},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:_n},r16float:{render:hn,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:hn,filter:bn,webgpu:527},rgba16float:{render:hn,filter:bn,webgpu:31},r32uint:{webgpu:_n},rg32uint:{webgpu:16387},rgba32uint:{webgpu:_n},r32sint:{webgpu:_n},rg32sint:{webgpu:16387},rgba32sint:{webgpu:_n},r32float:{render:un,filter:gn,webgpu:_n},rg32float:{render:!1,filter:gn,webgpu:16387},"rgb32float-webgl":{render:un,filter:gn},rgba32float:{render:un,filter:gn,webgpu:_n},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:"rgb9e5ufloat-renderable-webgl",webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:un,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},...{"bc1-rgb-unorm-webgl":{f:on},"bc1-rgb-unorm-srgb-webgl":{f:on},"bc1-rgba-unorm":{f:on},"bc1-rgba-unorm-srgb":{f:on},"bc2-rgba-unorm":{f:on},"bc2-rgba-unorm-srgb":{f:on},"bc3-rgba-unorm":{f:on},"bc3-rgba-unorm-srgb":{f:on},"bc4-r-unorm":{f:on},"bc4-r-snorm":{f:on},"bc5-rg-unorm":{f:on},"bc5-rg-snorm":{f:on},"bc6h-rgb-ufloat":{f:on},"bc6h-rgb-float":{f:on},"bc7-rgba-unorm":{f:on},"bc7-rgba-unorm-srgb":{f:on},"etc2-rgb8unorm":{f:an},"etc2-rgb8unorm-srgb":{f:an},"etc2-rgb8a1unorm":{f:an},"etc2-rgb8a1unorm-srgb":{f:an},"etc2-rgba8unorm":{f:an},"etc2-rgba8unorm-srgb":{f:an},"eac-r11unorm":{f:an},"eac-r11snorm":{f:an},"eac-rg11unorm":{f:an},"eac-rg11snorm":{f:an},"astc-4x4-unorm":{f:sn},"astc-4x4-unorm-srgb":{f:sn},"astc-5x4-unorm":{f:sn},"astc-5x4-unorm-srgb":{f:sn},"astc-5x5-unorm":{f:sn},"astc-5x5-unorm-srgb":{f:sn},"astc-6x5-unorm":{f:sn},"astc-6x5-unorm-srgb":{f:sn},"astc-6x6-unorm":{f:sn},"astc-6x6-unorm-srgb":{f:sn},"astc-8x5-unorm":{f:sn},"astc-8x5-unorm-srgb":{f:sn},"astc-8x6-unorm":{f:sn},"astc-8x6-unorm-srgb":{f:sn},"astc-8x8-unorm":{f:sn},"astc-8x8-unorm-srgb":{f:sn},"astc-10x5-unorm":{f:sn},"astc-10x5-unorm-srgb":{f:sn},"astc-10x6-unorm":{f:sn},"astc-10x6-unorm-srgb":{f:sn},"astc-10x8-unorm":{f:sn},"astc-10x8-unorm-srgb":{f:sn},"astc-10x10-unorm":{f:sn},"astc-10x10-unorm-srgb":{f:sn},"astc-12x10-unorm":{f:sn},"astc-12x10-unorm-srgb":{f:sn},"astc-12x12-unorm":{f:sn},"astc-12x12-unorm-srgb":{f:sn},"pvrtc-rgb4unorm-webgl":{f:cn},"pvrtc-rgba4unorm-webgl":{f:cn},"pvrtc-rgb2unorm-webgl":{f:cn},"pvrtc-rgba2unorm-webgl":{f:cn},"etc1-rbg-unorm-webgl":{f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{f:ln},"atc-rgba-unorm-webgl":{f:ln},"atc-rgbai-unorm-webgl":{f:ln}}},En=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,xn=["rgb","rgba","bgra"],Tn=["depth","stencil"],Mn=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Sn=new class{isColor(e){return xn.some(t=>e.startsWith(t))}isDepthStencil(e){return Tn.some(t=>e.startsWith(t))}isCompressed(e){return Mn.some(t=>e.startsWith(t))}getInfo(e){return Pn(e)}getCapabilities(e){return function(e){const t=vn(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=Pn(e),i=e.startsWith("depth")||e.startsWith("stencil"),o=r?.signed,s=r?.integer,a=r?.webgl,c=Boolean(r?.compressed);return n.render&&=!i&&!c,n.filter&&=!(i||o||s||a),n}(e)}getWebGPUCapabilities(e){const t=vn(e);return void 0!==t.webgpu?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?5:0}computeMemoryLayout(e){return function({format:e,width:t,height:n,depth:r,byteAlignment:i}){const{bytesPerPixel:o,bytesPerBlock:s=o,blockWidth:a=1,blockHeight:c=1,compressed:l=!1}=Sn.getInfo(e),u=l?Math.ceil(t/a):t,h=l?Math.ceil(n/c):n,d=u*s,f=Math.ceil(d/i)*i;return{bytesPerPixel:o,bytesPerRow:f,rowsPerImage:h,depthOrArrayLayers:r,bytesPerImage:f*h,byteLength:f*h*r}}(e)}};function Pn(t){let n=function(e){const t={...vn(e)},n=t.bytesPerPixel||1,r=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,delete t.webgpu,{...t,format:e,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||t.channels?.length||1,bytesPerPixel:n,bitsPerChannel:r,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}(t);if(Sn.isCompressed(t)){n.channels="rgb",n.components=3,n.bytesPerPixel=1,n.srgb=!1,n.compressed=!0,n.bytesPerBlock=function(e){return e.startsWith("bc1")||e.startsWith("bc4")||e.startsWith("etc1")||e.startsWith("etc2-rgb8")||e.startsWith("etc2-rgb8a1")||e.startsWith("eac-r11")||"atc-rgb-unorm-webgl"===e?8:e.startsWith("bc2")||e.startsWith("bc3")||e.startsWith("bc5")||e.startsWith("bc6h")||e.startsWith("bc7")||e.startsWith("etc2-rgba8")||e.startsWith("eac-rg11")||e.startsWith("astc")||"atc-rgba-unorm-webgl"===e||"atc-rgbai-unorm-webgl"===e?16:e.startsWith("pvrtc")?8:16}(t);const e=function(e){const t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){const[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}return e.startsWith("bc")||e.startsWith("etc1")||e.startsWith("etc2")||e.startsWith("eac")||e.startsWith("atc")||e.startsWith("pvrtc-rgb4")||e.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:e.startsWith("pvrtc-rgb2")||e.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}(t);e&&(n.blockWidth=e.blockWidth,n.blockHeight=e.blockHeight)}const r=n.packed?null:En.exec(t);if(r){const[,i,o,s,a,c]=r,l=`${s}${o}`,u=e.getDataTypeInfo(l),h=8*u.byteLength,d=i?.length??1,f=[h,d>=2?h:0,d>=3?h:0,d>=4?h:0];n={format:t,attachment:n.attachment,dataType:u.signedType,components:d,channels:i,integer:u.integer,signed:u.signed,normalized:u.normalized,bitsPerChannel:f,bytesPerPixel:u.byteLength*d,packed:n.packed,srgb:n.srgb},"-webgl"===c&&(n.webgl=!0),"-srgb"===a&&(n.srgb=!0)}return t.endsWith("-webgl")&&(n.webgl=!0),t.endsWith("-srgb")&&(n.srgb=!0),n}function On(e){return"undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}function An(e){if("undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}var jn=class{};function Ln(e){if(void 0!==e){if(null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(Ln);if("object"==typeof e){if(function(e){return"toString"in e&&"function"==typeof e.toString&&e.toString!==Object.prototype.toString}(e)){const t=String(e);if("[object Object]"!==t)return t}return function(e){return"message"in e&&"type"in e}(e)?function(e){const t="string"==typeof e.type?e.type:"message",n="string"==typeof e.message?e.message:"",r="number"==typeof e.lineNum?e.lineNum:null,i="number"==typeof e.linePos?e.linePos:null;return`${t}${null!==r&&null!==i?` @ ${r}:${i}`:null!==r?` @ ${r}`:""}: ${n}`.trim()}(e):e.constructor?.name||"Object"}return String(e)}}var In=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};function Cn(){if("undefined"==typeof HTMLCanvasElement)return!1;const e=HTMLCanvasElement.prototype;return"layoutSubtree"in e&&"function"==typeof e.requestPaint}var Rn=class e{static defaultProps={...Qt};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=rn;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=/* @__PURE__ */new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(t){this.props={...e.defaultProps,...t},this.id=this.props.id||n(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return r.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Sn.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){return 1+Math.floor(Math.log2(Math.max(e,t,n)))}isExternalImage(e){return On(e)}getExternalImageSize(e){return An(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Sn.isCompressed(e)}getSupportedCompressedTextureFormats(){const e=[];for(const t of Object.keys(wn))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){if(!this.props.onError(e,t)){const r=function(e,t){return[Ln(e),...t.map(Ln).filter(e=>void 0!==e)].filter(e=>void 0!==e)}(t,n);return o.error("webgl"===this.type?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...r)}return()=>{}}debug(){this.props.debug||o.once(0,"'Type luma.log.set({debug: true}) in console to enable debug breakpoints',\nor create a device with the 'debug: true' prop.")()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,n,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,n,r,i){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return null!==this._debugGPUTimeQuery}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return!0===e.createCanvasContext?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=Sn.getCapabilities(e),n=e=>("string"==typeof e?this.features.has(e):e)??!0,r=n(t.create);return{format:e,create:r,render:r&&n(t.render),filter:r&&n(t.filter),blend:r&&n(t.blend),store:r&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&a.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}},$n=class e extends t{static defaultProps={...t.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(t,n){super(t,n=e.normalizeProps(t,n),e.defaultProps)}static normalizeProps(e,t){return t}},kn={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Nn=class e extends t{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(t,n,r){if(super(t,n=e.normalizeProps(t,n),e.defaultProps),this.dimension=this.props.dimension,this.baseDimension=kn[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,"cube"===this.dimension&&(this.depth=6),void 0===this.props.width||void 0===this.props.height)if(t.isExternalImage(n.data)){const e=t.getExternalImageSize(n.data);this.width=e?.width||1,this.height=e?.height||1}else this.width=1,this.height=1,void 0!==this.props.width&&void 0!==this.props.height||o.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=r?.byteAlignment||1,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof $n?e:this.device.createSampler(e)}copyImageData(e){const{data:t,depth:n,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??n})}computeMemoryLayout(e={}){const{width:t=this.width,height:n=this.height,depthOrArrayLayers:r=this.depth}=this._normalizeTextureReadOptions(e),{format:i,byteAlignment:o}=this;return Sn.computeMemoryLayout({format:i,width:t,height:n,depth:r,byteAlignment:o})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){const n={...t},{width:r,height:i}=n;return"number"==typeof r&&(n.width=Math.max(1,Math.ceil(r))),"number"==typeof i&&(n.height=Math.max(1,Math.ceil(i))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){const{data:t,depth:n,...r}=e,i=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??n});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o=this.device.getExternalImageSize(t.image),s={...e.defaultCopyExternalImageOptions,...i,...o,...n};return s.width=Math.min(s.width,i.width-s.x),s.height=Math.min(s.height,i.height-s.y),s.depth=Math.min(s.depth,i.depthOrArrayLayers-s.z),s}_normalizeCopyElementImageOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o={...e.defaultCopyElementImageOptions,...i,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depth=Math.min(o.depth,i.depthOrArrayLayers-o.z),o}_normalizeTextureReadOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o={...e.defaultTextureReadOptions,...i,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,i.depthOrArrayLayers-o.z),o}_getSupportedColorReadOptions(e){const t=this._normalizeTextureReadOptions(e),n=Sn.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if("all"!==e.aspect)throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o={...e.defaultTextureWriteOptions,...i,...n};o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,i.depthOrArrayLayers-o.z);const s=Sn.computeMemoryLayout({format:this.format,width:o.width,height:o.height,depth:o.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*o.width;if(o.bytesPerRow=n.bytesPerRow??s.bytesPerRow,o.rowsPerImage=n.rowsPerImage??o.height,o.bytesPerRow<a)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be at least ${a} for ${this.format}`);if(o.rowsPerImage<o.height)throw new Error(`rowsPerImage (${o.rowsPerImage}) must be at least ${o.height} for ${this.format}`);const c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&o.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return o}_getMipLevelSize(e){return{width:Math.max(1,this.width>>e),height:"1d"===this.baseDimension?1:Math.max(1,this.height>>e),depthOrArrayLayers:"3d"===this.dimension?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){const{width:n,height:r,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=Sn.computeMemoryLayout({format:this.format,width:n,height:r,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}static defaultProps={...t.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:e.SAMPLE|e.RENDER|e.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}},zn=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Dn=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Un(e){return`${e.name}Uniforms`}function Wn(e,t){const n="wgsl"===t?e.source:"vertex"===t?e.vs:e.fs;if(!n)return null;return function(e,t,n){const r="wgsl"===t?function(e,t){const n=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!n)return null;const r=e.indexOf("{",n.index);if(r<0)return null;let i=0;for(let o=r;o<e.length;o++){const t=e[o];if("{"!==t){if("}"===t&&(i--,0===i))return e.slice(r+1,o)}else i++}return null}(e,n):function(e,t){return Bn(e).find(e=>e.blockName===t)?.body||null}(e,n);if(!r)return null;const i=[];for(const o of r.split("\n")){const e=o.replace(/\/\/.*$/,"").trim();if(!e||e.startsWith("#"))continue;const n="wgsl"===t?e.match(/^([A-Za-z0-9_]+)\s*:/):e.match(zn);n&&i.push(n[1])}return i}(n,"wgsl"===t?"wgsl":"glsl",Un(e))}function Fn(e,t,n={}){const r=function(e,t){const n=Object.keys(e.uniformTypes||{});if(!n.length)return null;const r=Wn(e,t);return r?{moduleName:e.name,uniformBlockName:Un(e),stage:t,expectedUniformNames:n,actualUniformNames:r,matches:Gn(n,r)}:null}(e,t);if(!r||r.matches)return r;const i=function(e){const{expectedUniformNames:t,actualUniformNames:n}=e,r=t.filter(e=>!n.includes(e)),i=n.filter(e=>!t.includes(e)),o=[`Expected ${t.length} fields, found ${n.length}.`],s=function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return`First mismatch at field ${r+1}: expected ${e[r]}, found ${t[r]}.`;return e.length>t.length?`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`:t.length>e.length?`Shader block has extra field ${t.length}: ${t[e.length]}.`:null}(t,n);s&&o.push(s);r.length&&o.push(`Missing from shader block (${r.length}): ${Yn(r)}.`);i.length&&o.push(`Unexpected in shader block (${i.length}): ${Yn(i)}.`);t.length<=12&&n.length<=12&&(r.length||i.length)&&(o.push(`Expected: ${t.join(", ")}.`),o.push(`Actual: ${n.join(", ")}.`));return`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${o.join(" ")}`}(r);return n.log?.error?.(i,r)(),!1!==n.throwOnError&&Ct(!1,i),r}function Bn(e){const t=[],n=function(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}(e);for(const r of n.matchAll(Dn)){const e=r[1]?.trim()||null;t.push({blockName:r[2],body:r[3],instanceName:r[4]||null,layoutQualifier:e,hasLayoutQualifier:Boolean(e),isStd140:Boolean(e&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(e))})}return t}function Gn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Vn(e){return e.replace(/\s+/g," ").trim()}function Yn(e,t=8){if(e.length<=t)return e.join(", ");const n=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${n} more)`}var Xn=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],qn=[...Xn,[Kn("attribute"),"in $1"],[Kn("varying"),"out $1"]],Hn=[...Xn,[Kn("varying"),"in $1"]];function Zn(e,t){for(const[n,r]of t)e=e.replace(n,r);return e}function Kn(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Jn(e,t,n="glsl"){let r="";for(const i in e){const o=e[i];if(r+=`${"wgsl"===n?"fn":"void"} ${o.signature} {\n`,o.header&&(r+=` ${o.header}`),t[i]){const e=t[i];e.sort((e,t)=>e.order-t.order);for(const t of e)r+=` ${t.injection}\n`}o.footer&&(r+=` ${o.footer}`),r+="}\n"}return r}function Qn(e){const t={vertex:{},fragment:{}};for(const n of e){let e,r;"string"!=typeof n?(e=n,r=e.hook):(e={},r=n),r=r.trim();const i=r.indexOf(":"),o=r.slice(0,i),s=r.slice(i+1),a=r.replace(/\(.+/,""),c=Object.assign(e,{signature:s});switch(o){case"vs":t.vertex[a]=c;break;case"fs":t.fragment[a]=c;break;default:throw new Error(o)}}return t}function er(e,t="unnamed"){const n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function tr(e){let t=100;const n=e.match(/[^\s]+/g);if(n&&n.length>=2&&"#version"===n[0]){const e=parseInt(n[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}var nr=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ct}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${ct}\\s*:\\s*([^;]+);`,"g")];function rr(e,t=[]){const n=pt(e),r=/* @__PURE__ */new Map;for(const o of t)r.set(or(o.name,o.group,o.location),o.moduleName);const i=[];for(const o of nr){let e;for(o.lastIndex=0,e=o.exec(n);e;){const t=o===nr[0],s=Number(e[t?1:2]),a=Number(e[t?2:1]),c=e[3]?.trim(),l=e[4],u=e[5].trim(),h=r.get(or(l,a,s));i.push(ir({name:l,group:a,binding:s,owner:h?"module":"application",moduleName:h,accessDeclaration:c,resourceType:u})),e=o.exec(n)}}return i.sort((e,t)=>e.group!==t.group?e.group-t.group:e.binding!==t.binding?e.binding-t.binding:e.name.localeCompare(t.name))}function ir(e){const t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:"unknown",moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){const n=e.accessDeclaration.split(",").map(e=>e.trim());if("uniform"===n[0])return{...t,kind:"uniform",access:"uniform"};if("storage"===n[0]){const e=n[1]||"read_write";return{...t,kind:"read"===e?"read-only-storage":"storage",access:e}}}return"sampler"===e.resourceType||"sampler_comparison"===e.resourceType?{...t,kind:"sampler",samplerKind:"sampler_comparison"===e.resourceType?"comparison":"filtering"}:e.resourceType.startsWith("texture_storage_")?{...t,kind:"storage-texture",access:(n=e.resourceType,/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]),viewDimension:sr(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:sr(e.resourceType),sampleType:ar(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t;var n}function or(e,t,n){return`${t}:${n}:${e}`}function sr(e){return e.includes("cube_array")?"cube-array":e.includes("2d_array")?"2d-array":e.includes("cube")?"cube":e.includes("3d")?"3d":e.includes("2d")?"2d":e.includes("1d")?"1d":void 0}function ar(e){return e.startsWith("texture_depth_")?"depth":e.includes("<i32>")?"sint":e.includes("<u32>")?"uint":e.includes("<f32>")?"float":void 0}var cr="([a-zA-Z_][a-zA-Z0-9_]*)",lr=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,ur=new RegExp(`^\\s*\\#\\s*ifdef\\s*${cr}\\s*$`),hr=new RegExp(`^\\s*\\#\\s*ifndef\\s*${cr}\\s*(?:\\/\\/.*)?$`),dr=/^\s*\#\s*else\s*(?:\/\/.*)?$/,fr=/^\s*\#\s*endif\s*$/,pr=new RegExp(`^\\s*\\#\\s*ifdef\\s*${cr}\\s*(?:\\/\\/.*)?$`),mr=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function gr(e,t){const n=e.split("\n"),r=[],i=[];let o=!0;for(const s of n){const e=s.match(lr),n=s.match(pr)||s.match(ur),a=s.match(hr),c=s.match(dr),l=s.match(mr)||s.match(fr);if(e){const n=br(e[1],t?.defines||{}),r=o&&n;i.push({parentActive:o,branchTaken:n,active:r}),o=r}else if(n||a){const e=(n||a)?.[1],r=Boolean(t?.defines?.[e]),s=n?r:!r,c=o&&s;i.push({parentActive:o,branchTaken:s,active:c}),o=c}else if(c){const e=i[i.length-1];if(!e)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");e.active=e.parentActive&&!e.branchTaken,e.branchTaken=!0,o=e.active}else l?(i.pop(),o=!i.length||i[i.length-1].active):o&&r.push(s)}if(i.length>0)throw new Error("Unterminated conditional block in shader source");return r.join("\n")}function br(e,t){const n=e.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(n))return 0!==Number(n);if("true"===n)return!0;if("false"===n)return!1;const r=n.match(new RegExp(`^!\\s*${cr}$`));if(r)return!Boolean(t[r[1]]);const i=n.match(new RegExp(`^${cr}$`));if(i)return Boolean(t[i[1]]);const o=n.match(new RegExp(`^defined\\s*\\(\\s*${cr}\\s*\\)$`));if(o)return void 0!==t[o[1]];const s=n.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${cr}\\s*\\)$`));if(s)return void 0===t[s[1]];throw new Error(`Unsupported #if expression "${e}"`)}function _r(e,t,n){const r=Object.entries(n);if(0===r.length)return{source:e,declarations:"",initialization:""};const i=function(e,t){const n=new RegExp(`\\bfn\\s+${Or(t)}\\s*\\(`,"g").exec(e);if(!n)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${t}"`);const r=e.indexOf("(",n.index),i=Sr(e,r,"(",")");if(i<0)throw new Error(`Unable to parse WGSL vertex entry point "${t}" parameters`);return{openParenthesis:r,closeParenthesis:i}}(e,t),o=e.slice(i.openParenthesis+1,i.closeParenthesis),s=function(e,t){const n=wr(t),r=new Set(Er(t)),i=function(e){const t=[],n=/:\s*([A-Za-z_][\w]*)\b/g;let r=n.exec(e);for(;r;)t.push(r[1]),r=n.exec(e);return t}(t);for(const o of i){const t=xr(e,o);if(null!==t){n.push(...wr(t));for(const e of Er(t))r.add(e)}}return{locations:n,names:r}}(e,o),a=new Set(s.locations),c=[],l=[],u=[];for(const[p,m]of r){if(s.names.has(p)||Tr(e,p))throw new Error(`ShaderPlugin vertex input "${p}" conflicts with an existing WGSL shader input or variable`);const t=Mr(a);a.add(t);const n=`_luma_${p}`;c.push(`@location(${t}) ${n}: ${m}`),l.push(`var<private> ${p}: ${m};`),u.push(`${p} = ${n};`)}const h=o.trim()?",\n ":"\n ",d=o.trim()?"":"\n",f=`${o}${h}${c.join(",\n ")}${d}`;return{source:e.slice(0,i.openParenthesis+1)+f+e.slice(i.closeParenthesis),declarations:l.join("\n"),initialization:u.join("\n")}}function yr(e){const{primitiveType:t,components:n}=s.getAttributeShaderTypeInfo(e),r="i32"===t?"int":"u32"===t?"uint":"float";return 1===n?r:`${"int"===r?"i":"uint"===r?"u":""}vec${n}`}function vr(e,t){const n=Or(t);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${n}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin vertex input "${t}" conflicts with an existing GLSL input`)}function wr(e){const t=[],n=/@location\s*\(\s*(\d+)\s*\)/g;let r=n.exec(e);for(;r;)t.push(Number(r[1])),r=n.exec(e);return t}function Er(e){const t=[],n=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;let r=n.exec(e);for(;r;)t.push(r[1]),r=n.exec(e);return t}function xr(e,t){const n=new RegExp(`\\bstruct\\s+${Or(t)}\\s*\\{`,"g").exec(e);if(!n)return null;const r=e.indexOf("{",n.index),i=Sr(e,r,"{","}");return i<0?null:e.slice(r+1,i)}function Tr(e,t){const n=Or(t),r=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${n}\\b`,"g");let i=r.exec(e);for(;i;){if(0===Pr(e,i.index))return!0;i=r.exec(e)}return!1}function Mr(e){let t=0;for(;e.has(t);)t++;return t}function Sr(e,t,n,r){let i=0,o=0,s=!1;for(let a=t;a<e.length;a++){const t=e[a],c=e[a+1];if(s)"\n"===t&&(s=!1);else if(o>0)"/"===t&&"*"===c?(o++,a++):"*"===t&&"/"===c&&(o--,a++);else if("/"!==t||"/"!==c)if("/"!==t||"*"!==c){if(t===n&&i++,t===r&&0===--i)return a}else o=1,a++;else s=!0,a++}return-1}function Pr(e,t){let n=0,r=0,i=!1;for(let o=0;o<t;o++){const t=e[o],s=e[o+1];i?"\n"===t&&(i=!1):r>0?"/"===t&&"*"===s?(r++,o++):"*"===t&&"/"===s&&(r--,o++):"/"===t&&"/"===s?(i=!0,o++):"/"===t&&"*"===s?(r=1,o++):"{"===t?n++:"}"===t&&n--}return n}function Or(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ar(e,t,n,r){const i=Object.entries(r);if(0===i.length)return{source:e,declarations:"",vertexInitialization:"",fragmentInitialization:""};let o=e,s=jr(o,t,"vertex");const a=function(e,t){const n=e.slice(t.closeParenthesis+1,t.openBrace),r=/->\s*([A-Za-z_][\w]*)\s*$/.exec(n.trim());if(!r||null===Ir(e,r[1]))throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return r[1]}(o,s);let c=jr(o,n,"fragment");const l=function(e,t){const n=[];for(const r of function(e,t){const n=[];let r=0,i=0,o=0;for(let s=0;s<e.length;s++){const a=e[s];"("===a&&i++,")"===a&&i--,"<"===a&&o++,">"===a&&o--,a===t&&0===i&&0===o&&(n.push(e.slice(r,s)),r=s+1)}return n.push(e.slice(r)),n}(t.parameters,",")){const t=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(r.trim());t&&Ir(e,t[2])&&n.push({name:t[1],type:t[2]})}if(1!==n.length)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${n.length}`);return n[0]}(o,c),u=Lr(o,a),h=Lr(o,l.type),d=/* @__PURE__ */new Set([...kr(s.parameters),...kr(u.body),...kr(c.parameters),...kr(h.body)]),f=/* @__PURE__ */new Set([...$r(u.body),...$r(h.body)]),p=[],m=[],g=[],b=[];for(const[y,v]of i){if(d.has(y)||Nr(o,y))throw new Error(`ShaderPlugin varying "${y}" conflicts with existing WGSL stage I/O or a module variable`);const e=zr(f);f.add(e);const t="flat"===v.interpolation?" @interpolate(flat)":"";p.push(` @location(${e})${t} ${y}: ${v.type},`),m.push(`var<private> ${y}: ${v.type};`),g.push(`${y} = ${Ur(v.type)};`),b.push(`${y} = ${l.name}.${y};`)}!function(e,t,n,r){const i=new RegExp(`\\b${Gr(t)}\\s*\\(`,"g");let o=i.exec(e);for(;o;){if(o.index<n||o.index>r)throw new Error(`ShaderPlugin varying output struct "${t}" is constructed outside the selected vertex entry point`);o=i.exec(e)}}(o,a,s.openBrace,s.closeBrace),o=function(e,t,n,r){const i=new RegExp(`\\b${Gr(t)}\\s*\\(`,"g"),o=[];let s=i.exec(e);for(;s;){if(s.index>n.openBrace&&s.index<n.closeBrace){const r=e.indexOf("(",s.index),i=Fr(e,r,"(",")");if(i<0||i>n.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${t}"`);o.push({openParenthesis:r,closeParenthesis:i})}s=i.exec(e)}for(const a of o.sort((e,t)=>t.closeParenthesis-e.closeParenthesis)){const t=e.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";e=e.slice(0,a.closeParenthesis)+t+r.join(", ")+e.slice(a.closeParenthesis)}return e}(o,a,s,i.map(([e])=>e)),s=jr(o,t,"vertex"),o=function(e,t,n){const r=function(e,t,n){const r=[];let i=t;for(;i<n;)if(i=Rr(e,i,n),"return"!==e.slice(i,i+6)||/[A-Za-z0-9_]/.test(e[i+6]||""))i++;else{const t=i+6,o=Cr(e,t,n);if(o<0)throw new Error("Unable to parse WGSL return statement in selected vertex entry point");r.push({start:i,expressionStart:t,semicolon:o}),i=o+1}return r}(e,t.openBrace+1,t.closeBrace);for(let i=r.length-1;i>=0;i--){const t=r[i],o=e.slice(t.expressionStart,t.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");const s=`_luma_vertexOutput${i}`,a=`{\nvar ${s} = ${o};\n${n.map(e=>`${s}.${e} = ${e};`).join("\n")}\nreturn ${s};\n}`;e=e.slice(0,t.start)+a+e.slice(t.semicolon+1)}return e}(o,s,i.map(([e])=>e));const _=(a===l.type?[a]:[a,l.type]).map(e=>Lr(o,e).closeBrace).sort((e,t)=>t-e);for(const y of _)o=o.slice(0,y)+`${p.join("\n")}\n`+o.slice(y);if(c=jr(o,n,"fragment"),!new RegExp(`\\b${Gr(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:o,declarations:m.join("\n"),vertexInitialization:g.join("\n"),fragmentInitialization:b.join("\n")}}function jr(e,t,n){const r=new RegExp(`\\bfn\\s+${Gr(t)}\\s*\\(`,"g").exec(e);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${n} entry point "${t}"`);const i=e.indexOf("(",r.index),o=Fr(e,i,"(",")"),s=e.indexOf("{",o),a=Fr(e,s,"{","}");if(o<0||s<0||a<0)throw new Error(`Unable to parse WGSL ${n} entry point "${t}"`);return{openParenthesis:i,closeParenthesis:o,openBrace:s,closeBrace:a,parameters:e.slice(i+1,o)}}function Lr(e,t){const n=Ir(e,t);if(!n)throw new Error(`Unable to find WGSL stage I/O struct "${t}"`);return n}function Ir(e,t){const n=new RegExp(`\\bstruct\\s+${Gr(t)}\\s*\\{`,"g").exec(e);if(!n)return null;const r=e.indexOf("{",n.index),i=Fr(e,r,"{","}");return i<0?null:{openBrace:r,closeBrace:i,body:e.slice(r+1,i)}}function Cr(e,t,n){let r=0,i=0;for(let o=t;o<n;o++){const t=Rr(e,o,n);if(t!==o){o=t-1;continue}const s=e[o];if("("===s&&r++,")"===s&&r--,"["===s&&i++,"]"===s&&i--,";"===s&&0===r&&0===i)return o}return-1}function Rr(e,t,n){let r=t;if("/"===e[r]&&"/"===e[r+1]){const t=e.indexOf("\n",r+2);return t<0||t>n?n:t+1}if("/"===e[r]&&"*"===e[r+1]){let t=1;for(r+=2;r<n&&t>0;)"/"===e[r]&&"*"===e[r+1]?(t++,r+=2):"*"===e[r]&&"/"===e[r+1]?(t--,r+=2):r++}return r}function $r(e){const t=[],n=/@location\s*\(\s*(\d+)\s*\)/g;let r=n.exec(e);for(;r;)t.push(Number(r[1])),r=n.exec(e);return t}function kr(e){const t=[],n=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;let r=n.exec(e);for(;r;)t.push(r[1]),r=n.exec(e);return t}function Nr(e,t){const n=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Gr(t)}\\b`,"g");let r=n.exec(e);for(;r;){if(0===Br(e,r.index))return!0;r=n.exec(e)}return!1}function zr(e){let t=0;for(;e.has(t);)t++;return t}function Dr(e){const{primitiveType:t,components:n}=s.getAttributeShaderTypeInfo(e),r="u32"===t?"0u":"i32"===t?"0":"0.0";return 1===n?r:`${yr(e)}(${r})`}function Ur(e){const{primitiveType:t,components:n}=s.getAttributeShaderTypeInfo(e),r=`${t}(0)`;return 1===n?r:`${e}(${r})`}function Wr(e,t){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Gr(t)}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin varying "${t}" conflicts with existing GLSL stage I/O`)}function Fr(e,t,n,r){let i=0,o=0,s=!1;for(let a=t;a<e.length;a++){const t=e[a],c=e[a+1];if(s)"\n"===t&&(s=!1);else if(o>0)"/"===t&&"*"===c?(o++,a++):"*"===t&&"/"===c&&(o--,a++);else if("/"!==t||"/"!==c)if("/"!==t||"*"!==c){if(t===n&&i++,t===r&&0===--i)return a}else o=1,a++;else s=!0,a++}return-1}function Br(e,t){let n=0;for(let r=0;r<t;r++){const i=Rr(e,r,t);i===r?("{"===e[r]&&n++,"}"===e[r]&&n--):r=i-1}return n}function Gr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Vr=`\n\n${Wt}\n`,Yr=100;function Xr(e){const t=Ht(e.modules||[]),{source:n,bindingAssignments:r}=function(e,t){const{source:n,stage:r,modules:i,defines:o={},hookFunctions:s=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:h="vertexMain",fragmentEntryPoint:d="fragmentMain",log:f}=t;Ct("string"==typeof n,"shader source must be a string");const p=gr(n,{defines:o}),m=_r(p,h,l),g=Ar(m.source,h,d,u),b=g.source;let _="";const y=Qn(s),v={},w={},E={};Kr(c,v,w,E);for(const O in a){const e="string"==typeof a[O]?{injection:a[O],order:0}:a[O],t=/^(v|f)s:(#)?([\w-]+)$/.exec(O);if(t){const n=t[2],r=t[3];n?"decl"===r?w[O]=[e]:E[O]=[e]:v[O]=[e]}else E[O]=[e]}(function(e,t,n,r){e&&(n["vs:#decl"]=n["vs:#decl"]||[],n["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER}));t&&(r["vs:#main-start"]=r["vs:#main-start"]||[],r["vs:#main-start"].push({injection:t,order:Number.MIN_SAFE_INTEGER}))})(m.declarations,m.initialization,w,E),function(e,t,n){e.declarations&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:e.declarations,order:Number.MIN_SAFE_INTEGER}));e.vertexInitialization&&(n["vs:#main-start"]=n["vs:#main-start"]||[],n["vs:#main-start"].push({injection:e.vertexInitialization,order:Number.MIN_SAFE_INTEGER}));e.fragmentInitialization&&(n["fs:#main-start"]=n["fs:#main-start"]||[],n["fs:#main-start"].push({injection:e.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}(g,w,E);const x=i,T=function(e){const t=mt(e,ht),n=/* @__PURE__ */new Map;for(const o of t){if("auto"===o.bindingToken)continue;const e=Number(o.bindingToken),t=Number(o.groupToken);ni(t,e,o.name),ii(n,t,e,`application binding "${o.name}"`)}const r={sawSupportedBindingDeclaration:t.length>0},i=gt(e,ht,e=>function(e,t,n){const{match:r,bindingToken:i,groupToken:o,name:s}=e,a=Number(o);if("auto"===i){const e=function(e,t){const n=t.get(e)||/* @__PURE__ */new Set;let r=0;for(;n.has(r);)r++;return r}(a,t);return ni(a,e,s),ii(t,a,e,`application binding "${s}"`),r.replace(/@binding\(\s*auto\s*\)/,`@binding(${e})`)}return n.sawSupportedBindingDeclaration=!0,r}(e,n,r));if(bt(e)&&!r.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:i}}(b),M=function(e){const t=/* @__PURE__ */new Map;for(const n of mt(e,dt)){const e=Number(n.bindingToken),r=Number(n.groupToken);ni(r,e,n.name),ii(t,r,e,`application binding "${n.name}"`)}return t}(T.source),S=function(e,t,n,r){const i=/* @__PURE__ */new Map;if(!t)return i;for(const o of e)for(const e of ti(o,r)){const r=oi(e.group,o.name,e.name),s=t.get(r);if(void 0!==s){const t=i.get(e.group)||/* @__PURE__ */new Map,o=t.get(s);if(o&&o!==r)throw new Error(`Duplicate WGSL binding reservation for modules "${o}" and "${r}": group ${e.group}, binding ${s}.`);ii(n,e.group,s,`registered module binding "${r}"`),t.set(s,r),i.set(e.group,t)}}return i}(x,t._bindingRegistry,M,o),P=[];for(const O of x){f&&Xt(O,b,f);const e=ei(gr(Qr(O,"wgsl",f),{defines:o}),O,{usedBindingsByGroup:M,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:S});P.push(...e.bindingAssignments);_+=e.source;const n=Jr(O);for(const t in n){const e=/^(v|f)s:#([\w-]+)$/.exec(t);if(e){const r="decl"===e[2]?w:E;r[t]=r[t]||[],r[t].push(n[t])}else v[t]=v[t]||[],v[t].push(n[t])}}return _+=Vr,_=Gt(_,r,function(e){const t=[...e["vs:#decl"]||[],...e["fs:#decl"]||[]];return t.length?{"vs:#decl":t}:{}}(w),!1,"wgsl",{vertex:h,fragment:d}),_+=function(e,t){return Jn(e.vertex,t,"wgsl")+Jn(e.fragment,t,"wgsl")}(y,v),_+=function(e){if(0===e.length)return"";let t="// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------\n";for(const n of e)t+=`// ${n.moduleName}.${n.name} -> @group(${n.group}) @binding(${n.location})\n`;return t+="\n",t}(P),_+=T.source,_=Gt(_,r,E,!1,"wgsl",{vertex:h,fragment:d}),function(e){const t=function(e,t){return mt(e,t===ut||t===ht?ft:t).find(e=>"auto"===e.bindingToken)}(e,ut);if(!t)return;const n=function(e,t){const n=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;let r,i;i=n.exec(e);for(;i&&i.index<=t;)r=i[1],i=n.exec(e);return r}(e,t.index);if(n)throw new Error(`Unresolved @binding(auto) for module "${n}" binding "${t.name}" remained in assembled WGSL source.`);if(function(e,t){const n=e.indexOf(Vr);return!(n>=0)||t>n}(e,t.index))throw new Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`);throw new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${function(e){return e.replace(/\s+/g," ").trim()}(t.match)}".`)}(_),{source:_,bindingAssignments:P}}(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:n,getUniforms:Zr(t),bindingAssignments:r,bindingTable:rr(n,r),shaderLayout:_t(n,{vertexEntryPoint:e.vertexEntryPoint,scanVertexAttributes:e.scanVertexAttributes})}}function qr(e){const{vs:t,fs:n}=e,r=Ht(e.modules||[]);return{vs:Hr(e.platformInfo,{...e,source:t,stage:"vertex",modules:r}),fs:Hr(e.platformInfo,{...e,source:n,stage:"fragment",modules:r}),getUniforms:Zr(r)}}function Hr(e,t){const{source:n,stage:r,language:i="glsl",modules:o,defines:s={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:h={},prologue:d=!0,log:f}=t;Ct("string"==typeof n,"shader source must be a string");const p="glsl"===i?function(e,t){return{name:er(e,t),language:"glsl",version:tr(e)}}(n).version:-1,m=e.shaderLanguageVersion,g=100===p?"#version 100":"#version 300 es",b=n.split("\n").slice(1).join("\n"),_={};o.forEach(e=>{Object.assign(_,e.defines)}),Object.assign(_,s);let y="";switch(i){case"wgsl":break;case"glsl":y=d?`${g}\n\n// ----- PROLOGUE -------------------------\n#define SHADER_TYPE_${r.toUpperCase()}\n\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n// Apple optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Headless Chrome's software shader 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// If the GPU doesn't have full 32 bits precision, will causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const n in e){const r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}(_)}\n\n`:`${g}\n`}const v=Qn(a),w={},E={},x={};Kr(l,w,E,x);for(const M in c){const e="string"==typeof c[M]?{injection:c[M],order:0}:c[M],t=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(t){const n=t[2],r=t[3];n?"decl"===r?E[M]=[e]:x[M]=[e]:w[M]=[e]}else x[M]=[e]}if("vertex"===r){const e=function(e,t){const n=[];for(const[r,i]of Object.entries(t))vr(e,r),n.push(`in ${yr(i)} ${r};`);return n.join("\n")}(b,u);e&&(E["vs:#decl"]=E["vs:#decl"]||[],E["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}const T=function(e,t,n){const r=[],i=[];for(const[o,s]of Object.entries(n)){Wr(e,o);const n="flat"===s.interpolation?"flat ":"",a="vertex"===t?"out":"in";r.push(`${n}${a} ${yr(s.type)} ${o};`),"vertex"===t&&i.push(`${o} = ${Dr(s.type)};`)}return{declarations:r.join("\n"),initialization:i.join("\n")}}(b,r,h);if(T.declarations){const e="vertex"===r?"vs:#decl":"fs:#decl";E[e]=E[e]||[],E[e].push({injection:T.declarations,order:Number.MIN_SAFE_INTEGER})}T.initialization&&(x["vs:#main-start"]=x["vs:#main-start"]||[],x["vs:#main-start"].push({injection:T.initialization,order:Number.MIN_SAFE_INTEGER}));for(const M of o){f&&Xt(M,b,f);y+=Qr(M,r,f);const e=M.instance?.normalizedInjections[r]||{};for(const t in e){const n=/^(v|f)s:#([\w-]+)$/.exec(t);if(n){const r="decl"===n[2]?E:x;r[t]=r[t]||[],r[t].push(e[t])}else w[t]=w[t]||[],w[t].push(e[t])}}return y+="// ----- MAIN SHADER SOURCE -------------------------",y+=Vr,y=Gt(y,r,E),y+=Jn(v[r],w),y+=b,y=Gt(y,r,x),"glsl"===i&&p!==m&&(y=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return Zn(e,qn);case"fragment":return Zn(e,Hn);default:throw new Error(t)}}(y,r)),"glsl"===i&&function(e,t,n,r){const i=Bn(e).filter(e=>!e.isStd140),o=/* @__PURE__ */new Set;for(const s of i){if(o.has(s.blockName))continue;o.add(s.blockName);const e=r?.label?`${r.label} `:"",i=s.hasLayoutQualifier?`declares ${Vn(s.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",a=`${e}${t} shader uniform block ${s.blockName} ${i}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;n?.warn?.(a,s)()}}(y,r,f),y.trim()}function Zr(e){return function(t){const n={};for(const r of e){const e=r.getUniforms?.(t,n);Object.assign(n,e)}return n}}function Kr(e,t,n,r){for(const i in e){const o=/^(v|f)s:(#)?([\w-]+)$/.exec(i);if(o){const s=o[2],a=o[3],c=s?"decl"===a?n:r:t;c[i]=c[i]||[],c[i].push(...e[i])}else r[i]=r[i]||[],r[i].push(...e[i])}}function Jr(e){return{...e.instance?.normalizedInjections.vertex||{},...e.instance?.normalizedInjections.fragment||{}}}function Qr(e,t,n){let r;switch(t){case"vertex":r=e.vs||"";break;case"fragment":r=e.fs||"";break;case"wgsl":r=e.source||"";break;default:Ct(!1)}if(!e.name)throw new Error("Shader module must have a name");Fn(e,t,{log:n});const i=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let o=`// ----- MODULE ${e.name} ---------------\n\n`;return"wgsl"!==t&&(o+=`#define MODULE_${i}\n`),o+=`${r}\n`,o}function ei(e,t,n){const r=[],i={sawSupportedBindingDeclaration:mt(e,ut).length>0,nextHintedBindingLocation:"number"==typeof t.firstBindingSlot?t.firstBindingSlot:null},o=gt(e,ut,e=>function(e,t){const{module:n,context:r,bindingAssignments:i,relocationState:o}=t,{match:s,bindingToken:a,groupToken:c,name:l}=e,u=Number(c);if("auto"===a){const e=oi(u,n.name,l),t=r.bindingRegistry?.get(e),a=void 0!==t?t:function(e,t,n,r,i){const o=t.get(e)||/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,a=`${e}:`,c=`${a}${n}:`;for(const[u,h]of i||[])u.startsWith(c)&&s.add(h);let l=r??(0===e?Yr:o.size>0?Math.max(...o)+1:0);for(;o.has(l)||s.has(l);)l++;for(const[u,h]of i||[])h===l&&u.startsWith(a)&&i?.delete(u);return l}(u,r.usedBindingsByGroup,n.name,o.nextHintedBindingLocation??void 0,r.bindingRegistry);return ri(n.name,u,a,l),void 0!==t&&function(e,t,n,r){const i=e.get(t);if(!i)return!1;const o=i.get(n);if(!o)return!1;if(o!==r)throw new Error(`Registered module binding "${r}" collided with "${o}": group ${t}, binding ${n}.`);return!0}(r.reservedBindingKeysByGroup,u,a,e)?(i.push({moduleName:n.name,name:l,group:u,location:a}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${a})`)):(ii(r.usedBindingsByGroup,u,a,`module "${n.name}" binding "${l}"`),r.bindingRegistry?.set(e,a),i.push({moduleName:n.name,name:l,group:u,location:a}),null!==o.nextHintedBindingLocation&&void 0===t&&(o.nextHintedBindingLocation=a+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${a})`))}const h=Number(a);return ri(n.name,u,h,l),ii(r.usedBindingsByGroup,u,h,`module "${n.name}" binding "${l}"`),i.push({moduleName:n.name,name:l,group:u,location:h}),s}(e,{module:t,context:n,bindingAssignments:r,relocationState:i}));if(bt(e)&&!i.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:r}}function ti(e,t){const n=[],r=gr(e.source||"",{defines:t});for(const i of mt(r,ut))n.push({name:i.name,group:Number(i.groupToken)});return n}function ni(e,t,n){if(0===e&&t>=Yr)throw new Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below 100.`)}function ri(e,t,n,r){if(0===t&&n<Yr)throw new Error(`Module "${e}" binding "${r}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be 100 or higher.`)}function ii(e,t,n,r){const i=e.get(t)||/* @__PURE__ */new Set;if(i.has(n))throw new Error(`Duplicate WGSL binding assignment for ${r}: group ${t}, binding ${n}.`);i.add(n),e.set(t,i)}function oi(e,t,n){return`${e}:${t}:${n}`}var si=class e{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(t){return Ct("glsl"===t||"wgsl"===t),"wgsl"===t?(e.defaultShaderAssemblers.wgsl=e.defaultShaderAssemblers.wgsl||new ci,e.defaultShaderAssemblers.wgsl):(e.defaultShaderAssemblers.glsl=e.defaultShaderAssemblers.glsl||new ai,e.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),n={};let r=0;for(let i=0,o=this._defaultModules.length;i<o;++i){const e=this._defaultModules[i],o=e.name;t[r++]=e,n[o]=!0}for(let i=0,o=e.length;i<o;++i){const o=e[i],s=o.name;n[s]||(t[r++]=o,n[s]=!0)}return t.length=r,Yt(t),t}},ai=class extends si{shaderLanguage="glsl";assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),n=this._hookFunctions;return{...qr({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}},ci=class e extends si{shaderLanguage="wgsl";_wgslBindingRegistry=/* @__PURE__ */new Map;assembleWGSLShader(t){const n=this._getModuleList(t.modules),r=this._hookFunctions,i=e.getShaderPreprocessorDefines(t,n),o="wgsl"===t.platformInfo.shaderLanguage&&t.source?gr(t.source,{defines:i}):t.source,{source:s,getUniforms:a,bindingAssignments:c}=Xr({...t,source:o,defines:i,_bindingRegistry:this._wgslBindingRegistry,modules:n,hookFunctions:r}),l="wgsl"===t.platformInfo.shaderLanguage?gr(s,{defines:i}):s;return{source:l,getUniforms:a,modules:n,bindingAssignments:c,bindingTable:rr(l,c),shaderLayout:_t(l,{vertexEntryPoint:t.vertexEntryPoint,scanVertexAttributes:t.scanVertexAttributes})}}static getShaderPreprocessorDefines(t,n){return{...e.getPlatformPreprocessorDefines(t.platformInfo),...n.reduce((e,t)=>(Object.assign(e,t.defines),e),{}),...t.defines}}static getPlatformPreprocessorDefines(e){const t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:"webgpu"===e.type&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:"webgpu"===e.type&&"nvidia"!==e.gpu.toLowerCase()&&"amd"!==e.gpu.toLowerCase(),LUMA_FP64_INTEGER_ARITHMETIC:"webgpu"===e.type&&"apple"===e.gpu.toLowerCase()}}},li=1/Math.PI*180,ui=1/180*Math.PI;globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};var hi=globalThis.mathgl.config;function di(e,{precision:t=hi.precision}={}){return e=function(e){return Math.round(e/hi.EPSILON)*hi.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function fi(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pi(e){return function(e,t){return vi(e,e=>e*ui,t)}(e)}function mi(e){return gi(e)}function gi(e,t){return vi(e,e=>e*li,t)}function bi(e,t,n){return vi(e,e=>Math.max(t,Math.min(n,e)))}function _i(e,t,n){return fi(e)?e.map((e,r)=>_i(e,t[r],n)):n*t+(1-n)*e}function yi(e,t,n){const r=hi.EPSILON;n&&(hi.EPSILON=n);try{if(e===t)return!0;if(fi(e)&&fi(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!yi(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=hi.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{hi.EPSILON=r}}function vi(e,t,n){if(fi(e)){const r=e;n=n||function(e){return e.clone?e.clone():new Array(e.length)}(r);for(let i=0;i<n.length&&i<r.length;++i){const r="number"==typeof e?e:e[i];n[i]=t(r,i,n)}return n}return t(e)}var wi=class extends Array{clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:fi(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(hi)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+di(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!yi(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(void 0===n)return this.lerp(this,e,t);for(let r=0;r<this.ELEMENTS;++r){const i=e[r],o="number"==typeof t?t:t[r];this[r]=i+n*(o-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(hi.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function Ei(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function xi(e,t,n=""){if(hi.debug&&!function(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Ti(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Mi=class extends wi{get x(){return this[0]}set x(e){this[0]=Ei(e)}get y(){return this[1]}set y(e){this[1]=Ei(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){const r=this[n]-e[n];t+=r*r}return Ei(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return Ei(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Ti(e>=0&&e<this.ELEMENTS,"index is out of range"),Ei(this[e])}setComponent(e,t){return Ti(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}},Si=1e-6,Pi="undefined"!=typeof Float32Array?Float32Array:Array;function Oi(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Ai(e,t,n,r){const i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e}function ji(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e}function Li(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e}function Ii(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e}function Ci(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}var Ri=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e};!function(){const e=function(){const e=new Pi(2);return Pi!=Float32Array&&(e[0]=0,e[1]=0),e}()}();function $i(e,t,n){const r=t[0],i=t[1],o=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/o,e[1]=(n[1]*r+n[5]*i)/o,e}function ki(e,t,n){const r=t[0],i=t[1],o=t[2],s=n[3]*r+n[7]*i+n[11]*o||1;return e[0]=(n[0]*r+n[4]*i+n[8]*o)/s,e[1]=(n[1]*r+n[5]*i+n[9]*o)/s,e[2]=(n[2]*r+n[6]*i+n[10]*o)/s,e}function Ni(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2],e[3]=t[3],e}function zi(e,t,n){const r=t[0],i=t[1],o=t[2];return e[0]=n[0]*r+n[3]*i+n[6]*o,e[1]=n[1]*r+n[4]*i+n[7]*o,e[2]=n[2]*r+n[5]*i+n[8]*o,e[3]=t[3],e}function Di(){const e=new Pi(3);return Pi!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Ui(e){const t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Wi(e,t,n){const r=new Pi(3);return r[0]=e,r[1]=t,r[2]=n,r}function Fi(e,t){const n=t[0],r=t[1],i=t[2];let o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Bi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Gi(e,t,n){const r=t[0],i=t[1],o=t[2],s=n[0],a=n[1],c=n[2];return e[0]=i*c-o*a,e[1]=o*s-r*c,e[2]=r*a-i*s,e}function Vi(e,t,n,r){const i=t[0],o=t[1],s=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=s+r*(n[2]-s),e}function Yi(e,t,n){const r=t[0],i=t[1],o=t[2];let s=n[3]*r+n[7]*i+n[11]*o+n[15];return s=s||1,e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/s,e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/s,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/s,e}function Xi(e,t,n){const r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e}function qi(e,t,n){const r=n[0],i=n[1],o=n[2],s=n[3],a=t[0],c=t[1],l=t[2];let u=i*l-o*c,h=o*a-r*l,d=r*c-i*a,f=i*d-o*h,p=o*u-r*d,m=r*h-i*u;const g=2*s;return u*=g,h*=g,d*=g,f*=2,p*=2,m*=2,e[0]=a+u+f,e[1]=c+h+p,e[2]=l+d+m,e}var Hi,Zi=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e},Ki=Ui,Ji=function(e){const t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},Qi=(function(){const e=Di()}(),[0,0,0]),eo=class e extends Mi{static get ZERO(){return Hi||(Hi=new e(0,0,0),Object.freeze(Hi)),Hi}constructor(e=0,t=0,n=0){super(-0,-0,-0),1===arguments.length&&fi(e)?this.copy(e):(hi.debug&&(Ei(e),Ei(t),Ei(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return hi.debug&&(Ei(e.x),Ei(e.y),Ei(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Ei(e)}angle(e){return function(e,t){const n=e[0],r=e[1],i=e[2],o=t[0],s=t[1],a=t[2],c=Math.sqrt((n*n+r*r+i*i)*(o*o+s*s+a*a)),l=c&&Bi(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}(this,e)}cross(e){return Gi(this,this,e),this.check()}rotateX({radians:e,origin:t=Qi}){return function(e,t,n,r){const i=[],o=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2]}(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Qi}){return function(e,t,n,r){const i=[],o=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2]}(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Qi}){return function(e,t,n,r){const i=[],o=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2]}(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Yi(this,this,e),this.check()}transformAsVector(e){return ki(this,this,e),this.check()}transformByMatrix3(e){return Xi(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,n){const r=t[0],i=t[1];e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return qi(this,this,e),this.check()}},to=class extends wi{toString(){let e="[";if(hi.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=Ei(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const n=e*this.RANK;for(let r=0;r<this.RANK;++r)t[r]=this[n+r];return t}setColumn(e,t){const n=e*this.RANK;for(let r=0;r<this.RANK;++r)this[n+r]=t[r];return this}};function no(e,t){const n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],b=t[15],_=n*a-r*s,y=n*c-i*s,v=n*l-o*s,w=r*c-i*a,E=r*l-o*a,x=i*l-o*c,T=u*m-h*p,M=u*g-d*p,S=u*b-f*p,P=h*g-d*m,O=h*b-f*m,A=d*b-f*g;let j=_*A-y*O+v*P+w*S-E*M+x*T;return j?(j=1/j,e[0]=(a*A-c*O+l*P)*j,e[1]=(i*O-r*A-o*P)*j,e[2]=(m*x-g*E+b*w)*j,e[3]=(d*E-h*x-f*w)*j,e[4]=(c*S-s*A-l*M)*j,e[5]=(n*A-i*S+o*M)*j,e[6]=(g*v-p*x-b*y)*j,e[7]=(u*x-d*v+f*y)*j,e[8]=(s*O-a*S+l*T)*j,e[9]=(r*S-n*O-o*T)*j,e[10]=(p*E-m*v+b*_)*j,e[11]=(h*v-u*E-f*_)*j,e[12]=(a*M-s*P-c*T)*j,e[13]=(n*P-r*M+i*T)*j,e[14]=(m*y-p*w-g*_)*j,e[15]=(u*w-h*y+d*_)*j,e):null}function ro(e,t,n){const r=t[0],i=t[1],o=t[2],s=t[3],a=t[4],c=t[5],l=t[6],u=t[7],h=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],b=t[14],_=t[15];let y=n[0],v=n[1],w=n[2],E=n[3];return e[0]=y*r+v*a+w*h+E*m,e[1]=y*i+v*c+w*d+E*g,e[2]=y*o+v*l+w*f+E*b,e[3]=y*s+v*u+w*p+E*_,y=n[4],v=n[5],w=n[6],E=n[7],e[4]=y*r+v*a+w*h+E*m,e[5]=y*i+v*c+w*d+E*g,e[6]=y*o+v*l+w*f+E*b,e[7]=y*s+v*u+w*p+E*_,y=n[8],v=n[9],w=n[10],E=n[11],e[8]=y*r+v*a+w*h+E*m,e[9]=y*i+v*c+w*d+E*g,e[10]=y*o+v*l+w*f+E*b,e[11]=y*s+v*u+w*p+E*_,y=n[12],v=n[13],w=n[14],E=n[15],e[12]=y*r+v*a+w*h+E*m,e[13]=y*i+v*c+w*d+E*g,e[14]=y*o+v*l+w*f+E*b,e[15]=y*s+v*u+w*p+E*_,e}function io(e,t,n){const r=n[0],i=n[1],o=n[2];let s,a,c,l,u,h,d,f,p,m,g,b;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*o+t[12],e[13]=t[1]*r+t[5]*i+t[9]*o+t[13],e[14]=t[2]*r+t[6]*i+t[10]*o+t[14],e[15]=t[3]*r+t[7]*i+t[11]*o+t[15]):(s=t[0],a=t[1],c=t[2],l=t[3],u=t[4],h=t[5],d=t[6],f=t[7],p=t[8],m=t[9],g=t[10],b=t[11],e[0]=s,e[1]=a,e[2]=c,e[3]=l,e[4]=u,e[5]=h,e[6]=d,e[7]=f,e[8]=p,e[9]=m,e[10]=g,e[11]=b,e[12]=s*r+u*i+p*o+t[12],e[13]=a*r+h*i+m*o+t[13],e[14]=c*r+d*i+g*o+t[14],e[15]=l*r+f*i+b*o+t[15]),e}function oo(e,t,n){const r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function so(e,t,n){const r=Math.sin(n),i=Math.cos(n),o=t[4],s=t[5],a=t[6],c=t[7],l=t[8],u=t[9],h=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]=o*i+l*r,e[5]=s*i+u*r,e[6]=a*i+h*r,e[7]=c*i+d*r,e[8]=l*i-o*r,e[9]=u*i-s*r,e[10]=h*i-a*r,e[11]=d*i-c*r,e}function ao(e,t,n){const r=Math.sin(n),i=Math.cos(n),o=t[0],s=t[1],a=t[2],c=t[3],l=t[4],u=t[5],h=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]=o*i+l*r,e[1]=s*i+u*r,e[2]=a*i+h*r,e[3]=c*i+d*r,e[4]=l*i-o*r,e[5]=u*i-s*r,e[6]=h*i-a*r,e[7]=d*i-c*r,e}function co(e,t){const n=t[0],r=t[1],i=t[2],o=t[4],s=t[5],a=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+r*r+i*i),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(c*c+l*l+u*u),e}var lo=function(e,t,n,r,i){const o=1/Math.tan(t/2);if(e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){const t=1/(r-i);e[10]=(i+r)*t,e[14]=2*i*r*t}else e[10]=-1,e[14]=-2*r;return e};var uo=function(e,t,n,r,i,o,s){const a=1/(t-n),c=1/(r-i),l=1/(o-s);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+n)*a,e[13]=(i+r)*c,e[14]=(s+o)*l,e[15]=1,e};function ho(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function fo(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function po(e){const t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)}function mo(e){const t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i}function go(e,t){const n=t[0],r=t[1],i=t[2],o=t[3];let s=n*n+r*r+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=n*s,e[1]=r*s,e[2]=i*s,e[3]=o*s,e}function bo(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function _o(e,t,n,r){const i=t[0],o=t[1],s=t[2],a=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=s+r*(n[2]-s),e[3]=a+r*(n[3]-a),e}function yo(e,t,n){const r=t[0],i=t[1],o=t[2],s=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*s,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*s,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*s,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*s,e}function vo(e,t,n){const r=t[0],i=t[1],o=t[2],s=n[0],a=n[1],c=n[2],l=n[3],u=l*r+a*o-c*i,h=l*i+c*r-s*o,d=l*o+s*i-a*r,f=-s*r-a*i-c*o;return e[0]=u*l+f*-s+h*-c-d*-a,e[1]=h*l+f*-a+d*-s-u*-c,e[2]=d*l+f*-c+u*-a-h*-s,e[3]=t[3],e}var wo;!function(){const e=function(){const e=new Pi(4);return Pi!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();!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"}(wo||(wo={}));var Eo,xo,To=45*Math.PI/180,Mo=1,So=.1,Po=500,Oo=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Ao=class extends to{static get IDENTITY(){return function(){xo||(xo=new Ao,Object.freeze(xo));return xo}()}static get ZERO(){return function(){Eo||(Eo=new Ao([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Eo));return Eo}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return wo}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,r,i,o,s,a,c,l,u,h,d,f,p,m){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=o,this[6]=s,this[7]=a,this[8]=c,this[9]=l,this[10]=u,this[11]=h,this[12]=d,this[13]=f,this[14]=p,this[15]=m,this.check()}setRowMajor(e,t,n,r,i,o,s,a,c,l,u,h,d,f,p,m){return this[0]=e,this[1]=i,this[2]=c,this[3]=d,this[4]=t,this[5]=o,this[6]=l,this[7]=f,this[8]=n,this[9]=s,this[10]=u,this[11]=p,this[12]=r,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Oo)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const n=t[0],r=t[1],i=t[2],o=t[3],s=n+n,a=r+r,c=i+i,l=n*s,u=r*s,h=r*a,d=i*s,f=i*a,p=i*c,m=o*s,g=o*a,b=o*c;e[0]=1-h-p,e[1]=u+b,e[2]=d-g,e[3]=0,e[4]=u-b,e[5]=1-l-p,e[6]=f+m,e[7]=0,e[8]=d+g,e[9]=f-m,e[10]=1-l-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:n,bottom:r,top:i,near:o=So,far:s=Po}=e;return s===1/0?function(e,t,n,r,i,o){const s=2*o/(n-t),a=2*o/(i-r),c=(n+t)/(n-t),l=(i+r)/(i-r),u=-1,h=-1,d=-2*o;e[0]=s,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]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,n,r,i,o):function(e,t,n,r,i,o,s){const a=1/(n-t),c=1/(i-r),l=1/(o-s);e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*c,e[6]=0,e[7]=0,e[8]=(n+t)*a,e[9]=(i+r)*c,e[10]=(s+o)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*l,e[15]=0}(this,t,n,r,i,o,s),this.check()}lookAt(e){const{eye:t,center:n=[0,0,0],up:r=[0,1,0]}=e;return function(e,t,n,r){let i,o,s,a,c,l,u,h,d,f;const p=t[0],m=t[1],g=t[2],b=r[0],_=r[1],y=r[2],v=n[0],w=n[1],E=n[2];Math.abs(p-v)<1e-6&&Math.abs(m-w)<1e-6&&Math.abs(g-E)<1e-6?function(e){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):(h=p-v,d=m-w,f=g-E,i=1/Math.sqrt(h*h+d*d+f*f),h*=i,d*=i,f*=i,o=_*f-y*d,s=y*h-b*f,a=b*d-_*h,i=Math.sqrt(o*o+s*s+a*a),i?(i=1/i,o*=i,s*=i,a*=i):(o=0,s=0,a=0),c=d*a-f*s,l=f*o-h*a,u=h*s-d*o,i=Math.sqrt(c*c+l*l+u*u),i?(i=1/i,c*=i,l*=i,u*=i):(c=0,l=0,u=0),e[0]=o,e[1]=c,e[2]=h,e[3]=0,e[4]=s,e[5]=l,e[6]=d,e[7]=0,e[8]=a,e[9]=u,e[10]=f,e[11]=0,e[12]=-(o*p+s*m+a*g),e[13]=-(c*p+l*m+u*g),e[14]=-(h*p+d*m+f*g),e[15]=1)}(this,t,n,r),this.check()}ortho(e){const{left:t,right:n,bottom:r,top:i,near:o=So,far:s=Po}=e;return uo(this,t,n,r,i,o,s),this.check()}orthographic(e){const{fovy:t=To,aspect:n=Mo,focalDistance:r=1,near:i=So,far:o=Po}=e;jo(t);const s=t/2,a=r*Math.tan(s),c=a*n;return this.ortho({left:-c,right:c,bottom:-a,top:a,near:i,far:o})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:n=1,near:r=.1,far:i=500}=e;return jo(t),lo(this,t,n,r,i),this.check()}determinant(){return function(e){const t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=t*s-n*o,b=t*a-r*o,_=n*a-r*s,y=l*p-u*f,v=l*m-h*f,w=u*m-h*p;return c*(t*w-n*v+r*y)-i*(o*w-s*v+a*y)+e[15]*(l*_-u*b+h*g)-d*(f*_-p*b+m*g)}(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),r=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),r=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*o,e}transpose(){return function(e,t){if(e===t){const n=t[1],r=t[2],i=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=s,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]}(this,this),this.check()}invert(){return no(this,this),this.check()}multiplyLeft(e){return ro(this,e,this),this.check()}multiplyRight(e){return ro(this,this,e),this.check()}rotateX(e){return so(this,this,e),this.check()}rotateY(e){return function(e,t,n){const r=Math.sin(n),i=Math.cos(n),o=t[0],s=t[1],a=t[2],c=t[3],l=t[8],u=t[9],h=t[10],d=t[11];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]=o*i-l*r,e[1]=s*i-u*r,e[2]=a*i-h*r,e[3]=c*i-d*r,e[8]=o*r+l*i,e[9]=s*r+u*i,e[10]=a*r+h*i,e[11]=c*r+d*i}(this,this,e),this.check()}rotateZ(e){return ao(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,n,r){let i,o,s,a,c,l,u,h,d,f,p,m,g,b,_,y,v,w,E,x,T,M,S,P,O=r[0],A=r[1],j=r[2],L=Math.sqrt(O*O+A*A+j*j);L<1e-6||(L=1/L,O*=L,A*=L,j*=L,o=Math.sin(n),i=Math.cos(n),s=1-i,a=t[0],c=t[1],l=t[2],u=t[3],h=t[4],d=t[5],f=t[6],p=t[7],m=t[8],g=t[9],b=t[10],_=t[11],y=O*O*s+i,v=A*O*s+j*o,w=j*O*s-A*o,E=O*A*s-j*o,x=A*A*s+i,T=j*A*s+O*o,M=O*j*s+A*o,S=A*j*s-O*o,P=j*j*s+i,e[0]=a*y+h*v+m*w,e[1]=c*y+d*v+g*w,e[2]=l*y+f*v+b*w,e[3]=u*y+p*v+_*w,e[4]=a*E+h*x+m*T,e[5]=c*E+d*x+g*T,e[6]=l*E+f*x+b*T,e[7]=u*E+p*x+_*T,e[8]=a*M+h*S+m*P,e[9]=c*M+d*S+g*P,e[10]=l*M+f*S+b*P,e[11]=u*M+p*S+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){return oo(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return io(this,this,e),this.check()}transform(e,t){return 4===e.length?(xi(t=yo(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:n}=e;let r;switch(n){case 2:r=Ci(t||[-0,-0],e,this);break;case 3:r=Yi(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return xi(r,e.length),r}transformAsVector(e,t){let n;switch(e.length){case 2:n=$i(t||[-0,-0],e,this);break;case 3:n=ki(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return xi(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}};function jo(e){if(e>2*Math.PI)throw Error("expected radians")}var Lo,Io,Co,Ro={name:"fp32",source:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst FP32_TWO_PI: f32 = 6.2831854820251465;\nconst FP32_PI_2: f32 = 1.5707963705062866;\nconst FP32_PI_16: f32 = 0.1963495463132858;\n\nconst FP32_SIN_TABLE_0: f32 = 0.19509032368659973;\nconst FP32_SIN_TABLE_1: f32 = 0.3826834261417389;\nconst FP32_SIN_TABLE_2: f32 = 0.5555702447891235;\nconst FP32_SIN_TABLE_3: f32 = 0.7071067690849304;\n\nconst FP32_COS_TABLE_0: f32 = 0.9807852506637573;\nconst FP32_COS_TABLE_1: f32 = 0.9238795042037964;\nconst FP32_COS_TABLE_2: f32 = 0.8314695954322815;\nconst FP32_COS_TABLE_3: f32 = 0.7071067690849304;\n\nconst FP32_INVERSE_FACTORIAL_3: f32 = 1.666666716337204e-01;\nconst FP32_INVERSE_FACTORIAL_5: f32 = 8.333333767950535e-03;\nconst FP32_INVERSE_FACTORIAL_7: f32 = 1.9841270113829523e-04;\nconst FP32_INVERSE_FACTORIAL_9: f32 = 2.75573188446287533e-06;\nconst FP32_OVERFLOW: f32 = 3.402823466e+38;\n\nfn sin_taylor_fp32(a: f32) -> f32 {\n if (a == 0.0) {\n return 0.0;\n }\n\n let x = -a * a;\n var sum = a;\n var term = a;\n\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_3;\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_5;\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_7;\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_9;\n\n return sum;\n}\n\nfn tan_taylor_fp32(a: f32) -> f32 {\n if (a == 0.0) {\n return 0.0;\n }\n\n let z = floor(a / FP32_TWO_PI);\n let reduced = a - FP32_TWO_PI * z;\n\n var quadrantValue = floor(reduced / FP32_PI_2 + 0.5);\n let quadrant = i32(quadrantValue);\n if (quadrant < -2 || quadrant > 2) {\n return FP32_OVERFLOW;\n }\n\n var angle = reduced - FP32_PI_2 * quadrantValue;\n quadrantValue = floor(angle / FP32_PI_16 + 0.5);\n let tableIndex = i32(quadrantValue);\n let absoluteTableIndex = abs(tableIndex);\n if (absoluteTableIndex > 4) {\n return FP32_OVERFLOW;\n }\n\n angle = angle - FP32_PI_16 * quadrantValue;\n let sinAngle = sin_taylor_fp32(angle);\n let cosAngle = sqrt(1.0 - sinAngle * sinAngle);\n\n var tableCos = 0.0;\n var tableSin = 0.0;\n if (absoluteTableIndex == 1) {\n tableCos = FP32_COS_TABLE_0;\n tableSin = FP32_SIN_TABLE_0;\n } else if (absoluteTableIndex == 2) {\n tableCos = FP32_COS_TABLE_1;\n tableSin = FP32_SIN_TABLE_1;\n } else if (absoluteTableIndex == 3) {\n tableCos = FP32_COS_TABLE_2;\n tableSin = FP32_SIN_TABLE_2;\n } else if (absoluteTableIndex == 4) {\n tableCos = FP32_COS_TABLE_3;\n tableSin = FP32_SIN_TABLE_3;\n }\n\n var sinReduced = sinAngle;\n var cosReduced = cosAngle;\n if (tableIndex > 0) {\n sinReduced = tableCos * sinAngle + tableSin * cosAngle;\n cosReduced = tableCos * cosAngle - tableSin * sinAngle;\n } else if (tableIndex < 0) {\n sinReduced = tableCos * sinAngle - tableSin * cosAngle;\n cosReduced = tableCos * cosAngle + tableSin * sinAngle;\n }\n\n var sinValue = 0.0;\n var cosValue = 0.0;\n if (quadrant == 0) {\n sinValue = sinReduced;\n cosValue = cosReduced;\n } else if (quadrant == 1) {\n sinValue = cosReduced;\n cosValue = -sinReduced;\n } else if (quadrant == -1) {\n sinValue = -cosReduced;\n cosValue = sinReduced;\n } else {\n sinValue = -sinReduced;\n cosValue = -cosReduced;\n }\n\n return sinValue / cosValue;\n}\n\nfn tan_fp32(a: f32) -> f32 {\n return tan_taylor_fp32(a);\n}\n#else\nfn tan_fp32(a: f32) -> f32 {\n return tan(a);\n}\n#endif\n",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n\n// All these functions are for substituting tan() function from Intel GPU only\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!\n\nfloat sin_taylor_fp32(float a) {\n float r, s, t, x;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n x = -a * a;\n s = a;\n r = a;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_3;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_5;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_7;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_9;\n s = s + t;\n\n return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n if (a == 0.0) {\n sin_t = 0.0;\n cos_t = 1.0;\n }\n sin_t = sin_taylor_fp32(a);\n cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n float sin_a;\n float cos_a;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n // 2pi range reduction\n float z = floor(a / TWO_PI);\n float r = a - TWO_PI * z;\n\n float t;\n float q = floor(r / PI_2 + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return 1.0 / 0.0;\n }\n\n t = r - PI_2 * q;\n\n q = floor(t / PI_16 + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return 1.0 / 0.0;\n } else {\n t = t - PI_16 * q;\n }\n\n float u = 0.0;\n float v = 0.0;\n\n float sin_t, cos_t;\n float s, c;\n sincos_taylor_fp32(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0;\n v = SIN_TABLE_0;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1;\n v = SIN_TABLE_1;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2;\n v = SIN_TABLE_2;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3;\n v = SIN_TABLE_3;\n }\n if (k > 0) {\n s = u * sin_t + v * cos_t;\n c = u * cos_t - v * sin_t;\n } else {\n s = u * sin_t - v * cos_t;\n c = u * cos_t + v * sin_t;\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n return tan_taylor_fp32(a);\n#else\n return tan(a);\n#endif\n}\n"},$o="#define SMOOTH_EDGE_RADIUS 0.5",ko={name:"geometry",source:"const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4<f32>,\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry_: VertexGeometry = VertexGeometry(\n vec4<f32>(0.0, 0.0, 1.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2<f32>,\n};\n\nvar<private> fragmentGeometry: FragmentGeometry;\n\nfn smoothedge(edge: f32, x: f32) -> f32 {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n",vs:`${$o}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`${$o}\n\nstruct FragmentGeometry {\n vec2 uv;\n};\nFragmentGeometry geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};!function(e){e[e.Start=1]="Start",e[e.Move=2]="Move",e[e.End=4]="End",e[e.Cancel=8]="Cancel"}(Lo||(Lo={})),function(e){e[e.None=0]="None",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Up=4]="Up",e[e.Down=8]="Down",e[e.Horizontal=3]="Horizontal",e[e.Vertical=12]="Vertical",e[e.All=15]="All"}(Io||(Io={})),function(e){e[e.Possible=1]="Possible",e[e.Began=2]="Began",e[e.Changed=4]="Changed",e[e.Ended=8]="Ended",e[e.Recognized=8]="Recognized",e[e.Cancelled=16]="Cancelled",e[e.Failed=32]="Failed"}(Co||(Co={}));var No="manipulation",zo="none",Do="pan-x",Uo="pan-y";var Wo=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){"compute"===e&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(const t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return function(e){if(e.includes("none"))return zo;const t=e.includes(Do),n=e.includes(Uo);return t&&n?zo:t||n?t?Do:Uo:e.includes("manipulation")?No:"auto"}(e.join(" "))}};function Fo(e){return e.trim().split(/\s+/g)}function Bo(e,t,n){if(e)for(const r of Fo(t))e.addEventListener(r,n,!1)}function Go(e,t,n){if(e)for(const r of Fo(t))e.removeEventListener(r,n,!1)}function Vo(e){return(e.ownerDocument||e).defaultView}function Yo(e){const t=e.length;if(1===t)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,r=0,i=0;for(;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:Math.round(n/t),y:Math.round(r/t)}}function Xo(e){const t=[];let n=0;for(;n<e.pointers.length;)t[n]={clientX:Math.round(e.pointers[n].clientX),clientY:Math.round(e.pointers[n].clientY)},n++;return{timeStamp:Date.now(),pointers:t,center:Yo(t),deltaX:e.deltaX,deltaY:e.deltaY}}function qo(e,t){const n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ho(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}function Zo(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY;return 180*Math.atan2(r,n)/Math.PI}function Ko(e,t){return e===t?Io.None:Math.abs(e)>=Math.abs(t)?e<0?Io.Left:Io.Right:t<0?Io.Up:Io.Down}function Jo(e,t,n){return{x:t/e||0,y:n/e||0}}function Qo(e,t){return"pointerId"in e?e.pointerId:t}function es(e,t){e.movementOrigin=new Map(t.map((e,t)=>[Qo(e,t),{clientX:e.clientX,clientY:e.clientY}])),e.firstMovementTime=void 0}function ts(e,t){const{session:n}=e,{pointers:r}=t,{length:i}=r;n.firstInput||(n.firstInput=Xo(t)),i>1&&!n.firstMultiple?n.firstMultiple=Xo(t):1===i&&(n.firstMultiple=!1);const{firstInput:o,firstMultiple:s}=n,a=s?s.center:o.center,c=t.center=Yo(r);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-o.timeStamp,function(e,t){const n=t.pointers.map(Qo);if(e.movementOrigin?.size===n.length&&n.every(t=>e.movementOrigin.has(t))||es(e,t.pointers),t.distancePerPointer=t.pointers.map((t,r)=>Ho(e.movementOrigin.get(n[r]),t)),t.eventType&Lo.Move&&t.distancePerPointer.some(e=>e>0)&&(e.firstMovementTime??(e.firstMovementTime=t.timeStamp)),t.movementDeltaTime=void 0===e.firstMovementTime?0:t.timeStamp-e.firstMovementTime,t.eventType&(Lo.End|Lo.Cancel)){const r=t.changedPointers.map(e=>Qo(e,t.pointers.indexOf(e)));es(e,t.pointers.filter((e,t)=>!r.includes(n[t])))}}(n,t),t.angle=function(e,t){const n=t.x-e.x,r=t.y-e.y;return 180*Math.atan2(r,n)/Math.PI}(a,c),t.distance=qo(a,c);const{deltaX:l,deltaY:u}=function(e,t){const n=t.center;let r=e.offsetDelta,i=e.prevDelta;const o=e.prevInput;return t.eventType!==Lo.Start&&o?.eventType!==Lo.End||(i=e.prevDelta={x:o?.deltaX||0,y:o?.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),{deltaX:i.x+(n.x-r.x),deltaY:i.y+(n.y-r.y)}}(n,t);t.deltaX=l,t.deltaY=u,t.offsetDirection=Ko(t.deltaX,t.deltaY);const h=Jo(t.deltaTime,t.deltaX,t.deltaY);var d,f;t.overallVelocityX=h.x,t.overallVelocityY=h.y,t.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,t.scale=s?(d=s.pointers,Ho((f=r)[0],f[1])/Ho(d[0],d[1])):1,t.rotation=s?function(e,t){return Zo(t[1],t[0])-Zo(e[1],e[0])}(s.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let p=e.element;return function(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}(t.srcEvent.target,p)&&(p=t.srcEvent.target),t.target=p,function(e,t){const n=e.lastInterval||t,r=t.timeStamp-n.timeStamp;let i,o,s,a;if(t.eventType!==Lo.Cancel&&(r>25||void 0===n.velocity)){const c=t.deltaX-n.deltaX,l=t.deltaY-n.deltaY,u=Jo(r,c,l);o=u.x,s=u.y,i=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=Ko(c,l),e.lastInterval=t}else i=n.velocity,o=n.velocityX,s=n.velocityY,a=n.direction;t.velocity=i,t.velocityX=o,t.velocityY=s,t.direction=a}(n,t),t}var ns=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=e=>{this.manager.options.enable&&this.handler(e)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){!function(e,t,n){const r=n.pointers.length,i=n.changedPointers.length,o=t&Lo.Start&&r-i===0,s=t&(Lo.End|Lo.Cancel)&&r-i===0;n.isFirst=Boolean(o),n.isFinal=Boolean(s),o&&(e.session={}),n.eventType=t;const a=ts(e,n);e.emit("hammer.input",a),e.recognize(a),e.session.prevInput=a}(this.manager,e,t)}init(){Bo(this.element,this.evEl,this.domHandler),Bo(this.target,this.evTarget,this.domHandler),Bo(Vo(this.element),this.evWin,this.domHandler)}destroy(){Go(this.element,this.evEl,this.domHandler),Go(this.target,this.evTarget,this.domHandler),Go(Vo(this.element),this.evWin,this.domHandler)}},rs={pointerdown:Lo.Start,pointermove:Lo.Move,pointerup:Lo.End,pointercancel:Lo.Cancel,pointerout:Lo.Cancel},is=class extends ns{constructor(e){super(e),this.evEl="pointerdown",this.evWin="pointermove pointerup pointercancel",this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){const{store:t}=this;let n=!1;const r=rs[e.type],i=e.pointerType,o="touch"===i;let s=t.findIndex(t=>t.pointerId===e.pointerId);r&Lo.Start&&(e.buttons||o)?s<0&&(t.push(e),s=t.length-1):r&(Lo.End|Lo.Cancel)&&(n=!0),s<0||(t[s]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:i,srcEvent:e}),n&&t.splice(s,1))}},os=["","webkit","Moz","MS","ms","o"];function ss(e,t){const n=t[0].toUpperCase()+t.slice(1);for(const r of os){const i=r?r+n:t;if(i in e)return i}}var as={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},cs=class{constructor(e,t){this.options={...as,...t,cssProps:{...as.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new is(this),this.touchAction=new Wo(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?2:1}recognize(e){const{session:t}=this;if(t.stopped)return;let n;this.session.prevented&&e.srcEvent.preventDefault();const{recognizers:r}=this;let{curRecognizer:i}=t;(!i||i&&i.state&Co.Recognized)&&(i=t.curRecognizer=null);let o=0;for(;o<r.length;)n=r[o],2===t.stopped||i&&n!==i&&!n.canRecognizeWith(i)?n.reset():n.recognize(e),!i&&n.state&(Co.Began|Co.Changed|Co.Ended)&&(i=t.curRecognizer=n),o++}get(e){const{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(const t of e)this.add(t);return this}const t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(const t of e)this.remove(t);return this}const t="string"==typeof e?this.get(e):e;if(t){const{recognizers:e}=this,n=e.indexOf(t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;const{handlers:n}=this;for(const r of Fo(e))n[r]=n[r]||[],n[r].push(t)}off(e,t){if(!e)return;const{handlers:n}=this;for(const r of Fo(e))t?n[r]&&n[r].splice(n[r].indexOf(t),1):delete n[r]}emit(e,t){const n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;const r=t;r.type=e,r.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](r),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){const{element:t}=this;if(t){for(const[n,r]of Object.entries(this.options.cssProps)){const i=ss(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=r):t.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}},ls=1;function us(e){return e&Co.Cancelled?"cancel":e&Co.Ended?"end":e&Co.Changed?"move":e&Co.Began?"start":""}var hs=class{constructor(e){this.options=e,this.id=ls++,this.state=Co.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(const t of e)this.recognizeWith(t);return this}let t;if("string"==typeof e){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;const{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(const t of e)this.dropRecognizeWith(t);return this}let t;return t="string"==typeof e?this.manager.get(e):e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(const t of e)this.requireFailure(t);return this}let t;if("string"==typeof e){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;const{requireFail:n}=this;return-1===n.indexOf(t)&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(const t of e)this.dropRequireFailure(t);return this}let t;if(t="string"==typeof e?this.manager.get(e):e,t){const e=this.requireFail.indexOf(t);e>-1&&this.requireFail.splice(e,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;const{state:t}=this;t<Co.Ended&&this.manager.emit(this.options.event+us(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=Co.Ended&&this.manager.emit(this.options.event+us(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=Co.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(Co.Failed|Co.Possible)))return!1;e++}return!0}recognize(e){const t={...e};if(!this.options.enable)return this.reset(),void(this.state=Co.Failed);this.state&(Co.Recognized|Co.Cancelled|Co.Failed)&&(this.state=Co.Possible),this.state=this.process(t),this.state&(Co.Began|Co.Changed|Co.Ended|Co.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}};function ds(e,t){return(void 0===t.distance||e.distance>=t.distance)&&(void 0===t.distancePerPointer||e.distancePerPointer.length>0&&e.distancePerPointer.every(e=>e>=t.distancePerPointer))&&(void 0===t.movementDeltaTime||e.movementDeltaTime>=t.movementDeltaTime)&&(void 0===t.rotation||(n=e.rotation,Math.abs(((n+180)%360+360)%360-180)>=t.rotation))&&(void 0===t.scale||Math.abs(e.scale-1)>=t.scale);var n}var fs=class extends hs{attrTest(e){const t=this.options.pointers;return 0===t||e.pointers.length===t}coherentTest(e){const t=this.options.coherent;return!t?.length||t.some(t=>ds(e,t))}process(e){const{state:t}=this,{eventType:n}=e,r=t&(Co.Began|Co.Changed),i=this.attrTest(e);return r&&(n&Lo.Cancel||!i)?t|Co.Cancelled:r||i?n&Lo.End?t|Co.Ended:t&Co.Began?t|Co.Changed:Co.Began:Co.Failed}},ps=["","start","move","end","cancel"],ms=class extends hs{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[No]}process(e){const{options:t}=this,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&Lo.Start&&0===this.count)return this.failTimeout();if(r&&i&&n){if(e.eventType!==Lo.End)return this.failTimeout();const n=!this.pTime||e.timeStamp-this.pTime<t.interval,r=!this.pCenter||qo(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,r&&n?this.count+=1:this.count=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=Co.Recognized,this.tryEmit(this._input)},t.interval),Co.Began):Co.Recognized}return Co.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Co.Failed},this.options.interval),Co.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===Co.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}},gs=class extends fs{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{"trackpad"===e.device&&this.handleTrackpadEvent(e)}}set(e){const{wheelSession:t,...n}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(n),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){const{srcEvent:n}=e,r=t.deltaX??e.deltaX,i=t.deltaY??e.deltaY,o=Ko(r,i),s=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY);return{pointers:[n,n],changedPointers:[n,n],pointerType:"trackpad",srcEvent:n,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:i,angle:180*Math.atan2(i,r)/Math.PI,distance:Math.sqrt(r*r+i*i),distancePerPointer:[s,s],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:n.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){const e=Boolean(this.wheelSession&&this.options.enable&&this.options.trackpad&&2===this.options.pointers);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}},bs=["","start","move","end","cancel","up","down","left","right"],_s=class extends gs{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Io.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){const{options:{direction:e}}=this,t=[];return e&Io.Horizontal&&t.push(Uo),e&Io.Vertical&&t.push(Do),t}getEventNames(){return bs.map(e=>this.options.event+e)}directionTest(e){const{options:t}=this;let n=!0,{distance:r}=e,{direction:i}=e;const o=e.deltaX,s=e.deltaY;return i&t.direction||(t.direction&Io.Horizontal?(i=0===o?Io.None:o<0?Io.Left:Io.Right,n=o!==this.pX,r=Math.abs(e.deltaX)):(i=0===s?Io.None:s<0?Io.Up:Io.Down,n=s!==this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&Boolean(i&t.direction)}attrTest(e){const t=Boolean(this.state&Co.Began),n=!(this.options.coherent?.length&&e.eventType&(Lo.End|Lo.Cancel));return super.attrTest(e)&&(t||n&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;const t=Io[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Co.Recognized|Co.Cancelled|Co.Failed)&&(this.state=Co.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}},ys=["","start","move","end","cancel","in","out"],vs=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}},ws=-1!==("undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"").indexOf("firefox"),Es=class extends vs{constructor(e,t,n){n.enable=n.enable??!1,super(e,t,n),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(ws&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=40)),e.shiftKey&&t&&(t*=.25),this.callback({type:"wheel",center:{x:e.clientX,y:e.clientY},delta:-t,device:this.options.wheelSession?.device??"unknown",srcEvent:e,pointerType:"mouse",target:e.target})},n.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){"wheel"===e&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}},xs={classificationDelay:32,endDelay:80},Ts=class{constructor(e,t={}){this.subscriptions=/* @__PURE__ */new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=/* @__PURE__ */new Set,this.listeningForControlKeys=!1,this.handleEvent=e=>{if(!this.hasSubscribers)return"unknown";const t=function(e,t){let n=e.deltaX,r=e.deltaY;1===e.deltaMode&&(n*=40,r*=40);return{event:e,timeStamp:e.timeStamp,deltaX:n,deltaY:r,isControlKeyDown:t}}(e,this.pressedControlKeys.size>0);let n=this.session;if(n&&t.timeStamp-n.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";n=null}n?(this.scheduleEnd(),this.addSample(n,t)):(n=this.startPendingSession(t),this.scheduleEnd());let{device:r}=n;return"unknown"===r&&(r=Ms(n.samples,!1),"unknown"!==r&&this.begin(n,r)),r},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||"unknown"!==this.session.device)return;const e=this.session,t=Ms(e.samples,!0);this.begin(e,"unknown"===t?"mouse":t)},this.end=()=>{if(!this.session)return;if("unknown"===this.session.device){const e=this.session,t=Ms(e.samples,!0);this.begin(e,"unknown"===t?"mouse":t)}if(!this.session)return;const e=this.session;this.emit(Lo.End,e.lastEvent),this.reset()},this.handleKeyDown=e=>{"Control"===e.key&&this.pressedControlKeys.add(e.code||e.key)},this.handleKeyUp=e=>{"Control"===e.key&&(e.code?this.pressedControlKeys.delete(e.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...xs,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){const t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){const e=this.session;e&&"unknown"!==e.device&&this.emit(Lo.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){const t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,"unknown"!==e.device){const n=e.samples[e.samples.length-2],r=t.timeStamp-n.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(Lo.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(Lo.Start,e.samples[0].event);const n=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=n>0?e.totalDeltaX/n:0,e.velocityY=n>0?e.totalDeltaY/n:0,this.emit(Lo.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,n){const r=this.session;if(!r||"unknown"===r.device)return;const i=e===Lo.Start,o=e===Lo.End||e===Lo.Cancel,s=i?r.firstTimeStamp:r.lastTimeStamp,a=i?0:Math.max(0,s-r.firstTimeStamp),c=i?0:r.totalDeltaX,l=i?0:r.totalDeltaY,u=a>0?c/a:0,h=a>0?l/a:0,d=i?0:n?.velocityX??r.velocityX,f=i?0:n?.velocityY??r.velocityY,p={eventType:e,device:r.device,srcEvent:t,timeStamp:s,center:{x:t.clientX,y:t.clientY},deltaX:c,deltaY:l,deltaTime:a,velocity:Math.abs(d)>Math.abs(f)?d:f,velocityX:d,velocityY:f,overallVelocity:Math.abs(u)>Math.abs(h)?u:h,overallVelocityX:u,overallVelocityY:h,isFirst:i,isFinal:o};for(const{listener:m}of[...this.subscriptions.values()])m(p)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){null!==this.classificationTimer&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){null!==this.endTimer&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){const e=this.hasSubscribers,t="undefined"!=typeof window?window:globalThis.document?.defaultView;t&&e!==this.listeningForControlKeys&&(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function Ms(e,t){return e.some(({event:e,isControlKeyDown:t})=>e.ctrlKey&&!t)?"trackpad":e.some(({event:e})=>0!==e.deltaMode)||e.some(Ss)||e.every(({event:e})=>{const t=e.wheelDelta;return void 0!==t&&Math.abs(t)%40==0})?"mouse":e.some(({deltaX:e})=>0!==e)||e.length>1&&function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Math.abs(n.deltaX)>40||Math.abs(n.deltaY)>40)return!1;if(t>0&&n.timeStamp-e[t-1].timeStamp>40)return!1}return!0}(e)?"trackpad":t?"mouse":"unknown"}function Ss({event:e,deltaX:t,deltaY:n}){if(0!==t||0===n)return!1;const r=Math.abs(n/4.000244140625);if(Number.isInteger(r))return!0;const i=e.wheelDelta;return"number"==typeof i&&0!==i&&i%120==0}var Ps=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],Os=class extends vs{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;const{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&Ps.forEach(e=>this.listen(e,!0))}destroy(){Ps.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t))}}handleOverEvent(e){this.enableOverEvent&&"mouseover"===e.type&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&"mouseout"===e.type&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&"mouseenter"===e.type&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&"mouseleave"===e.type&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":0===e.buttons&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}},As=["keydown","keyup"],js=class extends vs{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=e=>{const t=e.target||e.srcElement;"INPUT"===t.tagName&&"text"===t.type||"TEXTAREA"===t.tagName||(this.enableDownEvent&&"keydown"===e.type&&this.callback({type:"keydown",srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&"keyup"===e.type&&this.callback({type:"keyup",srcEvent:e,key:e.key,target:e.target}))};const{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&As.forEach(e=>this.listen(e,!0))}destroy(){As.forEach(e=>this.listen(e,!1))}enableEventType(e,t){"keydown"===e&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),"keyup"===e&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}},Ls=class extends vs{constructor(e,t,n){n.enable=n.enable??!1,super(e,t,n),this.handleEvent=e=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})},n.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){"contextmenu"===e&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}},Is={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function Cs(e){const t=Is[e.srcEvent.type];if(!t)return null;const{buttons:n,button:r}=e.srcEvent;let i=!1,o=!1,s=!1;return 2===t?(i=Boolean(1&n),o=Boolean(4&n),s=Boolean(2&n)):(i=0===r,o=1===r,s=2===r),{leftButton:i,middleButton:o,rightButton:s}}function Rs(e,t){const n=e.center;if(!n)return null;const r=t.getBoundingClientRect(),i=r.width/t.offsetWidth||1,o=r.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-r.left-t.clientLeft)/i,y:(n.y-r.top-t.clientTop)/o}}}var $s={srcElement:"root",priority:0},ks=class{constructor(e,t){this.handleEvent=e=>{if(this.isEmpty())return;const t=this._normalizeEvent(e);let n=e.srcEvent.target;for(;n&&n!==t.rootElement;){if(this._emit(t,n),t.handled)return;n=n.parentNode}this._emit(t,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=/* @__PURE__ */new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,r=!1,i=!1){const{handlers:o,handlersByElement:s}=this,a={...$s,...n};let c=s.get(a.srcElement);c||(c=[],s.set(a.srcElement,c));const l={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};r&&(l.once=!0),i&&(l.passive=!0),o.push(l),this._active=this._active||!l.passive;let u=c.length-1;for(;u>=0&&!(c[u].priority>=l.priority);)u--;c.splice(u+1,0,l)}remove(e,t){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type===e&&o.handler===t){n.splice(i,1);const e=r.get(o.srcElement);e.splice(e.indexOf(o),1),0===e.length&&r.delete(o.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){const n=this.handlersByElement.get(t);if(n){let t=!1;const r=()=>{e.handled=!0},i=()=>{e.handled=!0,t=!0},o=[];for(let s=0;s<n.length;s++){const{type:a,handler:c,once:l}=n[s];if(c({...e,type:a,stopPropagation:r,stopImmediatePropagation:i}),l&&o.push(n[s]),t)break}for(let e=0;e<o.length;e++){const{type:t,handler:n}=o[e];this.remove(t,n)}}}_normalizeEvent(e){const t=this.eventManager.getElement();return{...e,...Cs(e),...Rs(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function Ns(e){if("recognizer"in e)return e;let t;const n=Array.isArray(e)?[...e]:[e];return t="function"==typeof n[0]?new(n.shift())(n.shift()||{}):n.shift(),{recognizer:t,recognizeWith:"string"==typeof n[0]?[n[0]]:n[0],requireFailure:"string"==typeof n[1]?[n[1]]:n[1]}}var zs=class{constructor(e=null,t={}){if(this._onBasicInput=e=>{this.manager.emit(e.srcEvent.type,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=/* @__PURE__ */new Map,this.element=e,this.wheelSession=new Ts(e),e){this.manager=new cs(e,this.options);for(const e of this.options.recognizers){const{recognizer:t,recognizeWith:n,requireFailure:r}=Ns(e);this.manager.add(t),n&&t.recognizeWith(n),r&&t.requireFailure(r)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new Es(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new Os(e,this._onOtherEvent,{enable:!1}),this.keyInput=new js(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new Ls(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element?(this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()):this.wheelSession.destroy()}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){const{manager:n}=this;if(!n)return;const r=n.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,r,i){if("string"!=typeof e){n=t;for(const[t,o]of Object.entries(e))this._addEventHandler(t,o,n,r,i);return}const{manager:o,events:s}=this;if(!o)return;let a=s.get(e);if(!a){const t=this._getRecognizerName(e)||e;a=new ks(this,t),s.set(e,a),o&&o.on(e,a.handleEvent)}a.add(e,t,n,r,i),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(e,t){if("string"!=typeof e){for(const[t,n]of Object.entries(e))this._removeEventHandler(t,n);return}const{events:n}=this,r=n.get(e);if(r&&(r.remove(e,t),r.isEmpty())){const{recognizerName:e}=r;let t=!1;for(const r of n.values())if(r.recognizerName===e&&!r.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}},Ds={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(Ds,"IDENTITY",{get:()=>(rt.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),Ds.CARTESIAN)});var Us={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ws={common:0,meters:1,pixels:2},Fs={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Bs={multipan:[_s,{threshold:10,pointers:2,trackpad:!0}],pinch:[class extends gs{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[zo]}getEventNames(){return ys.map(e=>this.options.event+e)}attrTest(e){const t=Boolean(this.options.coherent?.length),n=Boolean(this.state&Co.Began),r=!(t&&e.eventType&(Lo.End|Lo.Cancel));return super.attrTest(e)&&(n||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(1!==e.scale){const t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Co.Recognized|Co.Cancelled|Co.Failed)&&(this.state=Co.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}},{trackpad:!0},null,["multipan"]],pan:[_s,{threshold:1},["pinch"],["multipan"]],dblclick:[ms,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[class extends hs{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[No]}getEventNames(){return ps.map(e=>this.options.event+e)}process(e){const{options:t}=this;return e.pointers.length!==t.pointers?(this.reset(),Co.Failed):e.eventType&Lo.Start?this._handleStart(e):e.eventType&Lo.Move?this._handleMove(e):e.eventType&Lo.Cancel?this._handleEnd(e,!0):e.eventType&Lo.End?this._handleEnd(e,!1):Co.Failed}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===Co.Began){if(!this._drag?.active||this._emittedStart)return;return this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),void this.manager.emit(this.options.event,e)}if(this.state===Co.Changed){if(!this._emittedStart)return;return this.manager.emit(`${this.options.event}move`,e),void this.manager.emit(this.options.event,e)}if(this.state===Co.Ended){if(!this._emittedStart)return;return this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),void(this._emittedStart=!1)}if(this.state===Co.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){const t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,Co.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,Co.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return Co.Failed;const t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t)<this.options.dragThreshold?Co.Began:(this._drag.active=!0,e.scale=Math.pow(2,t/this.options.pixelsPerScale),this._emittedStart?Co.Changed:Co.Began)}_handleEnd(e,t){if(this._drag&&this._isSamePointer(e,this._drag.pointerId)){const{active:n,startCenter:r}=this._drag;if(this._drag=null,this._tapStart=null,this._lastTap=null,!n)return this._emittedStart=!1,Co.Failed;const i=r.y-e.center.y;return e.scale=Math.pow(2,i/this.options.pixelsPerScale),t?Co.Cancelled:Co.Ended}return this._tapStart&&this._isSamePointer(e,this._tapStart.pointerId)?(this._isValidTap(e)?this._lastTap={center:e.center,timeStamp:e.timeStamp,pointerId:this._tapStart.pointerId}:this._lastTap=null,this._tapStart=null,Co.Failed):(t&&this.reset(),Co.Failed)}_isTapMatch(e,t){return e.timeStamp-t.timeStamp<=this.options.interval&&qo(e.center,t.center)<=this.options.threshold}_isValidTap(e){return e.deltaTime<=this.options.time&&e.distance<=this.options.threshold}_getPointerId(e){return"pointerId"in e.srcEvent?e.srcEvent.pointerId:null}_isSamePointer(e,t){return null===t||this._getPointerId(e)===t}},{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[ms,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function Gs(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}function Vs(e){let t,n={};return r=>{for(const i in r)if(!Gs(r[i],n[i])){t=e(r),n=r;break}return t}}var Ys=[0,0,0,0],Xs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],qs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Hs=[0,0,0],Zs=[0,0,0],Ks={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Js(e){const t=Ks[e];if(void 0===t)throw new Error(`Invalid coordinateSystem: ${e}`);return t}var Qs=Vs(function({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r}){const{projectionCenter:i,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=function(e,t,n){const{viewMatrixUncentered:r,projectionMatrix:i}=e;let{viewMatrix:o,viewProjectionMatrix:s}=e,a=Ys,c=Ys,l=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=ea(e,t,n);d&&(c=e.projectPosition(u||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=yo([],c,s),o=r||o,s=ro([],i,o),s=ro([],s,Xs));return{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,n,r),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=yo([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,f={coordinateSystem:Js(n),projectionMode:e.projectionMode,coordinateOrigin:c,commonOrigin:s.slice(0,3),center:i,pseudoMeters:Boolean(e._pseudoMeters),viewportSize:h,devicePixelRatio:t,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:Hs,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:o,modelMatrix:qs,cameraPosition:a};if(l){const t=e.getDistanceScales(l);switch(n){case"meter-offsets":f.commonUnitsPerWorldUnit=t.unitsPerMeter,f.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":e._pseudoMeters||(f.commonUnitsPerMeter=t.unitsPerMeter),f.commonUnitsPerWorldUnit=t.unitsPerDegree,f.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case"cartesian":f.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],f.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}if(e.projectionMode===Us.GLOBE&&"meter-offsets"===n){const e=6370972,t=256,n=r[0]*Math.PI/180,i=r[1]*Math.PI/180,o=Math.cos(i),s=((r[2]||0)/e+1)*t;f.commonOrigin=[Math.sin(n)*o*s,-Math.cos(n)*o*s,Math.sin(i)*s]}return f});function ea(e,t,n=Zs){n.length<3&&(n=[n[0],n[1],0]);let r,i=n,o=!0;switch(r="lnglat-offsets"===t||"meter-offsets"===t?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case Us.WEB_MERCATOR:"lnglat"===t?(r=[0,0,0],o=!1):"cartesian"===t&&(o=!1,r=e.unprojectPosition([Math.fround(e.center[0]),Math.fround(e.center[1]),0]));break;case Us.WEB_MERCATOR_AUTO_OFFSET:"lnglat"===t?i=r:"cartesian"===t&&(i=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],r=e.unprojectPosition(i),i[0]-=n[0],i[1]-=n[1],i[2]-=n[2]);break;case Us.IDENTITY:i=e.position.map(Math.fround),i[2]=i[2]||0;break;case Us.GLOBE:o=!1,r=null;break;default:o=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:o}}var ta=`${`${["default","lnglat","meter-offsets","lnglat-offsets","cartesian"].map(e=>`const COORDINATE_SYSTEM_${e.toUpperCase().replaceAll("-","_")}: i32 = ${Js(e)};`).join("")}\n${Object.keys(Us).map(e=>`const PROJECTION_MODE_${e}: i32 = ${Us[e]};`).join("")}\n${Object.keys(Ws).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${Ws[e]};`).join("")}\n\nconst TILE_SIZE: f32 = 512.0;\nconst PI: f32 = 3.1415926536;\nconst WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0);\nconst ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);\nconst EARTH_RADIUS: f32 = 6370972.0; // meters\nconst GLOBE_RADIUS: f32 = 256.0;\n\n// -----------------------------------------------------------------------------\n// Uniform block (converted from GLSL uniform block)\n// -----------------------------------------------------------------------------\nstruct ProjectUniforms {\n wrapLongitude: i32,\n coordinateSystem: i32,\n commonUnitsPerMeter: vec3<f32>,\n projectionMode: i32,\n scale: f32,\n commonUnitsPerWorldUnit: vec3<f32>,\n commonUnitsPerWorldUnit2: vec3<f32>,\n center: vec4<f32>,\n modelMatrix: mat4x4<f32>,\n viewProjectionMatrix: mat4x4<f32>,\n viewportSize: vec2<f32>,\n devicePixelRatio: f32,\n focalDistance: f32,\n cameraPosition: vec3<f32>,\n coordinateOrigin: vec3<f32>,\n commonOrigin: vec3<f32>,\n pseudoMeters: i32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> project: ProjectUniforms;\n\n// -----------------------------------------------------------------------------\n// Geometry data shared across the project helpers.\n// The active layer shader is responsible for populating this private module\n// state before calling the project functions below.\n// -----------------------------------------------------------------------------\n\n// Structure to carry additional geometry data used by deck.gl filters.\nstruct Geometry {\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n position: vec4<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry: Geometry;\n`}\n\n// -----------------------------------------------------------------------------\n// Functions\n// -----------------------------------------------------------------------------\n\n// Returns an adjustment factor for commonUnitsPerMeter\nfn _project_size_at_latitude(lat: f32) -> f32 {\n let y = clamp(lat, -89.9, 89.9);\n return 1.0 / cos(radians(y));\n}\n\n// Overloaded version: scales a value in meters at a given latitude.\nfn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 {\n return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat);\n}\n\n// Computes a non-linear scale factor based on geometry.\n// (Note: This function relies on "geometry" being provided.)\nfn project_size() -> f32 {\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\n project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\n project.pseudoMeters == 0) {\n if (geometry.position.w == 0.0) {\n return _project_size_at_latitude(geometry.worldPosition.y);\n }\n let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\n let y2 = y * y;\n let y4 = y2 * y2;\n let y6 = y4 * y2;\n return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n }\n return 1.0;\n}\n\n// Overloads to scale offsets (meters to world units)\nfn project_size_float(meters: f32) -> f32 {\n return meters * project.commonUnitsPerMeter.z * project_size();\n}\n\nfn project_size_vec2(meters: vec2<f32>) -> vec2<f32> {\n return meters * project.commonUnitsPerMeter.xy * project_size();\n}\n\nfn project_size_vec3(meters: vec3<f32>) -> vec3<f32> {\n return meters * project.commonUnitsPerMeter * project_size();\n}\n\nfn project_size_vec4(meters: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\n\n// Returns a rotation matrix aligning the z‑axis with the given up vector.\nfn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> {\n let uz = normalize(up);\n let ux = select(\n vec3<f32>(1.0, 0.0, 0.0),\n normalize(vec3<f32>(uz.y, -uz.x, 0.0)),\n abs(uz.z) == 1.0\n );\n let uy = cross(uz, ux);\n return mat3x3<f32>(ux, uy, uz);\n}\n\n// Since WGSL does not support "out" parameters, we return a struct.\nstruct RotationResult {\n needsRotation: bool,\n transform: mat3x3<f32>,\n};\n\nfn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n return RotationResult(true, project_get_orientation_matrix(commonPosition));\n } else {\n return RotationResult(false, mat3x3<f32>()); // identity alternative if needed\n };\n}\n\n// Projects a normal vector from the current coordinate system to world space.\nfn project_normal(vector: vec3<f32>) -> vec3<f32> {\n let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0);\n var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\n let rotResult = project_needs_rotation(geometry.position.xyz);\n if (rotResult.needsRotation) {\n n = rotResult.transform * n;\n }\n return n;\n}\n\n// Applies a scale offset based on y-offset (dy)\nfn project_offset_(offset: vec4<f32>) -> vec4<f32> {\n let dy: f32 = offset.y;\n let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\n return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\n\n// Projects lng/lat coordinates to a unit tile [0,1]\nfn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {\n var x = lnglat.x;\n if (project.wrapLongitude != 0) {\n x = ((x + 180.0) % 360.0) - 180.0;\n }\n let y = clamp(lnglat.y, -89.9, 89.9);\n return vec2<f32>(\n radians(x) + PI,\n PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// Projects lng/lat/z coordinates for a globe projection.\nfn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> {\n let lambda = radians(lnglatz.x);\n let phi = radians(lnglatz.y);\n let cosPhi = cos(phi);\n let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\n return vec3<f32>(\n sin(lambda) * cosPhi,\n -cos(lambda) * cosPhi,\n sin(phi)\n ) * D;\n}\n\n// Mercator y of project_mercator_'s latitude clamp: log(tan(PI / 4 + radians(89.9) / 2))\nconst MAX_MERCATOR_Y: f32 = 7.0439589847;\n\n// Inverse of project_globe_ followed by project_mercator_, without forming lat/lng:\n// Mercator y = atanh(sin(lat)) = log((D + |z|) / |xy|), which stays accurate near the poles\nfn project_globe_to_mercator_(spherePos: vec3<f32>) -> vec2<f32> {\n let D = length(spherePos);\n let h = max(length(spherePos.xy), 1e-20);\n let y = sign(spherePos.z) * min(log((D + abs(spherePos.z)) / h), MAX_MERCATOR_Y);\n let x = atan2(spherePos.x, -spherePos.y);\n return (vec2<f32>(x, y) + PI) * WORLD_SCALE;\n}\n\n// Flat common space (Mercator or cartesian) of a common position; identity except under GLOBE.\n// WGSL has no function overloading: pass position.xyz for a vec4. See project.glsl.ts.\nfn project_common_position_to_flat(commonPosition: vec3<f32>) -> vec2<f32> {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n return project_globe_to_mercator_(commonPosition);\n }\n return commonPosition.xy;\n}\n\n// World copy of a flat x nearest to referenceX\nfn project_wrap_flat_x_(x: f32, referenceX: f32) -> f32 {\n return x - TILE_SIZE * floor((x - referenceX) / TILE_SIZE + 0.5);\n}\n\n// Flat position in the world copy nearest to referenceX (e.g. a bounds centre); geospatial only\nfn project_common_position_to_flat_wrapped(commonPosition: vec3<f32>, referenceX: f32) -> vec2<f32> {\n var flatPosition = project_common_position_to_flat(commonPosition);\n if (project.projectionMode != PROJECTION_MODE_IDENTITY) {\n flatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n }\n return flatPosition;\n}\n\n// Flat position continuous across the antimeridian under GLOBE (seam moved opposite referenceX,\n// e.g. the camera); identity for flat modes. For periodic patterns.\nfn project_common_position_to_flat_continuous(commonPosition: vec3<f32>, referenceX: f32) -> vec2<f32> {\n var flatPosition = project_common_position_to_flat(commonPosition);\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n flatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n }\n return flatPosition;\n}\n\n// Projects positions (with an optional 64-bit low part) from the input\n// coordinate system to the common space.\nfn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> {\n var position_world = project.modelMatrix * position;\n\n // Work around for a Mac+NVIDIA bug:\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4<f32>(\n project_mercator_(position_world.xy),\n _project_size_at_latitude_m(position_world.z, position_world.y),\n position_world.w\n );\n }\n if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\n position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w);\n }\n }\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4<f32>(\n project_globe_(position_world.xyz),\n position_world.w\n );\n }\n if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) {\n let enuMatrix = project_get_orientation_matrix(project.commonOrigin);\n let metersToCommon = GLOBE_RADIUS / EARTH_RADIUS;\n let offsetCommon = (enuMatrix * vec3<f32>(-position_world.x, -position_world.y, position_world.z)) * metersToCommon;\n return vec4<f32>(project.commonOrigin + offsetCommon, position_world.w);\n }\n }\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\n return vec4<f32>(\n project_mercator_(position_world.xy) - project.commonOrigin.xy,\n project_size_float(position_world.z),\n position_world.w\n );\n }\n }\n }\n if (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\n position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w);\n }\n\n return project_offset_(position_world) +\n project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0));\n}\n\n// Overloaded versions for different input types.\nfn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> {\n return project_position_vec4_f64(position, ZERO_64_LOW);\n}\n\nfn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low);\n return projected_position.xyz;\n}\n\nfn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW);\n return projected_position.xyz;\n}\n\nfn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW);\n return projected_position.xy;\n}\n\n// Transforms a common space position to clip space.\nfn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> {\n var clipPosition = viewProjectionMatrix * position + center;\n // deck.gl projection matrices use WebGL's [-w, w] depth range; WebGPU clips z to [0, w].\n clipPosition.z = (clipPosition.z + clipPosition.w) * 0.5;\n return clipPosition;\n}\n\n// Uses the project viewProjectionMatrix and center.\nfn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> {\n return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center);\n}\n\n// Returns a clip space offset corresponding to a given number of screen pixels.\nfn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> {\n let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\n return offset * project.focalDistance;\n}\n\nfn project_meter_size_to_pixel(meters: f32) -> f32 {\n return project_size_float(meters) * project.scale;\n}\n\nfn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 {\n if (unit == UNIT_METERS) {\n return project_meter_size_to_pixel(size);\n } else if (unit == UNIT_COMMON) {\n return size * project.scale;\n }\n // UNIT_PIXELS: no scaling applied.\n return size;\n}\n\nfn project_pixel_size_float(pixels: f32) -> f32 {\n return pixels / project.scale;\n}\n\nfn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {\n return pixels / project.scale;\n}\n`,na=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"].map(e=>`const int COORDINATE_SYSTEM_${e.toUpperCase().replaceAll("-","_")} = ${Js(e)};`).join(""),ra=Object.keys(Us).map(e=>`const int PROJECTION_MODE_${e} = ${Us[e]};`).join(""),ia=Object.keys(Ws).map(e=>`const int UNIT_${e.toUpperCase()} = ${Ws[e]};`).join(""),oa={};var sa={name:"project",dependencies:[Ro,ko],source:ta,vs:`${na}\n${ra}\n${ia}\nlayout(std140) uniform projectUniforms {\nbool wrapLongitude;\nint coordinateSystem;\nvec3 commonUnitsPerMeter;\nint projectionMode;\nfloat scale;\nvec3 commonUnitsPerWorldUnit;\nvec3 commonUnitsPerWorldUnit2;\nvec4 center;\nmat4 modelMatrix;\nmat4 viewProjectionMatrix;\nvec2 viewportSize;\nfloat devicePixelRatio;\nfloat focalDistance;\nvec3 cameraPosition;\nvec3 coordinateOrigin;\nvec3 commonOrigin;\nbool pseudoMeters;\n} project;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject.pseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project.commonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project.commonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project.commonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project.wrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nconst float MAX_MERCATOR_Y = 7.0439589847;\nvec2 project_globe_to_mercator_(vec3 spherePos) {\nfloat D = length(spherePos);\nfloat h = max(length(spherePos.xy), 1e-20);\nfloat y = sign(spherePos.z) * min(log((D + abs(spherePos.z)) / h), MAX_MERCATOR_Y);\nfloat x = atan(spherePos.x, -spherePos.y);\nreturn (vec2(x, y) + PI) * WORLD_SCALE;\n}\nvec2 project_common_position_to_flat(vec3 commonPosition) {\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nreturn project_globe_to_mercator_(commonPosition);\n}\nreturn commonPosition.xy;\n}\nvec2 project_common_position_to_flat(vec4 commonPosition) {\nreturn project_common_position_to_flat(commonPosition.xyz);\n}\nfloat project_wrap_flat_x_(float x, float referenceX) {\nreturn x - TILE_SIZE * floor((x - referenceX) / TILE_SIZE + 0.5);\n}\nvec2 project_common_position_to_flat_wrapped(vec3 commonPosition, float referenceX) {\nvec2 flatPosition = project_common_position_to_flat(commonPosition);\nif (project.projectionMode != PROJECTION_MODE_IDENTITY) {\nflatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n}\nreturn flatPosition;\n}\nvec2 project_common_position_to_flat_wrapped(vec4 commonPosition, float referenceX) {\nreturn project_common_position_to_flat_wrapped(commonPosition.xyz, referenceX);\n}\nvec2 project_common_position_to_flat_continuous(vec3 commonPosition, float referenceX) {\nvec2 flatPosition = project_common_position_to_flat(commonPosition);\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nflatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n}\nreturn flatPosition;\n}\nvec2 project_common_position_to_flat_continuous(vec4 commonPosition, float referenceX) {\nreturn project_common_position_to_flat_continuous(commonPosition.xyz, referenceX);\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project.modelMatrix * position;\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project.coordinateOrigin;\n}\n}\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\nif (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) {\nmat3 enuMatrix = project_get_orientation_matrix(project.commonOrigin);\nfloat metersToCommon = GLOBE_RADIUS / EARTH_RADIUS;\nvec3 offsetCommon = (enuMatrix * vec3(-position_world.xy, position_world.z)) * metersToCommon;\nreturn vec4(project.commonOrigin + offsetCommon, position_world.w);\n}\n}\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project.commonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project.coordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\nreturn offset * project.focalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project.scale;\n}\nvec2 project_size_to_pixel(vec2 meters) {\nreturn project_size(meters) * project.scale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project.scale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project.scale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project.scale;\n}\n`,getUniforms:function(e=oa){return"viewport"in e?function({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:r="default",coordinateOrigin:i=Zs,autoWrapLongitude:o=!1}){"default"===r&&(r=e.isGeospatial?"lnglat":"cartesian");const s=Qs({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i});return s.wrapLongitude=o,s.modelMatrix=n||qs,s}(e):{}},uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}};function aa(e,t){const n=yo([],t,e);return fo(n,n,1/n[3]),n}function ca(e,t,n){return e<t?t:e>n?n:e}var la=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function ua(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var ha=Math.PI,da=ha/4,fa=ha/180,pa=180/ha,ma=512,ga=4003e4,ba=85.051129,_a=1.5;function ya(e){const[t,n]=e;ua(Number.isFinite(t)),ua(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");const r=n*fa;return[ma*(t*fa+ha)/(2*ha),ma*(ha+Math.log(Math.tan(da+.5*r)))/(2*ha)]}function va(e){const[t,n]=e,r=t/ma*(2*ha)-ha,i=2*(Math.atan(Math.exp(n/ma*(2*ha)-ha))-da);return[r*pa,i*pa]}function wa(e){const{latitude:t}=e;ua(Number.isFinite(t));const n=Math.cos(t*fa);return function(e){return la(e)}(ga*n)-9}function Ea(e){return 12790407194604047e-21/Math.cos(e*fa)}function xa(e){const{latitude:t,longitude:n,highPrecision:r=!1}=e;ua(Number.isFinite(t)&&Number.isFinite(n));const i=ma,o=Math.cos(t*fa),s=i/360,a=s/o,c=12790407194604047e-21/o,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[s,a,c],degreesPerUnit:[.703125,1/a,1/c]};if(r){const e=fa*Math.tan(t*fa)/o,n=s*e/2,r=12790407194604047e-21*e,i=r/a*c;l.unitsPerDegree2=[0,n,r],l.unitsPerMeter2=[i,0,i]}return l}function Ta(e,t){const[n,r,i]=e,[o,s,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=xa({longitude:n,latitude:r,highPrecision:!0}),u=ya(e);u[0]+=o*(c[0]+l[0]*s),u[1]+=s*(c[1]+l[1]*s);const h=va(u),d=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[h[0],h[1],d]:h}function Ma(e){return 2*Math.atan(.5/e)*pa}function Sa(e){return.5/Math.tan(.5*e*fa)}function Pa(e,t){const[n,r,i=0]=e;return ua(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),aa(t,[n,r,i,1])}function Oa(e,t,n=0){const[r,i,o]=e;if(ua(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(o))return aa(t,[r,i,o,1]);const s=aa(t,[r,i,0,1]),a=aa(t,[r,i,1,1]),c=s[2],l=a[2];return Ai([],s,a,c===l?0:((n||0)-c)/(l-c))}function Aa(e){const{width:t,height:n,bounds:r,minExtent:i=0,maxZoom:o=24,offset:s=[0,0]}=e,[[a,c],[l,u]]=r,h=function(e=0){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:(ua(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}(e.padding),d=ya([a,ca(u,-85.051129,ba)]),f=ya([l,ca(c,-85.051129,ba)]),p=[Math.max(Math.abs(f[0]-d[0]),i),Math.max(Math.abs(f[1]-d[1]),i)],m=[t-h.left-h.right-2*Math.abs(s[0]),n-h.top-h.bottom-2*Math.abs(s[1])];ua(m[0]>0&&m[1]>0);const g=m[0]/p[0],b=m[1]/p[1],_=(h.right-h.left)/2/g,y=(h.top-h.bottom)/2/b,v=va([(f[0]+d[0])/2+_,(f[1]+d[1])/2+y]),w=Math.min(o,la(Math.abs(Math.min(g,b))));return ua(Number.isFinite(w)),{longitude:v[0],latitude:v[1],zoom:w}}var ja=Math.PI/180;function La(e,t,n){const{pixelUnprojectionMatrix:r}=e,i=aa(r,[t,0,1,1]),o=aa(r,[t,e.height,1,1]),s=va(Ai([],i,o,(n*e.distanceScales.unitsPerMeter[2]-i[2])/(o[2]-i[2])));return s.push(n),s}var Ia=new class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:r,padding:i=0,copy:o=!1,initialize:s=!1,maxCount:a}){const c=r||e&&e.constructor||Float32Array,l=t*n+i;if(ArrayBuffer.isView(e)){if(l<=e.length)return e;if(l*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new c(e.buffer,0,l)}let u=1/0;a&&(u=a*n+i);const h=this._allocate(c,l,s,u);return e&&o?h.set(e):s||h.fill(0,0,4),this._release(e),h}release(e){this._release(e)}_allocate(e,t,n,r){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>r&&(i=r);const o=this._pool,s=e.BYTES_PER_ELEMENT*i,a=o.findIndex(e=>e.byteLength>=s);if(a>=0){const t=new e(o.splice(a,1)[0],0,i);return n&&t.fill(0),t}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:n}=e,{byteLength:r}=n,i=t.findIndex(e=>e.byteLength>=r);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}};function Ca(e,t){const n=e%t;return n<0?t+n:n}var Ra,$a=new eo;function ka(e,t,n,r){$a.set(e,t,n);const i=$a.len();return{distance:r/i,normal:new eo(-e/i,-t/i,-n/i)}}function Na(e){return e-Math.fround(e)}function za(e,t){const{size:n=1,startIndex:r=0}=t,i=void 0!==t.endIndex?t.endIndex:e.length,o=(i-r)/n;Ra=Ia.allocate(Ra,o,{type:Float32Array,size:2*n});let s=r,a=0;for(;s<i;){for(let t=0;t<n;t++){const r=e[s++];Ra[a+t]=r,Ra[a+t+n]=Na(r)}a+=2*n}return Ra.subarray(0,o*n*2)}function Da(e){let t=null,n=!1;for(const r of e)r&&(t?(n||(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],n=!0),t[0][0]=Math.min(t[0][0],r[0][0]),t[0][1]=Math.min(t[0][1],r[0][1]),t[1][0]=Math.max(t[1][0],r[1][0]),t[1][1]=Math.max(t[1][1],r[1][1])):t=r);return t}var Ua=Math.PI/180,Wa=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Fa=[0,0,0],Ba={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};var Ga=class e{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||Ba,this.focalDistance=e.focalDistance||1,this.position=e.position||Fa,this.modelMatrix=e.modelMatrix||null;const{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?Us.WEB_MERCATOR:Us.WEB_MERCATOR_AUTO_OFFSET:Us.IDENTITY}equals(t){return t instanceof e&&(this===t||t.width===this.width&&t.height===this.height&&t.scale===this.scale&&t.projectionMode===this.projectionMode&&t.resolution===this.resolution&&yi(t.distanceScales.unitsPerMeter,this.distanceScales.unitsPerMeter)&&yi(t.projectionMatrix,this.projectionMatrix)&&yi(t.viewMatrix,this.viewMatrix))}project(e,{topLeft:t=!0}={}){const n=Pa(this.projectPosition(e),this.pixelProjectionMatrix),[r,i]=n,o=t?i:this.height-i;return 2===e.length?[r,o]:[r,o,n[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[r,i,o]=e,s=t?i:this.height-i,a=n&&n*this.distanceScales.unitsPerMeter[2],c=Oa([r,s,o],this.pixelUnprojectionMatrix,a),[l,u,h]=this.unprojectPosition(c);return Number.isFinite(o)?[l,u,h]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){const[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){const[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){const t=ya(e);return t[1]=bi(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?va(e):e}getBounds(e={}){const t={targetZ:e.z||0},n=this.unproject([0,0],t),r=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),o=this.unproject([this.width,this.height],t);return[Math.min(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0]),Math.max(n[1],r[1],i[1],o[1])]}getDistanceScales(e){return e&&this.isGeospatial?xa({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:r=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+r}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,{left:ka((e=this.viewProjectionMatrix)[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:ka(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:ka(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:ka(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:ka(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:ka(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}),this._frustumPlanes;var e}panByPosition(e,t,n){return null}_initProps(e){const t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=wa({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||xa({latitude:n,longitude:t}));const r=Math.pow(2,this.zoom);this.scale=r;const{position:i,modelMatrix:o}=e;let s=Fa;if(i&&(s=o?new Ao(o).transformAsVector(i,[]):i),this.isGeospatial){const e=this.projectPosition([t,n,0]);this.center=new eo(s).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(s)}_initMatrices(e){const{viewMatrix:t=Wa,projectionMatrix:n=null,orthographic:r=!1,fovyRadians:i,fovy:o=75,near:s=.1,far:a=1e3,padding:c=null,focalDistance:l=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=(new Ao).multiplyRight(t).translate(new eo(this.center).negate()),this.projectionMatrix=n||function({width:e,height:t,orthographic:n,fovyRadians:r,focalDistance:i,padding:o,near:s,far:a}){const c=e/t,l=n?(new Ao).orthographic({fovy:r,aspect:c,focalDistance:i,near:s,far:a}):(new Ao).perspective({fovy:r,aspect:c,near:s,far:a});if(o){const{left:n=0,right:r=0,top:i=0,bottom:s=0}=o,a=bi((n+e-r)/2,0,e)-e/2,c=bi((i+t-s)/2,0,t)-t/2;l[8]-=2*a/e,l[9]+=2*c/t}return l}({width:this.width,height:this.height,orthographic:r,fovyRadians:i||o*Ua,focalDistance:l,padding:c,near:s,far:a});const u=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var h;ro(u,u,this.projectionMatrix),ro(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=no([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=[(h=this.viewMatrixInverse)[12],h[13],h[14]];const d=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];oo(d,d,[this.width/2,-this.height/2,1]),io(d,d,[1,-1,0]),ro(f,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=f,this.pixelUnprojectionMatrix=no([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||rt.warn("Pixel project matrix not invertible")()}};Ga.displayName="Viewport";var Va=class e extends Ga{constructor(e={}){const{latitude:t=0,longitude:n=0,zoom:r=0,pitch:i=0,bearing:o=0,nearZMultiplier:s=.1,farZMultiplier:a=1.01,nearZ:c,farZ:l,orthographic:u=!1,projectionMatrix:h,repeat:d=!1,worldOffset:f=0,position:p,padding:m,legacyMeterSizes:g=!1}=e;let{width:b,height:_,altitude:y=1.5}=e;const v=Math.pow(2,r);let w;b=b||1,_=_||1;let E=null;if(h)y=h[5]/2,w=Ma(y);else{let n;if(e.fovy?(w=e.fovy,y=Sa(w)):w=Ma(y),m){const{top:e=0,bottom:t=0}=m;n=[0,bi((e+_-t)/2,0,_)-_/2]}E=function(e){const{width:t,height:n,altitude:r,pitch:i=0,offset:o,center:s,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e;let{fovy:u=Ma(_a)}=e;void 0!==r&&(u=Ma(r));const h=u*fa,d=i*fa,f=Sa(u);let p=f;s&&(p+=s[2]*a/Math.cos(d)/n);const m=h*(.5+(o?o[1]:0)/n),g=Math.sin(m)*p/Math.sin(ca(Math.PI/2-d-m,.01,Math.PI-.01)),b=Math.sin(d)*g+p,_=10*p;return{fov:h,aspect:t/n,focalDistance:f,near:c,far:Math.min(b*l,_)}}({width:b,height:_,scale:v,center:p&&[0,0,p[2]*Ea(t)],offset:n,pitch:i,fovy:w,nearZMultiplier:s,farZMultiplier:a}),Number.isFinite(c)&&(E.near=c),Number.isFinite(l)&&(E.far=l)}let x=function(e){const{height:t,pitch:n,bearing:r,altitude:i,scale:o,center:s}=e,a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];io(a,a,[0,0,-i]),so(a,a,-n*fa),ao(a,a,r*fa);const c=o/t;var l,u;return oo(a,a,[c,c,c]),s&&io(a,a,((l=[])[0]=-(u=s)[0],l[1]=-u[1],l[2]=-u[2],l)),a}({height:_,pitch:i,bearing:o,scale:v,altitude:y});f&&(x=(new Ao).translate([512*f,0,0]).multiplyLeft(x)),super({...e,width:b,height:_,viewMatrix:x,longitude:n,latitude:t,zoom:r,...E,fovy:w,focalDistance:y}),this.latitude=t,this.longitude=n,this.zoom=r,this.pitch=i,this.bearing=o,this.altitude=y,this.fovy=w,this.orthographic=u,this._subViewports=d?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const t=this.getBounds(),n=Math.floor((t[0]+180)/360),r=Math.ceil((t[2]-180)/360);for(let i=n;i<=r;i++){const t=i?new e({...this,worldOffset:i}):this;this._subViewports.push(t)}}return this._subViewports}equals(t){return t instanceof e&&t._pseudoMeters===this._pseudoMeters&&super.equals(t)}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);const[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*Ea(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);const[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)/Ea(n)]}addMetersToLngLat(e,t){return Ta(e,t)}panByPosition(e,t,n){const r=Oa(t,this.pixelUnprojectionMatrix),i=Oi([],this.projectFlat(e),((o=[])[0]=-(s=r)[0],o[1]=-s[1],o));var o,s;const a=Oi([],this.center,i),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,t){const n=e[2]||0,r=Ri([],e,this.unproject(t,{targetZ:n}));return{longitude:this.longitude+r[0],latitude:this.latitude+r[1]}}getBounds(e={}){const t=function(e,t=0){const{width:n,height:r,unproject:i}=e,o={targetZ:t},s=i([0,r],o),a=i([n,r],o);let c,l;return(e.fovy?.5*e.fovy*ja:Math.atan(.5/e.altitude))>(90-e.pitch)*ja-.01?(c=La(e,0,t),l=La(e,n,t)):(c=i([0,0],o),l=i([n,0],o)),[s,a,l,c]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(t,n={}){const{width:r,height:i}=this,{longitude:o,latitude:s,zoom:a}=Aa({width:r,height:i,bounds:t,...n});return new e({width:r,height:i,longitude:o,latitude:s,zoom:a})}};Va.displayName="WebMercatorViewport";var Ya={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},Xa=Symbol.for("component"),qa=Symbol.for("propTypes"),Ha=Symbol.for("deprecatedProps"),Za=Symbol.for("asyncPropDefaults"),Ka=Symbol.for("asyncPropOriginal"),Ja=Symbol.for("asyncPropResolved");function Qa(e,t=()=>!0){return Array.isArray(e)?ec(e,t,[]):t(e)?[e]:[]}function ec(e,t,n){let r=-1;for(;++r<e.length;){const i=e[r];Array.isArray(i)?ec(i,t,n):t(i)&&n.push(i)}return n}function tc({target:e,source:t,start:n=0,count:r=1}){const i=t.length,o=r*i;let s=0;for(let a=n;s<i;s++)e[a++]=t[s];for(;s<o;)s<o-s?(e.copyWithin(n+s,n,n+s),s*=2):(e.copyWithin(n+s,n,n+o-s),s=o);return e}function nc(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!nc(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const o of r){if(!t.hasOwnProperty(o))return!1;if(!nc(e[o],t[o],n-1))return!1}return!0}return!1}var rc=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};function ic(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}var oc=null,sc=!1;async function ac(){hc()}function cc(e,t){return hc(),e}async function lc(e){hc()}function uc(e){return oc?.initialize(e),null}function hc(){sc||(sc=!0,o.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}export{vo as $,Qt as $t,va as A,bi as At,Ws as B,ci as Bt,ba as C,Pi as Ct,ya as D,Ei as Dt,Sa as E,Ti as Et,Vs as F,_i as Ft,ho as G,Rn as Gt,ko as H,Un as Ht,Ds as I,mi as It,_o as J,Cn as Jt,bo as K,In as Kt,Fs as L,pi as Lt,sa as M,gi as Mt,ea as N,yi as Nt,Oa as O,xi as Ot,Js as P,fi as Pt,yo as Q,rn as Qt,Us as R,ai as Rt,Ia as S,Ci as St,Ma as T,Mi as Tt,Ro as U,Nn as Ut,zs as V,Bn as Vt,Ao as W,$n as Wt,fo as X,On as Xt,go as Y,An as Yt,mo as Z,Sn as Zt,Va as _,w as _n,Ni as _t,ic as a,ke as an,Bi as at,Ca as b,c as bn,Li as bt,tc as c,te as cn,Ui as ct,Ka as d,H as dn,Ji as dt,Ht as en,co as et,Ja as f,G as fn,Zi as ft,qa as g,x as gn,$i as gt,Ya as h,T as hn,qi as ht,cc as i,nt as in,Gi as it,Pa as j,hi as jt,Ea as k,wi as kt,Qa as l,ee as ln,Vi as lt,Ha as m,S as mn,Yi as mt,lc as n,st as nn,eo as nt,rc as o,ie as on,Wi as ot,Xa as p,M as pn,Xi as pt,po as q,jn as qt,ac as r,rt as rn,Di as rt,nc as s,oe as sn,Ki as st,uc as t,at as tn,to as tt,Za as u,K as un,Fi as ut,Ga as v,d as vn,zi as vt,Ta as w,Si as wt,za as x,Ii as xt,Da as y,l as yn,ji as yt,Bs as z,si as zt};
|
|
1
|
+
/*! Web-kit v1.2.0-develop.14 | (c) 2026 MapVX */
|
|
2
|
+
!function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="260eec07-e78a-4b62-ab1b-c4453ec2a89b",e._sentryDebugIdIdentifier="sentry-dbid-260eec07-e78a-4b62-ab1b-c4453ec2a89b")}catch(e){}}();import{a as e,d as t,f as n,i as r,m as i,p as o,r as s,u as a}from"./shader-type-decoder-CmsRL_mF.js";function c(e,t){if(!e)throw new Error(t||"loader assertion failed.")}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof global&&global,"undefined"!=typeof document&&document;var l=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),u="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),h=(u&&parseFloat(u[1]),"4.5.4"[0]>="0"&&"4.5.4"[0]<="9"?"v4.5.4":"");var d=function(){const e=new i({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=h,globalThis.probe||={},globalThis.probe.loaders=e,e}(),f=e=>"function"==typeof e,p=e=>null!==e&&"object"==typeof e,m=e=>p(e)&&e.constructor==={}.constructor,g=e=>"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer,b=e=>p(e)&&"number"==typeof e.byteLength&&"function"==typeof e.slice,_=e=>"undefined"!=typeof Response&&e instanceof Response||p(e)&&f(e.arrayBuffer)&&f(e.text)&&f(e.json),y=e=>"undefined"!=typeof Blob&&e instanceof Blob,v=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||p(e)&&f(e.tee)&&f(e.cancel)&&f(e.getReader))(e)||(e=>p(e)&&f(e.read)&&f(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);function w(e,t){return E(e||{},t)}function E(e,t,n=0){if(n>3)return t;const r={...e};for(const[i,o]of Object.entries(t))o&&"object"==typeof o&&!Array.isArray(o)?r[i]=E(r[i]||{},t[i],n+1):r[i]=t[i];return r}var x=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.5.4"),globalThis._loadersgl_.version);function T(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof global&&global,"undefined"!=typeof document&&document;var M="object"!=typeof process||"[object process]"!==String(process)||process.browser,S="function"==typeof importScripts,P="undefined"!=typeof window&&void 0!==window.orientation,O="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),A=(O&&parseFloat(O[1]),class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){T(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){T(this.isRunning),this.isRunning=!1,this._reject(e)}}),j=class{terminate(){}},L=/* @__PURE__ */new Map;function I(e){T(e.source&&!e.url||!e.source&&e.url);let t=L.get(e.source||e.url);var n;return t||(e.url&&(t=(n=e.url).startsWith("http")?C(`try {\n importScripts('${n}');\n} catch (error) {\n console.error(error);\n throw error;\n}`):n,L.set(e.url,t)),e.source&&(t=C(e.source),L.set(e.source,t))),T(t),t}function C(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function R(e,t=!0,n){const r=n||/* @__PURE__ */new Set;if(e){if($(e))r.add(e);else if($(e.buffer))r.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)R(e[i],t,r)}else;return void 0===n?Array.from(r):[]}function $(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var k=()=>{},N=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&M||void 0!==j&&!M}constructor(e){const{name:t,source:n,url:r}=e;T(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=k,this.onError=e=>console.log(e),this.worker=M?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=k,this.onError=k,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||R(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=I({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(/* @__PURE__ */new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new j(t,{eval:!1,type:n})}else{if(!this.source)throw new Error("no worker");e=new j(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}},z=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return N.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,n)=>e.done(n),n=(e,t)=>e.error(t)){const r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const r=new A(t.name,e);e.onMessage=e=>t.onMessage(r,e.type,e.payload),e.onError=e=>t.onError(r,e),t.onStart(r);try{await r.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!M||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new N({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return P?this.maxMobileConcurrency:this.maxConcurrency}},D={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},U=class e{props;workerPools=/* @__PURE__ */new Map;static _workerFarm;static isSupported(){return N.isSupported()}static getWorkerFarm(t={}){return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}constructor(e){this.props={...D},this.setProps(e),this.workerPools=/* @__PURE__ */new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=/* @__PURE__ */new Map}setProps(e){this.props={...this.props,...e};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:n,url:r}=e;let i=this.workerPools.get(t);return i||(i=new z({name:t,source:n,url:r}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};async function W(e,t,n,r,i){const o=e.id,s=function(e,t={}){const n=t[e.id]||{},r=M?e.workerFile||`${e.id}-worker.js`:`${e.id}-worker-node.js`;let i=n.workerUrl;if(i||"compression"!==e.id||(i=t.workerUrl),"test"===(t._workerType||t?.core?._workerType)&&(i=M?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let t=e.version;"latest"===t&&(t="latest");const n=t?`@${t}`:"";i=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return T(i),i}(e,n),a=U.getWorkerFarm(n?.core).getWorkerPool({name:o,url:s});(n=JSON.parse(JSON.stringify(n||{})))._workerLoaderId=e.id,r=JSON.parse(JSON.stringify(r||{}));const c=await a.startJob("process-on-worker",F.bind(null,i));return c.postMessage("process",{input:t,options:n,context:r}),await(await c.result).result}async function F(e,t,n,r){switch(n){case"done":t.done(r);break;case"error":t.error(new Error(r.error));break;case"process":const{id:o,input:s,options:a}=r;try{const n=await e(s,a);t.postMessage("done",{id:o,result:n})}catch(i){const e=i instanceof Error?i.message:"unknown error";t.postMessage("error",{id:o,error:e})}break;default:console.warn(`parse-with-worker unknown message ${n}`)}}function B(...e){return function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n);let i=0;for(const o of t)r.set(o,i),i+=o.byteLength;return r.buffer}(e)}function G(e,t,n){const r=void 0!==n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function V(e){if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)){const{buffer:t,byteOffset:n,byteLength:r}=e;return Y(t,n,r)}return Y(e)}function Y(e,t=0,n=e.byteLength-t){const r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function X(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}var q=class{constructor(e,t){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=e,this.type=t,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(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=X(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(X()-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)}},H=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:n}=e;let r=this.stats[t];return r||(r=e instanceof q?e:new q(t,n),this.stats[t]=r),r}},Z={};function K(e){for(const t in Z)if(e.startsWith(t)){const n=Z[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}function J(e){return e&&"object"==typeof e&&e.isBuffer}function Q(e){if(J(e))return e;if(e instanceof ArrayBuffer)return e;if(g(e))return te(e);if(ArrayBuffer.isView(e)){const t=e.buffer;return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function ee(e){if(e instanceof ArrayBuffer)return e;if(g(e))return te(e);const{buffer:t,byteOffset:n,byteLength:r}=e;return t instanceof ArrayBuffer&&0===n&&r===t.byteLength?t:te(t,n,r)}function te(e,t=0,n=e.byteLength-t){const r=new Uint8Array(e,t,n),i=new Uint8Array(r.length);return i.set(r),i.buffer}function ne(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function re(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function ie(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function oe(...e){const t=[];for(let o=0;o<e.length;o++)t[o]=e[o];let n,r="",i=!1;for(let o=t.length-1;o>=-1&&!i;o--){let e;o>=0?e=t[o]:(void 0===n&&(n=ne()),e=n),0!==e.length&&(r=`${e}/${r}`,i=e.charCodeAt(0)===se)}return r=function(e,t){let n,r="",i=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===se)break;n=se}if(n===se){if(i===a-1||1===o);else if(i!==a-1&&2===o){if(r.length<2||!s||r.charCodeAt(r.length-1)!==ae||r.charCodeAt(r.length-2)!==ae)if(r.length>2){const e=r.length-1;let t=e;for(;t>=0&&r.charCodeAt(t)!==se;--t);if(t!==e){r=-1===t?"":r.slice(0,t),i=a,o=0,s=!1;continue}}else if(2===r.length||1===r.length){r="",i=a,o=0,s=!1;continue}t&&(r.length>0?r+="/..":r="..",s=!0)}else{const t=e.slice(i+1,a);r.length>0?r+=`/${t}`:r=t,s=!1}i=a,o=0}else n===ae&&-1!==o?++o:o=-1}return r}(r,!i),i?`/${r}`:r.length>0?r:"."}var se=47,ae=46;var ce=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response},le=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ue=/^([-\w.]+\/[-\w.+]+)/;function he(e,t){return e.toLowerCase()===t.toLowerCase()}function de(e){const t=le.exec(e);return t?t[1]:""}var fe=/\?.*/;function pe(e){return e.replace(fe,"")}function me(e){return _(e)?e.url:y(e)?("name"in e?e.name:"")||"":"string"==typeof e?e:""}function ge(e){if(_(e)){const t=e.headers.get("content-type")||"",n=pe(e.url);return function(e){const t=ue.exec(e);return t?t[1]:e}(t)||de(n)}return y(e)?e.type||"":"string"==typeof e?de(e):""}async function be(e){if(_(e))return e;const t={},n=function(e){return _(e)?e.headers["content-length"]||-1:y(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);n>=0&&(t["content-length"]=String(n));const r=me(e),i=ge(e);i&&(t["content-type"]=i);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const n=new FileReader;n.onload=t=>e(t?.target?.result),n.readAsDataURL(t)})}return e instanceof ArrayBuffer?`data:base64,${function(e){let t="";const n=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)t+=String.fromCharCode(n[r]);return btoa(t)}(e.slice(0,t))}`:null}(e);o&&(t["x-first-bytes"]=o),"string"==typeof e&&(e=(new TextEncoder).encode(e));const s=new Response(e,{headers:t});return Object.defineProperty(s,"url",{value:r}),s}async function _e(e){if(!e.ok)throw await async function(e){const t=function(e){if(e.length<50)return e;const t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}(e.url);let n=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;n=n.length>100?`${n.slice(0,100)}...`:n;const r={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");r.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(i){}return new ce(n,r)}(e)}async function ye(e,t){if("string"==typeof e){const n=K(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(n)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(n,t):await fetch(n,t)}return await be(e)}var ve=new i({id:"loaders.gl"}),we=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Ee={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:l,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},xe={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"},Te=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Me(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function Se(){const e=Me();return e.globalOptions=e.globalOptions||{...Ee,core:{...Ee.core}},Oe(e.globalOptions)}function Pe(e,t,n,r){return n=n||[],function(e,t){Ae(e,null,Ee,xe,t);for(const n of t){const r=e&&e[n.id]||{},i=n.options&&n.options[n.id]||{},o=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};Ae(r,n.id,i,o,t)}}(e,n=Array.isArray(n)?n:[n]),Oe(function(e,t,n){const r=e.options||{},i={...r};r.core&&(i.core={...r.core});Ie(i),null===i.core?.log&&(i.core={...i.core,log:new we});return Le(i,Oe(Se())),Le(i,Oe(t)),function(e,t){if(!t)return;void 0===e.core?.baseUrl&&(e.core||={},e.core.baseUrl=ie(pe(t)))}(i,n),function(e){const t=e.core;if(!t)return;for(const n of Te)void 0!==t[n]&&(e[n]=t[n])}(i),i}(t,e,r))}function Oe(e){const t=function(e){const t={...e};e.core&&(t.core={...e.core});return t}(e);Ie(t);for(const n of Te)t.core&&void 0!==t.core[n]&&delete t[n];return t.core&&void 0!==t.core._workerType&&delete t._worker,t}function Ae(e,t,n,r,i){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const c=!t&&p(e[a]);if(!(a in n)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in r)ve.level>0&&ve.warn(`${o} loader option '${s}${a}' no longer supported, use '${r[a]}'`)();else if(!c&&ve.level>0){const e=je(a,i);ve.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function je(e,t){const n=e.toLowerCase();let r="";for(const i of t)for(const t in i.options){if(e===t)return`Did you mean '${i.id}.${t}'?`;const o=t.toLowerCase();(n.startsWith(o)||o.startsWith(n))&&(r=r||`Did you mean '${i.id}.${t}'?`)}return r}function Le(e,t){for(const n in t)if(n in t){const r=t[n];m(r)&&m(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function Ie(e){void 0!==e.baseUri&&(e.core||={},void 0===e.core.baseUrl&&(e.core.baseUrl=e.baseUri));for(const n of Te)if(void 0!==e[n]){const t=e.core=e.core||{};void 0===t[n]&&(t[n]=e[n])}const t=e._worker;void 0!==t&&(e.core||={},void 0===e.core._workerType&&(e.core._workerType=t))}function Ce(e){return!!e&&(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions))}function Re(e){let t;return c(e,"null loader"),c(Ce(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}var $e=()=>{const e=Me();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function ke(e){const t=$e();e=Array.isArray(e)?e:[e];for(const n of e){const e=Re(n);t.find(t=>e===t)||t.unshift(e)}}var Ne=/\.([^.]+)$/;function ze(e){const t=ge(e);return Boolean(t&&(t.startsWith("text/")||"application/json"===t||t.endsWith("+json")))}function De(e,t=[],n,r){if(!Ue(e))return null;const i=Oe(n||{});if(i.core||={},t&&!Array.isArray(t))return Re(t);let o=[];t&&(o=o.concat(t)),i.core.ignoreRegisteredLoaders||o.push(...$e()),function(e){for(const t of e)Re(t)}(o);const s=function(e,t,n,r){const i=me(e),o=ge(e),s=pe(i)||r?.url;let a=null,c="";n?.core?.mimeType&&(a=Fe(t,n?.core?.mimeType),c=`match forced by supplied MIME type ${n?.core?.mimeType}`);a=a||function(e,t){const n=t&&Ne.exec(t),r=n&&n[1];return r?function(e,t){t=t.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===t)return n;return null}(e,r):null}(t,s),c=c||(a?`matched url ${s}`:""),a=a||Fe(t,o),c=c||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(Be(t,n))return n}else if(ArrayBuffer.isView(t)){if(Ge(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer&&Ge(t,0,n))return n;return null}(t,e),c=c||(a?`matched initial data ${Ve(e)}`:""),n?.core?.fallbackMimeType&&(a=a||Fe(t,n?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${o}`:""));c&&d.log(1,`selectLoader selected ${a?.name}: ${c}.`);return a}(e,o,i,r);if(!s&&!i.core.nothrow)throw new Error(We(e));return s}function Ue(e){return!(e instanceof Response&&204===e.status)}function We(e){const t=me(e),n=ge(e);let r="No valid loader found (";r+=t?`${re(t)}, `:"no url provided, ",r+=`MIME type: ${n?`"${n}"`:"not provided"}, `;const i=e?Ve(e):"";return r+=i?` first bytes: "${i}"`:"first bytes: not available",r+=")",r}function Fe(e,t){for(const n of e){if(n.mimeTypes?.some(e=>he(t,e)))return n;if(he(t,`application/x.${n.id}`))return n}return null}function Be(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Ge(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(n=>function(e,t,n,r){if(b(r))return function(e,t,n){if(n=n||e.byteLength,e.byteLength<n||t.byteLength<n)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let o=0;o<r.length;++o)if(r[o]!==i[o])return!1;return!0}(r,e,r.byteLength);switch(typeof r){case"function":return r(ee(e));case"string":return r===Ye(e,t,r.length);default:return!1}}(e,t,0,n))}function Ve(e,t=5){return"string"==typeof e?e.slice(0,t):ArrayBuffer.isView(e)?Ye(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?Ye(e,0,t):""}function Ye(e,t,n){if(e.byteLength<t+n)return"";const r=new DataView(e);let i="";for(let o=0;o<n;o++)i+=String.fromCharCode(r.getUint8(t+o));return i}var Xe=262144;function qe(e,t){return l?async function*(e,t){const n=e.getReader();let r;try{for(;;){const e=r||n.read();t?._streamReadAhead&&(r=n.read());const{done:i,value:o}=await e;if(i)return;yield Q(o)}}catch(i){n.releaseLock()}}(e,t):async function*(e){for await(const t of e)yield Q(t)}(e)}function He(e,t){if("string"==typeof e)return function*(e,t){const n=t?.chunkSize||262144;let r=0;const i=new TextEncoder;for(;r<e.length;){const t=Math.min(e.length-r,n),o=e.slice(r,r+t);r+=t,yield ee(i.encode(o))}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:n=Xe}=t;let r=0;for(;r<e.byteLength;){const t=Math.min(e.byteLength-r,n),i=new ArrayBuffer(t),o=new Uint8Array(e,r,t);new Uint8Array(i).set(o),r+=t,yield i}}(e,t);if(y(e))return async function*(e,t){const n=t?.chunkSize||1048576;let r=0;for(;r<e.size;){const t=r+n,i=await e.slice(r,t).arrayBuffer();r=t,yield i}}(e,t);if(v(e))return qe(e,t);if(_(e)){const n=e.body;if(!n)throw new Error("Readable stream not available on Response");return qe(n,t)}throw new Error("makeIterator")}var Ze="Cannot convert supplied data type";function Ke(e,t,n){if(t.text&&"string"==typeof e)return e;if(J(e)&&(e=e.buffer),b(e)){const n=function(e){return ArrayBuffer.isView(e)?e:new Uint8Array(e)}(e);return t.text&&!t.binary?new TextDecoder("utf8").decode(n):Q(n)}throw new Error(Ze)}async function Je(e,t,n){if("string"==typeof e||b(e))return Ke(e,t);if(y(e)&&(e=await be(e)),_(e))return await _e(e),t.binary?await e.arrayBuffer():await e.text();if(v(e)&&(e=He(e,n)),r=e,Boolean(r)&&f(r[Symbol.iterator])||(e=>Boolean(e)&&f(e[Symbol.asyncIterator]))(e))return async function(e){const t=[];for await(const n of e)t.push(V(n));return B(...t)}(e);var r;throw new Error(Ze)}function Qe(e,t){const n=Se(),r=e||n,i=r.fetch??r.core?.fetch;return"function"==typeof i?i:p(i)?e=>ye(e,i):t?.fetch?t?.fetch:ye}function et(e,t,n){if(n)return n;const r={fetch:Qe(t,e),...e};if(r.url){const e=pe(r.url);r.baseUrl=e,r.queryString=function(e){const t=e.match(fe);return t&&t[0]}(r.url),r.filename=re(e),r.baseUrl=ie(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}async function tt(e,t,n,r){!t||Array.isArray(t)||Ce(t)||(r=void 0,n=t,t=void 0),n=n||{};const i=me(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:void 0}(t,r),s=await async function(e,t=[],n,r){if(!Ue(e))return null;const i=Oe(n||{});if(i.core||={},e instanceof Response&&ze(e)){const n=De(await e.clone().text(),t,{...i,core:{...i.core,nothrow:!0}},r);if(n)return n}let o=De(e,t,{...i,core:{...i.core,nothrow:!0}},r);if(o)return o;if(y(e)&&(o=De(e=await e.slice(0,10).arrayBuffer(),t,i,r)),!o&&e instanceof Response&&ze(e)&&(o=De(await e.clone().text(),t,i,r)),!o&&!i.core.nothrow)throw new Error(We(e));return o}(e,o,n);if(!s)return null;const a=Pe(n,s,o,i);return r=et({url:i,_parse:tt,loaders:o},a,r||null),await async function(e,t,n,r){if(function(e){T(e,"no worker provided");const t=e.version}(e),n=w(e.options,n),_(t)){const{ok:e,redirected:n,status:i,statusText:o,type:s,url:a}=t;r.response={headers:Object.fromEntries(t.headers.entries()),ok:e,redirected:n,status:i,statusText:o,type:s,url:a}}t=await Je(t,e,n);const i=e;if(i.parseTextSync&&"string"==typeof t)return i.parseTextSync(t,n,r);if(function(e,t){if(!U.isSupported())return!1;if(!M&&!(t?._nodeWorkers??t?.core?._nodeWorkers))return!1;const n=t?.worker??t?.core?.worker;return Boolean(e.worker&&n)}(e,n))return await W(e,t,n,r,tt);if(i.parseText&&"string"==typeof t)return await i.parseText(t,n,r);if(i.parse)return await i.parse(t,n,r);throw T(!i.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,a,r)}async function nt(e,t,n,r){let i,o;Array.isArray(t)||Ce(t)?(i=t,o=n):(i=[],o=t);const s=Qe(o);let a=e;return"string"==typeof e&&(a=await s(e)),y(e)&&(a=await s(e)),"string"==typeof e&&(Oe(o||{}).core?.baseUrl||(o={...o,core:{...o?.core,baseUrl:e}})),Array.isArray(i),await tt(a,i,o)}var rt=new i({id:"deck"}),it={attributeUpdateStart:-1,attributeManagerUpdateStart:-1,attributeUpdateMessages:[]},ot={};function st(e){ot=e}function at(e,t,n,r){rt.level>0&&ot[e]&&ot[e].call(null,t,n,r)}"production"!==process.env.NODE_ENV&&(ot=(e=>({"layer.changeFlag":(t,n,r)=>{e.log(3,`${t.id} ${n}: `,r[n])()},"layer.initialize":t=>{e.log(1,`Initializing ${t}`)()},"layer.update":(t,n)=>{if(n){const n=t.getChangeFlags();e.log(2,`Updating ${t} because: ${Object.keys(n).filter(e=>n[e]).join(", ")}`)()}else e.log(4,`${t} does not need update`)()},"layer.matched":(t,n)=>{n&&e.log(4,`Matched ${t}, state transfered`)()},"layer.finalize":t=>{e.log(1,`Finalizing ${t}`)()},"compositeLayer.renderLayers":(t,n,r)=>{n?e.log(2,`Composite layer rendered new subLayers ${t}`,r)():e.log(4,`Composite layer reused subLayers ${t}`,r)()},"layerManager.setLayers":(t,n,r)=>{n&&e.log(2,`Updating ${r.length} deck layers`)()},"layerManager.activateViewport":(t,n)=>{e.log(3,"Viewport changed",n)()},"attributeManager.invalidate":(t,n,r)=>{e.log(1,r?`invalidated attributes ${r} (${n}) for ${t.id}`:`invalidated all attributes for ${t.id}`)()},"attributeManager.updateStart":e=>{it.attributeUpdateMessages.length=0,it.attributeManagerUpdateStart=Date.now()},"attributeManager.updateEnd":(t,n)=>{const r=Math.round(Date.now()-it.attributeManagerUpdateStart);e.groupCollapsed(2,`Updated attributes for ${n} instances in ${t.id} in ${r}ms`)();for(const i of it.attributeUpdateMessages)e.log(3,i)();e.groupEnd(2)()},"attribute.updateStart":e=>{it.attributeUpdateStart=Date.now()},"attribute.allocate":(e,t)=>{const n=`${e.id} allocated ${t}`;it.attributeUpdateMessages.push(n)},"attribute.updateEnd":(e,t)=>{const n=Math.round(Date.now()-it.attributeUpdateStart),r=`${e.id} updated ${t} in ${n}ms`;it.attributeUpdateMessages.push(r)},"deckRenderer.renderLayers":(t,n,r)=>{const{pass:i,redrawReason:o}=r;for(const s of n){const{totalCount:n,visibleCount:r,compositeCount:a,pickableCount:c}=s,l=n-a-r;e.log(2,`RENDER #${t.renderCount} ${r} (of ${n} layers) to ${i} because ${o} (${l} hidden, ${a} composite ${c} pickable)`)()}}}))(rt));var ct="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",lt="\\s*",ut=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}@group\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${lt}@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}${ct}`,"g")],ht=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}@group\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${lt}@binding\\(\\s*(auto|\\d+)\\s*\\)${lt}${ct}`,"g")],dt=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${lt}@group\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${lt}@binding\\(\\s*(\\d+)\\s*\\)${lt}${ct}`,"g")],ft=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${ct}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ct}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ct}`,"g")];function pt(e){const t=e.split("");let n=0,r=0,i=!1,o=!1,s=!1;for(;n<e.length;){const a=e[n],c=e[n+1];if(o)s?s=!1:"\\"===a?s=!0:'"'===a&&(o=!1),n++;else if(i)"\n"===a||"\r"===a?i=!1:t[n]=" ",n++;else if(r>0){if("/"===a&&"*"===c){t[n]=" ",t[n+1]=" ",r++,n+=2;continue}if("*"===a&&"/"===c){t[n]=" ",t[n+1]=" ",r--,n+=2;continue}"\n"!==a&&"\r"!==a&&(t[n]=" "),n++}else'"'!==a?"/"!==a||"/"!==c?"/"!==a||"*"!==c?n++:(t[n]=" ",t[n+1]=" ",r=1,n+=2):(t[n]=" ",t[n+1]=" ",i=!0,n+=2):(o=!0,n++)}return t.join("")}function mt(e,t){const n=pt(e),r=[];for(const i of t){let o;for(i.lastIndex=0,o=i.exec(n);o;){const s=i===t[0],a=o.index,c=o[0].length;r.push({match:e.slice(a,a+c),index:a,length:c,bindingToken:o[s?1:2],groupToken:o[s?2:1],accessDeclaration:o[3]?.trim(),name:o[4]}),o=i.exec(n)}}return r.sort((e,t)=>e.index-t.index)}function gt(e,t,n){const r=mt(e,t);if(!r.length)return e;let i="",o=0;for(const s of r)i+=e.slice(o,s.index),i+=n(s),o=s.index+s.length;return i+=e.slice(o),i}function bt(e){return/@binding\(\s*auto\s*\)/.test(pt(e))}function _t(e,t={}){const n=yt(e),r=function(e){const t=[];let n=0;for(const r of e){if("}"===r.value&&0===n)return null;t.push(n),"{"===r.value?n++:"}"===r.value&&n--}return 0===n?t:null}(n);if(!r)return null;const i=function(e,t){const n=/* @__PURE__ */new Map;for(let r=0;r<e.length;r++){if(0!==t[r]||"alias"!==e[r].value)continue;const i=e[r+1]?.value;if(!It(i)||"="!==e[r+2]?.value||n.has(i))return null;const o=At(e,t,r+3,";");if(o<0||o===r+3)return null;n.set(i,Lt(e.slice(r+3,o))),r=o}return n}(n,r);if(!i)return null;const o=function(e,t,n){const r=[],i=/* @__PURE__ */new Set,o=/* @__PURE__ */new Set;for(let s=0;s<e.length;s++){if(0!==t[s]||"var"!==e[s].value)continue;const a=jt(e,t,s),c=e.slice(a,s),l=Tt(c,"group"),u=Tt(c,"binding");if(null===l||null===u||void 0===l!=(void 0===u))return null;if(void 0===l||void 0===u)continue;let h=s+1,d=[];if("<"===e[h]?.value){const t=Pt(e,h,"<",">");if(t<0)return null;const n=Ot(e.slice(h+1,t),",");if(!n)return null;d=n.map(Lt),h=t+1}const f=e[h]?.value;if(!It(f)||":"!==e[h+1]?.value)return null;const p=At(e,t,h+2,";");if(p<0||p===h+2)return null;const m=Et(Lt(e.slice(h+2,p)),n);if(!m)return null;const g=vt({name:f,group:l,location:u,addressSpace:d,resourceType:m}),b=`${l}:${u}`;if(!g||i.has(b)||o.has(f))return null;r.push(g),i.add(b),o.add(f),s=p}return function(e){for(const t of e){if("sampler"!==t.type||t.samplerType||!t.name.endsWith("Sampler"))continue;const n=t.name.slice(0,-7);"depth"===e.find(e=>"texture"===e.type&&e.name===n&&e.group===t.group)?.sampleType&&(t.samplerType="non-filtering")}}(r),r.sort((e,t)=>e.group-t.group||e.location-t.location||e.name.localeCompare(t.name))}(n,r,i);if(!o)return null;if(!1===t.scanVertexAttributes)return{attributes:[],bindings:o};const s=function(e,t){const n=/* @__PURE__ */new Map;for(let r=0;r<e.length;r++){if(0!==t[r]||"struct"!==e[r].value)continue;const i=e[r+1]?.value,o=r+2;if(!It(i)||n.has(i)||"{"!==e[o]?.value)return null;const s=Pt(e,o,"{","}");if(s<0)return null;n.set(i,e.slice(o+1,s)),r=s}return n}(n,r);if(!s)return null;const a=function(e,t,n,r,i){const o=function(e,t){const n=[],r=/* @__PURE__ */new Set;for(let i=0;i<e.length;i++){if(0!==t[i]||"fn"!==e[i].value)continue;const o=e[i+1]?.value,s=i+2;if(!It(o)||r.has(o)||"("!==e[s]?.value)return null;const a=Pt(e,s,"(",")");if(a<0)return null;const c=jt(e,t,i);n.push({name:o,vertex:Mt(e.slice(c,i),"vertex"),parameters:e.slice(s+1,a)}),r.add(o),i=a}return n}(e,t);if(!o)return null;const s=o.filter(e=>e.vertex),a=i?s.find(e=>e.name===i):1===s.length?s[0]:void 0;if(!a)return 0!==s.length||i?null:[];const c=Ot(a.parameters,",");if(!c)return null;const l=[],u=/* @__PURE__ */new Set,h=/* @__PURE__ */new Set,d=/* @__PURE__ */new Set;for(const f of c)if(f.length>0&&!wt({declaration:f,aliases:n,structures:r,attributes:l,attributeLocations:u,attributeNames:h,visitedStructures:d}))return null;return l.sort((e,t)=>e.location-t.location||e.name.localeCompare(t.name))}(n,r,i,s,t.vertexEntryPoint);return a?{attributes:a,bindings:o}:null}function yt(e){const t=pt(e),n=/[A-Za-z_][A-Za-z0-9_]*|(?:0[xX][0-9A-Fa-f]+|\d+)|[@(){}<>\[\]:,;=]/g,r=[];let i=n.exec(t);for(;i;)r.push({value:i[0],index:i.index}),i=n.exec(t);return r}function vt(e){const{name:t,group:n,location:r,addressSpace:i,resourceType:o}=e,s={name:t,group:n,location:r};if("uniform"===i[0]&&1===i.length)return{...s,type:"uniform"};if("storage"===i[0]&&i.length<=2){const e=i[1]||"read";return"read"===e?{...s,type:"read-only-storage"}:"read_write"===e?{...s,type:"storage"}:null}return i.length>0?null:"sampler"===o||"sampler_comparison"===o?{...s,type:"sampler",..."sampler_comparison"===o?{samplerType:"comparison"}:{}}:"texture_external"===o?{...s,type:"external-texture"}:function(e,t){const n=/^texture_storage_(1d|2d|2d_array|3d)<([A-Za-z0-9_]+),(read|write|read_write)>$/.exec(t);if(!n)return null;const r={read:"read-only",write:"write-only",read_write:"read-write"}[n[3]];return{...e,type:"storage",format:n[2],access:r,viewDimension:St(n[1])}}(s,o)||function(e,t){const n=/^texture_(multisampled_)?(1d|2d|2d_array|cube|cube_array|3d)<(f32|i32|u32)>$/.exec(t);if(n){if(n[1]&&"2d"!==n[2])return null;const t={f32:"float",i32:"sint",u32:"uint"}[n[3]];return{...e,type:"texture",viewDimension:St(n[2]),sampleType:t,multisampled:Boolean(n[1])}}const r=/^texture_depth_(multisampled_)?(2d|2d_array|cube|cube_array)$/.exec(t);return!r||r[1]&&"2d"!==r[2]?null:{...e,type:"texture",viewDimension:St(r[2]),sampleType:"depth",multisampled:Boolean(r[1])}}(s,o)}function wt(e){const{declaration:t,aliases:n,structures:r,attributes:i,attributeLocations:o,attributeNames:s,visitedStructures:a}=e,c=function(e,t){const n=Ot(e,t);return n&&2===n.length?n[0].length:-1}(t,":");if(c<1||c===t.length-1)return!1;const l=function(e){for(let t=e.length-1;t>=0;t--)if(It(e[t].value))return e[t].value;return null}(t.slice(0,c)),u=Tt(t.slice(0,c),"location"),h=Mt(t.slice(0,c),"builtin"),d=Et(Lt(t.slice(c+1)),n);if(!l||null===u||!d||void 0!==u&&h)return!1;if(void 0!==u){const e=/^(?:i32|u32|f32|f16|vec[234]<(?:i32|u32|f32|f16)>)$/.test(f=d)?f:null;return!(!e||o.has(u)||s.has(l))&&(i.push({name:l,location:u,type:e}),o.add(u),s.add(l),!0)}var f;if(h)return!0;const p=r.get(d);if(!p||a.has(d))return!1;const m=Ot(p,",");if(!m)return!1;a.add(d);for(const g of m)if(g.length>0&&!wt({...e,declaration:g}))return!1;return a.delete(d),!0}function Et(e,t,n=/* @__PURE__ */new Set){const r=yt(e);let i="";for(const o of r){const e=t.get(o.value);if(!e){i+=xt(o.value);continue}if(n.has(o.value))return null;const r=new Set(n);r.add(o.value);const s=Et(e,t,r);if(!s)return null;i+=s}return i}function xt(e){const t=/^(vec[234]|mat[234]x[234])([fiuh])$/.exec(e);if(!t)return e;const n={f:"f32",i:"i32",u:"u32",h:"f16"}[t[2]];return`${t[1]}<${n}>`}function Tt(e,t){let n;for(let r=0;r<e.length;r++)if("@"===e[r].value&&e[r+1]?.value===t){if(void 0!==n||"("!==e[r+2]?.value||!/^\d+$/.test(e[r+3]?.value||"")||")"!==e[r+4]?.value)return null;n=Number(e[r+3].value)}return n}function Mt(e,t){return e.some((n,r)=>"@"===n.value&&e[r+1]?.value===t)}function St(e){return e.replace("_","-")}function Pt(e,t,n,r){let i=0;for(let o=t;o<e.length;o++)if(e[o].value===n)i++;else if(e[o].value===r&&0===--i)return o;return-1}function Ot(e,t){const n=[];let r=0;const i={"(":0,"<":0,"[":0,"{":0},o=Object.keys(i),s={")":"(",">":"<","]":"[","}":"{"};for(let a=0;a<e.length;a++){const c=e[a].value;if(c===t&&o.every(e=>0===i[e]))n.push(e.slice(r,a)),r=a+1;else if(c in i)i[c]++;else if(c in s){const e=s[c];if(i[e]--,i[e]<0)return null}}return o.every(e=>0===i[e])?(n.push(e.slice(r)),n):null}function At(e,t,n,r){for(let i=n;i<e.length;i++)if(0===t[i]&&e[i].value===r)return i;return-1}function jt(e,t,n){for(let r=n-1;r>=0;r--)if(";"===e[r].value&&0===t[r]||"}"===e[r].value&&1===t[r])return r+1;return 0}function Lt(e){return e.map(e=>e.value).join("")}function It(e){return Boolean(e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))}function Ct(e,t){if(!e){const e=new Error(t||"shadertools: assertion failed.");throw Error.captureStackTrace?.(e,Ct),e}}var Rt={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function $t(e){let t=kt(e);if("object"!==t)return{value:e,...Rt[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...Rt[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=kt(e.value),{...e,...Rt[t],type:t}):{type:"object",value:null};throw new Error("props")}function kt(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var Nt={vertex:"#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\n fragColor = material_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n fragColor = lighting_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_FOG\n fragColor = fog_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_PICKING\n fragColor = picking_filterHighlightColor(fragColor);\n fragColor = picking_filterPickingColor(fragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n"},zt=/void\s+main\s*\([^)]*\)\s*\{\n?/,Dt=/}\n?[^{}]*$/,Ut=[],Wt="__LUMA_INJECT_DECLARATIONS__";function Ft(e){const t={vertex:{},fragment:{}};for(const n in e){let r=e[n];"string"==typeof r&&(r={order:0,injection:r}),t[Bt(n)][n]=r}return t}function Bt(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function Gt(e,t,n,r=!1,i="glsl",o={}){const s="vertex"===t;for(const a in n){const t=n[a];t.sort((e,t)=>e.order-t.order),Ut.length=t.length;for(let e=0,n=t.length;e<n;++e)Ut[e]=t[e].injection;const r=`${Ut.join("\n")}\n`;switch(a){case"vs:#decl":("wgsl"===i||s)&&(e=e.replace(Wt,r));break;case"vs:#main-start":("wgsl"===i||s)&&(e="wgsl"===i?Vt(e,"vertex",r,"start",o.vertex):e.replace(zt,e=>e+r));break;case"vs:#main-end":("wgsl"===i||s)&&(e="wgsl"===i?Vt(e,"vertex",r,"end",o.vertex):e.replace(Dt,e=>r+e));break;case"fs:#decl":"wgsl"!==i&&s||(e=e.replace(Wt,r));break;case"fs:#main-start":"wgsl"!==i&&s||(e="wgsl"===i?Vt(e,"fragment",r,"start",o.fragment):e.replace(zt,e=>e+r));break;case"fs:#main-end":"wgsl"!==i&&s||(e="wgsl"===i?Vt(e,"fragment",r,"end",o.fragment):e.replace(Dt,e=>r+e));break;default:e=e.replace(a,e=>e+r)}}return e=e.replace(Wt,""),r&&(e=e.replace(/\}\s*$/,e=>e+Nt[t])),e}function Vt(e,t,n,r,i){const o=function(e,t,n){const r="vertex"===t?"@vertex":"@fragment",i=e.indexOf(r);if(i<0)return null;const o=n?e.search(new RegExp(`\\bfn\\s+${s=n,s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`)):e.indexOf("fn",i);var s;if(o<0)return null;const a=e.indexOf("{",o);if(a<0)return null;let c=0;for(let l=a;l<e.length;l++){const t=e[l];if("{"===t)c++;else if("}"===t&&(c--,0===c))return{openBraceIndex:a,closeBraceIndex:l}}return null}(e,t,i);if(!o)return e;if("start"===r){const t=o.openBraceIndex+1;return`${e.slice(0,t)}\n${n}${e.slice(t)}`}return`${e.slice(0,o.closeBraceIndex)}${n}${e.slice(o.closeBraceIndex)}`}function Yt(e){e.map(e=>function(e){if(e.instance)return;Yt(e.dependencies||[]);const{propTypes:t={},deprecations:n=[],inject:r={}}=e,i={normalizedInjections:Ft(r),parsedDeprecations:qt(n)};t&&(i.propValidators=function(e){const t={};for(const[n,r]of Object.entries(e))t[n]=$t(r);return t}(t));e.instance=i;let o={};t&&(o=Object.entries(t).reduce((e,[t,n])=>{const r=n?.value;return r&&(e[t]=r),e},{}));e.defaultUniforms={...e.defaultUniforms,...o}}(e))}function Xt(e,t,n){e.deprecations?.forEach(e=>{e.regex?.test(t)&&(e.deprecated?n.deprecated(e.old,e.new)():n.removed(e.old,e.new)())})}function qt(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}function Ht(e){Yt(e);const t={},n={};Zt({modules:e,level:0,moduleMap:t,moduleDepth:n});const r=Object.keys(n).sort((e,t)=>n[t]-n[e]).map(e=>t[e]);return Yt(r),r}function Zt(e){const{modules:t,level:n,moduleMap:r,moduleDepth:i}=e;if(n>=5)throw new Error("Possible loop in shader dependency graph");for(const o of t)r[o.name]=o,(void 0===i[o.name]||i[o.name]<n)&&(i[o.name]=n);for(const o of t)o.dependencies&&Zt({modules:o.dependencies,level:n+1,moduleMap:r,moduleDepth:i})}var Kt,Jt,Qt={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{const[n,r]=e.getDevicePixelSize();o.log(1,`${e} resized => ${n}x${r}px`)()},onPositionChange:(e,t)=>{const[n,r]=e.getPosition();o.log(1,`${e} repositioned => ${n},${r}`)()},onVisibilityChange:e=>o.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>o.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:(Kt=o.get("debug"),Jt=function(){const e=globalThis.process;if(e?.env)return e.env.NODE_ENV}(),null!=Kt?Boolean(Kt):void 0!==Jt&&"production"!==Jt),debugGPUTime:!1,debugShaders:o.get("debug-shaders")||void 0,debugFramebuffers:Boolean(o.get("debug-framebuffers")),debugFactories:Boolean(o.get("debug-factories")),debugWebGL:Boolean(o.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};var en=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],tn=/* @__PURE__ */new WeakMap,nn=/* @__PURE__ */new WeakMap,rn=new class{stats=/* @__PURE__ */new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new H({id:e}));const t=this.stats.get(e);return"GPU Time and Memory"===e&&function(e,t){const n=e.stats;let r=!1;for(const c of t)n[c]||(e.get(c),r=!0);const i=Object.keys(n).length,o=tn.get(e);if(!r&&o?.orderedStatNames===t&&o.statCount===i)return;const s={};let a=nn.get(t);a||(a=new Set(t),nn.set(t,a));for(const c of t)n[c]&&(s[c]=n[c]);for(const[c,l]of Object.entries(n))a.has(c)||(s[c]=l);for(const c of Object.keys(n))delete n[c];Object.assign(n,s),tn.set(e,{orderedStatNames:t,statCount:i})}(t,en),t}};var on="texture-compression-bc",sn="texture-compression-astc",an="texture-compression-etc2",cn="texture-compression-pvrtc-webgl",ln="texture-compression-atc-webgl",un="float32-renderable-webgl",hn="float16-renderable-webgl",dn="snorm8-renderable-webgl",fn="norm16-webgl",pn="norm16-renderable-webgl",mn="snorm16-renderable-webgl",gn="float32-filterable",bn="float16-filterable-webgl",_n=19,yn=992;function vn(e){const t=wn[e];if(!t)throw new Error(`Unsupported texture format ${e}`);return t}var wn={...{r8unorm:{webgpu:527},rg8unorm:{webgpu:527},"rgb8unorm-webgl":{},rgba8unorm:{webgpu:31},"rgba8unorm-srgb":{webgpu:15},r8snorm:{render:dn,webgpu:837},rg8snorm:{render:dn,webgpu:837},"rgb8snorm-webgl":{},rgba8snorm:{render:dn,webgpu:341},r8uint:{webgpu:515},rg8uint:{webgpu:515},rgba8uint:{webgpu:_n},r8sint:{webgpu:515},rg8sint:{webgpu:515},rgba8sint:{webgpu:_n},bgra8unorm:{webgpu:15},"bgra8unorm-srgb":{webgpu:15360},r16unorm:{f:fn,render:pn,webgpu:yn},rg16unorm:{f:fn,render:pn,webgpu:yn},"rgb16unorm-webgl":{f:fn,render:!1},rgba16unorm:{f:fn,render:pn,webgpu:yn},r16snorm:{f:fn,render:mn,webgpu:yn},rg16snorm:{f:fn,render:mn,webgpu:yn},"rgb16snorm-webgl":{f:fn,render:!1},rgba16snorm:{f:fn,render:mn,webgpu:yn},r16uint:{webgpu:515},rg16uint:{webgpu:515},rgba16uint:{webgpu:_n},r16sint:{webgpu:515},rg16sint:{webgpu:515},rgba16sint:{webgpu:_n},r16float:{render:hn,filter:"float16-filterable-webgl",webgpu:527},rg16float:{render:hn,filter:bn,webgpu:527},rgba16float:{render:hn,filter:bn,webgpu:31},r32uint:{webgpu:_n},rg32uint:{webgpu:16387},rgba32uint:{webgpu:_n},r32sint:{webgpu:_n},rg32sint:{webgpu:16387},rgba32sint:{webgpu:_n},r32float:{render:un,filter:gn,webgpu:_n},rg32float:{render:!1,filter:gn,webgpu:16387},"rgb32float-webgl":{render:un,filter:gn},rgba32float:{render:un,filter:gn,webgpu:_n},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:"rgb9e5ufloat-renderable-webgl",webgpu:5},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:un,webgpu:517},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:527},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1,webgpu:515},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8",webgpu:3},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16",webgpu:3},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32",webgpu:3},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32",webgpu:3},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0,webgpu:3},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0,f:"depth32float-stencil8",webgpu:3}},...{"bc1-rgb-unorm-webgl":{f:on},"bc1-rgb-unorm-srgb-webgl":{f:on},"bc1-rgba-unorm":{f:on},"bc1-rgba-unorm-srgb":{f:on},"bc2-rgba-unorm":{f:on},"bc2-rgba-unorm-srgb":{f:on},"bc3-rgba-unorm":{f:on},"bc3-rgba-unorm-srgb":{f:on},"bc4-r-unorm":{f:on},"bc4-r-snorm":{f:on},"bc5-rg-unorm":{f:on},"bc5-rg-snorm":{f:on},"bc6h-rgb-ufloat":{f:on},"bc6h-rgb-float":{f:on},"bc7-rgba-unorm":{f:on},"bc7-rgba-unorm-srgb":{f:on},"etc2-rgb8unorm":{f:an},"etc2-rgb8unorm-srgb":{f:an},"etc2-rgb8a1unorm":{f:an},"etc2-rgb8a1unorm-srgb":{f:an},"etc2-rgba8unorm":{f:an},"etc2-rgba8unorm-srgb":{f:an},"eac-r11unorm":{f:an},"eac-r11snorm":{f:an},"eac-rg11unorm":{f:an},"eac-rg11snorm":{f:an},"astc-4x4-unorm":{f:sn},"astc-4x4-unorm-srgb":{f:sn},"astc-5x4-unorm":{f:sn},"astc-5x4-unorm-srgb":{f:sn},"astc-5x5-unorm":{f:sn},"astc-5x5-unorm-srgb":{f:sn},"astc-6x5-unorm":{f:sn},"astc-6x5-unorm-srgb":{f:sn},"astc-6x6-unorm":{f:sn},"astc-6x6-unorm-srgb":{f:sn},"astc-8x5-unorm":{f:sn},"astc-8x5-unorm-srgb":{f:sn},"astc-8x6-unorm":{f:sn},"astc-8x6-unorm-srgb":{f:sn},"astc-8x8-unorm":{f:sn},"astc-8x8-unorm-srgb":{f:sn},"astc-10x5-unorm":{f:sn},"astc-10x5-unorm-srgb":{f:sn},"astc-10x6-unorm":{f:sn},"astc-10x6-unorm-srgb":{f:sn},"astc-10x8-unorm":{f:sn},"astc-10x8-unorm-srgb":{f:sn},"astc-10x10-unorm":{f:sn},"astc-10x10-unorm-srgb":{f:sn},"astc-12x10-unorm":{f:sn},"astc-12x10-unorm-srgb":{f:sn},"astc-12x12-unorm":{f:sn},"astc-12x12-unorm-srgb":{f:sn},"pvrtc-rgb4unorm-webgl":{f:cn},"pvrtc-rgba4unorm-webgl":{f:cn},"pvrtc-rgb2unorm-webgl":{f:cn},"pvrtc-rgba2unorm-webgl":{f:cn},"etc1-rbg-unorm-webgl":{f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{f:ln},"atc-rgba-unorm-webgl":{f:ln},"atc-rgbai-unorm-webgl":{f:ln}}},En=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,xn=["rgb","rgba","bgra"],Tn=["depth","stencil"],Mn=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Sn=new class{isColor(e){return xn.some(t=>e.startsWith(t))}isDepthStencil(e){return Tn.some(t=>e.startsWith(t))}isCompressed(e){return Mn.some(t=>e.startsWith(t))}getInfo(e){return Pn(e)}getCapabilities(e){return function(e){const t=vn(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},r=Pn(e),i=e.startsWith("depth")||e.startsWith("stencil"),o=r?.signed,s=r?.integer,a=r?.webgl,c=Boolean(r?.compressed);return n.render&&=!i&&!c,n.filter&&=!(i||o||s||a),n}(e)}getWebGPUCapabilities(e){const t=vn(e);return void 0!==t.webgpu?t.webgpu:this.isCompressed(e)&&!e.endsWith("-webgl")?5:0}computeMemoryLayout(e){return function({format:e,width:t,height:n,depth:r,byteAlignment:i}){const{bytesPerPixel:o,bytesPerBlock:s=o,blockWidth:a=1,blockHeight:c=1,compressed:l=!1}=Sn.getInfo(e),u=l?Math.ceil(t/a):t,h=l?Math.ceil(n/c):n,d=u*s,f=Math.ceil(d/i)*i;return{bytesPerPixel:o,bytesPerRow:f,rowsPerImage:h,depthOrArrayLayers:r,bytesPerImage:f*h,byteLength:f*h*r}}(e)}};function Pn(t){let n=function(e){const t={...vn(e)},n=t.bytesPerPixel||1,r=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,delete t.webgpu,{...t,format:e,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||t.channels?.length||1,bytesPerPixel:n,bitsPerChannel:r,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}(t);if(Sn.isCompressed(t)){n.channels="rgb",n.components=3,n.bytesPerPixel=1,n.srgb=!1,n.compressed=!0,n.bytesPerBlock=function(e){return e.startsWith("bc1")||e.startsWith("bc4")||e.startsWith("etc1")||e.startsWith("etc2-rgb8")||e.startsWith("etc2-rgb8a1")||e.startsWith("eac-r11")||"atc-rgb-unorm-webgl"===e?8:e.startsWith("bc2")||e.startsWith("bc3")||e.startsWith("bc5")||e.startsWith("bc6h")||e.startsWith("bc7")||e.startsWith("etc2-rgba8")||e.startsWith("eac-rg11")||e.startsWith("astc")||"atc-rgba-unorm-webgl"===e||"atc-rgbai-unorm-webgl"===e?16:e.startsWith("pvrtc")?8:16}(t);const e=function(e){const t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){const[,e,n]=t;return{blockWidth:Number(e),blockHeight:Number(n)}}return e.startsWith("bc")||e.startsWith("etc1")||e.startsWith("etc2")||e.startsWith("eac")||e.startsWith("atc")||e.startsWith("pvrtc-rgb4")||e.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:e.startsWith("pvrtc-rgb2")||e.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}(t);e&&(n.blockWidth=e.blockWidth,n.blockHeight=e.blockHeight)}const r=n.packed?null:En.exec(t);if(r){const[,i,o,s,a,c]=r,l=`${s}${o}`,u=e.getDataTypeInfo(l),h=8*u.byteLength,d=i?.length??1,f=[h,d>=2?h:0,d>=3?h:0,d>=4?h:0];n={format:t,attachment:n.attachment,dataType:u.signedType,components:d,channels:i,integer:u.integer,signed:u.signed,normalized:u.normalized,bitsPerChannel:f,bytesPerPixel:u.byteLength*d,packed:n.packed,srgb:n.srgb},"-webgl"===c&&(n.webgl=!0),"-srgb"===a&&(n.srgb=!0)}return t.endsWith("-webgl")&&(n.webgl=!0),t.endsWith("-srgb")&&(n.srgb=!0),n}function On(e){return"undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}function An(e){if("undefined"!=typeof ImageData&&e instanceof ImageData||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if("undefined"!=typeof VideoFrame&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}var jn=class{};function Ln(e){if(void 0!==e){if(null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(Ln);if("object"==typeof e){if(function(e){return"toString"in e&&"function"==typeof e.toString&&e.toString!==Object.prototype.toString}(e)){const t=String(e);if("[object Object]"!==t)return t}return function(e){return"message"in e&&"type"in e}(e)?function(e){const t="string"==typeof e.type?e.type:"message",n="string"==typeof e.message?e.message:"",r="number"==typeof e.lineNum?e.lineNum:null,i="number"==typeof e.linePos?e.linePos:null;return`${t}${null!==r&&null!==i?` @ ${r}:${i}`:null!==r?` @ ${r}`:""}: ${n}`.trim()}(e):e.constructor?.name||"Object"}return String(e)}}var In=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}};function Cn(){if("undefined"==typeof HTMLCanvasElement)return!1;const e=HTMLCanvasElement.prototype;return"layoutSubtree"in e&&"function"==typeof e.requestPaint}var Rn=class e{static defaultProps={...Qt};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=rn;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=/* @__PURE__ */new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(t){this.props={...e.defaultProps,...t},this.id=this.props.id||n(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return r.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Sn.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){return 1+Math.floor(Math.log2(Math.max(e,t,n)))}isExternalImage(e){return On(e)}getExternalImageSize(e){return An(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Sn.isCompressed(e)}getSupportedCompressedTextureFormats(){const e=[];for(const t of Object.keys(wn))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){if(!this.props.onError(e,t)){const r=function(e,t){return[Ln(e),...t.map(Ln).filter(e=>void 0!==e)].filter(e=>void 0!==e)}(t,n);return o.error("webgl"===this.type?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...r)}return()=>{}}debug(){this.props.debug||o.once(0,"'Type luma.log.set({debug: true}) in console to enable debug breakpoints',\nor create a device with the 'debug: true' prop.")()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,n,r=0){throw new Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,n,r,i){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return null!==this._debugGPUTimeQuery}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return!0===e.createCanvasContext?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=Sn.getCapabilities(e),n=e=>("string"==typeof e?this.features.has(e):e)??!0,r=n(t.create);return{format:e,create:r,render:r&&n(t.render),filter:r&&n(t.filter),blend:r&&n(t.blend),store:r&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&a.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}},$n=class e extends t{static defaultProps={...t.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(t,n){super(t,n=e.normalizeProps(t,n),e.defaultProps)}static normalizeProps(e,t){return t}},kn={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Nn=class e extends t{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(t,n,r){if(super(t,n=e.normalizeProps(t,n),e.defaultProps),this.dimension=this.props.dimension,this.baseDimension=kn[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,"cube"===this.dimension&&(this.depth=6),void 0===this.props.width||void 0===this.props.height)if(t.isExternalImage(n.data)){const e=t.getExternalImageSize(n.data);this.width=e?.width||1,this.height=e?.height||1}else this.width=1,this.height=1,void 0!==this.props.width&&void 0!==this.props.height||o.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=r?.byteAlignment||1,this.updateTimestamp=t.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof $n?e:this.device.createSampler(e)}copyImageData(e){const{data:t,depth:n,...r}=e;this.writeData(t,{...r,depthOrArrayLayers:r.depthOrArrayLayers??n})}computeMemoryLayout(e={}){const{width:t=this.width,height:n=this.height,depthOrArrayLayers:r=this.depth}=this._normalizeTextureReadOptions(e),{format:i,byteAlignment:o}=this;return Sn.computeMemoryLayout({format:i,width:t,height:n,depth:r,byteAlignment:o})}readBuffer(e,t){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,t){throw new Error("readBuffer not implemented")}writeData(e,t){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){const n={...t},{width:r,height:i}=n;return"number"==typeof r&&(n.width=Math.max(1,Math.ceil(r))),"number"==typeof i&&(n.height=Math.max(1,Math.ceil(i))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){const{data:t,depth:n,...r}=e,i=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??n});return{data:t,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o=this.device.getExternalImageSize(t.image),s={...e.defaultCopyExternalImageOptions,...i,...o,...n};return s.width=Math.min(s.width,i.width-s.x),s.height=Math.min(s.height,i.height-s.y),s.depth=Math.min(s.depth,i.depthOrArrayLayers-s.z),s}_normalizeCopyElementImageOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o={...e.defaultCopyElementImageOptions,...i,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depth=Math.min(o.depth,i.depthOrArrayLayers-o.z),o}_normalizeTextureReadOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o={...e.defaultTextureReadOptions,...i,...n};return o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,i.depthOrArrayLayers-o.z),o}_getSupportedColorReadOptions(e){const t=this._normalizeTextureReadOptions(e),n=Sn.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(n),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if("all"!==e.aspect)throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(t){const n=e._omitUndefined(t),r=n.mipLevel??0,i=this._getMipLevelSize(r),o={...e.defaultTextureWriteOptions,...i,...n};o.width=Math.min(o.width,i.width-o.x),o.height=Math.min(o.height,i.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,i.depthOrArrayLayers-o.z);const s=Sn.computeMemoryLayout({format:this.format,width:o.width,height:o.height,depth:o.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*o.width;if(o.bytesPerRow=n.bytesPerRow??s.bytesPerRow,o.rowsPerImage=n.rowsPerImage??o.height,o.bytesPerRow<a)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be at least ${a} for ${this.format}`);if(o.rowsPerImage<o.height)throw new Error(`rowsPerImage (${o.rowsPerImage}) must be at least ${o.height} for ${this.format}`);const c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&o.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return o}_getMipLevelSize(e){return{width:Math.max(1,this.width>>e),height:"1d"===this.baseDimension?1:Math.max(1,this.height>>e),depthOrArrayLayers:"3d"===this.dimension?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){const{width:n,height:r,depthOrArrayLayers:i}=this._getMipLevelSize(t);e+=Sn.computeMemoryLayout({format:this.format,width:n,height:r,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}static defaultProps={...t.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:e.SAMPLE|e.RENDER|e.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultCopyElementImageOptions={element:void 0,width:void 0,height:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}},zn=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,Dn=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Un(e){return`${e.name}Uniforms`}function Wn(e,t){const n="wgsl"===t?e.source:"vertex"===t?e.vs:e.fs;if(!n)return null;return function(e,t,n){const r="wgsl"===t?function(e,t){const n=new RegExp(`\\bstruct\\s+${t}\\b`,"m").exec(e);if(!n)return null;const r=e.indexOf("{",n.index);if(r<0)return null;let i=0;for(let o=r;o<e.length;o++){const t=e[o];if("{"!==t){if("}"===t&&(i--,0===i))return e.slice(r+1,o)}else i++}return null}(e,n):function(e,t){return Bn(e).find(e=>e.blockName===t)?.body||null}(e,n);if(!r)return null;const i=[];for(const o of r.split("\n")){const e=o.replace(/\/\/.*$/,"").trim();if(!e||e.startsWith("#"))continue;const n="wgsl"===t?e.match(/^([A-Za-z0-9_]+)\s*:/):e.match(zn);n&&i.push(n[1])}return i}(n,"wgsl"===t?"wgsl":"glsl",Un(e))}function Fn(e,t,n={}){const r=function(e,t){const n=Object.keys(e.uniformTypes||{});if(!n.length)return null;const r=Wn(e,t);return r?{moduleName:e.name,uniformBlockName:Un(e),stage:t,expectedUniformNames:n,actualUniformNames:r,matches:Gn(n,r)}:null}(e,t);if(!r||r.matches)return r;const i=function(e){const{expectedUniformNames:t,actualUniformNames:n}=e,r=t.filter(e=>!n.includes(e)),i=n.filter(e=>!t.includes(e)),o=[`Expected ${t.length} fields, found ${n.length}.`],s=function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return`First mismatch at field ${r+1}: expected ${e[r]}, found ${t[r]}.`;return e.length>t.length?`Shader block ends after field ${t.length}; expected next field ${e[t.length]}.`:t.length>e.length?`Shader block has extra field ${t.length}: ${t[e.length]}.`:null}(t,n);s&&o.push(s);r.length&&o.push(`Missing from shader block (${r.length}): ${Yn(r)}.`);i.length&&o.push(`Unexpected in shader block (${i.length}): ${Yn(i)}.`);t.length<=12&&n.length<=12&&(r.length||i.length)&&(o.push(`Expected: ${t.join(", ")}.`),o.push(`Actual: ${n.join(", ")}.`));return`${e.moduleName}: ${e.stage} shader uniform block ${e.uniformBlockName} does not match module.uniformTypes. ${o.join(" ")}`}(r);return n.log?.error?.(i,r)(),!1!==n.throwOnError&&Ct(!1,i),r}function Bn(e){const t=[],n=function(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}(e);for(const r of n.matchAll(Dn)){const e=r[1]?.trim()||null;t.push({blockName:r[2],body:r[3],instanceName:r[4]||null,layoutQualifier:e,hasLayoutQualifier:Boolean(e),isStd140:Boolean(e&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(e))})}return t}function Gn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Vn(e){return e.replace(/\s+/g," ").trim()}function Yn(e,t=8){if(e.length<=t)return e.join(", ");const n=e.length-t;return`${e.slice(0,t).join(", ")}, ... (${n} more)`}var Xn=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,"#version 300 es\n"],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],qn=[...Xn,[Kn("attribute"),"in $1"],[Kn("varying"),"out $1"]],Hn=[...Xn,[Kn("varying"),"in $1"]];function Zn(e,t){for(const[n,r]of t)e=e.replace(n,r);return e}function Kn(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Jn(e,t,n="glsl"){let r="";for(const i in e){const o=e[i];if(r+=`${"wgsl"===n?"fn":"void"} ${o.signature} {\n`,o.header&&(r+=` ${o.header}`),t[i]){const e=t[i];e.sort((e,t)=>e.order-t.order);for(const t of e)r+=` ${t.injection}\n`}o.footer&&(r+=` ${o.footer}`),r+="}\n"}return r}function Qn(e){const t={vertex:{},fragment:{}};for(const n of e){let e,r;"string"!=typeof n?(e=n,r=e.hook):(e={},r=n),r=r.trim();const i=r.indexOf(":"),o=r.slice(0,i),s=r.slice(i+1),a=r.replace(/\(.+/,""),c=Object.assign(e,{signature:s});switch(o){case"vs":t.vertex[a]=c;break;case"fs":t.fragment[a]=c;break;default:throw new Error(o)}}return t}function er(e,t="unnamed"){const n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function tr(e){let t=100;const n=e.match(/[^\s]+/g);if(n&&n.length>=2&&"#version"===n[0]){const e=parseInt(n[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}var nr=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ct}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${ct}\\s*:\\s*([^;]+);`,"g")];function rr(e,t=[]){const n=pt(e),r=/* @__PURE__ */new Map;for(const o of t)r.set(or(o.name,o.group,o.location),o.moduleName);const i=[];for(const o of nr){let e;for(o.lastIndex=0,e=o.exec(n);e;){const t=o===nr[0],s=Number(e[t?1:2]),a=Number(e[t?2:1]),c=e[3]?.trim(),l=e[4],u=e[5].trim(),h=r.get(or(l,a,s));i.push(ir({name:l,group:a,binding:s,owner:h?"module":"application",moduleName:h,accessDeclaration:c,resourceType:u})),e=o.exec(n)}}return i.sort((e,t)=>e.group!==t.group?e.group-t.group:e.binding!==t.binding?e.binding-t.binding:e.name.localeCompare(t.name))}function ir(e){const t={name:e.name,group:e.group,binding:e.binding,owner:e.owner,kind:"unknown",moduleName:e.moduleName,resourceType:e.resourceType};if(e.accessDeclaration){const n=e.accessDeclaration.split(",").map(e=>e.trim());if("uniform"===n[0])return{...t,kind:"uniform",access:"uniform"};if("storage"===n[0]){const e=n[1]||"read_write";return{...t,kind:"read"===e?"read-only-storage":"storage",access:e}}}return"sampler"===e.resourceType||"sampler_comparison"===e.resourceType?{...t,kind:"sampler",samplerKind:"sampler_comparison"===e.resourceType?"comparison":"filtering"}:e.resourceType.startsWith("texture_storage_")?{...t,kind:"storage-texture",access:(n=e.resourceType,/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(n)?.[1]),viewDimension:sr(e.resourceType)}:e.resourceType.startsWith("texture_")?{...t,kind:"texture",viewDimension:sr(e.resourceType),sampleType:ar(e.resourceType),multisampled:e.resourceType.startsWith("texture_multisampled_")}:t;var n}function or(e,t,n){return`${t}:${n}:${e}`}function sr(e){return e.includes("cube_array")?"cube-array":e.includes("2d_array")?"2d-array":e.includes("cube")?"cube":e.includes("3d")?"3d":e.includes("2d")?"2d":e.includes("1d")?"1d":void 0}function ar(e){return e.startsWith("texture_depth_")?"depth":e.includes("<i32>")?"sint":e.includes("<u32>")?"uint":e.includes("<f32>")?"float":void 0}var cr="([a-zA-Z_][a-zA-Z0-9_]*)",lr=/^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/,ur=new RegExp(`^\\s*\\#\\s*ifdef\\s*${cr}\\s*$`),hr=new RegExp(`^\\s*\\#\\s*ifndef\\s*${cr}\\s*(?:\\/\\/.*)?$`),dr=/^\s*\#\s*else\s*(?:\/\/.*)?$/,fr=/^\s*\#\s*endif\s*$/,pr=new RegExp(`^\\s*\\#\\s*ifdef\\s*${cr}\\s*(?:\\/\\/.*)?$`),mr=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function gr(e,t){const n=e.split("\n"),r=[],i=[];let o=!0;for(const s of n){const e=s.match(lr),n=s.match(pr)||s.match(ur),a=s.match(hr),c=s.match(dr),l=s.match(mr)||s.match(fr);if(e){const n=br(e[1],t?.defines||{}),r=o&&n;i.push({parentActive:o,branchTaken:n,active:r}),o=r}else if(n||a){const e=(n||a)?.[1],r=Boolean(t?.defines?.[e]),s=n?r:!r,c=o&&s;i.push({parentActive:o,branchTaken:s,active:c}),o=c}else if(c){const e=i[i.length-1];if(!e)throw new Error("Encountered #else without matching #if, #ifdef or #ifndef");e.active=e.parentActive&&!e.branchTaken,e.branchTaken=!0,o=e.active}else l?(i.pop(),o=!i.length||i[i.length-1].active):o&&r.push(s)}if(i.length>0)throw new Error("Unterminated conditional block in shader source");return r.join("\n")}function br(e,t){const n=e.trim();if(/^[+-]?\d+(?:\.\d+)?$/.test(n))return 0!==Number(n);if("true"===n)return!0;if("false"===n)return!1;const r=n.match(new RegExp(`^!\\s*${cr}$`));if(r)return!Boolean(t[r[1]]);const i=n.match(new RegExp(`^${cr}$`));if(i)return Boolean(t[i[1]]);const o=n.match(new RegExp(`^defined\\s*\\(\\s*${cr}\\s*\\)$`));if(o)return void 0!==t[o[1]];const s=n.match(new RegExp(`^!\\s*defined\\s*\\(\\s*${cr}\\s*\\)$`));if(s)return void 0===t[s[1]];throw new Error(`Unsupported #if expression "${e}"`)}function _r(e,t,n){const r=Object.entries(n);if(0===r.length)return{source:e,declarations:"",initialization:""};const i=function(e,t){const n=new RegExp(`\\bfn\\s+${Or(t)}\\s*\\(`,"g").exec(e);if(!n)throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${t}"`);const r=e.indexOf("(",n.index),i=Sr(e,r,"(",")");if(i<0)throw new Error(`Unable to parse WGSL vertex entry point "${t}" parameters`);return{openParenthesis:r,closeParenthesis:i}}(e,t),o=e.slice(i.openParenthesis+1,i.closeParenthesis),s=function(e,t){const n=wr(t),r=new Set(Er(t)),i=function(e){const t=[],n=/:\s*([A-Za-z_][\w]*)\b/g;let r=n.exec(e);for(;r;)t.push(r[1]),r=n.exec(e);return t}(t);for(const o of i){const t=xr(e,o);if(null!==t){n.push(...wr(t));for(const e of Er(t))r.add(e)}}return{locations:n,names:r}}(e,o),a=new Set(s.locations),c=[],l=[],u=[];for(const[p,m]of r){if(s.names.has(p)||Tr(e,p))throw new Error(`ShaderPlugin vertex input "${p}" conflicts with an existing WGSL shader input or variable`);const t=Mr(a);a.add(t);const n=`_luma_${p}`;c.push(`@location(${t}) ${n}: ${m}`),l.push(`var<private> ${p}: ${m};`),u.push(`${p} = ${n};`)}const h=o.trim()?",\n ":"\n ",d=o.trim()?"":"\n",f=`${o}${h}${c.join(",\n ")}${d}`;return{source:e.slice(0,i.openParenthesis+1)+f+e.slice(i.closeParenthesis),declarations:l.join("\n"),initialization:u.join("\n")}}function yr(e){const{primitiveType:t,components:n}=s.getAttributeShaderTypeInfo(e),r="i32"===t?"int":"u32"===t?"uint":"float";return 1===n?r:`${"int"===r?"i":"uint"===r?"u":""}vec${n}`}function vr(e,t){const n=Or(t);if(new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${n}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin vertex input "${t}" conflicts with an existing GLSL input`)}function wr(e){const t=[],n=/@location\s*\(\s*(\d+)\s*\)/g;let r=n.exec(e);for(;r;)t.push(Number(r[1])),r=n.exec(e);return t}function Er(e){const t=[],n=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;let r=n.exec(e);for(;r;)t.push(r[1]),r=n.exec(e);return t}function xr(e,t){const n=new RegExp(`\\bstruct\\s+${Or(t)}\\s*\\{`,"g").exec(e);if(!n)return null;const r=e.indexOf("{",n.index),i=Sr(e,r,"{","}");return i<0?null:e.slice(r+1,i)}function Tr(e,t){const n=Or(t),r=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${n}\\b`,"g");let i=r.exec(e);for(;i;){if(0===Pr(e,i.index))return!0;i=r.exec(e)}return!1}function Mr(e){let t=0;for(;e.has(t);)t++;return t}function Sr(e,t,n,r){let i=0,o=0,s=!1;for(let a=t;a<e.length;a++){const t=e[a],c=e[a+1];if(s)"\n"===t&&(s=!1);else if(o>0)"/"===t&&"*"===c?(o++,a++):"*"===t&&"/"===c&&(o--,a++);else if("/"!==t||"/"!==c)if("/"!==t||"*"!==c){if(t===n&&i++,t===r&&0===--i)return a}else o=1,a++;else s=!0,a++}return-1}function Pr(e,t){let n=0,r=0,i=!1;for(let o=0;o<t;o++){const t=e[o],s=e[o+1];i?"\n"===t&&(i=!1):r>0?"/"===t&&"*"===s?(r++,o++):"*"===t&&"/"===s&&(r--,o++):"/"===t&&"/"===s?(i=!0,o++):"/"===t&&"*"===s?(r=1,o++):"{"===t?n++:"}"===t&&n--}return n}function Or(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ar(e,t,n,r){const i=Object.entries(r);if(0===i.length)return{source:e,declarations:"",vertexInitialization:"",fragmentInitialization:""};let o=e,s=jr(o,t,"vertex");const a=function(e,t){const n=e.slice(t.closeParenthesis+1,t.openBrace),r=/->\s*([A-Za-z_][\w]*)\s*$/.exec(n.trim());if(!r||null===Ir(e,r[1]))throw new Error("ShaderPlugin varyings require the WGSL vertex entry point to return a named struct");return r[1]}(o,s);let c=jr(o,n,"fragment");const l=function(e,t){const n=[];for(const r of function(e,t){const n=[];let r=0,i=0,o=0;for(let s=0;s<e.length;s++){const a=e[s];"("===a&&i++,")"===a&&i--,"<"===a&&o++,">"===a&&o--,a===t&&0===i&&0===o&&(n.push(e.slice(r,s)),r=s+1)}return n.push(e.slice(r)),n}(t.parameters,",")){const t=/(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(r.trim());t&&Ir(e,t[2])&&n.push({name:t[1],type:t[2]})}if(1!==n.length)throw new Error(`ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${n.length}`);return n[0]}(o,c),u=Lr(o,a),h=Lr(o,l.type),d=/* @__PURE__ */new Set([...kr(s.parameters),...kr(u.body),...kr(c.parameters),...kr(h.body)]),f=/* @__PURE__ */new Set([...$r(u.body),...$r(h.body)]),p=[],m=[],g=[],b=[];for(const[y,v]of i){if(d.has(y)||Nr(o,y))throw new Error(`ShaderPlugin varying "${y}" conflicts with existing WGSL stage I/O or a module variable`);const e=zr(f);f.add(e);const t="flat"===v.interpolation?" @interpolate(flat)":"";p.push(` @location(${e})${t} ${y}: ${v.type},`),m.push(`var<private> ${y}: ${v.type};`),g.push(`${y} = ${Ur(v.type)};`),b.push(`${y} = ${l.name}.${y};`)}!function(e,t,n,r){const i=new RegExp(`\\b${Gr(t)}\\s*\\(`,"g");let o=i.exec(e);for(;o;){if(o.index<n||o.index>r)throw new Error(`ShaderPlugin varying output struct "${t}" is constructed outside the selected vertex entry point`);o=i.exec(e)}}(o,a,s.openBrace,s.closeBrace),o=function(e,t,n,r){const i=new RegExp(`\\b${Gr(t)}\\s*\\(`,"g"),o=[];let s=i.exec(e);for(;s;){if(s.index>n.openBrace&&s.index<n.closeBrace){const r=e.indexOf("(",s.index),i=Fr(e,r,"(",")");if(i<0||i>n.closeBrace)throw new Error(`Unable to parse WGSL output constructor "${t}"`);o.push({openParenthesis:r,closeParenthesis:i})}s=i.exec(e)}for(const a of o.sort((e,t)=>t.closeParenthesis-e.closeParenthesis)){const t=e.slice(a.openParenthesis+1,a.closeParenthesis).trim()?", ":"";e=e.slice(0,a.closeParenthesis)+t+r.join(", ")+e.slice(a.closeParenthesis)}return e}(o,a,s,i.map(([e])=>e)),s=jr(o,t,"vertex"),o=function(e,t,n){const r=function(e,t,n){const r=[];let i=t;for(;i<n;)if(i=Rr(e,i,n),"return"!==e.slice(i,i+6)||/[A-Za-z0-9_]/.test(e[i+6]||""))i++;else{const t=i+6,o=Cr(e,t,n);if(o<0)throw new Error("Unable to parse WGSL return statement in selected vertex entry point");r.push({start:i,expressionStart:t,semicolon:o}),i=o+1}return r}(e,t.openBrace+1,t.closeBrace);for(let i=r.length-1;i>=0;i--){const t=r[i],o=e.slice(t.expressionStart,t.semicolon).trim();if(!o)throw new Error("ShaderPlugin varying vertex entry point cannot use an empty return");const s=`_luma_vertexOutput${i}`,a=`{\nvar ${s} = ${o};\n${n.map(e=>`${s}.${e} = ${e};`).join("\n")}\nreturn ${s};\n}`;e=e.slice(0,t.start)+a+e.slice(t.semicolon+1)}return e}(o,s,i.map(([e])=>e));const _=(a===l.type?[a]:[a,l.type]).map(e=>Lr(o,e).closeBrace).sort((e,t)=>t-e);for(const y of _)o=o.slice(0,y)+`${p.join("\n")}\n`+o.slice(y);if(c=jr(o,n,"fragment"),!new RegExp(`\\b${Gr(l.name)}\\s*:`).test(c.parameters))throw new Error(`Unable to preserve WGSL fragment input "${l.name}"`);return{source:o,declarations:m.join("\n"),vertexInitialization:g.join("\n"),fragmentInitialization:b.join("\n")}}function jr(e,t,n){const r=new RegExp(`\\bfn\\s+${Gr(t)}\\s*\\(`,"g").exec(e);if(!r)throw new Error(`ShaderPlugin varyings require WGSL ${n} entry point "${t}"`);const i=e.indexOf("(",r.index),o=Fr(e,i,"(",")"),s=e.indexOf("{",o),a=Fr(e,s,"{","}");if(o<0||s<0||a<0)throw new Error(`Unable to parse WGSL ${n} entry point "${t}"`);return{openParenthesis:i,closeParenthesis:o,openBrace:s,closeBrace:a,parameters:e.slice(i+1,o)}}function Lr(e,t){const n=Ir(e,t);if(!n)throw new Error(`Unable to find WGSL stage I/O struct "${t}"`);return n}function Ir(e,t){const n=new RegExp(`\\bstruct\\s+${Gr(t)}\\s*\\{`,"g").exec(e);if(!n)return null;const r=e.indexOf("{",n.index),i=Fr(e,r,"{","}");return i<0?null:{openBrace:r,closeBrace:i,body:e.slice(r+1,i)}}function Cr(e,t,n){let r=0,i=0;for(let o=t;o<n;o++){const t=Rr(e,o,n);if(t!==o){o=t-1;continue}const s=e[o];if("("===s&&r++,")"===s&&r--,"["===s&&i++,"]"===s&&i--,";"===s&&0===r&&0===i)return o}return-1}function Rr(e,t,n){let r=t;if("/"===e[r]&&"/"===e[r+1]){const t=e.indexOf("\n",r+2);return t<0||t>n?n:t+1}if("/"===e[r]&&"*"===e[r+1]){let t=1;for(r+=2;r<n&&t>0;)"/"===e[r]&&"*"===e[r+1]?(t++,r+=2):"*"===e[r]&&"/"===e[r+1]?(t--,r+=2):r++}return r}function $r(e){const t=[],n=/@location\s*\(\s*(\d+)\s*\)/g;let r=n.exec(e);for(;r;)t.push(Number(r[1])),r=n.exec(e);return t}function kr(e){const t=[],n=/(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;let r=n.exec(e);for(;r;)t.push(r[1]),r=n.exec(e);return t}function Nr(e,t){const n=new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${Gr(t)}\\b`,"g");let r=n.exec(e);for(;r;){if(0===Br(e,r.index))return!0;r=n.exec(e)}return!1}function zr(e){let t=0;for(;e.has(t);)t++;return t}function Dr(e){const{primitiveType:t,components:n}=s.getAttributeShaderTypeInfo(e),r="u32"===t?"0u":"i32"===t?"0":"0.0";return 1===n?r:`${yr(e)}(${r})`}function Ur(e){const{primitiveType:t,components:n}=s.getAttributeShaderTypeInfo(e),r=`${t}(0)`;return 1===n?r:`${e}(${r})`}function Wr(e,t){if(new RegExp(`\\b(?:flat\\s+|smooth\\s+)?(?:in|out|varying)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${Gr(t)}\\s*(?:\\[|;)`).test(e))throw new Error(`ShaderPlugin varying "${t}" conflicts with existing GLSL stage I/O`)}function Fr(e,t,n,r){let i=0,o=0,s=!1;for(let a=t;a<e.length;a++){const t=e[a],c=e[a+1];if(s)"\n"===t&&(s=!1);else if(o>0)"/"===t&&"*"===c?(o++,a++):"*"===t&&"/"===c&&(o--,a++);else if("/"!==t||"/"!==c)if("/"!==t||"*"!==c){if(t===n&&i++,t===r&&0===--i)return a}else o=1,a++;else s=!0,a++}return-1}function Br(e,t){let n=0;for(let r=0;r<t;r++){const i=Rr(e,r,t);i===r?("{"===e[r]&&n++,"}"===e[r]&&n--):r=i-1}return n}function Gr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Vr=`\n\n${Wt}\n`,Yr=100;function Xr(e){const t=Ht(e.modules||[]),{source:n,bindingAssignments:r}=function(e,t){const{source:n,stage:r,modules:i,defines:o={},hookFunctions:s=[],inject:a={},pluginInjections:c={},pluginVertexInputs:l={},pluginVaryings:u={},vertexEntryPoint:h="vertexMain",fragmentEntryPoint:d="fragmentMain",log:f}=t;Ct("string"==typeof n,"shader source must be a string");const p=gr(n,{defines:o}),m=_r(p,h,l),g=Ar(m.source,h,d,u),b=g.source;let _="";const y=Qn(s),v={},w={},E={};Kr(c,v,w,E);for(const O in a){const e="string"==typeof a[O]?{injection:a[O],order:0}:a[O],t=/^(v|f)s:(#)?([\w-]+)$/.exec(O);if(t){const n=t[2],r=t[3];n?"decl"===r?w[O]=[e]:E[O]=[e]:v[O]=[e]}else E[O]=[e]}(function(e,t,n,r){e&&(n["vs:#decl"]=n["vs:#decl"]||[],n["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER}));t&&(r["vs:#main-start"]=r["vs:#main-start"]||[],r["vs:#main-start"].push({injection:t,order:Number.MIN_SAFE_INTEGER}))})(m.declarations,m.initialization,w,E),function(e,t,n){e.declarations&&(t["vs:#decl"]=t["vs:#decl"]||[],t["vs:#decl"].push({injection:e.declarations,order:Number.MIN_SAFE_INTEGER}));e.vertexInitialization&&(n["vs:#main-start"]=n["vs:#main-start"]||[],n["vs:#main-start"].push({injection:e.vertexInitialization,order:Number.MIN_SAFE_INTEGER}));e.fragmentInitialization&&(n["fs:#main-start"]=n["fs:#main-start"]||[],n["fs:#main-start"].push({injection:e.fragmentInitialization,order:Number.MIN_SAFE_INTEGER}))}(g,w,E);const x=i,T=function(e){const t=mt(e,ht),n=/* @__PURE__ */new Map;for(const o of t){if("auto"===o.bindingToken)continue;const e=Number(o.bindingToken),t=Number(o.groupToken);ni(t,e,o.name),ii(n,t,e,`application binding "${o.name}"`)}const r={sawSupportedBindingDeclaration:t.length>0},i=gt(e,ht,e=>function(e,t,n){const{match:r,bindingToken:i,groupToken:o,name:s}=e,a=Number(o);if("auto"===i){const e=function(e,t){const n=t.get(e)||/* @__PURE__ */new Set;let r=0;for(;n.has(r);)r++;return r}(a,t);return ni(a,e,s),ii(t,a,e,`application binding "${s}"`),r.replace(/@binding\(\s*auto\s*\)/,`@binding(${e})`)}return n.sawSupportedBindingDeclaration=!0,r}(e,n,r));if(bt(e)&&!r.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:i}}(b),M=function(e){const t=/* @__PURE__ */new Map;for(const n of mt(e,dt)){const e=Number(n.bindingToken),r=Number(n.groupToken);ni(r,e,n.name),ii(t,r,e,`application binding "${n.name}"`)}return t}(T.source),S=function(e,t,n,r){const i=/* @__PURE__ */new Map;if(!t)return i;for(const o of e)for(const e of ti(o,r)){const r=oi(e.group,o.name,e.name),s=t.get(r);if(void 0!==s){const t=i.get(e.group)||/* @__PURE__ */new Map,o=t.get(s);if(o&&o!==r)throw new Error(`Duplicate WGSL binding reservation for modules "${o}" and "${r}": group ${e.group}, binding ${s}.`);ii(n,e.group,s,`registered module binding "${r}"`),t.set(s,r),i.set(e.group,t)}}return i}(x,t._bindingRegistry,M,o),P=[];for(const O of x){f&&Xt(O,b,f);const e=ei(gr(Qr(O,"wgsl",f),{defines:o}),O,{usedBindingsByGroup:M,bindingRegistry:t._bindingRegistry,reservedBindingKeysByGroup:S});P.push(...e.bindingAssignments);_+=e.source;const n=Jr(O);for(const t in n){const e=/^(v|f)s:#([\w-]+)$/.exec(t);if(e){const r="decl"===e[2]?w:E;r[t]=r[t]||[],r[t].push(n[t])}else v[t]=v[t]||[],v[t].push(n[t])}}return _+=Vr,_=Gt(_,r,function(e){const t=[...e["vs:#decl"]||[],...e["fs:#decl"]||[]];return t.length?{"vs:#decl":t}:{}}(w),!1,"wgsl",{vertex:h,fragment:d}),_+=function(e,t){return Jn(e.vertex,t,"wgsl")+Jn(e.fragment,t,"wgsl")}(y,v),_+=function(e){if(0===e.length)return"";let t="// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------\n";for(const n of e)t+=`// ${n.moduleName}.${n.name} -> @group(${n.group}) @binding(${n.location})\n`;return t+="\n",t}(P),_+=T.source,_=Gt(_,r,E,!1,"wgsl",{vertex:h,fragment:d}),function(e){const t=function(e,t){return mt(e,t===ut||t===ht?ft:t).find(e=>"auto"===e.bindingToken)}(e,ut);if(!t)return;const n=function(e,t){const n=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;let r,i;i=n.exec(e);for(;i&&i.index<=t;)r=i[1],i=n.exec(e);return r}(e,t.index);if(n)throw new Error(`Unresolved @binding(auto) for module "${n}" binding "${t.name}" remained in assembled WGSL source.`);if(function(e,t){const n=e.indexOf(Vr);return!(n>=0)||t>n}(e,t.index))throw new Error(`Unresolved @binding(auto) for application binding "${t.name}" remained in assembled WGSL source.`);throw new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${function(e){return e.replace(/\s+/g," ").trim()}(t.match)}".`)}(_),{source:_,bindingAssignments:P}}(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t});return{source:n,getUniforms:Zr(t),bindingAssignments:r,bindingTable:rr(n,r),shaderLayout:_t(n,{vertexEntryPoint:e.vertexEntryPoint,scanVertexAttributes:e.scanVertexAttributes})}}function qr(e){const{vs:t,fs:n}=e,r=Ht(e.modules||[]);return{vs:Hr(e.platformInfo,{...e,source:t,stage:"vertex",modules:r}),fs:Hr(e.platformInfo,{...e,source:n,stage:"fragment",modules:r}),getUniforms:Zr(r)}}function Hr(e,t){const{source:n,stage:r,language:i="glsl",modules:o,defines:s={},hookFunctions:a=[],inject:c={},pluginInjections:l={},pluginVertexInputs:u={},pluginVaryings:h={},prologue:d=!0,log:f}=t;Ct("string"==typeof n,"shader source must be a string");const p="glsl"===i?function(e,t){return{name:er(e,t),language:"glsl",version:tr(e)}}(n).version:-1,m=e.shaderLanguageVersion,g=100===p?"#version 100":"#version 300 es",b=n.split("\n").slice(1).join("\n"),_={};o.forEach(e=>{Object.assign(_,e.defines)}),Object.assign(_,s);let y="";switch(i){case"wgsl":break;case"glsl":y=d?`${g}\n\n// ----- PROLOGUE -------------------------\n#define SHADER_TYPE_${r.toUpperCase()}\n\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n// Apple optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n// Nvidia optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n// Intel optimizes away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Intel's built-in 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n// Prevent driver from optimizing away the calculation necessary for emulated fp64\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n// Headless Chrome's software shader 'tan' function doesn't have acceptable precision\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n// If the GPU doesn't have full 32 bits precision, will causes overflow\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const n in e){const r=e[n];(r||Number.isFinite(r))&&(t+=`#define ${n.toUpperCase()} ${e[n]}\n`)}return t}(_)}\n\n`:`${g}\n`}const v=Qn(a),w={},E={},x={};Kr(l,w,E,x);for(const M in c){const e="string"==typeof c[M]?{injection:c[M],order:0}:c[M],t=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(t){const n=t[2],r=t[3];n?"decl"===r?E[M]=[e]:x[M]=[e]:w[M]=[e]}else x[M]=[e]}if("vertex"===r){const e=function(e,t){const n=[];for(const[r,i]of Object.entries(t))vr(e,r),n.push(`in ${yr(i)} ${r};`);return n.join("\n")}(b,u);e&&(E["vs:#decl"]=E["vs:#decl"]||[],E["vs:#decl"].push({injection:e,order:Number.MIN_SAFE_INTEGER}))}const T=function(e,t,n){const r=[],i=[];for(const[o,s]of Object.entries(n)){Wr(e,o);const n="flat"===s.interpolation?"flat ":"",a="vertex"===t?"out":"in";r.push(`${n}${a} ${yr(s.type)} ${o};`),"vertex"===t&&i.push(`${o} = ${Dr(s.type)};`)}return{declarations:r.join("\n"),initialization:i.join("\n")}}(b,r,h);if(T.declarations){const e="vertex"===r?"vs:#decl":"fs:#decl";E[e]=E[e]||[],E[e].push({injection:T.declarations,order:Number.MIN_SAFE_INTEGER})}T.initialization&&(x["vs:#main-start"]=x["vs:#main-start"]||[],x["vs:#main-start"].push({injection:T.initialization,order:Number.MIN_SAFE_INTEGER}));for(const M of o){f&&Xt(M,b,f);y+=Qr(M,r,f);const e=M.instance?.normalizedInjections[r]||{};for(const t in e){const n=/^(v|f)s:#([\w-]+)$/.exec(t);if(n){const r="decl"===n[2]?E:x;r[t]=r[t]||[],r[t].push(e[t])}else w[t]=w[t]||[],w[t].push(e[t])}}return y+="// ----- MAIN SHADER SOURCE -------------------------",y+=Vr,y=Gt(y,r,E),y+=Jn(v[r],w),y+=b,y=Gt(y,r,x),"glsl"===i&&p!==m&&(y=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return Zn(e,qn);case"fragment":return Zn(e,Hn);default:throw new Error(t)}}(y,r)),"glsl"===i&&function(e,t,n,r){const i=Bn(e).filter(e=>!e.isStd140),o=/* @__PURE__ */new Set;for(const s of i){if(o.has(s.blockName))continue;o.add(s.blockName);const e=r?.label?`${r.label} `:"",i=s.hasLayoutQualifier?`declares ${Vn(s.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",a=`${e}${t} shader uniform block ${s.blockName} ${i}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;n?.warn?.(a,s)()}}(y,r,f),y.trim()}function Zr(e){return function(t){const n={};for(const r of e){const e=r.getUniforms?.(t,n);Object.assign(n,e)}return n}}function Kr(e,t,n,r){for(const i in e){const o=/^(v|f)s:(#)?([\w-]+)$/.exec(i);if(o){const s=o[2],a=o[3],c=s?"decl"===a?n:r:t;c[i]=c[i]||[],c[i].push(...e[i])}else r[i]=r[i]||[],r[i].push(...e[i])}}function Jr(e){return{...e.instance?.normalizedInjections.vertex||{},...e.instance?.normalizedInjections.fragment||{}}}function Qr(e,t,n){let r;switch(t){case"vertex":r=e.vs||"";break;case"fragment":r=e.fs||"";break;case"wgsl":r=e.source||"";break;default:Ct(!1)}if(!e.name)throw new Error("Shader module must have a name");Fn(e,t,{log:n});const i=e.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let o=`// ----- MODULE ${e.name} ---------------\n\n`;return"wgsl"!==t&&(o+=`#define MODULE_${i}\n`),o+=`${r}\n`,o}function ei(e,t,n){const r=[],i={sawSupportedBindingDeclaration:mt(e,ut).length>0,nextHintedBindingLocation:"number"==typeof t.firstBindingSlot?t.firstBindingSlot:null},o=gt(e,ut,e=>function(e,t){const{module:n,context:r,bindingAssignments:i,relocationState:o}=t,{match:s,bindingToken:a,groupToken:c,name:l}=e,u=Number(c);if("auto"===a){const e=oi(u,n.name,l),t=r.bindingRegistry?.get(e),a=void 0!==t?t:function(e,t,n,r,i){const o=t.get(e)||/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,a=`${e}:`,c=`${a}${n}:`;for(const[u,h]of i||[])u.startsWith(c)&&s.add(h);let l=r??(0===e?Yr:o.size>0?Math.max(...o)+1:0);for(;o.has(l)||s.has(l);)l++;for(const[u,h]of i||[])h===l&&u.startsWith(a)&&i?.delete(u);return l}(u,r.usedBindingsByGroup,n.name,o.nextHintedBindingLocation??void 0,r.bindingRegistry);return ri(n.name,u,a,l),void 0!==t&&function(e,t,n,r){const i=e.get(t);if(!i)return!1;const o=i.get(n);if(!o)return!1;if(o!==r)throw new Error(`Registered module binding "${r}" collided with "${o}": group ${t}, binding ${n}.`);return!0}(r.reservedBindingKeysByGroup,u,a,e)?(i.push({moduleName:n.name,name:l,group:u,location:a}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${a})`)):(ii(r.usedBindingsByGroup,u,a,`module "${n.name}" binding "${l}"`),r.bindingRegistry?.set(e,a),i.push({moduleName:n.name,name:l,group:u,location:a}),null!==o.nextHintedBindingLocation&&void 0===t&&(o.nextHintedBindingLocation=a+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${a})`))}const h=Number(a);return ri(n.name,u,h,l),ii(r.usedBindingsByGroup,u,h,`module "${n.name}" binding "${l}"`),i.push({moduleName:n.name,name:l,group:u,location:h}),s}(e,{module:t,context:n,bindingAssignments:r,relocationState:i}));if(bt(e)&&!i.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${t.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:r}}function ti(e,t){const n=[],r=gr(e.source||"",{defines:t});for(const i of mt(r,ut))n.push({name:i.name,group:Number(i.groupToken)});return n}function ni(e,t,n){if(0===e&&t>=Yr)throw new Error(`Application binding "${n}" in group 0 uses reserved binding ${t}. Application-owned explicit group-0 bindings must stay below 100.`)}function ri(e,t,n,r){if(0===t&&n<Yr)throw new Error(`Module "${e}" binding "${r}" in group 0 uses reserved application binding ${n}. Module-owned explicit group-0 bindings must be 100 or higher.`)}function ii(e,t,n,r){const i=e.get(t)||/* @__PURE__ */new Set;if(i.has(n))throw new Error(`Duplicate WGSL binding assignment for ${r}: group ${t}, binding ${n}.`);i.add(n),e.set(t,i)}function oi(e,t,n){return`${e}:${t}:${n}`}var si=class e{static defaultShaderAssemblers={};_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(t){return Ct("glsl"===t||"wgsl"===t),"wgsl"===t?(e.defaultShaderAssemblers.wgsl=e.defaultShaderAssemblers.wgsl||new ci,e.defaultShaderAssemblers.wgsl):(e.defaultShaderAssemblers.glsl=e.defaultShaderAssemblers.glsl||new ai,e.defaultShaderAssemblers.glsl)}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),n={};let r=0;for(let i=0,o=this._defaultModules.length;i<o;++i){const e=this._defaultModules[i],o=e.name;t[r++]=e,n[o]=!0}for(let i=0,o=e.length;i<o;++i){const o=e[i],s=o.name;n[s]||(t[r++]=o,n[s]=!0)}return t.length=r,Yt(t),t}},ai=class extends si{shaderLanguage="glsl";assembleGLSLShaderPair(e){const t=this._getModuleList(e.modules),n=this._hookFunctions;return{...qr({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}},ci=class e extends si{shaderLanguage="wgsl";_wgslBindingRegistry=/* @__PURE__ */new Map;assembleWGSLShader(t){const n=this._getModuleList(t.modules),r=this._hookFunctions,i=e.getShaderPreprocessorDefines(t,n),o="wgsl"===t.platformInfo.shaderLanguage&&t.source?gr(t.source,{defines:i}):t.source,{source:s,getUniforms:a,bindingAssignments:c}=Xr({...t,source:o,defines:i,_bindingRegistry:this._wgslBindingRegistry,modules:n,hookFunctions:r}),l="wgsl"===t.platformInfo.shaderLanguage?gr(s,{defines:i}):s;return{source:l,getUniforms:a,modules:n,bindingAssignments:c,bindingTable:rr(l,c),shaderLayout:_t(l,{vertexEntryPoint:t.vertexEntryPoint,scanVertexAttributes:t.scanVertexAttributes})}}static getShaderPreprocessorDefines(t,n){return{...e.getPlatformPreprocessorDefines(t.platformInfo),...n.reduce((e,t)=>(Object.assign(e,t.defines),e),{}),...t.defines}}static getPlatformPreprocessorDefines(e){const t=e.limits||{};return{LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS:"webgpu"===e.type&&(t.maxStorageBuffersInVertexStage||0)>0,LUMA_FP32_TAN_PRECISION_WORKAROUND:"webgpu"===e.type&&"nvidia"!==e.gpu.toLowerCase()&&"amd"!==e.gpu.toLowerCase(),LUMA_FP64_INTEGER_ARITHMETIC:"webgpu"===e.type&&"apple"===e.gpu.toLowerCase()}}},li=1/Math.PI*180,ui=1/180*Math.PI;globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};var hi=globalThis.mathgl.config;function di(e,{precision:t=hi.precision}={}){return e=function(e){return Math.round(e/hi.EPSILON)*hi.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function fi(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pi(e){return function(e,t){return vi(e,e=>e*ui,t)}(e)}function mi(e){return gi(e)}function gi(e,t){return vi(e,e=>e*li,t)}function bi(e,t,n){return vi(e,e=>Math.max(t,Math.min(n,e)))}function _i(e,t,n){return fi(e)?e.map((e,r)=>_i(e,t[r],n)):n*t+(1-n)*e}function yi(e,t,n){const r=hi.EPSILON;n&&(hi.EPSILON=n);try{if(e===t)return!0;if(fi(e)&&fi(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!yi(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=hi.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{hi.EPSILON=r}}function vi(e,t,n){if(fi(e)){const r=e;n=n||function(e){return e.clone?e.clone():new Array(e.length)}(r);for(let i=0;i<n.length&&i<r.length;++i){const r="number"==typeof e?e:e[i];n[i]=t(r,i,n)}return n}return t(e)}var wi=class extends Array{clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:fi(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(hi)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+di(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!yi(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(void 0===n)return this.lerp(this,e,t);for(let r=0;r<this.ELEMENTS;++r){const i=e[r],o="number"==typeof t?t:t[r];this[r]=i+n*(o-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(hi.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function Ei(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function xi(e,t,n=""){if(hi.debug&&!function(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Ti(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Mi=class extends wi{get x(){return this[0]}set x(e){this[0]=Ei(e)}get y(){return this[1]}set y(e){this[1]=Ei(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){const r=this[n]-e[n];t+=r*r}return Ei(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return Ei(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Ti(e>=0&&e<this.ELEMENTS,"index is out of range"),Ei(this[e])}setComponent(e,t){return Ti(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}},Si=1e-6,Pi="undefined"!=typeof Float32Array?Float32Array:Array;function Oi(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Ai(e,t,n,r){const i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e}function ji(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e}function Li(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e}function Ii(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e}function Ci(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e}var Ri=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e};!function(){const e=function(){const e=new Pi(2);return Pi!=Float32Array&&(e[0]=0,e[1]=0),e}()}();function $i(e,t,n){const r=t[0],i=t[1],o=n[3]*r+n[7]*i||1;return e[0]=(n[0]*r+n[4]*i)/o,e[1]=(n[1]*r+n[5]*i)/o,e}function ki(e,t,n){const r=t[0],i=t[1],o=t[2],s=n[3]*r+n[7]*i+n[11]*o||1;return e[0]=(n[0]*r+n[4]*i+n[8]*o)/s,e[1]=(n[1]*r+n[5]*i+n[9]*o)/s,e[2]=(n[2]*r+n[6]*i+n[10]*o)/s,e}function Ni(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2],e[3]=t[3],e}function zi(e,t,n){const r=t[0],i=t[1],o=t[2];return e[0]=n[0]*r+n[3]*i+n[6]*o,e[1]=n[1]*r+n[4]*i+n[7]*o,e[2]=n[2]*r+n[5]*i+n[8]*o,e[3]=t[3],e}function Di(){const e=new Pi(3);return Pi!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Ui(e){const t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Wi(e,t,n){const r=new Pi(3);return r[0]=e,r[1]=t,r[2]=n,r}function Fi(e,t){const n=t[0],r=t[1],i=t[2];let o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Bi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Gi(e,t,n){const r=t[0],i=t[1],o=t[2],s=n[0],a=n[1],c=n[2];return e[0]=i*c-o*a,e[1]=o*s-r*c,e[2]=r*a-i*s,e}function Vi(e,t,n,r){const i=t[0],o=t[1],s=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=s+r*(n[2]-s),e}function Yi(e,t,n){const r=t[0],i=t[1],o=t[2];let s=n[3]*r+n[7]*i+n[11]*o+n[15];return s=s||1,e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/s,e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/s,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/s,e}function Xi(e,t,n){const r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e}function qi(e,t,n){const r=n[0],i=n[1],o=n[2],s=n[3],a=t[0],c=t[1],l=t[2];let u=i*l-o*c,h=o*a-r*l,d=r*c-i*a,f=i*d-o*h,p=o*u-r*d,m=r*h-i*u;const g=2*s;return u*=g,h*=g,d*=g,f*=2,p*=2,m*=2,e[0]=a+u+f,e[1]=c+h+p,e[2]=l+d+m,e}var Hi,Zi=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e},Ki=Ui,Ji=function(e){const t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},Qi=(function(){const e=Di()}(),[0,0,0]),eo=class e extends Mi{static get ZERO(){return Hi||(Hi=new e(0,0,0),Object.freeze(Hi)),Hi}constructor(e=0,t=0,n=0){super(-0,-0,-0),1===arguments.length&&fi(e)?this.copy(e):(hi.debug&&(Ei(e),Ei(t),Ei(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return hi.debug&&(Ei(e.x),Ei(e.y),Ei(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Ei(e)}angle(e){return function(e,t){const n=e[0],r=e[1],i=e[2],o=t[0],s=t[1],a=t[2],c=Math.sqrt((n*n+r*r+i*i)*(o*o+s*s+a*a)),l=c&&Bi(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}(this,e)}cross(e){return Gi(this,this,e),this.check()}rotateX({radians:e,origin:t=Qi}){return function(e,t,n,r){const i=[],o=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2]}(this,this,t,e),this.check()}rotateY({radians:e,origin:t=Qi}){return function(e,t,n,r){const i=[],o=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2]}(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=Qi}){return function(e,t,n,r){const i=[],o=[];i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2]}(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Yi(this,this,e),this.check()}transformAsVector(e){return ki(this,this,e),this.check()}transformByMatrix3(e){return Xi(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,n){const r=t[0],i=t[1];e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return qi(this,this,e),this.check()}},to=class extends wi{toString(){let e="[";if(hi.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=Ei(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const n=e*this.RANK;for(let r=0;r<this.RANK;++r)t[r]=this[n+r];return t}setColumn(e,t){const n=e*this.RANK;for(let r=0;r<this.RANK;++r)this[n+r]=t[r];return this}};function no(e,t){const n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],b=t[15],_=n*a-r*s,y=n*c-i*s,v=n*l-o*s,w=r*c-i*a,E=r*l-o*a,x=i*l-o*c,T=u*m-h*p,M=u*g-d*p,S=u*b-f*p,P=h*g-d*m,O=h*b-f*m,A=d*b-f*g;let j=_*A-y*O+v*P+w*S-E*M+x*T;return j?(j=1/j,e[0]=(a*A-c*O+l*P)*j,e[1]=(i*O-r*A-o*P)*j,e[2]=(m*x-g*E+b*w)*j,e[3]=(d*E-h*x-f*w)*j,e[4]=(c*S-s*A-l*M)*j,e[5]=(n*A-i*S+o*M)*j,e[6]=(g*v-p*x-b*y)*j,e[7]=(u*x-d*v+f*y)*j,e[8]=(s*O-a*S+l*T)*j,e[9]=(r*S-n*O-o*T)*j,e[10]=(p*E-m*v+b*_)*j,e[11]=(h*v-u*E-f*_)*j,e[12]=(a*M-s*P-c*T)*j,e[13]=(n*P-r*M+i*T)*j,e[14]=(m*y-p*w-g*_)*j,e[15]=(u*w-h*y+d*_)*j,e):null}function ro(e,t,n){const r=t[0],i=t[1],o=t[2],s=t[3],a=t[4],c=t[5],l=t[6],u=t[7],h=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],b=t[14],_=t[15];let y=n[0],v=n[1],w=n[2],E=n[3];return e[0]=y*r+v*a+w*h+E*m,e[1]=y*i+v*c+w*d+E*g,e[2]=y*o+v*l+w*f+E*b,e[3]=y*s+v*u+w*p+E*_,y=n[4],v=n[5],w=n[6],E=n[7],e[4]=y*r+v*a+w*h+E*m,e[5]=y*i+v*c+w*d+E*g,e[6]=y*o+v*l+w*f+E*b,e[7]=y*s+v*u+w*p+E*_,y=n[8],v=n[9],w=n[10],E=n[11],e[8]=y*r+v*a+w*h+E*m,e[9]=y*i+v*c+w*d+E*g,e[10]=y*o+v*l+w*f+E*b,e[11]=y*s+v*u+w*p+E*_,y=n[12],v=n[13],w=n[14],E=n[15],e[12]=y*r+v*a+w*h+E*m,e[13]=y*i+v*c+w*d+E*g,e[14]=y*o+v*l+w*f+E*b,e[15]=y*s+v*u+w*p+E*_,e}function io(e,t,n){const r=n[0],i=n[1],o=n[2];let s,a,c,l,u,h,d,f,p,m,g,b;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*o+t[12],e[13]=t[1]*r+t[5]*i+t[9]*o+t[13],e[14]=t[2]*r+t[6]*i+t[10]*o+t[14],e[15]=t[3]*r+t[7]*i+t[11]*o+t[15]):(s=t[0],a=t[1],c=t[2],l=t[3],u=t[4],h=t[5],d=t[6],f=t[7],p=t[8],m=t[9],g=t[10],b=t[11],e[0]=s,e[1]=a,e[2]=c,e[3]=l,e[4]=u,e[5]=h,e[6]=d,e[7]=f,e[8]=p,e[9]=m,e[10]=g,e[11]=b,e[12]=s*r+u*i+p*o+t[12],e[13]=a*r+h*i+m*o+t[13],e[14]=c*r+d*i+g*o+t[14],e[15]=l*r+f*i+b*o+t[15]),e}function oo(e,t,n){const r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function so(e,t,n){const r=Math.sin(n),i=Math.cos(n),o=t[4],s=t[5],a=t[6],c=t[7],l=t[8],u=t[9],h=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]=o*i+l*r,e[5]=s*i+u*r,e[6]=a*i+h*r,e[7]=c*i+d*r,e[8]=l*i-o*r,e[9]=u*i-s*r,e[10]=h*i-a*r,e[11]=d*i-c*r,e}function ao(e,t,n){const r=Math.sin(n),i=Math.cos(n),o=t[0],s=t[1],a=t[2],c=t[3],l=t[4],u=t[5],h=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]=o*i+l*r,e[1]=s*i+u*r,e[2]=a*i+h*r,e[3]=c*i+d*r,e[4]=l*i-o*r,e[5]=u*i-s*r,e[6]=h*i-a*r,e[7]=d*i-c*r,e}function co(e,t){const n=t[0],r=t[1],i=t[2],o=t[4],s=t[5],a=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+r*r+i*i),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(c*c+l*l+u*u),e}var lo=function(e,t,n,r,i){const o=1/Math.tan(t/2);if(e[0]=o/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){const t=1/(r-i);e[10]=(i+r)*t,e[14]=2*i*r*t}else e[10]=-1,e[14]=-2*r;return e};var uo=function(e,t,n,r,i,o,s){const a=1/(t-n),c=1/(r-i),l=1/(o-s);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+n)*a,e[13]=(i+r)*c,e[14]=(s+o)*l,e[15]=1,e};function ho(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function fo(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function po(e){const t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)}function mo(e){const t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i}function go(e,t){const n=t[0],r=t[1],i=t[2],o=t[3];let s=n*n+r*r+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=n*s,e[1]=r*s,e[2]=i*s,e[3]=o*s,e}function bo(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function _o(e,t,n,r){const i=t[0],o=t[1],s=t[2],a=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=s+r*(n[2]-s),e[3]=a+r*(n[3]-a),e}function yo(e,t,n){const r=t[0],i=t[1],o=t[2],s=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*s,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*s,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*s,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*s,e}function vo(e,t,n){const r=t[0],i=t[1],o=t[2],s=n[0],a=n[1],c=n[2],l=n[3],u=l*r+a*o-c*i,h=l*i+c*r-s*o,d=l*o+s*i-a*r,f=-s*r-a*i-c*o;return e[0]=u*l+f*-s+h*-c-d*-a,e[1]=h*l+f*-a+d*-s-u*-c,e[2]=d*l+f*-c+u*-a-h*-s,e[3]=t[3],e}var wo;!function(){const e=function(){const e=new Pi(4);return Pi!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();!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"}(wo||(wo={}));var Eo,xo,To=45*Math.PI/180,Mo=1,So=.1,Po=500,Oo=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Ao=class extends to{static get IDENTITY(){return function(){xo||(xo=new Ao,Object.freeze(xo));return xo}()}static get ZERO(){return function(){Eo||(Eo=new Ao([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Eo));return Eo}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return wo}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,r,i,o,s,a,c,l,u,h,d,f,p,m){return this[0]=e,this[1]=t,this[2]=n,this[3]=r,this[4]=i,this[5]=o,this[6]=s,this[7]=a,this[8]=c,this[9]=l,this[10]=u,this[11]=h,this[12]=d,this[13]=f,this[14]=p,this[15]=m,this.check()}setRowMajor(e,t,n,r,i,o,s,a,c,l,u,h,d,f,p,m){return this[0]=e,this[1]=i,this[2]=c,this[3]=d,this[4]=t,this[5]=o,this[6]=l,this[7]=f,this[8]=n,this[9]=s,this[10]=u,this[11]=p,this[12]=r,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Oo)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const n=t[0],r=t[1],i=t[2],o=t[3],s=n+n,a=r+r,c=i+i,l=n*s,u=r*s,h=r*a,d=i*s,f=i*a,p=i*c,m=o*s,g=o*a,b=o*c;e[0]=1-h-p,e[1]=u+b,e[2]=d-g,e[3]=0,e[4]=u-b,e[5]=1-l-p,e[6]=f+m,e[7]=0,e[8]=d+g,e[9]=f-m,e[10]=1-l-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:n,bottom:r,top:i,near:o=So,far:s=Po}=e;return s===1/0?function(e,t,n,r,i,o){const s=2*o/(n-t),a=2*o/(i-r),c=(n+t)/(n-t),l=(i+r)/(i-r),u=-1,h=-1,d=-2*o;e[0]=s,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]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,n,r,i,o):function(e,t,n,r,i,o,s){const a=1/(n-t),c=1/(i-r),l=1/(o-s);e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*c,e[6]=0,e[7]=0,e[8]=(n+t)*a,e[9]=(i+r)*c,e[10]=(s+o)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*l,e[15]=0}(this,t,n,r,i,o,s),this.check()}lookAt(e){const{eye:t,center:n=[0,0,0],up:r=[0,1,0]}=e;return function(e,t,n,r){let i,o,s,a,c,l,u,h,d,f;const p=t[0],m=t[1],g=t[2],b=r[0],_=r[1],y=r[2],v=n[0],w=n[1],E=n[2];Math.abs(p-v)<1e-6&&Math.abs(m-w)<1e-6&&Math.abs(g-E)<1e-6?function(e){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):(h=p-v,d=m-w,f=g-E,i=1/Math.sqrt(h*h+d*d+f*f),h*=i,d*=i,f*=i,o=_*f-y*d,s=y*h-b*f,a=b*d-_*h,i=Math.sqrt(o*o+s*s+a*a),i?(i=1/i,o*=i,s*=i,a*=i):(o=0,s=0,a=0),c=d*a-f*s,l=f*o-h*a,u=h*s-d*o,i=Math.sqrt(c*c+l*l+u*u),i?(i=1/i,c*=i,l*=i,u*=i):(c=0,l=0,u=0),e[0]=o,e[1]=c,e[2]=h,e[3]=0,e[4]=s,e[5]=l,e[6]=d,e[7]=0,e[8]=a,e[9]=u,e[10]=f,e[11]=0,e[12]=-(o*p+s*m+a*g),e[13]=-(c*p+l*m+u*g),e[14]=-(h*p+d*m+f*g),e[15]=1)}(this,t,n,r),this.check()}ortho(e){const{left:t,right:n,bottom:r,top:i,near:o=So,far:s=Po}=e;return uo(this,t,n,r,i,o,s),this.check()}orthographic(e){const{fovy:t=To,aspect:n=Mo,focalDistance:r=1,near:i=So,far:o=Po}=e;jo(t);const s=t/2,a=r*Math.tan(s),c=a*n;return this.ortho({left:-c,right:c,bottom:-a,top:a,near:i,far:o})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:n=1,near:r=.1,far:i=500}=e;return jo(t),lo(this,t,n,r,i),this.check()}determinant(){return function(e){const t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],s=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=t*s-n*o,b=t*a-r*o,_=n*a-r*s,y=l*p-u*f,v=l*m-h*f,w=u*m-h*p;return c*(t*w-n*v+r*y)-i*(o*w-s*v+a*y)+e[15]*(l*_-u*b+h*g)-d*(f*_-p*b+m*g)}(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),r=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*i,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*i,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const n=this.getScale(t),r=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*r,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*i,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*i,e[8]=this[10]*o,e}transpose(){return function(e,t){if(e===t){const n=t[1],r=t[2],i=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=s,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]}(this,this),this.check()}invert(){return no(this,this),this.check()}multiplyLeft(e){return ro(this,e,this),this.check()}multiplyRight(e){return ro(this,this,e),this.check()}rotateX(e){return so(this,this,e),this.check()}rotateY(e){return function(e,t,n){const r=Math.sin(n),i=Math.cos(n),o=t[0],s=t[1],a=t[2],c=t[3],l=t[8],u=t[9],h=t[10],d=t[11];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]=o*i-l*r,e[1]=s*i-u*r,e[2]=a*i-h*r,e[3]=c*i-d*r,e[8]=o*r+l*i,e[9]=s*r+u*i,e[10]=a*r+h*i,e[11]=c*r+d*i}(this,this,e),this.check()}rotateZ(e){return ao(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,n,r){let i,o,s,a,c,l,u,h,d,f,p,m,g,b,_,y,v,w,E,x,T,M,S,P,O=r[0],A=r[1],j=r[2],L=Math.sqrt(O*O+A*A+j*j);L<1e-6||(L=1/L,O*=L,A*=L,j*=L,o=Math.sin(n),i=Math.cos(n),s=1-i,a=t[0],c=t[1],l=t[2],u=t[3],h=t[4],d=t[5],f=t[6],p=t[7],m=t[8],g=t[9],b=t[10],_=t[11],y=O*O*s+i,v=A*O*s+j*o,w=j*O*s-A*o,E=O*A*s-j*o,x=A*A*s+i,T=j*A*s+O*o,M=O*j*s+A*o,S=A*j*s-O*o,P=j*j*s+i,e[0]=a*y+h*v+m*w,e[1]=c*y+d*v+g*w,e[2]=l*y+f*v+b*w,e[3]=u*y+p*v+_*w,e[4]=a*E+h*x+m*T,e[5]=c*E+d*x+g*T,e[6]=l*E+f*x+b*T,e[7]=u*E+p*x+_*T,e[8]=a*M+h*S+m*P,e[9]=c*M+d*S+g*P,e[10]=l*M+f*S+b*P,e[11]=u*M+p*S+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){return oo(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return io(this,this,e),this.check()}transform(e,t){return 4===e.length?(xi(t=yo(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:n}=e;let r;switch(n){case 2:r=Ci(t||[-0,-0],e,this);break;case 3:r=Yi(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return xi(r,e.length),r}transformAsVector(e,t){let n;switch(e.length){case 2:n=$i(t||[-0,-0],e,this);break;case 3:n=ki(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return xi(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}};function jo(e){if(e>2*Math.PI)throw Error("expected radians")}var Lo,Io,Co,Ro={name:"fp32",source:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst FP32_TWO_PI: f32 = 6.2831854820251465;\nconst FP32_PI_2: f32 = 1.5707963705062866;\nconst FP32_PI_16: f32 = 0.1963495463132858;\n\nconst FP32_SIN_TABLE_0: f32 = 0.19509032368659973;\nconst FP32_SIN_TABLE_1: f32 = 0.3826834261417389;\nconst FP32_SIN_TABLE_2: f32 = 0.5555702447891235;\nconst FP32_SIN_TABLE_3: f32 = 0.7071067690849304;\n\nconst FP32_COS_TABLE_0: f32 = 0.9807852506637573;\nconst FP32_COS_TABLE_1: f32 = 0.9238795042037964;\nconst FP32_COS_TABLE_2: f32 = 0.8314695954322815;\nconst FP32_COS_TABLE_3: f32 = 0.7071067690849304;\n\nconst FP32_INVERSE_FACTORIAL_3: f32 = 1.666666716337204e-01;\nconst FP32_INVERSE_FACTORIAL_5: f32 = 8.333333767950535e-03;\nconst FP32_INVERSE_FACTORIAL_7: f32 = 1.9841270113829523e-04;\nconst FP32_INVERSE_FACTORIAL_9: f32 = 2.75573188446287533e-06;\nconst FP32_OVERFLOW: f32 = 3.402823466e+38;\n\nfn sin_taylor_fp32(a: f32) -> f32 {\n if (a == 0.0) {\n return 0.0;\n }\n\n let x = -a * a;\n var sum = a;\n var term = a;\n\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_3;\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_5;\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_7;\n term = term * x;\n sum = sum + term * FP32_INVERSE_FACTORIAL_9;\n\n return sum;\n}\n\nfn tan_taylor_fp32(a: f32) -> f32 {\n if (a == 0.0) {\n return 0.0;\n }\n\n let z = floor(a / FP32_TWO_PI);\n let reduced = a - FP32_TWO_PI * z;\n\n var quadrantValue = floor(reduced / FP32_PI_2 + 0.5);\n let quadrant = i32(quadrantValue);\n if (quadrant < -2 || quadrant > 2) {\n return FP32_OVERFLOW;\n }\n\n var angle = reduced - FP32_PI_2 * quadrantValue;\n quadrantValue = floor(angle / FP32_PI_16 + 0.5);\n let tableIndex = i32(quadrantValue);\n let absoluteTableIndex = abs(tableIndex);\n if (absoluteTableIndex > 4) {\n return FP32_OVERFLOW;\n }\n\n angle = angle - FP32_PI_16 * quadrantValue;\n let sinAngle = sin_taylor_fp32(angle);\n let cosAngle = sqrt(1.0 - sinAngle * sinAngle);\n\n var tableCos = 0.0;\n var tableSin = 0.0;\n if (absoluteTableIndex == 1) {\n tableCos = FP32_COS_TABLE_0;\n tableSin = FP32_SIN_TABLE_0;\n } else if (absoluteTableIndex == 2) {\n tableCos = FP32_COS_TABLE_1;\n tableSin = FP32_SIN_TABLE_1;\n } else if (absoluteTableIndex == 3) {\n tableCos = FP32_COS_TABLE_2;\n tableSin = FP32_SIN_TABLE_2;\n } else if (absoluteTableIndex == 4) {\n tableCos = FP32_COS_TABLE_3;\n tableSin = FP32_SIN_TABLE_3;\n }\n\n var sinReduced = sinAngle;\n var cosReduced = cosAngle;\n if (tableIndex > 0) {\n sinReduced = tableCos * sinAngle + tableSin * cosAngle;\n cosReduced = tableCos * cosAngle - tableSin * sinAngle;\n } else if (tableIndex < 0) {\n sinReduced = tableCos * sinAngle - tableSin * cosAngle;\n cosReduced = tableCos * cosAngle + tableSin * sinAngle;\n }\n\n var sinValue = 0.0;\n var cosValue = 0.0;\n if (quadrant == 0) {\n sinValue = sinReduced;\n cosValue = cosReduced;\n } else if (quadrant == 1) {\n sinValue = cosReduced;\n cosValue = -sinReduced;\n } else if (quadrant == -1) {\n sinValue = -cosReduced;\n cosValue = sinReduced;\n } else {\n sinValue = -sinReduced;\n cosValue = -cosReduced;\n }\n\n return sinValue / cosValue;\n}\n\nfn tan_fp32(a: f32) -> f32 {\n return tan_taylor_fp32(a);\n}\n#else\nfn tan_fp32(a: f32) -> f32 {\n return tan(a);\n}\n#endif\n",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n\n// All these functions are for substituting tan() function from Intel GPU only\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\n\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\n\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\n\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!\n\nfloat sin_taylor_fp32(float a) {\n float r, s, t, x;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n x = -a * a;\n s = a;\n r = a;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_3;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_5;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_7;\n s = s + t;\n\n r = r * x;\n t = r * INVERSE_FACTORIAL_9;\n s = s + t;\n\n return s;\n}\n\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\n if (a == 0.0) {\n sin_t = 0.0;\n cos_t = 1.0;\n }\n sin_t = sin_taylor_fp32(a);\n cos_t = sqrt(1.0 - sin_t * sin_t);\n}\n\nfloat tan_taylor_fp32(float a) {\n float sin_a;\n float cos_a;\n\n if (a == 0.0) {\n return 0.0;\n }\n\n // 2pi range reduction\n float z = floor(a / TWO_PI);\n float r = a - TWO_PI * z;\n\n float t;\n float q = floor(r / PI_2 + 0.5);\n int j = int(q);\n\n if (j < -2 || j > 2) {\n return 1.0 / 0.0;\n }\n\n t = r - PI_2 * q;\n\n q = floor(t / PI_16 + 0.5);\n int k = int(q);\n int abs_k = int(abs(float(k)));\n\n if (abs_k > 4) {\n return 1.0 / 0.0;\n } else {\n t = t - PI_16 * q;\n }\n\n float u = 0.0;\n float v = 0.0;\n\n float sin_t, cos_t;\n float s, c;\n sincos_taylor_fp32(t, sin_t, cos_t);\n\n if (k == 0) {\n s = sin_t;\n c = cos_t;\n } else {\n if (abs(float(abs_k) - 1.0) < 0.5) {\n u = COS_TABLE_0;\n v = SIN_TABLE_0;\n } else if (abs(float(abs_k) - 2.0) < 0.5) {\n u = COS_TABLE_1;\n v = SIN_TABLE_1;\n } else if (abs(float(abs_k) - 3.0) < 0.5) {\n u = COS_TABLE_2;\n v = SIN_TABLE_2;\n } else if (abs(float(abs_k) - 4.0) < 0.5) {\n u = COS_TABLE_3;\n v = SIN_TABLE_3;\n }\n if (k > 0) {\n s = u * sin_t + v * cos_t;\n c = u * cos_t - v * sin_t;\n } else {\n s = u * sin_t - v * cos_t;\n c = u * cos_t + v * sin_t;\n }\n }\n\n if (j == 0) {\n sin_a = s;\n cos_a = c;\n } else if (j == 1) {\n sin_a = c;\n cos_a = -s;\n } else if (j == -1) {\n sin_a = -c;\n cos_a = s;\n } else {\n sin_a = -s;\n cos_a = -c;\n }\n return sin_a / cos_a;\n}\n#endif\n\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\n return tan_taylor_fp32(a);\n#else\n return tan(a);\n#endif\n}\n"},$o="#define SMOOTH_EDGE_RADIUS 0.5",ko={name:"geometry",source:"const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4<f32>,\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry_: VertexGeometry = VertexGeometry(\n vec4<f32>(0.0, 0.0, 1.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2<f32>,\n};\n\nvar<private> fragmentGeometry: FragmentGeometry;\n\nfn smoothedge(edge: f32, x: f32) -> f32 {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n",vs:`${$o}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`${$o}\n\nstruct FragmentGeometry {\n vec2 uv;\n};\nFragmentGeometry geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};!function(e){e[e.Start=1]="Start",e[e.Move=2]="Move",e[e.End=4]="End",e[e.Cancel=8]="Cancel"}(Lo||(Lo={})),function(e){e[e.None=0]="None",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Up=4]="Up",e[e.Down=8]="Down",e[e.Horizontal=3]="Horizontal",e[e.Vertical=12]="Vertical",e[e.All=15]="All"}(Io||(Io={})),function(e){e[e.Possible=1]="Possible",e[e.Began=2]="Began",e[e.Changed=4]="Changed",e[e.Ended=8]="Ended",e[e.Recognized=8]="Recognized",e[e.Cancelled=16]="Cancelled",e[e.Failed=32]="Failed"}(Co||(Co={}));var No="manipulation",zo="none",Do="pan-x",Uo="pan-y";var Wo=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){"compute"===e&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(const t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return function(e){if(e.includes("none"))return zo;const t=e.includes(Do),n=e.includes(Uo);return t&&n?zo:t||n?t?Do:Uo:e.includes("manipulation")?No:"auto"}(e.join(" "))}};function Fo(e){return e.trim().split(/\s+/g)}function Bo(e,t,n){if(e)for(const r of Fo(t))e.addEventListener(r,n,!1)}function Go(e,t,n){if(e)for(const r of Fo(t))e.removeEventListener(r,n,!1)}function Vo(e){return(e.ownerDocument||e).defaultView}function Yo(e){const t=e.length;if(1===t)return{x:Math.round(e[0].clientX),y:Math.round(e[0].clientY)};let n=0,r=0,i=0;for(;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:Math.round(n/t),y:Math.round(r/t)}}function Xo(e){const t=[];let n=0;for(;n<e.pointers.length;)t[n]={clientX:Math.round(e.pointers[n].clientX),clientY:Math.round(e.pointers[n].clientY)},n++;return{timeStamp:Date.now(),pointers:t,center:Yo(t),deltaX:e.deltaX,deltaY:e.deltaY}}function qo(e,t){const n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ho(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(n*n+r*r)}function Zo(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY;return 180*Math.atan2(r,n)/Math.PI}function Ko(e,t){return e===t?Io.None:Math.abs(e)>=Math.abs(t)?e<0?Io.Left:Io.Right:t<0?Io.Up:Io.Down}function Jo(e,t,n){return{x:t/e||0,y:n/e||0}}function Qo(e,t){return"pointerId"in e?e.pointerId:t}function es(e,t){e.movementOrigin=new Map(t.map((e,t)=>[Qo(e,t),{clientX:e.clientX,clientY:e.clientY}])),e.firstMovementTime=void 0}function ts(e,t){const{session:n}=e,{pointers:r}=t,{length:i}=r;n.firstInput||(n.firstInput=Xo(t)),i>1&&!n.firstMultiple?n.firstMultiple=Xo(t):1===i&&(n.firstMultiple=!1);const{firstInput:o,firstMultiple:s}=n,a=s?s.center:o.center,c=t.center=Yo(r);t.timeStamp=Date.now(),t.deltaTime=t.timeStamp-o.timeStamp,function(e,t){const n=t.pointers.map(Qo);if(e.movementOrigin?.size===n.length&&n.every(t=>e.movementOrigin.has(t))||es(e,t.pointers),t.distancePerPointer=t.pointers.map((t,r)=>Ho(e.movementOrigin.get(n[r]),t)),t.eventType&Lo.Move&&t.distancePerPointer.some(e=>e>0)&&(e.firstMovementTime??(e.firstMovementTime=t.timeStamp)),t.movementDeltaTime=void 0===e.firstMovementTime?0:t.timeStamp-e.firstMovementTime,t.eventType&(Lo.End|Lo.Cancel)){const r=t.changedPointers.map(e=>Qo(e,t.pointers.indexOf(e)));es(e,t.pointers.filter((e,t)=>!r.includes(n[t])))}}(n,t),t.angle=function(e,t){const n=t.x-e.x,r=t.y-e.y;return 180*Math.atan2(r,n)/Math.PI}(a,c),t.distance=qo(a,c);const{deltaX:l,deltaY:u}=function(e,t){const n=t.center;let r=e.offsetDelta,i=e.prevDelta;const o=e.prevInput;return t.eventType!==Lo.Start&&o?.eventType!==Lo.End||(i=e.prevDelta={x:o?.deltaX||0,y:o?.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),{deltaX:i.x+(n.x-r.x),deltaY:i.y+(n.y-r.y)}}(n,t);t.deltaX=l,t.deltaY=u,t.offsetDirection=Ko(t.deltaX,t.deltaY);const h=Jo(t.deltaTime,t.deltaX,t.deltaY);var d,f;t.overallVelocityX=h.x,t.overallVelocityY=h.y,t.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,t.scale=s?(d=s.pointers,Ho((f=r)[0],f[1])/Ho(d[0],d[1])):1,t.rotation=s?function(e,t){return Zo(t[1],t[0])-Zo(e[1],e[0])}(s.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length;let p=e.element;return function(e,t){let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}(t.srcEvent.target,p)&&(p=t.srcEvent.target),t.target=p,function(e,t){const n=e.lastInterval||t,r=t.timeStamp-n.timeStamp;let i,o,s,a;if(t.eventType!==Lo.Cancel&&(r>25||void 0===n.velocity)){const c=t.deltaX-n.deltaX,l=t.deltaY-n.deltaY,u=Jo(r,c,l);o=u.x,s=u.y,i=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=Ko(c,l),e.lastInterval=t}else i=n.velocity,o=n.velocityX,s=n.velocityY,a=n.direction;t.velocity=i,t.velocityX=o,t.velocityY=s,t.direction=a}(n,t),t}var ns=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=e=>{this.manager.options.enable&&this.handler(e)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){!function(e,t,n){const r=n.pointers.length,i=n.changedPointers.length,o=t&Lo.Start&&r-i===0,s=t&(Lo.End|Lo.Cancel)&&r-i===0;n.isFirst=Boolean(o),n.isFinal=Boolean(s),o&&(e.session={}),n.eventType=t;const a=ts(e,n);e.emit("hammer.input",a),e.recognize(a),e.session.prevInput=a}(this.manager,e,t)}init(){Bo(this.element,this.evEl,this.domHandler),Bo(this.target,this.evTarget,this.domHandler),Bo(Vo(this.element),this.evWin,this.domHandler)}destroy(){Go(this.element,this.evEl,this.domHandler),Go(this.target,this.evTarget,this.domHandler),Go(Vo(this.element),this.evWin,this.domHandler)}},rs={pointerdown:Lo.Start,pointermove:Lo.Move,pointerup:Lo.End,pointercancel:Lo.Cancel,pointerout:Lo.Cancel},is=class extends ns{constructor(e){super(e),this.evEl="pointerdown",this.evWin="pointermove pointerup pointercancel",this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){const{store:t}=this;let n=!1;const r=rs[e.type],i=e.pointerType,o="touch"===i;let s=t.findIndex(t=>t.pointerId===e.pointerId);r&Lo.Start&&(e.buttons||o)?s<0&&(t.push(e),s=t.length-1):r&(Lo.End|Lo.Cancel)&&(n=!0),s<0||(t[s]=e,this.callback(r,{pointers:t,changedPointers:[e],eventType:r,pointerType:i,srcEvent:e}),n&&t.splice(s,1))}},os=["","webkit","Moz","MS","ms","o"];function ss(e,t){const n=t[0].toUpperCase()+t.slice(1);for(const r of os){const i=r?r+n:t;if(i in e)return i}}var as={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},cs=class{constructor(e,t){this.options={...as,...t,cssProps:{...as.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new is(this),this.touchAction=new Wo(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?2:1}recognize(e){const{session:t}=this;if(t.stopped)return;let n;this.session.prevented&&e.srcEvent.preventDefault();const{recognizers:r}=this;let{curRecognizer:i}=t;(!i||i&&i.state&Co.Recognized)&&(i=t.curRecognizer=null);let o=0;for(;o<r.length;)n=r[o],2===t.stopped||i&&n!==i&&!n.canRecognizeWith(i)?n.reset():n.recognize(e),!i&&n.state&(Co.Began|Co.Changed|Co.Ended)&&(i=t.curRecognizer=n),o++}get(e){const{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(const t of e)this.add(t);return this}const t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(const t of e)this.remove(t);return this}const t="string"==typeof e?this.get(e):e;if(t){const{recognizers:e}=this,n=e.indexOf(t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;const{handlers:n}=this;for(const r of Fo(e))n[r]=n[r]||[],n[r].push(t)}off(e,t){if(!e)return;const{handlers:n}=this;for(const r of Fo(e))t?n[r]&&n[r].splice(n[r].indexOf(t),1):delete n[r]}emit(e,t){const n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;const r=t;r.type=e,r.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](r),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){const{element:t}=this;if(t){for(const[n,r]of Object.entries(this.options.cssProps)){const i=ss(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=r):t.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}},ls=1;function us(e){return e&Co.Cancelled?"cancel":e&Co.Ended?"end":e&Co.Changed?"move":e&Co.Began?"start":""}var hs=class{constructor(e){this.options=e,this.id=ls++,this.state=Co.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(const t of e)this.recognizeWith(t);return this}let t;if("string"==typeof e){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;const{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(const t of e)this.dropRecognizeWith(t);return this}let t;return t="string"==typeof e?this.manager.get(e):e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(const t of e)this.requireFailure(t);return this}let t;if("string"==typeof e){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;const{requireFail:n}=this;return-1===n.indexOf(t)&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(const t of e)this.dropRequireFailure(t);return this}let t;if(t="string"==typeof e?this.manager.get(e):e,t){const e=this.requireFail.indexOf(t);e>-1&&this.requireFail.splice(e,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;const{state:t}=this;t<Co.Ended&&this.manager.emit(this.options.event+us(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=Co.Ended&&this.manager.emit(this.options.event+us(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=Co.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(Co.Failed|Co.Possible)))return!1;e++}return!0}recognize(e){const t={...e};if(!this.options.enable)return this.reset(),void(this.state=Co.Failed);this.state&(Co.Recognized|Co.Cancelled|Co.Failed)&&(this.state=Co.Possible),this.state=this.process(t),this.state&(Co.Began|Co.Changed|Co.Ended|Co.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}};function ds(e,t){return(void 0===t.distance||e.distance>=t.distance)&&(void 0===t.distancePerPointer||e.distancePerPointer.length>0&&e.distancePerPointer.every(e=>e>=t.distancePerPointer))&&(void 0===t.movementDeltaTime||e.movementDeltaTime>=t.movementDeltaTime)&&(void 0===t.rotation||(n=e.rotation,Math.abs(((n+180)%360+360)%360-180)>=t.rotation))&&(void 0===t.scale||Math.abs(e.scale-1)>=t.scale);var n}var fs=class extends hs{attrTest(e){const t=this.options.pointers;return 0===t||e.pointers.length===t}coherentTest(e){const t=this.options.coherent;return!t?.length||t.some(t=>ds(e,t))}process(e){const{state:t}=this,{eventType:n}=e,r=t&(Co.Began|Co.Changed),i=this.attrTest(e);return r&&(n&Lo.Cancel||!i)?t|Co.Cancelled:r||i?n&Lo.End?t|Co.Ended:t&Co.Began?t|Co.Changed:Co.Began:Co.Failed}},ps=["","start","move","end","cancel"],ms=class extends hs{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[No]}process(e){const{options:t}=this,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&Lo.Start&&0===this.count)return this.failTimeout();if(r&&i&&n){if(e.eventType!==Lo.End)return this.failTimeout();const n=!this.pTime||e.timeStamp-this.pTime<t.interval,r=!this.pCenter||qo(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,r&&n?this.count+=1:this.count=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=Co.Recognized,this.tryEmit(this._input)},t.interval),Co.Began):Co.Recognized}return Co.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Co.Failed},this.options.interval),Co.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===Co.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}},gs=class extends fs{constructor(){super(...arguments),this.wheelSession=null,this.wheelSessionUnsubscribe=null,this.handleWheelSessionEvent=e=>{"trackpad"===e.device&&this.handleTrackpadEvent(e)}}set(e){const{wheelSession:t,...n}=e;return t&&t!==this.wheelSession&&(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=null,this.wheelSession=t),super.set(n),this.updateWheelSessionSubscription(),this}getTrackpadInput(e,t={}){const{srcEvent:n}=e,r=t.deltaX??e.deltaX,i=t.deltaY??e.deltaY,o=Ko(r,i),s=Math.sqrt(e.deltaX*e.deltaX+e.deltaY*e.deltaY);return{pointers:[n,n],changedPointers:[n,n],pointerType:"trackpad",srcEvent:n,eventType:e.eventType,timeStamp:e.timeStamp,deltaTime:e.deltaTime,center:e.center,deltaX:r,deltaY:i,angle:180*Math.atan2(i,r)/Math.PI,distance:Math.sqrt(r*r+i*i),distancePerPointer:[s,s],movementDeltaTime:e.deltaTime,scale:1,rotation:0,direction:o,offsetDirection:o,velocity:e.velocity,velocityX:e.velocityX,velocityY:e.velocityY,overallVelocity:e.overallVelocity,overallVelocityX:e.overallVelocityX,overallVelocityY:e.overallVelocityY,maxPointers:2,target:n.target||this.manager.element,additionalEvent:"",...t}}updateWheelSessionSubscription(){const e=Boolean(this.wheelSession&&this.options.enable&&this.options.trackpad&&2===this.options.pointers);e&&!this.wheelSessionUnsubscribe?this.wheelSessionUnsubscribe=this.wheelSession.on(this.handleWheelSessionEvent):!e&&this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe(),this.wheelSessionUnsubscribe=null)}},bs=["","start","move","end","cancel","up","down","left","right"],_s=class extends gs{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Io.All,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1,this.pX=null,this.pY=null}getTouchAction(){const{options:{direction:e}}=this,t=[];return e&Io.Horizontal&&t.push(Uo),e&Io.Vertical&&t.push(Do),t}getEventNames(){return bs.map(e=>this.options.event+e)}directionTest(e){const{options:t}=this;let n=!0,{distance:r}=e,{direction:i}=e;const o=e.deltaX,s=e.deltaY;return i&t.direction||(t.direction&Io.Horizontal?(i=0===o?Io.None:o<0?Io.Left:Io.Right,n=o!==this.pX,r=Math.abs(e.deltaX)):(i=0===s?Io.None:s<0?Io.Up:Io.Down,n=s!==this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&Boolean(i&t.direction)}attrTest(e){const t=Boolean(this.state&Co.Began),n=!(this.options.coherent?.length&&e.eventType&(Lo.End|Lo.Cancel));return super.attrTest(e)&&(t||n&&this.coherentTest(e)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;const t=Io[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=!e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Co.Recognized|Co.Cancelled|Co.Failed)&&(this.state=Co.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:-e.deltaX,deltaY:-e.deltaY,velocity:-e.velocity,velocityX:-e.velocityX,velocityY:-e.velocityY,overallVelocity:-e.overallVelocity,overallVelocityX:-e.overallVelocityX,overallVelocityY:-e.overallVelocityY})),e.isFinal&&(this.trackpadGesture=!1))}},ys=["","start","move","end","cancel","in","out"],vs=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}listen(e,t){t?this.element.addEventListener(e,this.handleEvent,{passive:!1}):this.element.removeEventListener(e,this.handleEvent)}},ws=-1!==("undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"").indexOf("firefox"),Es=class extends vs{constructor(e,t,n){n.enable=n.enable??!1,super(e,t,n),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;globalThis.WheelEvent&&(ws&&e.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(t/=globalThis.devicePixelRatio),e.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(t*=40)),e.shiftKey&&t&&(t*=.25),this.callback({type:"wheel",center:{x:e.clientX,y:e.clientY},delta:-t,device:this.options.wheelSession?.device??"unknown",srcEvent:e,pointerType:"mouse",target:e.target})},n.enable&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{}),this.listen("wheel",!0))}destroy(){this.listen("wheel",!1),this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0}enableEventType(e,t){"wheel"===e&&this.options.enable!==t&&(this.options.enable=t,t&&!this.wheelSessionUnsubscribe&&(this.wheelSessionUnsubscribe=this.options.wheelSession?.on(()=>{})),this.listen("wheel",t),t||(this.wheelSessionUnsubscribe?.(),this.wheelSessionUnsubscribe=void 0))}},xs={classificationDelay:32,endDelay:80},Ts=class{constructor(e,t={}){this.subscriptions=/* @__PURE__ */new Map,this.session=null,this.classificationTimer=null,this.endTimer=null,this.pressedControlKeys=/* @__PURE__ */new Set,this.listeningForControlKeys=!1,this.handleEvent=e=>{if(!this.hasSubscribers)return"unknown";const t=function(e,t){let n=e.deltaX,r=e.deltaY;1===e.deltaMode&&(n*=40,r*=40);return{event:e,timeStamp:e.timeStamp,deltaX:n,deltaY:r,isControlKeyDown:t}}(e,this.pressedControlKeys.size>0);let n=this.session;if(n&&t.timeStamp-n.lastTimeStamp>=this.options.endDelay){if(this.end(),!this.hasSubscribers)return"unknown";n=null}n?(this.scheduleEnd(),this.addSample(n,t)):(n=this.startPendingSession(t),this.scheduleEnd());let{device:r}=n;return"unknown"===r&&(r=Ms(n.samples,!1),"unknown"!==r&&this.begin(n,r)),r},this.finishClassification=()=>{if(this.classificationTimer=null,!this.session||"unknown"!==this.session.device)return;const e=this.session,t=Ms(e.samples,!0);this.begin(e,"unknown"===t?"mouse":t)},this.end=()=>{if(!this.session)return;if("unknown"===this.session.device){const e=this.session,t=Ms(e.samples,!0);this.begin(e,"unknown"===t?"mouse":t)}if(!this.session)return;const e=this.session;this.emit(Lo.End,e.lastEvent),this.reset()},this.handleKeyDown=e=>{"Control"===e.key&&this.pressedControlKeys.add(e.code||e.key)},this.handleKeyUp=e=>{"Control"===e.key&&(e.code?this.pressedControlKeys.delete(e.code):this.pressedControlKeys.clear())},this.handleWindowBlur=()=>{this.pressedControlKeys.clear()},this.element=e,this.options={...xs,...t},this.element?.addEventListener("wheel",this.handleEvent,{passive:!0})}get hasSubscribers(){return this.subscriptions.size>0}get device(){return this.session?.device??"unknown"}on(e){const t={listener:e};return this.subscriptions.set(e,t),this.updateControlKeyEventListeners(),()=>{this.subscriptions.get(e)===t&&this.off(e)}}off(e){this.subscriptions.delete(e),this.updateControlKeyEventListeners(),this.hasSubscribers||this.reset()}cancel(){const e=this.session;e&&"unknown"!==e.device&&this.emit(Lo.Cancel,e.lastEvent),this.reset()}destroy(){this.cancel(),this.subscriptions.clear(),this.updateControlKeyEventListeners(),this.element?.removeEventListener("wheel",this.handleEvent)}startPendingSession(e){const t={samples:[e],device:"unknown",firstTimeStamp:e.timeStamp,lastTimeStamp:e.timeStamp,totalDeltaX:e.deltaX,totalDeltaY:e.deltaY,velocityX:0,velocityY:0,lastEvent:e.event};return this.session=t,this.classificationTimer=globalThis.setTimeout(this.finishClassification,this.options.classificationDelay),t}addSample(e,t){if(e.samples.push(t),e.lastTimeStamp=t.timeStamp,e.lastEvent=t.event,e.totalDeltaX+=t.deltaX,e.totalDeltaY+=t.deltaY,"unknown"!==e.device){const n=e.samples[e.samples.length-2],r=t.timeStamp-n.timeStamp;e.velocityX=r>0?t.deltaX/r:0,e.velocityY=r>0?t.deltaY/r:0,this.emit(Lo.Move,t.event,{velocityX:e.velocityX,velocityY:e.velocityY})}}begin(e,t){e.device=t,this.clearClassificationTimer(),this.emit(Lo.Start,e.samples[0].event);const n=e.lastTimeStamp-e.firstTimeStamp;e.velocityX=n>0?e.totalDeltaX/n:0,e.velocityY=n>0?e.totalDeltaY/n:0,this.emit(Lo.Move,e.lastEvent,{velocityX:e.velocityX,velocityY:e.velocityY})}scheduleEnd(){this.clearEndTimer(),this.endTimer=globalThis.setTimeout(this.end,this.options.endDelay)}emit(e,t,n){const r=this.session;if(!r||"unknown"===r.device)return;const i=e===Lo.Start,o=e===Lo.End||e===Lo.Cancel,s=i?r.firstTimeStamp:r.lastTimeStamp,a=i?0:Math.max(0,s-r.firstTimeStamp),c=i?0:r.totalDeltaX,l=i?0:r.totalDeltaY,u=a>0?c/a:0,h=a>0?l/a:0,d=i?0:n?.velocityX??r.velocityX,f=i?0:n?.velocityY??r.velocityY,p={eventType:e,device:r.device,srcEvent:t,timeStamp:s,center:{x:t.clientX,y:t.clientY},deltaX:c,deltaY:l,deltaTime:a,velocity:Math.abs(d)>Math.abs(f)?d:f,velocityX:d,velocityY:f,overallVelocity:Math.abs(u)>Math.abs(h)?u:h,overallVelocityX:u,overallVelocityY:h,isFirst:i,isFinal:o};for(const{listener:m}of[...this.subscriptions.values()])m(p)}reset(){this.clearClassificationTimer(),this.clearEndTimer(),this.session=null}clearClassificationTimer(){null!==this.classificationTimer&&(globalThis.clearTimeout(this.classificationTimer),this.classificationTimer=null)}clearEndTimer(){null!==this.endTimer&&(globalThis.clearTimeout(this.endTimer),this.endTimer=null)}updateControlKeyEventListeners(){const e=this.hasSubscribers,t="undefined"!=typeof window?window:globalThis.document?.defaultView;t&&e!==this.listeningForControlKeys&&(this.listeningForControlKeys=e,e?(t.addEventListener("keydown",this.handleKeyDown,!0),t.addEventListener("keyup",this.handleKeyUp,!0),t.addEventListener("blur",this.handleWindowBlur)):(t.removeEventListener("keydown",this.handleKeyDown,!0),t.removeEventListener("keyup",this.handleKeyUp,!0),t.removeEventListener("blur",this.handleWindowBlur),this.pressedControlKeys.clear()))}};function Ms(e,t){return e.some(({event:e,isControlKeyDown:t})=>e.ctrlKey&&!t)?"trackpad":e.some(({event:e})=>0!==e.deltaMode)||e.some(Ss)||e.every(({event:e})=>{const t=e.wheelDelta;return void 0!==t&&Math.abs(t)%40==0})?"mouse":e.some(({deltaX:e})=>0!==e)||e.length>1&&function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Math.abs(n.deltaX)>40||Math.abs(n.deltaY)>40)return!1;if(t>0&&n.timeStamp-e[t-1].timeStamp>40)return!1}return!0}(e)?"trackpad":t?"mouse":"unknown"}function Ss({event:e,deltaX:t,deltaY:n}){if(0!==t||0===n)return!1;const r=Math.abs(n/4.000244140625);if(Number.isInteger(r))return!0;const i=e.wheelDelta;return"number"==typeof i&&0!==i&&i%120==0}var Ps=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseenter","mouseleave"],Os=class extends vs{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;const{enable:r=!1}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,r&&Ps.forEach(e=>this.listen(e,!0))}destroy(){Ps.forEach(e=>this.listen(e,!1))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent!==t&&(this.enableMoveEvent=t,this.listen("mousedown",t),this.listen("mousemove",t),this.listen("mouseup",t));break;case"pointerover":this.enableOverEvent!==t&&(this.enableOverEvent=t,this.listen("mouseover",t));break;case"pointerout":this.enableOutEvent!==t&&(this.enableOutEvent=t,this.listen("mouseout",t));break;case"pointerenter":this.enableEnterEvent!==t&&(this.enableEnterEvent=t,this.listen("mouseenter",t));break;case"pointerleave":this.enableLeaveEvent!==t&&(this.enableLeaveEvent=t,this.listen("mouseleave",t))}}handleOverEvent(e){this.enableOverEvent&&"mouseover"===e.type&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&"mouseout"===e.type&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&"mouseenter"===e.type&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&"mouseleave"===e.type&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":0===e.buttons&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}},As=["keydown","keyup"],js=class extends vs{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=e=>{const t=e.target||e.srcElement;"INPUT"===t.tagName&&"text"===t.type||"TEXTAREA"===t.tagName||(this.enableDownEvent&&"keydown"===e.type&&this.callback({type:"keydown",srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&"keyup"===e.type&&this.callback({type:"keyup",srcEvent:e,key:e.key,target:e.target}))};const{enable:r=!1}=this.options;this.enableDownEvent=r,this.enableUpEvent=r,e.tabIndex=this.options.tabIndex,e.style.outline="none",r&&As.forEach(e=>this.listen(e,!0))}destroy(){As.forEach(e=>this.listen(e,!1))}enableEventType(e,t){"keydown"===e&&this.enableDownEvent!==t&&(this.enableDownEvent=t,this.listen(e,t)),"keyup"===e&&this.enableUpEvent!==t&&(this.enableUpEvent=t,this.listen(e,t))}},Ls=class extends vs{constructor(e,t,n){n.enable=n.enable??!1,super(e,t,n),this.handleEvent=e=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})},n.enable&&this.listen("contextmenu",!0)}destroy(){this.listen("contextmenu",!1)}enableEventType(e,t){"contextmenu"===e&&this.options.enable!==t&&(this.options.enable=t,this.listen("contextmenu",t))}},Is={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function Cs(e){const t=Is[e.srcEvent.type];if(!t)return null;const{buttons:n,button:r}=e.srcEvent;let i=!1,o=!1,s=!1;return 2===t?(i=Boolean(1&n),o=Boolean(4&n),s=Boolean(2&n)):(i=0===r,o=1===r,s=2===r),{leftButton:i,middleButton:o,rightButton:s}}function Rs(e,t){const n=e.center;if(!n)return null;const r=t.getBoundingClientRect(),i=r.width/t.offsetWidth||1,o=r.height/t.offsetHeight||1;return{center:n,offsetCenter:{x:(n.x-r.left-t.clientLeft)/i,y:(n.y-r.top-t.clientTop)/o}}}var $s={srcElement:"root",priority:0},ks=class{constructor(e,t){this.handleEvent=e=>{if(this.isEmpty())return;const t=this._normalizeEvent(e);let n=e.srcEvent.target;for(;n&&n!==t.rootElement;){if(this._emit(t,n),t.handled)return;n=n.parentNode}this._emit(t,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=/* @__PURE__ */new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,r=!1,i=!1){const{handlers:o,handlersByElement:s}=this,a={...$s,...n};let c=s.get(a.srcElement);c||(c=[],s.set(a.srcElement,c));const l={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};r&&(l.once=!0),i&&(l.passive=!0),o.push(l),this._active=this._active||!l.passive;let u=c.length-1;for(;u>=0&&!(c[u].priority>=l.priority);)u--;c.splice(u+1,0,l)}remove(e,t){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type===e&&o.handler===t){n.splice(i,1);const e=r.get(o.srcElement);e.splice(e.indexOf(o),1),0===e.length&&r.delete(o.srcElement)}}this._active=n.some(e=>!e.passive)}_emit(e,t){const n=this.handlersByElement.get(t);if(n){let t=!1;const r=()=>{e.handled=!0},i=()=>{e.handled=!0,t=!0},o=[];for(let s=0;s<n.length;s++){const{type:a,handler:c,once:l}=n[s];if(c({...e,type:a,stopPropagation:r,stopImmediatePropagation:i}),l&&o.push(n[s]),t)break}for(let e=0;e<o.length;e++){const{type:t,handler:n}=o[e];this.remove(t,n)}}}_normalizeEvent(e){const t=this.eventManager.getElement();return{...e,...Cs(e),...Rs(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function Ns(e){if("recognizer"in e)return e;let t;const n=Array.isArray(e)?[...e]:[e];return t="function"==typeof n[0]?new(n.shift())(n.shift()||{}):n.shift(),{recognizer:t,recognizeWith:"string"==typeof n[0]?[n[0]]:n[0],requireFailure:"string"==typeof n[1]?[n[1]]:n[1]}}var zs=class{constructor(e=null,t={}){if(this._onBasicInput=e=>{this.manager.emit(e.srcEvent.type,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=/* @__PURE__ */new Map,this.element=e,this.wheelSession=new Ts(e),e){this.manager=new cs(e,this.options);for(const e of this.options.recognizers){const{recognizer:t,recognizeWith:n,requireFailure:r}=Ns(e);this.manager.add(t),n&&t.recognizeWith(n),r&&t.requireFailure(r)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new Es(e,this._onOtherEvent,{enable:!1,wheelSession:this.wheelSession}),this.moveInput=new Os(e,this._onOtherEvent,{enable:!1}),this.keyInput=new js(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new Ls(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element?(this.wheelInput.destroy(),this.wheelSession.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy()):this.wheelSession.destroy()}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}emit(e){this.manager?.emit(e.type,e)}_toggleRecognizer(e,t){const{manager:n}=this;if(!n)return;const r=n.get(e);r&&(r.set({enable:t,wheelSession:this.wheelSession}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,r,i){if("string"!=typeof e){n=t;for(const[t,o]of Object.entries(e))this._addEventHandler(t,o,n,r,i);return}const{manager:o,events:s}=this;if(!o)return;let a=s.get(e);if(!a){const t=this._getRecognizerName(e)||e;a=new ks(this,t),s.set(e,a),o&&o.on(e,a.handleEvent)}a.add(e,t,n,r,i),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(e,t){if("string"!=typeof e){for(const[t,n]of Object.entries(e))this._removeEventHandler(t,n);return}const{events:n}=this,r=n.get(e);if(r&&(r.remove(e,t),r.isEmpty())){const{recognizerName:e}=r;let t=!1;for(const r of n.values())if(r.recognizerName===e&&!r.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}},Ds={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(Ds,"IDENTITY",{get:()=>(rt.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),Ds.CARTESIAN)});var Us={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ws={common:0,meters:1,pixels:2},Fs={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Bs={multipan:[_s,{threshold:10,pointers:2,trackpad:!0}],pinch:[class extends gs{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,trackpad:!1,coherent:[],...e}),this.trackpadGesture=!1}getTouchAction(){return[zo]}getEventNames(){return ys.map(e=>this.options.event+e)}attrTest(e){const t=Boolean(this.options.coherent?.length),n=Boolean(this.state&Co.Began),r=!(t&&e.eventType&(Lo.End|Lo.Cancel));return super.attrTest(e)&&(n||r&&(t?this.coherentTest(e):Math.abs(e.scale-1)>this.options.threshold))}emit(e){if(1!==e.scale){const t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}handleTrackpadEvent(e){e.isFirst&&(this.trackpadGesture=e.srcEvent.ctrlKey,!this.trackpadGesture&&this.state&(Co.Recognized|Co.Cancelled|Co.Failed)&&(this.state=Co.Possible)),this.trackpadGesture&&(this.recognize(this.getTrackpadInput(e,{deltaX:0,deltaY:0,velocity:0,velocityX:0,velocityY:0,overallVelocity:0,overallVelocityX:0,overallVelocityY:0,scale:Math.exp(-e.deltaY/100)})),e.isFinal&&(this.trackpadGesture=!1))}},{trackpad:!0},null,["multipan"]],pan:[_s,{threshold:1},["pinch"],["multipan"]],dblclick:[ms,{event:"dblclick",taps:2,enable:!1}],dblclickdrag:[class extends hs{constructor(e={}){super({enable:!0,event:"doubleclickdrag",pointers:1,interval:500,time:350,threshold:28,dragThreshold:1,pixelsPerScale:120,...e}),this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}getTouchAction(){return[No]}getEventNames(){return ps.map(e=>this.options.event+e)}process(e){const{options:t}=this;return e.pointers.length!==t.pointers?(this.reset(),Co.Failed):e.eventType&Lo.Start?this._handleStart(e):e.eventType&Lo.Move?this._handleMove(e):e.eventType&Lo.Cancel?this._handleEnd(e,!0):e.eventType&Lo.End?this._handleEnd(e,!1):Co.Failed}reset(){this._tapStart=null,this._lastTap=null,this._drag=null,this._emittedStart=!1}emit(e){if(e){if(this.state===Co.Began){if(!this._drag?.active||this._emittedStart)return;return this._emittedStart=!0,this.manager.emit(`${this.options.event}start`,e),void this.manager.emit(this.options.event,e)}if(this.state===Co.Changed){if(!this._emittedStart)return;return this.manager.emit(`${this.options.event}move`,e),void this.manager.emit(this.options.event,e)}if(this.state===Co.Ended){if(!this._emittedStart)return;return this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}end`,e),void(this._emittedStart=!1)}if(this.state===Co.Cancelled){if(!this._emittedStart)return;this.manager.emit(this.options.event,e),this.manager.emit(`${this.options.event}cancel`,e),this._emittedStart=!1}}}_handleStart(e){const t=this._getPointerId(e);return this._lastTap&&this._isTapMatch(e,this._lastTap)?(this._tapStart=null,this._lastTap=null,this._drag={startCenter:e.center,pointerId:t,active:!1},this._emittedStart=!1,Co.Began):(this._tapStart={center:e.center,timeStamp:e.timeStamp,pointerId:t},this._lastTap=null,this._drag=null,this._emittedStart=!1,Co.Failed)}_handleMove(e){if(!this._drag||!this._isSamePointer(e,this._drag.pointerId))return Co.Failed;const t=this._drag.startCenter.y-e.center.y;return!this._drag.active&&Math.abs(t)<this.options.dragThreshold?Co.Began:(this._drag.active=!0,e.scale=Math.pow(2,t/this.options.pixelsPerScale),this._emittedStart?Co.Changed:Co.Began)}_handleEnd(e,t){if(this._drag&&this._isSamePointer(e,this._drag.pointerId)){const{active:n,startCenter:r}=this._drag;if(this._drag=null,this._tapStart=null,this._lastTap=null,!n)return this._emittedStart=!1,Co.Failed;const i=r.y-e.center.y;return e.scale=Math.pow(2,i/this.options.pixelsPerScale),t?Co.Cancelled:Co.Ended}return this._tapStart&&this._isSamePointer(e,this._tapStart.pointerId)?(this._isValidTap(e)?this._lastTap={center:e.center,timeStamp:e.timeStamp,pointerId:this._tapStart.pointerId}:this._lastTap=null,this._tapStart=null,Co.Failed):(t&&this.reset(),Co.Failed)}_isTapMatch(e,t){return e.timeStamp-t.timeStamp<=this.options.interval&&qo(e.center,t.center)<=this.options.threshold}_isValidTap(e){return e.deltaTime<=this.options.time&&e.distance<=this.options.threshold}_getPointerId(e){return"pointerId"in e.srcEvent?e.srcEvent.pointerId:null}_isSamePointer(e,t){return null===t||this._getPointerId(e)===t}},{event:"dblclickdrag",enable:!1},["dblclick"],null],click:[ms,{event:"click"},["dblclickdrag"],["dblclick","dblclickdrag"]]};function Gs(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}function Vs(e){let t,n={};return r=>{for(const i in r)if(!Gs(r[i],n[i])){t=e(r),n=r;break}return t}}var Ys=[0,0,0,0],Xs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],qs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Hs=[0,0,0],Zs=[0,0,0],Ks={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Js(e){const t=Ks[e];if(void 0===t)throw new Error(`Invalid coordinateSystem: ${e}`);return t}var Qs=Vs(function({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r}){const{projectionCenter:i,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=function(e,t,n){const{viewMatrixUncentered:r,projectionMatrix:i}=e;let{viewMatrix:o,viewProjectionMatrix:s}=e,a=Ys,c=Ys,l=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=ea(e,t,n);d&&(c=e.projectPosition(u||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=yo([],c,s),o=r||o,s=ro([],i,o),s=ro([],s,Xs));return{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,n,r),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=yo([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,f={coordinateSystem:Js(n),projectionMode:e.projectionMode,coordinateOrigin:c,commonOrigin:s.slice(0,3),center:i,pseudoMeters:Boolean(e._pseudoMeters),viewportSize:h,devicePixelRatio:t,focalDistance:d,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:Hs,scale:e.scale,wrapLongitude:!1,viewProjectionMatrix:o,modelMatrix:qs,cameraPosition:a};if(l){const t=e.getDistanceScales(l);switch(n){case"meter-offsets":f.commonUnitsPerWorldUnit=t.unitsPerMeter,f.commonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":e._pseudoMeters||(f.commonUnitsPerMeter=t.unitsPerMeter),f.commonUnitsPerWorldUnit=t.unitsPerDegree,f.commonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case"cartesian":f.commonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],f.commonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}if(e.projectionMode===Us.GLOBE&&"meter-offsets"===n){const e=6370972,t=256,n=r[0]*Math.PI/180,i=r[1]*Math.PI/180,o=Math.cos(i),s=((r[2]||0)/e+1)*t;f.commonOrigin=[Math.sin(n)*o*s,-Math.cos(n)*o*s,Math.sin(i)*s]}return f});function ea(e,t,n=Zs){n.length<3&&(n=[n[0],n[1],0]);let r,i=n,o=!0;switch(r="lnglat-offsets"===t||"meter-offsets"===t?n:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case Us.WEB_MERCATOR:"lnglat"===t?(r=[0,0,0],o=!1):"cartesian"===t&&(o=!1,r=e.unprojectPosition([Math.fround(e.center[0]),Math.fround(e.center[1]),0]));break;case Us.WEB_MERCATOR_AUTO_OFFSET:"lnglat"===t?i=r:"cartesian"===t&&(i=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],r=e.unprojectPosition(i),i[0]-=n[0],i[1]-=n[1],i[2]-=n[2]);break;case Us.IDENTITY:i=e.position.map(Math.fround),i[2]=i[2]||0;break;case Us.GLOBE:o=!1,r=null;break;default:o=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:i,offsetMode:o}}var ta=`${`${["default","lnglat","meter-offsets","lnglat-offsets","cartesian"].map(e=>`const COORDINATE_SYSTEM_${e.toUpperCase().replaceAll("-","_")}: i32 = ${Js(e)};`).join("")}\n${Object.keys(Us).map(e=>`const PROJECTION_MODE_${e}: i32 = ${Us[e]};`).join("")}\n${Object.keys(Ws).map(e=>`const UNIT_${e.toUpperCase()}: i32 = ${Ws[e]};`).join("")}\n\nconst TILE_SIZE: f32 = 512.0;\nconst PI: f32 = 3.1415926536;\nconst WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0);\nconst ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);\nconst EARTH_RADIUS: f32 = 6370972.0; // meters\nconst GLOBE_RADIUS: f32 = 256.0;\n\n// -----------------------------------------------------------------------------\n// Uniform block (converted from GLSL uniform block)\n// -----------------------------------------------------------------------------\nstruct ProjectUniforms {\n wrapLongitude: i32,\n coordinateSystem: i32,\n commonUnitsPerMeter: vec3<f32>,\n projectionMode: i32,\n scale: f32,\n commonUnitsPerWorldUnit: vec3<f32>,\n commonUnitsPerWorldUnit2: vec3<f32>,\n center: vec4<f32>,\n modelMatrix: mat4x4<f32>,\n viewProjectionMatrix: mat4x4<f32>,\n viewportSize: vec2<f32>,\n devicePixelRatio: f32,\n focalDistance: f32,\n cameraPosition: vec3<f32>,\n coordinateOrigin: vec3<f32>,\n commonOrigin: vec3<f32>,\n pseudoMeters: i32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> project: ProjectUniforms;\n\n// -----------------------------------------------------------------------------\n// Geometry data shared across the project helpers.\n// The active layer shader is responsible for populating this private module\n// state before calling the project functions below.\n// -----------------------------------------------------------------------------\n\n// Structure to carry additional geometry data used by deck.gl filters.\nstruct Geometry {\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n position: vec4<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry: Geometry;\n`}\n\n// -----------------------------------------------------------------------------\n// Functions\n// -----------------------------------------------------------------------------\n\n// Returns an adjustment factor for commonUnitsPerMeter\nfn _project_size_at_latitude(lat: f32) -> f32 {\n let y = clamp(lat, -89.9, 89.9);\n return 1.0 / cos(radians(y));\n}\n\n// Overloaded version: scales a value in meters at a given latitude.\nfn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 {\n return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat);\n}\n\n// Computes a non-linear scale factor based on geometry.\n// (Note: This function relies on "geometry" being provided.)\nfn project_size() -> f32 {\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\n project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\n project.pseudoMeters == 0) {\n if (geometry.position.w == 0.0) {\n return _project_size_at_latitude(geometry.worldPosition.y);\n }\n let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\n let y2 = y * y;\n let y4 = y2 * y2;\n let y6 = y4 * y2;\n return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n }\n return 1.0;\n}\n\n// Overloads to scale offsets (meters to world units)\nfn project_size_float(meters: f32) -> f32 {\n return meters * project.commonUnitsPerMeter.z * project_size();\n}\n\nfn project_size_vec2(meters: vec2<f32>) -> vec2<f32> {\n return meters * project.commonUnitsPerMeter.xy * project_size();\n}\n\nfn project_size_vec3(meters: vec3<f32>) -> vec3<f32> {\n return meters * project.commonUnitsPerMeter * project_size();\n}\n\nfn project_size_vec4(meters: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\n\n// Returns a rotation matrix aligning the z‑axis with the given up vector.\nfn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> {\n let uz = normalize(up);\n let ux = select(\n vec3<f32>(1.0, 0.0, 0.0),\n normalize(vec3<f32>(uz.y, -uz.x, 0.0)),\n abs(uz.z) == 1.0\n );\n let uy = cross(uz, ux);\n return mat3x3<f32>(ux, uy, uz);\n}\n\n// Since WGSL does not support "out" parameters, we return a struct.\nstruct RotationResult {\n needsRotation: bool,\n transform: mat3x3<f32>,\n};\n\nfn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n return RotationResult(true, project_get_orientation_matrix(commonPosition));\n } else {\n return RotationResult(false, mat3x3<f32>()); // identity alternative if needed\n };\n}\n\n// Projects a normal vector from the current coordinate system to world space.\nfn project_normal(vector: vec3<f32>) -> vec3<f32> {\n let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0);\n var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\n let rotResult = project_needs_rotation(geometry.position.xyz);\n if (rotResult.needsRotation) {\n n = rotResult.transform * n;\n }\n return n;\n}\n\n// Applies a scale offset based on y-offset (dy)\nfn project_offset_(offset: vec4<f32>) -> vec4<f32> {\n let dy: f32 = offset.y;\n let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\n return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\n\n// Projects lng/lat coordinates to a unit tile [0,1]\nfn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {\n var x = lnglat.x;\n if (project.wrapLongitude != 0) {\n x = ((x + 180.0) % 360.0) - 180.0;\n }\n let y = clamp(lnglat.y, -89.9, 89.9);\n return vec2<f32>(\n radians(x) + PI,\n PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// Projects lng/lat/z coordinates for a globe projection.\nfn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> {\n let lambda = radians(lnglatz.x);\n let phi = radians(lnglatz.y);\n let cosPhi = cos(phi);\n let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\n return vec3<f32>(\n sin(lambda) * cosPhi,\n -cos(lambda) * cosPhi,\n sin(phi)\n ) * D;\n}\n\n// Mercator y of project_mercator_'s latitude clamp: log(tan(PI / 4 + radians(89.9) / 2))\nconst MAX_MERCATOR_Y: f32 = 7.0439589847;\n\n// Inverse of project_globe_ followed by project_mercator_, without forming lat/lng:\n// Mercator y = atanh(sin(lat)) = log((D + |z|) / |xy|), which stays accurate near the poles\nfn project_globe_to_mercator_(spherePos: vec3<f32>) -> vec2<f32> {\n let D = length(spherePos);\n let h = max(length(spherePos.xy), 1e-20);\n let y = sign(spherePos.z) * min(log((D + abs(spherePos.z)) / h), MAX_MERCATOR_Y);\n let x = atan2(spherePos.x, -spherePos.y);\n return (vec2<f32>(x, y) + PI) * WORLD_SCALE;\n}\n\n// Flat common space (Mercator or cartesian) of a common position; identity except under GLOBE.\n// WGSL has no function overloading: pass position.xyz for a vec4. See project.glsl.ts.\nfn project_common_position_to_flat(commonPosition: vec3<f32>) -> vec2<f32> {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n return project_globe_to_mercator_(commonPosition);\n }\n return commonPosition.xy;\n}\n\n// World copy of a flat x nearest to referenceX\nfn project_wrap_flat_x_(x: f32, referenceX: f32) -> f32 {\n return x - TILE_SIZE * floor((x - referenceX) / TILE_SIZE + 0.5);\n}\n\n// Flat position in the world copy nearest to referenceX (e.g. a bounds centre); geospatial only\nfn project_common_position_to_flat_wrapped(commonPosition: vec3<f32>, referenceX: f32) -> vec2<f32> {\n var flatPosition = project_common_position_to_flat(commonPosition);\n if (project.projectionMode != PROJECTION_MODE_IDENTITY) {\n flatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n }\n return flatPosition;\n}\n\n// Flat position continuous across the antimeridian under GLOBE (seam moved opposite referenceX,\n// e.g. the camera); identity for flat modes. For periodic patterns.\nfn project_common_position_to_flat_continuous(commonPosition: vec3<f32>, referenceX: f32) -> vec2<f32> {\n var flatPosition = project_common_position_to_flat(commonPosition);\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n flatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n }\n return flatPosition;\n}\n\n// Projects positions (with an optional 64-bit low part) from the input\n// coordinate system to the common space.\nfn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> {\n var position_world = project.modelMatrix * position;\n\n // Work around for a Mac+NVIDIA bug:\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4<f32>(\n project_mercator_(position_world.xy),\n _project_size_at_latitude_m(position_world.z, position_world.y),\n position_world.w\n );\n }\n if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\n position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w);\n }\n }\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4<f32>(\n project_globe_(position_world.xyz),\n position_world.w\n );\n }\n if (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) {\n let enuMatrix = project_get_orientation_matrix(project.commonOrigin);\n let metersToCommon = GLOBE_RADIUS / EARTH_RADIUS;\n let offsetCommon = (enuMatrix * vec3<f32>(-position_world.x, -position_world.y, position_world.z)) * metersToCommon;\n return vec4<f32>(project.commonOrigin + offsetCommon, position_world.w);\n }\n }\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\n return vec4<f32>(\n project_mercator_(position_world.xy) - project.commonOrigin.xy,\n project_size_float(position_world.z),\n position_world.w\n );\n }\n }\n }\n if (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\n position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w);\n }\n\n return project_offset_(position_world) +\n project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0));\n}\n\n// Overloaded versions for different input types.\nfn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> {\n return project_position_vec4_f64(position, ZERO_64_LOW);\n}\n\nfn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low);\n return projected_position.xyz;\n}\n\nfn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW);\n return projected_position.xyz;\n}\n\nfn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> {\n let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW);\n return projected_position.xy;\n}\n\n// Transforms a common space position to clip space.\nfn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> {\n var clipPosition = viewProjectionMatrix * position + center;\n // deck.gl projection matrices use WebGL's [-w, w] depth range; WebGPU clips z to [0, w].\n clipPosition.z = (clipPosition.z + clipPosition.w) * 0.5;\n return clipPosition;\n}\n\n// Uses the project viewProjectionMatrix and center.\nfn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> {\n return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center);\n}\n\n// Returns a clip space offset corresponding to a given number of screen pixels.\nfn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> {\n let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\n return offset * project.focalDistance;\n}\n\nfn project_meter_size_to_pixel(meters: f32) -> f32 {\n return project_size_float(meters) * project.scale;\n}\n\nfn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 {\n if (unit == UNIT_METERS) {\n return project_meter_size_to_pixel(size);\n } else if (unit == UNIT_COMMON) {\n return size * project.scale;\n }\n // UNIT_PIXELS: no scaling applied.\n return size;\n}\n\nfn project_pixel_size_float(pixels: f32) -> f32 {\n return pixels / project.scale;\n}\n\nfn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {\n return pixels / project.scale;\n}\n`,na=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"].map(e=>`const int COORDINATE_SYSTEM_${e.toUpperCase().replaceAll("-","_")} = ${Js(e)};`).join(""),ra=Object.keys(Us).map(e=>`const int PROJECTION_MODE_${e} = ${Us[e]};`).join(""),ia=Object.keys(Ws).map(e=>`const int UNIT_${e.toUpperCase()} = ${Ws[e]};`).join(""),oa={};var sa={name:"project",dependencies:[Ro,ko],source:ta,vs:`${na}\n${ra}\n${ia}\nlayout(std140) uniform projectUniforms {\nbool wrapLongitude;\nint coordinateSystem;\nvec3 commonUnitsPerMeter;\nint projectionMode;\nfloat scale;\nvec3 commonUnitsPerWorldUnit;\nvec3 commonUnitsPerWorldUnit2;\nvec4 center;\nmat4 modelMatrix;\nmat4 viewProjectionMatrix;\nvec2 viewportSize;\nfloat devicePixelRatio;\nfloat focalDistance;\nvec3 cameraPosition;\nvec3 coordinateOrigin;\nvec3 commonOrigin;\nbool pseudoMeters;\n} project;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject.pseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project.commonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project.commonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project.commonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project.wrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nconst float MAX_MERCATOR_Y = 7.0439589847;\nvec2 project_globe_to_mercator_(vec3 spherePos) {\nfloat D = length(spherePos);\nfloat h = max(length(spherePos.xy), 1e-20);\nfloat y = sign(spherePos.z) * min(log((D + abs(spherePos.z)) / h), MAX_MERCATOR_Y);\nfloat x = atan(spherePos.x, -spherePos.y);\nreturn (vec2(x, y) + PI) * WORLD_SCALE;\n}\nvec2 project_common_position_to_flat(vec3 commonPosition) {\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nreturn project_globe_to_mercator_(commonPosition);\n}\nreturn commonPosition.xy;\n}\nvec2 project_common_position_to_flat(vec4 commonPosition) {\nreturn project_common_position_to_flat(commonPosition.xyz);\n}\nfloat project_wrap_flat_x_(float x, float referenceX) {\nreturn x - TILE_SIZE * floor((x - referenceX) / TILE_SIZE + 0.5);\n}\nvec2 project_common_position_to_flat_wrapped(vec3 commonPosition, float referenceX) {\nvec2 flatPosition = project_common_position_to_flat(commonPosition);\nif (project.projectionMode != PROJECTION_MODE_IDENTITY) {\nflatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n}\nreturn flatPosition;\n}\nvec2 project_common_position_to_flat_wrapped(vec4 commonPosition, float referenceX) {\nreturn project_common_position_to_flat_wrapped(commonPosition.xyz, referenceX);\n}\nvec2 project_common_position_to_flat_continuous(vec3 commonPosition, float referenceX) {\nvec2 flatPosition = project_common_position_to_flat(commonPosition);\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nflatPosition.x = project_wrap_flat_x_(flatPosition.x, referenceX);\n}\nreturn flatPosition;\n}\nvec2 project_common_position_to_flat_continuous(vec4 commonPosition, float referenceX) {\nreturn project_common_position_to_flat_continuous(commonPosition.xyz, referenceX);\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project.modelMatrix * position;\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project.coordinateOrigin;\n}\n}\nif (project.projectionMode == PROJECTION_MODE_GLOBE) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\nif (project.coordinateSystem == COORDINATE_SYSTEM_METER_OFFSETS) {\nmat3 enuMatrix = project_get_orientation_matrix(project.commonOrigin);\nfloat metersToCommon = GLOBE_RADIUS / EARTH_RADIUS;\nvec3 offsetCommon = (enuMatrix * vec3(-position_world.xy, position_world.z)) * metersToCommon;\nreturn vec4(project.commonOrigin + offsetCommon, position_world.w);\n}\n}\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project.commonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project.coordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\nreturn offset * project.focalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project.scale;\n}\nvec2 project_size_to_pixel(vec2 meters) {\nreturn project_size(meters) * project.scale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project.scale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project.scale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project.scale;\n}\n`,getUniforms:function(e=oa){return"viewport"in e?function({viewport:e,devicePixelRatio:t=1,modelMatrix:n=null,coordinateSystem:r="default",coordinateOrigin:i=Zs,autoWrapLongitude:o=!1}){"default"===r&&(r=e.isGeospatial?"lnglat":"cartesian");const s=Qs({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i});return s.wrapLongitude=o,s.modelMatrix=n||qs,s}(e):{}},uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}};function aa(e,t){const n=yo([],t,e);return fo(n,n,1/n[3]),n}function ca(e,t,n){return e<t?t:e>n?n:e}var la=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function ua(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var ha=Math.PI,da=ha/4,fa=ha/180,pa=180/ha,ma=512,ga=4003e4,ba=85.051129,_a=1.5;function ya(e){const[t,n]=e;ua(Number.isFinite(t)),ua(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");const r=n*fa;return[ma*(t*fa+ha)/(2*ha),ma*(ha+Math.log(Math.tan(da+.5*r)))/(2*ha)]}function va(e){const[t,n]=e,r=t/ma*(2*ha)-ha,i=2*(Math.atan(Math.exp(n/ma*(2*ha)-ha))-da);return[r*pa,i*pa]}function wa(e){const{latitude:t}=e;ua(Number.isFinite(t));const n=Math.cos(t*fa);return function(e){return la(e)}(ga*n)-9}function Ea(e){return 12790407194604047e-21/Math.cos(e*fa)}function xa(e){const{latitude:t,longitude:n,highPrecision:r=!1}=e;ua(Number.isFinite(t)&&Number.isFinite(n));const i=ma,o=Math.cos(t*fa),s=i/360,a=s/o,c=12790407194604047e-21/o,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[s,a,c],degreesPerUnit:[.703125,1/a,1/c]};if(r){const e=fa*Math.tan(t*fa)/o,n=s*e/2,r=12790407194604047e-21*e,i=r/a*c;l.unitsPerDegree2=[0,n,r],l.unitsPerMeter2=[i,0,i]}return l}function Ta(e,t){const[n,r,i]=e,[o,s,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=xa({longitude:n,latitude:r,highPrecision:!0}),u=ya(e);u[0]+=o*(c[0]+l[0]*s),u[1]+=s*(c[1]+l[1]*s);const h=va(u),d=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[h[0],h[1],d]:h}function Ma(e){return 2*Math.atan(.5/e)*pa}function Sa(e){return.5/Math.tan(.5*e*fa)}function Pa(e,t){const[n,r,i=0]=e;return ua(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),aa(t,[n,r,i,1])}function Oa(e,t,n=0){const[r,i,o]=e;if(ua(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(o))return aa(t,[r,i,o,1]);const s=aa(t,[r,i,0,1]),a=aa(t,[r,i,1,1]),c=s[2],l=a[2];return Ai([],s,a,c===l?0:((n||0)-c)/(l-c))}function Aa(e){const{width:t,height:n,bounds:r,minExtent:i=0,maxZoom:o=24,offset:s=[0,0]}=e,[[a,c],[l,u]]=r,h=function(e=0){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:(ua(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}(e.padding),d=ya([a,ca(u,-85.051129,ba)]),f=ya([l,ca(c,-85.051129,ba)]),p=[Math.max(Math.abs(f[0]-d[0]),i),Math.max(Math.abs(f[1]-d[1]),i)],m=[t-h.left-h.right-2*Math.abs(s[0]),n-h.top-h.bottom-2*Math.abs(s[1])];ua(m[0]>0&&m[1]>0);const g=m[0]/p[0],b=m[1]/p[1],_=(h.right-h.left)/2/g,y=(h.top-h.bottom)/2/b,v=va([(f[0]+d[0])/2+_,(f[1]+d[1])/2+y]),w=Math.min(o,la(Math.abs(Math.min(g,b))));return ua(Number.isFinite(w)),{longitude:v[0],latitude:v[1],zoom:w}}var ja=Math.PI/180;function La(e,t,n){const{pixelUnprojectionMatrix:r}=e,i=aa(r,[t,0,1,1]),o=aa(r,[t,e.height,1,1]),s=va(Ai([],i,o,(n*e.distanceScales.unitsPerMeter[2]-i[2])/(o[2]-i[2])));return s.push(n),s}var Ia=new class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:r,padding:i=0,copy:o=!1,initialize:s=!1,maxCount:a}){const c=r||e&&e.constructor||Float32Array,l=t*n+i;if(ArrayBuffer.isView(e)){if(l<=e.length)return e;if(l*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new c(e.buffer,0,l)}let u=1/0;a&&(u=a*n+i);const h=this._allocate(c,l,s,u);return e&&o?h.set(e):s||h.fill(0,0,4),this._release(e),h}release(e){this._release(e)}_allocate(e,t,n,r){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>r&&(i=r);const o=this._pool,s=e.BYTES_PER_ELEMENT*i,a=o.findIndex(e=>e.byteLength>=s);if(a>=0){const t=new e(o.splice(a,1)[0],0,i);return n&&t.fill(0),t}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:n}=e,{byteLength:r}=n,i=t.findIndex(e=>e.byteLength>=r);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}};function Ca(e,t){const n=e%t;return n<0?t+n:n}var Ra,$a=new eo;function ka(e,t,n,r){$a.set(e,t,n);const i=$a.len();return{distance:r/i,normal:new eo(-e/i,-t/i,-n/i)}}function Na(e){return e-Math.fround(e)}function za(e,t){const{size:n=1,startIndex:r=0}=t,i=void 0!==t.endIndex?t.endIndex:e.length,o=(i-r)/n;Ra=Ia.allocate(Ra,o,{type:Float32Array,size:2*n});let s=r,a=0;for(;s<i;){for(let t=0;t<n;t++){const r=e[s++];Ra[a+t]=r,Ra[a+t+n]=Na(r)}a+=2*n}return Ra.subarray(0,o*n*2)}function Da(e){let t=null,n=!1;for(const r of e)r&&(t?(n||(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],n=!0),t[0][0]=Math.min(t[0][0],r[0][0]),t[0][1]=Math.min(t[0][1],r[0][1]),t[1][0]=Math.max(t[1][0],r[1][0]),t[1][1]=Math.max(t[1][1],r[1][1])):t=r);return t}var Ua=Math.PI/180,Wa=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Fa=[0,0,0],Ba={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};var Ga=class e{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||Ba,this.focalDistance=e.focalDistance||1,this.position=e.position||Fa,this.modelMatrix=e.modelMatrix||null;const{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?Us.WEB_MERCATOR:Us.WEB_MERCATOR_AUTO_OFFSET:Us.IDENTITY}equals(t){return t instanceof e&&(this===t||t.width===this.width&&t.height===this.height&&t.scale===this.scale&&t.projectionMode===this.projectionMode&&t.resolution===this.resolution&&yi(t.distanceScales.unitsPerMeter,this.distanceScales.unitsPerMeter)&&yi(t.projectionMatrix,this.projectionMatrix)&&yi(t.viewMatrix,this.viewMatrix))}project(e,{topLeft:t=!0}={}){const n=Pa(this.projectPosition(e),this.pixelProjectionMatrix),[r,i]=n,o=t?i:this.height-i;return 2===e.length?[r,o]:[r,o,n[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){const[r,i,o]=e,s=t?i:this.height-i,a=n&&n*this.distanceScales.unitsPerMeter[2],c=Oa([r,s,o],this.pixelUnprojectionMatrix,a),[l,u,h]=this.unprojectPosition(c);return Number.isFinite(o)?[l,u,h]:Number.isFinite(n)?[l,u,n]:[l,u]}projectPosition(e){const[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(e){const[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(e){if(this.isGeospatial){const t=ya(e);return t[1]=bi(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?va(e):e}getBounds(e={}){const t={targetZ:e.z||0},n=this.unproject([0,0],t),r=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),o=this.unproject([this.width,this.height],t);return[Math.min(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0]),Math.max(n[1],r[1],i[1],o[1])]}getDistanceScales(e){return e&&this.isGeospatial?xa({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:r=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+r}getFrustumPlanes(){return this._frustumPlanes.near||Object.assign(this._frustumPlanes,{left:ka((e=this.viewProjectionMatrix)[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:ka(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:ka(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:ka(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:ka(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:ka(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}),this._frustumPlanes;var e}panByPosition(e,t,n){return null}_initProps(e){const t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=wa({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||xa({latitude:n,longitude:t}));const r=Math.pow(2,this.zoom);this.scale=r;const{position:i,modelMatrix:o}=e;let s=Fa;if(i&&(s=o?new Ao(o).transformAsVector(i,[]):i),this.isGeospatial){const e=this.projectPosition([t,n,0]);this.center=new eo(s).scale(this.distanceScales.unitsPerMeter).add(e)}else this.center=this.projectPosition(s)}_initMatrices(e){const{viewMatrix:t=Wa,projectionMatrix:n=null,orthographic:r=!1,fovyRadians:i,fovy:o=75,near:s=.1,far:a=1e3,padding:c=null,focalDistance:l=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=(new Ao).multiplyRight(t).translate(new eo(this.center).negate()),this.projectionMatrix=n||function({width:e,height:t,orthographic:n,fovyRadians:r,focalDistance:i,padding:o,near:s,far:a}){const c=e/t,l=n?(new Ao).orthographic({fovy:r,aspect:c,focalDistance:i,near:s,far:a}):(new Ao).perspective({fovy:r,aspect:c,near:s,far:a});if(o){const{left:n=0,right:r=0,top:i=0,bottom:s=0}=o,a=bi((n+e-r)/2,0,e)-e/2,c=bi((i+t-s)/2,0,t)-t/2;l[8]-=2*a/e,l[9]+=2*c/t}return l}({width:this.width,height:this.height,orthographic:r,fovyRadians:i||o*Ua,focalDistance:l,padding:c,near:s,far:a});const u=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var h;ro(u,u,this.projectionMatrix),ro(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=no([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=[(h=this.viewMatrixInverse)[12],h[13],h[14]];const d=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],f=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];oo(d,d,[this.width/2,-this.height/2,1]),io(d,d,[1,-1,0]),ro(f,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=f,this.pixelUnprojectionMatrix=no([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||rt.warn("Pixel project matrix not invertible")()}};Ga.displayName="Viewport";var Va=class e extends Ga{constructor(e={}){const{latitude:t=0,longitude:n=0,zoom:r=0,pitch:i=0,bearing:o=0,nearZMultiplier:s=.1,farZMultiplier:a=1.01,nearZ:c,farZ:l,orthographic:u=!1,projectionMatrix:h,repeat:d=!1,worldOffset:f=0,position:p,padding:m,legacyMeterSizes:g=!1}=e;let{width:b,height:_,altitude:y=1.5}=e;const v=Math.pow(2,r);let w;b=b||1,_=_||1;let E=null;if(h)y=h[5]/2,w=Ma(y);else{let n;if(e.fovy?(w=e.fovy,y=Sa(w)):w=Ma(y),m){const{top:e=0,bottom:t=0}=m;n=[0,bi((e+_-t)/2,0,_)-_/2]}E=function(e){const{width:t,height:n,altitude:r,pitch:i=0,offset:o,center:s,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e;let{fovy:u=Ma(_a)}=e;void 0!==r&&(u=Ma(r));const h=u*fa,d=i*fa,f=Sa(u);let p=f;s&&(p+=s[2]*a/Math.cos(d)/n);const m=h*(.5+(o?o[1]:0)/n),g=Math.sin(m)*p/Math.sin(ca(Math.PI/2-d-m,.01,Math.PI-.01)),b=Math.sin(d)*g+p,_=10*p;return{fov:h,aspect:t/n,focalDistance:f,near:c,far:Math.min(b*l,_)}}({width:b,height:_,scale:v,center:p&&[0,0,p[2]*Ea(t)],offset:n,pitch:i,fovy:w,nearZMultiplier:s,farZMultiplier:a}),Number.isFinite(c)&&(E.near=c),Number.isFinite(l)&&(E.far=l)}let x=function(e){const{height:t,pitch:n,bearing:r,altitude:i,scale:o,center:s}=e,a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];io(a,a,[0,0,-i]),so(a,a,-n*fa),ao(a,a,r*fa);const c=o/t;var l,u;return oo(a,a,[c,c,c]),s&&io(a,a,((l=[])[0]=-(u=s)[0],l[1]=-u[1],l[2]=-u[2],l)),a}({height:_,pitch:i,bearing:o,scale:v,altitude:y});f&&(x=(new Ao).translate([512*f,0,0]).multiplyLeft(x)),super({...e,width:b,height:_,viewMatrix:x,longitude:n,latitude:t,zoom:r,...E,fovy:w,focalDistance:y}),this.latitude=t,this.longitude=n,this.zoom=r,this.pitch=i,this.bearing=o,this.altitude=y,this.fovy=w,this.orthographic=u,this._subViewports=d?[]:null,this._pseudoMeters=g,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const t=this.getBounds(),n=Math.floor((t[0]+180)/360),r=Math.ceil((t[2]-180)/360);for(let i=n;i<=r;i++){const t=i?new e({...this,worldOffset:i}):this;this._subViewports.push(t)}}return this._subViewports}equals(t){return t instanceof e&&t._pseudoMeters===this._pseudoMeters&&super.equals(t)}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);const[t,n]=this.projectFlat(e);return[t,n,(e[2]||0)*Ea(e[1])]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);const[t,n]=this.unprojectFlat(e);return[t,n,(e[2]||0)/Ea(n)]}addMetersToLngLat(e,t){return Ta(e,t)}panByPosition(e,t,n){const r=Oa(t,this.pixelUnprojectionMatrix),i=Oi([],this.projectFlat(e),((o=[])[0]=-(s=r)[0],o[1]=-s[1],o));var o,s;const a=Oi([],this.center,i),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,t){const n=e[2]||0,r=Ri([],e,this.unproject(t,{targetZ:n}));return{longitude:this.longitude+r[0],latitude:this.latitude+r[1]}}getBounds(e={}){const t=function(e,t=0){const{width:n,height:r,unproject:i}=e,o={targetZ:t},s=i([0,r],o),a=i([n,r],o);let c,l;return(e.fovy?.5*e.fovy*ja:Math.atan(.5/e.altitude))>(90-e.pitch)*ja-.01?(c=La(e,0,t),l=La(e,n,t)):(c=i([0,0],o),l=i([n,0],o)),[s,a,l,c]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(t,n={}){const{width:r,height:i}=this,{longitude:o,latitude:s,zoom:a}=Aa({width:r,height:i,bounds:t,...n});return new e({width:r,height:i,longitude:o,latitude:s,zoom:a})}};Va.displayName="WebMercatorViewport";var Ya={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},Xa=Symbol.for("component"),qa=Symbol.for("propTypes"),Ha=Symbol.for("deprecatedProps"),Za=Symbol.for("asyncPropDefaults"),Ka=Symbol.for("asyncPropOriginal"),Ja=Symbol.for("asyncPropResolved");function Qa(e,t=()=>!0){return Array.isArray(e)?ec(e,t,[]):t(e)?[e]:[]}function ec(e,t,n){let r=-1;for(;++r<e.length;){const i=e[r];Array.isArray(i)?ec(i,t,n):t(i)&&n.push(i)}return n}function tc({target:e,source:t,start:n=0,count:r=1}){const i=t.length,o=r*i;let s=0;for(let a=n;s<i;s++)e[a++]=t[s];for(;s<o;)s<o-s?(e.copyWithin(n+s,n,n+s),s*=2):(e.copyWithin(n+s,n,n+o-s),s=o);return e}function nc(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!nc(e[r],t[r],n-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const o of r){if(!t.hasOwnProperty(o))return!1;if(!nc(e[o],t[o],n-1))return!1}return!0}return!1}var rc=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};function ic(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}var oc=null,sc=!1;async function ac(){hc()}function cc(e,t){return hc(),e}async function lc(e){hc()}function uc(e){return oc?.initialize(e),null}function hc(){sc||(sc=!0,o.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}export{vo as $,Qt as $t,va as A,bi as At,Ws as B,ci as Bt,ba as C,Pi as Ct,ya as D,Ei as Dt,Sa as E,Ti as Et,Vs as F,_i as Ft,ho as G,Rn as Gt,ko as H,Un as Ht,Ds as I,mi as It,_o as J,Cn as Jt,bo as K,In as Kt,Fs as L,pi as Lt,sa as M,gi as Mt,ea as N,yi as Nt,Oa as O,xi as Ot,Js as P,fi as Pt,yo as Q,rn as Qt,Us as R,ai as Rt,Ia as S,Ci as St,Ma as T,Mi as Tt,Ro as U,Nn as Ut,zs as V,Bn as Vt,Ao as W,$n as Wt,fo as X,On as Xt,go as Y,An as Yt,mo as Z,Sn as Zt,Va as _,w as _n,Ni as _t,ic as a,ke as an,Bi as at,Ca as b,c as bn,Li as bt,tc as c,te as cn,Ui as ct,Ka as d,H as dn,Ji as dt,Ht as en,co as et,Ja as f,G as fn,Zi as ft,qa as g,x as gn,$i as gt,Ya as h,T as hn,qi as ht,cc as i,nt as in,Gi as it,Pa as j,hi as jt,Ea as k,wi as kt,Qa as l,ee as ln,Vi as lt,Ha as m,S as mn,Yi as mt,lc as n,st as nn,eo as nt,rc as o,ie as on,Wi as ot,Xa as p,M as pn,Xi as pt,po as q,jn as qt,ac as r,rt as rn,Di as rt,nc as s,oe as sn,Ki as st,uc as t,at as tn,to as tt,Za as u,K as un,Fi as ut,Ga as v,d as vn,zi as vt,Ta as w,Si as wt,za as x,Ii as xt,Da as y,l as yn,ji as yt,Bs as z,si as zt};
|