| Current Path : /home/atelierpru/www/airvalue/vendor/ |
| Current File : /home/atelierpru/www/airvalue/vendor/deck.gl.min.js |
/* deck.gl v9.3.7 — https://deck.gl — MIT License (bundle scripting officiel) */
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if (typeof define === 'function' && define.amd) define([], factory);
else if (typeof exports === 'object') exports['deck'] = factory();
else root['deck'] = factory();})(globalThis, function () {
"use strict";var __exports__=(()=>{var c5=Object.create;var Hl=Object.defineProperty;var l5=Object.getOwnPropertyDescriptor;var f5=Object.getOwnPropertyNames;var u5=Object.getPrototypeOf,d5=Object.prototype.hasOwnProperty;var h5=(t,e,r)=>e in t?Hl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var qw=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var L=(t,e)=>()=>(t&&(e=t(t=0)),e);var jl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ze=(t,e)=>{for(var r in e)Hl(t,r,{get:e[r],enumerable:!0})},Zw=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of f5(e))!d5.call(t,n)&&n!==r&&Hl(t,n,{get:()=>e[n],enumerable:!(o=l5(e,n))||o.enumerable});return t};var kn=(t,e,r)=>(r=t!=null?c5(u5(t)):{},Zw(e||!t||!t.__esModule?Hl(r,"default",{value:t,enumerable:!0}):r,t)),p5=t=>Zw(Hl({},"__esModule",{value:!0}),t);var k=(t,e,r)=>(h5(t,typeof e!="symbol"?e+"":e,r),r);var Op,b5,Fp,A5,Qw,_b=L(()=>{Op=globalThis,b5=globalThis.document||{},Fp=globalThis.process||{},A5=globalThis.console,Qw=globalThis.navigator||{}});function Np(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}var yb=L(()=>{});function Ot(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Np()}var xb=L(()=>{yb()});function bb(t){return!t&&!Ot()?"Node":Np(t)?"Electron":(t||Qw.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var eP=L(()=>{xb();yb();_b()});var Ab,Vn=L(()=>{_b();xb();eP();Ab="4.1.1"});function _a(t,e){if(!t)throw new Error(e||"Assertion failed")}var Tb=L(()=>{});function vb(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return _a(Number.isFinite(e)&&e>=0),e}function tP(t){let{logLevel:e,message:r}=t;t.logLevel=vb(e);let o=t.args?Array.from(t.args):[];for(;o.length&&o.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&o.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let n=typeof t.message;return _a(n==="string"||n==="object"),Object.assign(t,{args:o},t.opts)}var rP=L(()=>{Tb()});var Hi,Dp,oP=L(()=>{rP();Hi=()=>{},Dp=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...o){return this._log("log",e,r,o)}info(e,r,...o){return this._log("info",e,r,o)}once(e,r,...o){return this._log("once",e,r,o,{once:!0})}_log(e,r,o,n,i={}){let s=tP({logLevel:r,message:o,args:this._buildArgs(r,o,n),opts:i});return this._createLogFunction(e,s,i)}_buildArgs(e,r,o){return[e,r,...o]}_createLogFunction(e,r,o){if(!this._shouldLog(r.logLevel))return Hi;let n=this._getOnceTag(o.tag??r.tag??r.message);if((o.once||r.once)&&n!==void 0){if(this._onceCache.has(n))return Hi;this._onceCache.add(n)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=vb(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function v5(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Up,nP=L(()=>{Up=class{constructor(e,r,o="sessionStorage"){this.storage=v5(o),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}});function iP(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function sP(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var aP=L(()=>{});function cP(t){return typeof t!="string"?t:(t=t.toUpperCase(),kp[t]||kp.WHITE)}function lP(t,e,r){return!Ot&&typeof t=="string"&&(e&&(t=`\x1B[${cP(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${cP(r)+S5}m${t}\x1B[49m`)),t}var kp,S5,fP=L(()=>{Vn();(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(kp||(kp={}));S5=10});function uP(t,e=["constructor"]){let r=Object.getPrototypeOf(t),o=Object.getOwnPropertyNames(r),n=t;for(let i of o){let s=n[i];typeof s=="function"&&(e.find(a=>i===a)||(n[i]=s.bind(t)))}}var dP=L(()=>{});function ya(){let t;if(Ot()&&Op.performance)t=Op?.performance?.now?.();else if("hrtime"in Fp){let e=Fp?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var hP=L(()=>{Vn()});function C5(t,e,r){if(typeof e=="string"){let o=r.time?sP(iP(r.total)):"";e=r.time?`${t}: ${o} ${e}`:`${t}: ${e}`,e=lP(e,r.color,r.background)}return e}function E5(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var xa,Sb,ct,Cb=L(()=>{Vn();oP();nP();aP();fP();dP();Tb();hP();xa={debug:Ot()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Sb={enabled:!0,level:0},ct=class extends Dp{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Ab,this._startTs=ya(),this._deltaTs=ya(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Up(`__probe-${this.id}__`,{[this.id]:Sb}),this.timeStamp(`${this.id} started`),uP(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((ya()-this._startTs).toPrecision(10))}getDelta(){return Number((ya()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:xa.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:xa.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...o){return this._log("log",e,r,o,{method:xa.log,time:!0,once:!0})}log(e,r,...o){return this._log("log",e,r,o,{method:xa.debug})}info(e,r,...o){return this._log("info",e,r,o,{method:console.info})}once(e,r,...o){return this._log("once",e,r,o,{method:xa.debug||xa.info,once:!0})}table(e,r,o){return r?this._log("table",e,r,o&&[o]||[],{method:console.table||Hi,tag:E5(r)}):Hi}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||Hi})}group(e,r,o={collapsed:!1}){let n=(o.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:n})}groupCollapsed(e,r,o={}){return this.group(e,r,Object.assign({},o,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||Hi})}withGroup(e,r,o){this.group(e,r)();try{o()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let o=r.method;_a(o),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=ya();let n=C5(this.id,r.message,r);return o.bind(console,n,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(Sb),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...Sb};this._storage.setConfiguration({[this.id]:{...r,...e}})}};ct.VERSION=Ab});var pP=L(()=>{globalThis.probe={}});var Eb,zn=L(()=>{Cb();Cb();pP();Eb=new ct({id:"@probe.gl/log"})});function Zl(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Gb=L(()=>{});var $i,$b=L(()=>{Gb();$i=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(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=Zl(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Zl()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}});var Et,MP=L(()=>{$b();Et=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:o}=e,n=this.stats[r];return n||(e instanceof $i?n=e:n=new $i(r,o),this.stats[r]=n),n}}});var Xi=L(()=>{MP();$b();Gb()});function iX(t,e){let r=t.stats,o=!1;for(let c of e)r[c]||(t.get(c),o=!0);let n=Object.keys(r).length,i=s2.get(t);if(!o&&i?.orderedStatNames===e&&i.statCount===n)return;let s={},a=a2.get(e);a||(a=new Set(e),a2.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),s2.set(t,{orderedStatNames:e,statCount:n})}var oX,nX,s2,a2,yT,Sm,xT=L(()=>{Xi();oX="GPU Time and Memory",nX=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],s2=new WeakMap,a2=new WeakMap,yT=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Et({id:e}));let r=this.stats.get(e);return e===oX&&iX(r,nX),r}},Sm=new yT});var P,Er=L(()=>{zn();P=new ct({id:"luma.gl"})});function vo(t="id"){bT[t]=bT[t]||1;let e=bT[t]++;return`${t}-${e}`}var bT,Fa=L(()=>{bT={}});function uX(t,e){let r={...e};for(let o in t)t[o]!==void 0&&(r[o]=t[o]);return r}function h2(t,e){let r=t.stats,o=!1;for(let c of e)r[c]||(t.get(c),o=!0);let n=Object.keys(r).length,i=u2.get(t);if(!o&&i?.orderedStatNames===e&&i.statCount===n)return;let s={},a=d2.get(e);a||(a=new Set(e),d2.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),u2.set(t,{orderedStatNames:e,statCount:n})}function p2(t){return t.type==="webgl"?fX:lX}function Tf(t){let e=t.userData[sX];return e?.enabled?e:null}function ti(){return globalThis.performance?.now?.()??Date.now()}function dX(t,e){let r=Tf(t);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,e){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function hX(t){let e=Object.getPrototypeOf(t);for(;e;){let r=Object.getPrototypeOf(e);if(!r||r===J.prototype)return pX(e)||t[Symbol.toStringTag]||t.constructor.name;e=r}return t[Symbol.toStringTag]||t.constructor.name}function pX(t){let e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(t):typeof e?.value=="string"?e.value:null}var sX,c2,l2,f2,aX,cX,lX,fX,u2,d2,J,xt=L(()=>{Fa();sX="cpu-hotspot-profiler",c2="GPU Resource Counts",l2="Resource Counts",f2="GPU Time and Memory",aX=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],cX=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],lX=aX.flatMap(t=>[`${t} Created`,`${t} Active`]),fX=cX.flatMap(t=>[`${t} Created`,`${t} Active`]),u2=new WeakMap,d2=new WeakMap,J=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,r,o){if(!e)throw new Error("no device");this._device=e,this.props=uX(r,o);let n=this.props.id!=="undefined"?this.props.id:vo(this[Symbol.toStringTag]);this.props.id=n,this.id=n,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Tf(this._device),r=e?ti():0,o=[this._device.statsManager.getStats(c2),this._device.statsManager.getStats(l2)],n=p2(this._device);for(let s of o)h2(s,n);let i=this.getStatsName();for(let s of o)s.get("Resources Active").decrementCount(),s.get(`${i}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(ti()-r))}trackAllocatedMemory(e,r=this.getStatsName()){let o=Tf(this._device),n=o?ti():0,i=this._device.statsManager.getStats(f2);this.allocatedBytes>0&&this.allocatedBytesName&&(i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),i.get("GPU Memory").addCount(e),i.get(`${r} Memory`).addCount(e),o&&(o.statsBookkeepingCalls=(o.statsBookkeepingCalls||0)+1,o.statsBookkeepingTimeMs=(o.statsBookkeepingTimeMs||0)+(ti()-n)),this.allocatedBytes=e,this.allocatedBytesName=r}trackReferencedMemory(e,r=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${r}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=Tf(this._device),o=r?ti():0,n=this._device.statsManager.getStats(f2);n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(ti()-o)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),r=Tf(this._device),o=r?ti():0,n=[this._device.statsManager.getStats(c2),this._device.statsManager.getStats(l2)],i=p2(this._device);for(let s of n)h2(s,i);for(let s of n)s.get("Resources Created").incrementCount(),s.get("Resources Active").incrementCount(),s.get(`${e}s Created`).incrementCount(),s.get(`${e}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(ti()-o)),dX(this._device,e)}getStatsName(){return hX(this)}};k(J,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var vf,K,Cm=L(()=>{xt();vf=class extends J{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let o={...r};(r.usage||0)&vf.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?o.indexType="uint32":r.data instanceof Uint16Array?o.indexType="uint16":r.data instanceof Uint8Array&&(o.indexType="uint8")),delete o.data,super(e,o,vf.defaultProps),this.usage=o.usage||0,this.indexType=o.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,r,o){let n=null,i;ArrayBuffer.isView(e)?(n=e,i=e.buffer):i=e;let s=Math.min(e?e.byteLength:o,vf.DEBUG_DATA_MAX_LENGTH);if(i===null)this.debugData=new ArrayBuffer(s);else{let a=Math.min(n?.byteOffset||0,i.byteLength),c=Math.max(0,i.byteLength-a),l=Math.min(s,c);this.debugData=new Uint8Array(i,a,l).slice().buffer}}},K=vf;k(K,"INDEX",16),k(K,"VERTEX",32),k(K,"UNIFORM",64),k(K,"STORAGE",128),k(K,"INDIRECT",256),k(K,"QUERY_RESOLVE",512),k(K,"MAP_READ",1),k(K,"MAP_WRITE",2),k(K,"COPY_SRC",4),k(K,"COPY_DST",8),k(K,"DEBUG_DATA_MAX_LENGTH",32),k(K,"defaultProps",{...J.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});var TT,Dt,AT,Em=L(()=>{TT=class{getDataTypeInfo(e){let[r,o,n]=AT[e],i=e.includes("norm"),s=!i&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:r,primitiveType:o,byteLength:n,normalized:i,integer:s,signed:a}}getNormalizedDataType(e){let r=e;switch(r){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return r}}alignTo(e,r){switch(r){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let r=ArrayBuffer.isView(e)?e.constructor:e;if(r===Uint8ClampedArray)return"uint8";let o=Object.values(AT).find(n=>r===n[4]);if(!o)throw new Error(r.name);return o[0]}getTypedArrayConstructor(e){let[,,,,r]=AT[e];return r}},Dt=new TT,AT={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var vT,tn,wm=L(()=>{Em();vT=class{getVertexFormatInfo(e){let r;e.endsWith("-webgl")&&(e.replace("-webgl",""),r=!0);let[o,n]=e.split("x"),i=o,s=n?parseInt(n):1,a=Dt.getDataTypeInfo(i),c={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return r&&(c.webglOnly=!0),c}makeVertexFormat(e,r,o){let n=o?Dt.getNormalizedDataType(e):e;switch(n){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${n}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${n}x${r}`;case"uint8":case"sint8":if(r===1||r===3)throw new Error(`size: ${r}`);return`${n}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${n}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${n}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${n}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${n}x${r}`;case"float16":if(r===1||r===3)throw new Error(`size: ${r}`);return`${n}x${r}`;default:return r===1?n:`${n}x${r}`}}getVertexFormatFromAttribute(e,r,o){if(!r||r>4)throw new Error(`size ${r}`);let n=r,i=Dt.getDataType(e);return this.makeVertexFormat(i,n,o)}getCompatibleVertexFormat(e){let r;switch(e.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?r:`${r}x${e.components}`}},tn=new vT});function MT(t){let e=_2[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function g2(){return _2}var wt,we,So,mX,Pm,ST,Mm,CT,gX,ET,ri,wT,PT,Rm,m2,_X,yX,_2,RT=L(()=>{wt="texture-compression-bc",we="texture-compression-astc",So="texture-compression-etc2",mX="texture-compression-etc1-webgl",Pm="texture-compression-pvrtc-webgl",ST="texture-compression-atc-webgl",Mm="float32-renderable-webgl",CT="float16-renderable-webgl",gX="rgb9e5ufloat-renderable-webgl",ET="snorm8-renderable-webgl",ri="norm16-webgl",wT="norm16-renderable-webgl",PT="snorm16-renderable-webgl",Rm="float32-filterable",m2="float16-filterable-webgl";_X={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:ET},rg8snorm:{render:ET},"rgb8snorm-webgl":{},rgba8snorm:{render:ET},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:ri,render:wT},rg16unorm:{f:ri,render:wT},"rgb16unorm-webgl":{f:ri,render:!1},rgba16unorm:{f:ri,render:wT},r16snorm:{f:ri,render:PT},rg16snorm:{f:ri,render:PT},"rgb16snorm-webgl":{f:ri,render:!1},rgba16snorm:{f:ri,render:PT},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:CT,filter:"float16-filterable-webgl"},rg16float:{render:CT,filter:m2},rgba16float:{render:CT,filter:m2},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Mm,filter:Rm},rg32float:{render:!1,filter:Rm},"rgb32float-webgl":{render:Mm,filter:Rm},rgba32float:{render:Mm,filter:Rm},"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:gX},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Mm},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},yX={"bc1-rgb-unorm-webgl":{f:wt},"bc1-rgb-unorm-srgb-webgl":{f:wt},"bc1-rgba-unorm":{f:wt},"bc1-rgba-unorm-srgb":{f:wt},"bc2-rgba-unorm":{f:wt},"bc2-rgba-unorm-srgb":{f:wt},"bc3-rgba-unorm":{f:wt},"bc3-rgba-unorm-srgb":{f:wt},"bc4-r-unorm":{f:wt},"bc4-r-snorm":{f:wt},"bc5-rg-unorm":{f:wt},"bc5-rg-snorm":{f:wt},"bc6h-rgb-ufloat":{f:wt},"bc6h-rgb-float":{f:wt},"bc7-rgba-unorm":{f:wt},"bc7-rgba-unorm-srgb":{f:wt},"etc2-rgb8unorm":{f:So},"etc2-rgb8unorm-srgb":{f:So},"etc2-rgb8a1unorm":{f:So},"etc2-rgb8a1unorm-srgb":{f:So},"etc2-rgba8unorm":{f:So},"etc2-rgba8unorm-srgb":{f:So},"eac-r11unorm":{f:So},"eac-r11snorm":{f:So},"eac-rg11unorm":{f:So},"eac-rg11snorm":{f:So},"astc-4x4-unorm":{f:we},"astc-4x4-unorm-srgb":{f:we},"astc-5x4-unorm":{f:we},"astc-5x4-unorm-srgb":{f:we},"astc-5x5-unorm":{f:we},"astc-5x5-unorm-srgb":{f:we},"astc-6x5-unorm":{f:we},"astc-6x5-unorm-srgb":{f:we},"astc-6x6-unorm":{f:we},"astc-6x6-unorm-srgb":{f:we},"astc-8x5-unorm":{f:we},"astc-8x5-unorm-srgb":{f:we},"astc-8x6-unorm":{f:we},"astc-8x6-unorm-srgb":{f:we},"astc-8x8-unorm":{f:we},"astc-8x8-unorm-srgb":{f:we},"astc-10x5-unorm":{f:we},"astc-10x5-unorm-srgb":{f:we},"astc-10x6-unorm":{f:we},"astc-10x6-unorm-srgb":{f:we},"astc-10x8-unorm":{f:we},"astc-10x8-unorm-srgb":{f:we},"astc-10x10-unorm":{f:we},"astc-10x10-unorm-srgb":{f:we},"astc-12x10-unorm":{f:we},"astc-12x10-unorm-srgb":{f:we},"astc-12x12-unorm":{f:we},"astc-12x12-unorm-srgb":{f:we},"pvrtc-rgb4unorm-webgl":{f:Pm},"pvrtc-rgba4unorm-webgl":{f:Pm},"pvrtc-rgb2unorm-webgl":{f:Pm},"pvrtc-rgba2unorm-webgl":{f:Pm},"etc1-rbg-unorm-webgl":{f:mX},"atc-rgb-unorm-webgl":{f:ST},"atc-rgba-unorm-webgl":{f:ST},"atc-rgbai-unorm-webgl":{f:ST}},_2={..._X,...yX}});function vX({format:t,width:e,height:r,depth:o,byteAlignment:n}){let i=bt.getInfo(t),{bytesPerPixel:s,bytesPerBlock:a=s,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=i,u=f?Math.ceil(e/c):e,d=f?Math.ceil(r/l):r,h=u*a,p=Math.ceil(h/n)*n,m=d,g=p*m*o;return{bytesPerPixel:s,bytesPerRow:p,rowsPerImage:m,depthOrArrayLayers:o,bytesPerImage:p*m,byteLength:g}}function SX(t){let e=MT(t),r={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},o=y2(t),n=t.startsWith("depth")||t.startsWith("stencil"),i=o?.signed,s=o?.integer,a=o?.webgl,c=Boolean(o?.compressed);return r.render&&=!n&&!c,r.filter&&=!n&&!i&&!s&&!a,r}function y2(t){let e=CX(t);if(bt.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=wX(t);let o=EX(t);o&&(e.blockWidth=o.blockWidth,e.blockHeight=o.blockHeight)}let r=e.packed?null:xX.exec(t);if(r){let[,o,n,i,s,a]=r,c=`${i}${n}`,l=Dt.getDataTypeInfo(c),f=l.byteLength*8,u=o?.length??1,d=[f,u>=2?f:0,u>=3?f:0,u>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:u,channels:o,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:d,bytesPerPixel:l.byteLength*u,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),s==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function CX(t){let e=MT(t),r=e.bytesPerPixel||1,o=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:r,bitsPerChannel:o,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function EX(t){let r=/.*-(\d+)x(\d+)-.*/.exec(t);if(r){let[,o,n]=r;return{blockWidth:Number(o),blockHeight:Number(n)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function wX(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}var xX,bX,AX,TX,IT,bt,Im=L(()=>{Em();RT();xX=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,bX=["rgb","rgba","bgra"],AX=["depth","stencil"],TX=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],IT=class{isColor(e){return bX.some(r=>e.startsWith(r))}isDepthStencil(e){return AX.some(r=>e.startsWith(r))}isCompressed(e){return TX.some(r=>e.startsWith(r))}getInfo(e){return y2(e)}getCapabilities(e){return SX(e)}computeMemoryLayout(e){return vX(e)}},bt=new IT});function Na(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function Sf(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWidth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}var LT=L(()=>{});function PX(t,e){let r=BT(t),o=e.map(BT).filter(n=>n!==void 0);return[r,...o].filter(n=>n!==void 0)}function BT(t){if(t!==void 0){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(t instanceof Error)return t.message;if(Array.isArray(t))return t.map(BT);if(typeof t=="object"){if(MX(t)){let e=String(t);if(e!=="[object Object]")return e}return RX(t)?IX(t):t.constructor?.name||"Object"}return String(t)}}function MX(t){return"toString"in t&&typeof t.toString=="function"&&t.toString!==Object.prototype.toString}function RX(t){return"message"in t&&"type"in t}function IX(t){let e=typeof t.type=="string"?t.type:"message",r=typeof t.message=="string"?t.message:"",o=typeof t.lineNum=="number"?t.lineNum:null,n=typeof t.linePos=="number"?t.linePos:null,i=o!==null&&n!==null?` @ ${o}:${n}`:o!==null?` @ ${o}`:"";return`${e}${i}: ${r}`.trim()}function LX(t,e){return t!=null?Boolean(t):e!==void 0?e!=="production":!1}function BX(){return LX(P.get("debug"),OX())}function OX(){let t=globalThis.process;if(t?.env)return t.env.NODE_ENV}var Cf,Ef,OT,Xt,FT=L(()=>{xT();Er();Fa();Cm();wm();Im();LT();RT();Cf=class{};Ef=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},OT=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=Sm;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...OT.defaultProps,...e},this.id=this.props.id||vo(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return tn.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return bt.getInfo(e)}getTextureFormatCapabilities(e){let r=this._textureCaps[e];if(!r){let o=this._getDeviceTextureFormatCapabilities(e);r=this._getDeviceSpecificTextureFormatCapabilities(o),this._textureCaps[e]=r}return r}getMipLevelCount(e,r,o=1){let n=Math.max(e,r,o);return 1+Math.floor(Math.log2(n))}isExternalImage(e){return Na(e)}getExternalImageSize(e){return Sf(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 bt.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let r of Object.keys(g2()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&e.push(r);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,r,...o){if(!this.props.onError(e,r)){let i=PX(r,o);return P.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...i)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
or create a device with the 'debug: true' prop.`;P.once(0,e)()}}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)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,r,o,n,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 this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){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 e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let r=bt.getCapabilities(e),o=i=>(typeof i=="string"?this.features.has(i):i)??!0,n=o(r.create);return{format:e,create:n,render:n&&o(r.render),filter:n&&o(r.filter),blend:n&&o(r.blend),store:n&&o(r.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};if((e.usage||0)&K.INDEX&&(e.indexType||(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":e.data instanceof Uint8Array&&(r.data=new Uint16Array(e.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}},Xt=OT;k(Xt,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,r)=>{},onResize:(e,r)=>{let[o,n]=e.getDevicePixelSize();P.log(1,`${e} resized => ${o}x${n}px`)()},onPositionChange:(e,r)=>{let[o,n]=e.getPosition();P.log(1,`${e} repositioned => ${o},${n}`)()},onVisibilityChange:e=>P.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,r)=>P.log(1,`${e} DPR changed ${r.oldRatio} => ${e.devicePixelRatio}`)(),debug:BX(),debugGPUTime:!1,debugShaders:P.get("debug-shaders")||void 0,debugFramebuffers:Boolean(P.get("debug-framebuffers")),debugFactories:Boolean(P.get("debug-factories")),debugWebGL:Boolean(P.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var FX,x2,Bm,Lm,Co,b2=L(()=>{FT();xT();Er();FX="set luma.log.level=1 (or higher) to trace rendering",x2="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Bm=class{stats=Sm;log=P;VERSION="9.3.3";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw P.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),P.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");P.error("This version of luma.gl has already been initialized")()}P.log(1,`${this.VERSION} - ${FX}`)(),globalThis.luma=this}async createDevice(e={}){let r={...Bm.defaultProps,...e},o=this.selectAdapter(r.type,r.adapters);if(!o)throw new Error(x2);return r.waitForPageLoad&&await o.pageLoaded,await o.create(r)}async attachDevice(e,r){let o=this._getTypeFromHandle(e,r.adapters),n=o&&this.selectAdapter(o,r.adapters);if(!n)throw new Error(x2);return await n?.attach?.(e,r)}registerAdapters(e){for(let r of e)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(e=[]){let r=this._getAdapterMap(e);return Array.from(r).map(([,o])=>o).filter(o=>o.isSupported?.()).map(o=>o.type)}getBestAvailableAdapterType(e=[]){let r=["webgpu","webgl","null"],o=this._getAdapterMap(e);for(let n of r)if(o.get(n)?.isSupported?.())return n;return null}selectAdapter(e,r=[]){let o=e;e==="best-available"&&(o=this.getBestAvailableAdapterType(r));let n=this._getAdapterMap(r);return o&&n.get(o)||null}enforceWebGL2(e=!0,r=[]){let n=this._getAdapterMap(r).get("webgl");n||P.warn("enforceWebGL2: webgl adapter not found")(),n?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Bm.defaultProps,e)}_getAdapterMap(e=[]){let r=new Map(this.preregisteredAdapters);for(let o of e)r.set(o.type,o);return r}_getTypeFromHandle(e,r=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?P.warn("WebGL1 is not supported",e)():P.warn("Unknown handle type",e)(),null)}},Lm=Bm;k(Lm,"defaultProps",{...Xt.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});Co=new Lm});function UX(){return Om||(DX()||typeof window>"u"?Om=Promise.resolve():Om=new Promise(t=>window.addEventListener("load",()=>t()))),Om}var wf,NX,DX,Om,A2=L(()=>{Vn();wf=class{get pageLoaded(){return UX()}},NX=Ot()&&typeof document<"u",DX=()=>NX&&document.readyState==="complete",Om=null});var Fm,T2=L(()=>{Fm=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function v2(){let t,e;return{promise:new Promise((o,n)=>{t=o,e=n}),resolve:t,reject:e}}var S2=L(()=>{});function NT(t,e){if(!t){let r=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,NT),r}}function os(t,e){return NT(t,e),t}var DT=L(()=>{});function kX(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function VX(t){let e=document.getElementById(t);if(!rn.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function zX(t){let{width:e,height:r}=t,o=document.createElement("canvas");o.id=vo("lumagl-auto-created-canvas"),o.width=e||1,o.height=r||1,o.style.width=Number.isFinite(e)?`${e}px`:"100%",o.style.height=Number.isFinite(r)?`${r}px`:"100%",t?.visible||(o.style.visibility="hidden");let n=kX(t?.container||null);return n.insertBefore(o,n.firstChild),o}function HX(t,e,r,o,n){let i=t,s=C2(i[0],e,r),a=E2(i[1],e,o,n),c=C2(i[0]+1,e,r),l=c===r-1?c:c-1;c=E2(i[1]+1,e,o,n);let f;return n?(c=c===0?c:c+1,f=a,a=c):f=c===o-1?c:c-1,{x:s,y:a,width:Math.max(l-s+1,1),height:Math.max(f-a+1,1)}}function C2(t,e,r){return Math.min(Math.round(t*e),r-1)}function E2(t,e,r,o){return o?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var Pf,rn,UT=L(()=>{Vn();T2();Fa();S2();DT();Pf=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=v2();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...Pf.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Ot()?e.canvas?typeof e.canvas=="string"?this.canvas=VX(e.canvas):this.canvas=e.canvas:this.canvas=zX(e):this.canvas={width:e.width||1,height:e.height||1},Pf.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Pf.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Fm({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,r){e=Math.floor(e),r=Math.floor(r),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,r=!0){let o=this.cssToDeviceRatio(),[n,i]=this.getDrawingBufferSize();return HX(e,o,n,i,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,r]=this.getDrawingBufferSize();return e>0&&r>0?e/r:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?e/r:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let r=e.find(n=>n.target===this.canvas);if(!r)return;let o=r.isIntersecting;this.isVisible!==o&&(this.isVisible=o,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let r=e.find(l=>l.target===this.canvas);if(!r)return;let o=os(r.contentBoxSize?.[0]);this.cssWidth=o.inlineSize,this.cssHeight=o.blockSize;let n=this.getDevicePixelSize(),i=r.devicePixelContentBoxSize?.[0]?.inlineSize||o.inlineSize*devicePixelRatio,s=r.devicePixelContentBoxSize?.[0]?.blockSize||o.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(i,a)),this.devicePixelHeight=Math.max(1,Math.min(s,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:n})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let r=[e.left,e.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let n=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:n})}}}},rn=Pf;k(rn,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1})});var Da,w2=L(()=>{UT();Da=class extends rn{};k(Da,"defaultProps",rn.defaultProps)});var Mf,P2=L(()=>{UT();Mf=class extends rn{}});var Nm,Pt,kT=L(()=>{xt();Nm=class extends J{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=Nm.normalizeProps(e,r),super(e,r,Nm.defaultProps)}static normalizeProps(e,r){return r}},Pt=Nm;k(Pt,"defaultProps",{...J.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})});var jX,lr,Y,VT=L(()=>{xt();kT();Er();Im();jX={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},lr=class extends J{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(e,r,o){if(r=lr.normalizeProps(e,r),super(e,r,lr.defaultProps),this.dimension=this.props.dimension,this.baseDimension=jX[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,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(r.data)){let n=e.getExternalImageSize(r.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&P.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=o?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Pt?e:this.device.createSampler(e)}copyImageData(e){let{data:r,depth:o,...n}=e;this.writeData(r,{...n,depthOrArrayLayers:n.depthOrArrayLayers??o})}computeMemoryLayout(e={}){let r=this._normalizeTextureReadOptions(e),{width:o=this.width,height:n=this.height,depthOrArrayLayers:i=this.depth}=r,{format:s,byteAlignment:a}=this;return bt.computeMemoryLayout({format:s,width:o,height:n,depth:i,byteAlignment:a})}readBuffer(e,r){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,r){throw new Error("readBuffer not implemented")}writeData(e,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,r){let o={...r},{width:n,height:i}=o;return typeof n=="number"&&(o.width=Math.max(1,Math.ceil(n))),typeof i=="number"&&(o.height=Math.max(1,Math.ceil(i))),o}_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){let{data:r,depth:o,...n}=e,i=this._normalizeTextureWriteOptions({...n,depthOrArrayLayers:n.depthOrArrayLayers??o});return{data:r,depth:i.depthOrArrayLayers,...i}}_normalizeCopyExternalImageOptions(e){let r=lr._omitUndefined(e),o=r.mipLevel??0,n=this._getMipLevelSize(o),i=this.device.getExternalImageSize(e.image),s={...lr.defaultCopyExternalImageOptions,...n,...i,...r};return s.width=Math.min(s.width,n.width-s.x),s.height=Math.min(s.height,n.height-s.y),s.depth=Math.min(s.depth,n.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let r=lr._omitUndefined(e),o=r.mipLevel??0,n=this._getMipLevelSize(o),i={...lr.defaultTextureReadOptions,...n,...r};return i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,n.depthOrArrayLayers-i.z),i}_getSupportedColorReadOptions(e){let r=this._normalizeTextureReadOptions(e),o=bt.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(o),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")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(e){let r=lr._omitUndefined(e),o=r.mipLevel??0,n=this._getMipLevelSize(o),i={...lr.defaultTextureWriteOptions,...n,...r};i.width=Math.min(i.width,n.width-i.x),i.height=Math.min(i.height,n.height-i.y),i.depthOrArrayLayers=Math.min(i.depthOrArrayLayers,n.depthOrArrayLayers-i.z);let s=bt.computeMemoryLayout({format:this.format,width:i.width,height:i.height,depth:i.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*i.width;if(i.bytesPerRow=r.bytesPerRow??s.bytesPerRow,i.rowsPerImage=r.rowsPerImage??i.height,i.bytesPerRow<a)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be at least ${a} for ${this.format}`);if(i.rowsPerImage<i.height)throw new Error(`rowsPerImage (${i.rowsPerImage}) must be at least ${i.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&i.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${i.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return i}_getMipLevelSize(e){let r=Math.max(1,this.width>>e),o=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),n=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:r,height:o,depthOrArrayLayers:n}}getAllocatedByteLength(){let e=0;for(let r=0;r<this.mipLevels;r++){let{width:o,height:n,depthOrArrayLayers:i}=this._getMipLevelSize(r);e+=bt.computeMemoryLayout({format:this.format,width:o,height:n,depth:i,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}},Y=lr;k(Y,"SAMPLE",4),k(Y,"STORAGE",8),k(Y,"RENDER",16),k(Y,"COPY_SRC",1),k(Y,"COPY_DST",2),k(Y,"TEXTURE",4),k(Y,"RENDER_ATTACHMENT",16),k(Y,"defaultProps",{...J.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:lr.SAMPLE|lr.RENDER|lr.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),k(Y,"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"}),k(Y,"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}),k(Y,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),k(Y,"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"})});var zT,wr,M2=L(()=>{xt();zT=class extends J{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,zT.defaultProps)}},wr=zT;k(wr,"defaultProps",{...J.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function R2(t,e,r){let o="",n=e.split(/\r?\n/),i=t.slice().sort((s,a)=>s.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let s=0;for(let a=1;a<=n.length;a++){let c=n[a-1],l=i[s];for(c&&l&&(o+=I2(c,a,r));i.length>s&&l.lineNum===a;){let f=i[s++];f&&(o+=HT(f,n,f.lineNum,{...r,inlineSource:!1}))}}for(;i.length>s;){let a=i[s++];a&&(o+=HT(a,[],0,{...r,inlineSource:!1}))}return o;case"issues":case"no":for(let a of t)o+=HT(a,n,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return o}}function HT(t,e,r,o){if(o?.inlineSource){let i=WX(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
`:"";return`
${i}${s}${t.type.toUpperCase()}: ${t.message}
`}let n=t.type==="error"?"red":"orange";return o?.html?`<div class='luma-compiler-log-${t.type}' style="color:${n};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function WX(t,e,r){let o="";for(let n=e-2;n<=e;n++){let i=t[n-1];i!==void 0&&(o+=I2(i,e,r))}return o}function I2(t,e,r){let o=r?.html?$X(t):t;return`${GX(String(e),4)}: ${o}${r?.html?"<br/>":`
`}`}function GX(t,e){let r="";for(let o=t.length;o<e;++o)r+=" ";return r+t}function $X(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var L2=L(()=>{});function XX(t){return YX(t.source)||t.id||vo(`unnamed ${t.stage}-shader`)}function YX(t,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t)?.[1]??e}var jT,oi,WT=L(()=>{xt();Fa();L2();jT=class extends J{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){r={...r,debugShaders:r.debugShaders||e.props.debugShaders||"errors"},super(e,{id:XX(r),...r},jT.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();e==="warnings"&&r?.length===0||this._displayShaderLog(r,this.id)}_displayShaderLog(e,r){if(typeof document>"u"||!document?.createElement)return;let o=r,n=`${this.stage} shader "${o}"`,i=R2(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`<h1>Compilation error in ${n}</h1>
<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">
<button id="copy">Copy source</button><br/>
<button id="close">Close</button>
</div>
<code><pre>${i}</pre></code>`,s&&(a.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${s}</pre></code>`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}},oi=jT;k(oi,"defaultProps",{...J.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var GT,Eo,B2=L(()=>{xt();VT();Er();GT=class extends J{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,GT.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(n=>n.texture.clone(e)),o=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:r,depthStencilAttachment:o})}resize(e){let r=!e;if(e){let[o,n]=Array.isArray(e)?e:[e.width,e.height];r=r||n!==this.height||o!==this.width,this.width=o,this.height=n}r&&(P.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((r,o)=>{if(typeof r=="string"){let n=this.createColorTexture(r,o);return this.attachResource(n),n.view}return r instanceof Y?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof Y?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:Y.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Y.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){if(this.colorAttachments.forEach((o,n)=>{let i=o.texture.clone({width:e,height:r});this.destroyAttachedResource(o),this.colorAttachments[n]=i.view,this.attachResource(i.view)}),this.depthStencilAttachment){let o=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=o.view,this.attachResource(o)}this.updateAttachments()}},Eo=GT;k(Eo,"defaultProps",{...J.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var $T,fr,XT=L(()=>{xt();$T=class extends J{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,r){super(e,r,$T.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}},fr=$T;k(fr,"defaultProps",{...J.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0})});var Rf,O2=L(()=>{xt();Rf=class extends J{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,r){super(e,r,{...J.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var YT,Ua,F2=L(()=>{xt();YT=class extends J{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,YT.defaultProps),this.shaderLayout=r.shaderLayout}},Ua=YT;k(Ua,"defaultProps",{...J.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var KT,ka,N2=L(()=>{F2();XT();Er();Fa();KT=class{static getDefaultPipelineFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new KT(e),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let r={...fr.defaultProps,...e},o=this._renderPipelineCache,n=this._hashRenderPipeline(r),i=o[n]?.resource;if(i)o[n].useCount++,this.device.props.debugFactories&&P.log(3,`${this}: ${o[n].resource} reused, count=${o[n].useCount}, (id=${e.id})`)();else{let s=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;i=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:vo("unnamed-cached"),_sharedRenderPipeline:s}),i.hash=n,o[n]={resource:i,useCount:1},this.device.props.debugFactories&&P.log(3,`${this}: ${i} created, count=${o[n].useCount}`)()}return i}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let r={...Ua.defaultProps,...e},o=this._computePipelineCache,n=this._hashComputePipeline(r),i=o[n]?.resource;return i?(o[n].useCount++,this.device.props.debugFactories&&P.log(3,`${this}: ${o[n].resource} reused, count=${o[n].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),i.hash=n,o[n]={resource:i,useCount:1},this.device.props.debugFactories&&P.log(3,`${this}: ${i} created, count=${o[n].useCount}`)()),i}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let r=this._getCache(e),o=e.hash;r[o].useCount--,r[o].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&P.log(3,`${this}: ${e} released and destroyed`)()):r[o].useCount<0?(P.error(`${this}: ${e} released, useCount < 0, resetting`)(),r[o].useCount=0):this.device.props.debugFactories&&P.log(3,`${this}: ${e} released, count=${r[o].useCount}`)()}createSharedRenderPipeline(e){let r=this._hashSharedRenderPipeline(e),o=this._sharedRenderPipelineCache[r];return o||(o={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[r]=o),o.useCount++,o.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),o=this._sharedRenderPipelineCache[r];o&&(o.useCount--,o.useCount===0&&(o.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(e){let r=this._getCache(e);return this.device.props._destroyPipelines?(delete r[e.hash],e.destroy(),e instanceof fr&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let r;if(e instanceof Ua&&(r=this._computePipelineCache),e instanceof fr&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return r}_hashComputePipeline(e){let{type:r}=this.device,o=this._getHash(e.shader.source),n=this._getHash(JSON.stringify(e.shaderLayout));return`${r}/C/${o}SL${n}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,o=e.fs?this._getHash(e.fs.source):0,n=this._getWebGLVaryingHash(e),i=this._getHash(JSON.stringify(e.shaderLayout)),s=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":let c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${r}/${o}V${n}T${e.topology}P${c}SL${i}BL${s}`;case"webgpu":default:let l=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),u=this._getWebGPUAttachmentHash(e);return`${a}/R/${r}/${o}V${n}T${e.topology}EP${l}P${f}SL${i}BL${s}A${u}`}}_hashSharedRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,o=e.fs?this._getHash(e.fs.source):0,n=this._getWebGLVaryingHash(e);return`webgl/S/${r}/${o}V${n}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:r=[],bufferMode:o=null}=e;return this._getHash(JSON.stringify({varyings:r,bufferMode:o}))}_getWebGPUAttachmentHash(e){let r=e.colorAttachmentFormats??[this.device.preferredColorFormat],o=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:o}))}},ka=KT;k(ka,"defaultProps",{...fr.defaultProps})});var qT,Va,D2=L(()=>{WT();Er();qT=class{static getDefaultShaderFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new qT(e),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let r=this._hashShader(e),o=this._cache[r];if(o)o.useCount++,this.device.props.debugFactories&&P.log(3,`${this}: Reusing shader ${o.resource.id} count=${o.useCount}`)();else{let n=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=o={resource:n,useCount:1},this.device.props.debugFactories&&P.log(3,`${this}: Created new shader ${n.id}`)()}return o.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let r=this._hashShader(e),o=this._cache[r];if(o)if(o.useCount--,o.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],o.resource.destroy(),this.device.props.debugFactories&&P.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(o.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&P.log(3,`${this}: Releasing shader ${e.id} count=${o.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},Va=qT;k(Va,"defaultProps",{...oi.defaultProps})});function U2(t,e,r){let o=t.bindings.find(n=>n.name===e||`${n.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!o&&!r?.ignoreWarnings&&P.warn(`Binding ${e} not set: Not found in shader layout.`)(),o||null}function If(t,e){if(!e)return{};if(KX(e))return Object.fromEntries(Object.entries(e).map(([n,i])=>[Number(n),{...i}]));let r={};for(let[o,n]of Object.entries(e)){let s=U2(t,o)?.group??0;r[s]||={},r[s][o]=n}return r}function Dm(t){let e={};for(let r of Object.values(t))Object.assign(e,r);return e}function KX(t){let e=Object.keys(t);return e.length>0&&e.every(r=>/^\d+$/.test(r))}var k2=L(()=>{Er()});var ns,on,V2=L(()=>{xt();ns=class extends J{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=ns.normalizeProps(e,r),super(e,r,ns.defaultProps)}static normalizeProps(e,r){return r}},on=ns;k(on,"defaultClearColor",[0,0,0,1]),k(on,"defaultClearDepth",1),k(on,"defaultClearStencil",0),k(on,"defaultProps",{...J.defaultProps,framebuffer:null,parameters:void 0,clearColor:ns.defaultClearColor,clearColors:void 0,clearDepth:ns.defaultClearDepth,clearStencil:ns.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var ZT,za,z2=L(()=>{xt();ZT=class extends J{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,r){super(e,r,ZT.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let r=e*2,o=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),n=0n;for(let i=0;i<r;i+=2)n+=o[i+1]-o[i];this._gpuTimeMs=Number(n)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let r=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||r.timestampQuerySet!==void 0||r.beginTimestampIndex!==void 0||r.endTimestampIndex!==void 0)return r;let o=this._timeProfilingSlotCount;return o+1>=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:o,endTimestampIndex:o+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}},za=ZT;k(za,"defaultProps",{...J.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0})});var JT,Ha,H2=L(()=>{xt();JT=class extends J{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,JT.defaultProps)}},Ha=JT;k(Ha,"defaultProps",{...J.defaultProps})});function ja(t){let e=Um(t),r=QX[e];if(!r)throw new Error(`Unsupported variable shader type: ${t}`);return r}function j2(t){let e=W2(t),r=JX[e];if(!r)throw new Error(`Unsupported attribute shader type: ${t}`);let[o,n]=r,i=o==="i32"||o==="u32",s=o!=="u32",a=ZX[o]*n;return{primitiveType:o,components:n,byteLength:a,integer:i,signed:s}}function qX(t,e){return e===1?t:`vec${e}<${t}>`}function W2(t){return e7[t]||t}function Um(t){return t7[t]||t}var QT,ev,ZX,JX,QX,e7,t7,km=L(()=>{QT=class{getVariableShaderTypeInfo(e){return ja(e)}getAttributeShaderTypeInfo(e){return j2(e)}makeShaderAttributeType(e,r){return qX(e,r)}resolveAttributeShaderTypeAlias(e){return W2(e)}resolveVariableShaderTypeAlias(e){return Um(e)}};ev=new QT,ZX={f32:4,f16:2,i32:4,u32:4},JX={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},QX={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},e7={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},t7={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"}});function Vm(t,e){let r={};for(let o of t.attributes){let n=r7(t,e,o.name);n&&(r[o.name]=n)}return r}function G2(t,e,r=16){let o=Vm(t,e),n=new Array(r).fill(null);for(let i of Object.values(o))n[i.location]=i;return n}function r7(t,e,r){let o=o7(t,r),n=n7(e,r);if(!o)return null;let i=ev.getAttributeShaderTypeInfo(o.type),s=tn.getCompatibleVertexFormat(i),a=n?.vertexFormat||s,c=tn.getVertexFormatInfo(a);return{attributeName:n?.attributeName||o.name,bufferName:n?.bufferName||o.name,location:o.location,shaderType:o.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:i.integer,stepMode:n?.stepMode||o.stepMode||"vertex",byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function o7(t,e){let r=t.attributes.find(o=>o.name===e);return r||P.warn(`shader layout attribute "${e}" not present in shader`),r||null}function n7(t,e){i7(t);let r=s7(t,e);return r||(r=a7(t,e),r)?r:(P.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function i7(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&P.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function s7(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function a7(t,e){for(let r of t){let o=r.byteStride;if(typeof r.byteStride!="number")for(let i of r.attributes||[]){let s=tn.getVertexFormatInfo(i.format);o+=s.byteLength}let n=r.attributes?.find(i=>i.attribute===e);if(n)return{attributeName:n.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:o}}return null}var tv=L(()=>{Er();km();wm()});var rv,Wa,$2=L(()=>{tv();xt();rv=class extends J{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,rv.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=G2(r.shaderLayout,r.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"),this)()}},Wa=rv;k(Wa,"defaultProps",{...J.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var ov,Ga,X2=L(()=>{xt();ov=class extends J{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,ov.defaultProps)}},Ga=ov;k(Ga,"defaultProps",{...J.defaultProps,layout:void 0,buffers:{}})});var nv,$a,Y2=L(()=>{xt();nv=class extends J{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,nv.defaultProps)}},$a=nv;k($a,"defaultProps",{...J.defaultProps,type:void 0,count:void 0})});var iv,Xa,K2=L(()=>{xt();iv=class extends J{get[Symbol.toStringTag](){return"Fence"}constructor(e,r={}){super(e,r,iv.defaultProps)}},Xa=iv;k(Xa,"defaultProps",{...J.defaultProps})});function wo(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function Lf(t){let[,,,,e]=c7[t];return e}var c7,sv=L(()=>{c7={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});function Z2(t,e={}){let r={...t},o=e.layout??"std140",n={},i=0;for(let[s,a]of Object.entries(r))i=av(n,s,a,i,o);return i=wo(i,ni(r,o)),{layout:o,byteLength:i*4,uniformTypes:r,fields:n}}function Bf(t,e){let r=Um(t),o=ja(r),n=/^mat(\d)x(\d)<.+>$/.exec(r);if(n){let s=Number(n[1]),a=Number(n[2]),c=q2(a,r,o.type,e),l=f7(c.size,c.alignment,e);return{alignment:c.alignment,size:s*l,components:s*a,columns:s,rows:a,columnStride:l,shaderType:r,type:o.type}}let i=/^vec(\d)<.+>$/.exec(r);return i?q2(Number(i[1]),r,o.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:o.type}}function cv(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)}function av(t,e,r,o,n){if(typeof r=="string"){let i=Bf(r,n),s=wo(o,i.alignment);return t[e]={offset:s,...i},s+i.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${e}`);let i=r[0],s=r[1],a=Q2(i,n),c=wo(o,ni(r,n));for(let l=0;l<s;l++)av(t,`${e}[${l}]`,i,c+l*a,n);return c+a*s}if(cv(r)){let i=ni(r,n),s=wo(o,i);for(let[a,c]of Object.entries(r))s=av(t,`${e}.${a}`,c,s,n);return wo(s,i)}throw new Error(`Unsupported CompositeShaderType for ${e}`)}function J2(t,e){if(typeof t=="string")return Bf(t,e).size;if(Array.isArray(t)){let o=t[0],n=t[1];if(Array.isArray(o))throw new Error("Nested arrays are not supported");return Q2(o,e)*n}let r=0;for(let o of Object.values(t)){let n=o;r=wo(r,ni(n,e)),r+=J2(n,e)}return wo(r,ni(t,e))}function ni(t,e){if(typeof t=="string")return Bf(t,e).alignment;if(Array.isArray(t)){let o=t[0],n=ni(o,e);return eI(e)?Math.max(n,4):n}let r=1;for(let o of Object.values(t)){let n=ni(o,e);r=Math.max(r,n)}return u7(e)?Math.max(r,4):r}function q2(t,e,r,o){return{alignment:t===2?2:4,size:t===3?3:t,components:t,columns:1,rows:t,columnStride:t===3?3:t,shaderType:e,type:r}}function Q2(t,e){let r=J2(t,e),o=ni(t,e);return l7(r,o,e)}function l7(t,e,r){return wo(t,eI(r)?4:e)}function f7(t,e,r){return r==="std140"?4:wo(t,e)}function eI(t){return t==="std140"||t==="wgsl-uniform"}function u7(t){return t==="std140"||t==="wgsl-uniform"}var lv=L(()=>{sv();km()});function fv(t){return(!zm||zm.byteLength<t)&&(zm=new ArrayBuffer(t)),zm}function uv(t,e){let r=fv(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}var zm,dv=L(()=>{});function d7(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ya(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":d7(t)}var hv=L(()=>{});function h7(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function p7(t,e,r){return Array.prototype.slice.call(t,e,r)}var Hm,tI=L(()=>{dv();hv();Er();lv();Hm=class{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){let r=this.layout.fields[e];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(e){let r={};for(let[o,n]of Object.entries(e)){let i=this.layout.uniformTypes[o];i?this._flattenCompositeValue(r,o,i,n):this.layout.fields[o]&&(r[o]=n)}return r}getData(e){let r=fv(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let o={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},n=this.getFlatUniformValues(e);for(let[i,s]of Object.entries(n))this._writeLeafValue(o,i,s);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(e,r,o,n){if(n!==void 0){if(typeof o=="string"||this.layout.fields[r]){e[r]=n;return}if(Array.isArray(o)){let i=o[0],s=o[1];if(Array.isArray(i))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof i=="string"&&Ya(n)){this._flattenPackedArray(e,r,i,s,n);return}if(!Array.isArray(n)){P.warn(`Unsupported uniform array value for ${r}:`,n)();return}for(let a=0;a<Math.min(n.length,s);a++){let c=n[a];c!==void 0&&this._flattenCompositeValue(e,`${r}[${a}]`,i,c)}return}if(cv(o)&&h7(n)){for(let[i,s]of Object.entries(n)){if(s===void 0)continue;let a=`${r}.${i}`;this._flattenCompositeValue(e,a,o[i],s)}return}P.warn(`Unsupported uniform value for ${r}:`,n)()}}_flattenPackedArray(e,r,o,n,i){let s=i,c=Bf(o,this.layout.layout).components;for(let l=0;l<n;l++){let f=l*c;if(f>=s.length)break;c===1?e[`${r}[${l}]`]=Number(s[f]):e[`${r}[${l}]`]=p7(i,f,f+c)}}_writeLeafValue(e,r,o){let n=this.layout.fields[r];if(!n){P.warn(`Uniform ${r} not found in layout`)();return}let{type:i,components:s,columns:a,rows:c,offset:l,columnStride:f}=n,u=e[i];if(s===1){u[l]=Number(o);return}let d=o;if(a===1){for(let p=0;p<s;p++)u[l+p]=Number(d[p]??0);return}let h=0;for(let p=0;p<a;p++){let m=l+p*f;for(let g=0;g<c;g++)u[m+g]=Number(d[h++]??0)}}}});function rI(t,e,r=16){if(t===e)return!0;let o=t,n=e;if(!Ya(o)||!Ya(n)||o.length!==n.length)return!1;let i=Math.min(r,m7);if(o.length>i)return!1;for(let s=0;s<o.length;++s)if(n[s]!==o[s])return!1;return!0}function oI(t){return Ya(t)?t.slice():t}var m7,nI=L(()=>{hv();m7=128});var jm,iI=L(()=>{nI();jm=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let r=e?.shaderLayout.bindings?.find(n=>n.type==="uniform"&&n.name===e?.name);if(!r)throw new Error(e?.name);let o=r;for(let n of o.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(e){for(let[r,o]of Object.entries(e))this._setUniform(r,o),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${o}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){rI(this.uniforms[e],r)||(this.uniforms[e]=oI(r),this.modifiedUniforms[e]=!0,this.modified=!0)}}});function _7(t){return t.type==="webgpu"?"wgsl-uniform":"std140"}var g7,is,sI=L(()=>{Cm();Er();lv();iI();tI();g7=1024,is=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,r){this.device=e;for(let[o,n]of Object.entries(r)){let i=o,s=Z2(n.uniformTypes??{},{layout:n.layout??_7(e)}),a=new Hm(s);this.shaderBlockLayouts.set(i,s),this.shaderBlockWriters.set(i,a);let c=new jm({name:o});c.setUniforms(a.getFlatUniformValues(n.defaultUniforms||{})),this.uniformBlocks.set(i,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,o]of Object.entries(e)){let n=r,s=this.shaderBlockWriters.get(n)?.getFlatUniformValues(o||{});this.uniformBlocks.get(n)?.setUniforms(s||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let r=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(r,g7)}getUniformBufferData(e){let r=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(r)||new Uint8Array(0)}createUniformBuffer(e,r){r&&this.setUniforms(r);let o=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:K.UNIFORM|K.COPY_DST,byteLength:o}),i=this.getUniformBufferData(e);return n.write(i),n}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let r=this.getUniformBufferByteLength(e),o=this.device.createBuffer({usage:K.UNIFORM|K.COPY_DST,byteLength:r});this.uniformBuffers.set(e,o)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let o=this.updateUniformBuffer(r);e||=o}return e&&P.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),o=this.uniformBuffers.get(e),n=!1;if(o&&r?.needsRedraw){n||=r.needsRedraw;let i=this.getUniformBufferData(e);o=this.uniformBuffers.get(e),o?.write(i);let s=this.uniformBlocks.get(e)?.getAllUniforms();P.log(4,`Writing to uniform buffer ${String(e)}`,i,s)()}return n}}});var q=L(()=>{b2();A2();FT();w2();P2();Cm();VT();M2();WT();kT();B2();XT();O2();N2();D2();V2();z2();H2();$2();X2();Y2();K2();sI();Em();sv();km();wm();Im();LT();Er();k2();DT();dv();tv()});var hi,U3=L(()=>{(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(hi||(hi={}))});var k3=L(()=>{U3()});function V3(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(r,o){if(r==="webgl"||r==="experimental-webgl"){let n=this.originalGetContext("webgl2",o);return n instanceof HTMLElement&&$q(n),n}return this.originalGetContext(r,o)}}function $q(t){t.getExtension("EXT_color_buffer_float");let e={...Hq,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:jq(t),OES_vertex_array_object:Wq(t),ANGLE_instanced_arrays:Gq(t)},r=t.getExtension;t.getExtension=function(n){let i=r.call(t,n);return i||(n in e?e[n]:null)};let o=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(o.apply(t)||[])?.concat(Object.keys(e))}}var Hq,jq,Wq,Gq,z3=L(()=>{Hq={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},jq=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Wq=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),Gq=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}})});async function Ng(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let o=document.createElement("script");return o.setAttribute("type","text/javascript"),o.setAttribute("src",t),e&&(o.id=e),new Promise((n,i)=>{o.onload=n,o.onerror=s=>i(new Error(`Unable to load script '${t}': ${s}`)),r.appendChild(o)})}var o1=L(()=>{});function bs(t){let e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},t.luma=e,e}var Dg=L(()=>{});async function j3(t){if(!globalThis.SPECTOR)try{await Ng(t.debugSpectorJSUrl||Ug.debugSpectorJSUrl)}catch(e){P.warn(String(e))}}function W3(t){if(t={...Ug,...t},!t.debugSpectorJS)return null;if(!dr&&globalThis.SPECTOR&&!globalThis.luma?.spector){P.probe(Xq,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;dr=new e,globalThis.luma&&(globalThis.luma.spector=dr)}if(!dr)return null;if(H3||(H3=!0,dr.spyCanvases(),dr?.onCaptureStarted.add(e=>P.info("Spector capture started:",e)()),dr?.onCapture.add(e=>{P.info("Spector capture complete:",e)(),dr?.getResultUI(),dr?.resultView.display(),dr?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=bs(e),o=r.device;dr?.startCapture(t.gl,500),r.device=o,new Promise(n=>setTimeout(n,2e3)).then(n=>{P.info("Spector capture stopped after 2 seconds")(),dr?.stopCapture()})}return dr}var Xq,dr,H3,Ug,n1=L(()=>{q();o1();Dg();Xq=1,dr=null,H3=!1,Ug={debugSpectorJS:P.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function $3(t){return t.luma=t.luma||{},t.luma}async function X3(){Ot()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Ng(Yq))}function Y3(t,e={}){return e.debugWebGL||e.traceWebGL?qq(t,e):Kq(t)}function Kq(t){let e=$3(t);return e.realContext?e.realContext:t}function qq(t,e){if(!globalThis.WebGLDebugUtils)return P.warn("webgl-debug not loaded")(),t;let r=$3(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...hi,...t});let o=globalThis.WebGLDebugUtils.makeDebugContext(t,Zq.bind(null,e),Jq.bind(null,e));for(let s in hi)!(s in o)&&typeof hi[s]=="number"&&(o[s]=hi[s]);class n{}Object.setPrototypeOf(o,Object.getPrototypeOf(t)),Object.setPrototypeOf(n,o);let i=Object.create(n);return r.realContext=t,r.debugContext=i,i.luma=r,i.debug=!0,i}function G3(t,e){e=Array.from(e).map(o=>o===void 0?"undefined":o);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Zq(t,e,r,o){o=Array.from(o).map(a=>a===void 0?"undefined":a);let n=globalThis.WebGLDebugUtils.glEnumToString(e),i=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,o),s=`${n} in gl.${r}(${i})`;P.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",s)();debugger;throw new Error(s)}function Jq(t,e,r){let o="";t.traceWebGL&&P.level>=1&&(o=G3(e,r),P.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",o)());for(let n of r)if(n===void 0){o=o||G3(e,r);debugger}}var Yq,i1=L(()=>{q();k3();Vn();o1();Yq="https://unpkg.com/webgl-debug@2.0.1/index.js"});function s1(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ge(t,e,r){return e[t]!==void 0?e[t]:r[t]}var gu,it,K3,hr,q3,mu,Z3,J3,a1,Fo,c1,Q3,l1=L(()=>{gu={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},it=(t,e,r)=>e?t.enable(r):t.disable(r),K3=(t,e,r)=>t.hint(r,e),hr=(t,e,r)=>t.pixelStorei(r,e),q3=(t,e,r)=>{let o=r===36006?36009:36008;return t.bindFramebuffer(o,e)},mu=(t,e,r)=>{let n={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(n,e)};Z3={[3042]:it,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:it,[2885]:(t,e)=>t.cullFace(e),[2929]:it,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:it,[35723]:K3,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:q3,[36010]:q3,[34964]:mu,[36662]:mu,[36663]:mu,[35053]:mu,[35055]:mu,[2886]:(t,e)=>t.frontFace(e),[33170]:K3,[2849]:(t,e)=>t.lineWidth(e),[32823]:it,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:it,[32926]:it,[32928]:it,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:it,[3088]:(t,e)=>t.scissor(...e),[2960]:it,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.stencilMaskSeparate(1029,e),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(t,e)=>t.viewport(...e),[34383]:it,[10754]:it,[12288]:it,[12289]:it,[12290]:it,[12291]:it,[12292]:it,[12293]:it,[12294]:it,[12295]:it,[3333]:hr,[3317]:hr,[37440]:hr,[37441]:hr,[37443]:hr,[3330]:hr,[3332]:hr,[3331]:hr,[3314]:hr,[32878]:hr,[3316]:hr,[3315]:hr,[32877]:hr,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=s1(e)?e:[e,e];let[r,o]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,o)},stencilFunc:(t,e)=>{e=s1(e)&&e.length===3?[...e,...e]:e;let[r,o,n,i,s,a]=e;t.stencilFuncSeparate(1028,r,o,n),t.stencilFuncSeparate(1029,i,s,a)},stencilOp:(t,e)=>{e=s1(e)&&e.length===3?[...e,...e]:e;let[r,o,n,i,s,a]=e;t.stencilOpSeparate(1028,r,o,n),t.stencilOpSeparate(1029,i,s,a)},viewport:(t,e)=>t.viewport(...e)};J3={blendEquation:(t,e,r)=>t.blendEquationSeparate(Ge(32777,e,r),Ge(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(Ge(32969,e,r),Ge(32968,e,r),Ge(32971,e,r),Ge(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(Ge(32824,e,r),Ge(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(Ge(32938,e,r),Ge(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,Ge(2962,e,r),Ge(2967,e,r),Ge(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,Ge(34816,e,r),Ge(36003,e,r),Ge(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,Ge(2964,e,r),Ge(2965,e,r),Ge(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,Ge(34817,e,r),Ge(34818,e,r),Ge(34819,e,r))},a1={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let o={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return o?t({[o]:r}):{valueChanged:!0}},blendColor:(t,e,r,o,n)=>t({[32773]:new Float32Array([e,r,o,n])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,o,n)=>t({[32969]:e,[32968]:r,[32971]:o,[32970]:n}),clearColor:(t,e,r,o,n)=>t({[3106]:new Float32Array([e,r,o,n])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,o,n)=>t({[3107]:[e,r,o,n]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,o,n)=>t({[3088]:new Int32Array([e,r,o,n])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,o)=>t({[2962]:e,[2967]:r,[2963]:o,[34816]:e,[36003]:r,[36004]:o}),stencilFuncSeparate:(t,e,r,o,n)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:o,[e===1028?2963:36004]:n}),stencilOp:(t,e,r,o)=>t({[2964]:e,[2965]:r,[2966]:o,[34817]:e,[34818]:r,[34819]:o}),stencilOpSeparate:(t,e,r,o,n)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:o,[e===1028?2966:34819]:n}),viewport:(t,e,r,o,n)=>t({[2978]:[e,r,o,n]})},Fo=(t,e)=>t.isEnabled(e),c1={[3042]:Fo,[2884]:Fo,[2929]:Fo,[3024]:Fo,[32823]:Fo,[32926]:Fo,[32928]:Fo,[3089]:Fo,[2960]:Fo,[35977]:Fo},Q3=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068])});function ro(t,e){if(Qq(e))return;let r={};for(let n in e){let i=Number(n),s=Z3[n];s&&(typeof s=="string"?r[s]=!0:s(t,e[n],i))}let o=t.lumaState?.cache;if(o)for(let n in r){let i=J3[n];i(t,e,o)}}function kg(t,e=gu){if(typeof e=="number"){let n=e,i=c1[n];return i?i(t,n):t.getParameter(n)}let r=Array.isArray(e)?e:Object.keys(e),o={};for(let n of r){let i=c1[n];o[n]=i?i(t,Number(n)):t.getParameter(Number(n))}return o}function eL(t){ro(t,gu)}function Qq(t){for(let e in t)return!1;return!0}var hc=L(()=>{l1()});function rL(t,e){if(t===e)return!0;if(tL(t)&&tL(e)&&t.length===e.length){for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}return!1}function tL(t){return Array.isArray(t)||ArrayBuffer.isView(t)}var oL=L(()=>{});function nL(t,e){let r=t[e].bind(t);t[e]=function(n){if(n===void 0||Q3.has(n))return r(n);let i=oo.get(t);return n in i.cache||(i.cache[n]=r(n)),i.enable?i.cache[n]:r(n)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function eZ(t,e,r){if(!t[e])return;let o=t[e].bind(t);t[e]=function(...i){let s=oo.get(t),{valueChanged:a,oldValue:c}=r(s._updateCache,...i);return a&&o(...i),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function tZ(t){let e=t.useProgram.bind(t);t.useProgram=function(o){let n=oo.get(t);n.program!==o&&(e(o),n.program=o)}}var oo,f1=L(()=>{hc();oL();l1();oo=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,r){this.gl=e,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];ro(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r?.copyState?kg(e):Object.assign({},gu),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,tZ(e);for(let o in a1){let n=a1[o];eZ(e,o,n)}nL(e,"getParameter"),nL(e,"isEnabled")}_updateCache(e){let r=!1,o,n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let s=e[i],a=this.cache[i];rL(s,a)||(r=!0,o=a,n&&!(i in n)&&(n[i]=a),this.cache[i]=s)}return{valueChanged:r,oldValue:o}}}});function iL(t,e,r){let o="",n=c=>{let l=c.statusMessage;l&&(o||=l)};t.addEventListener("webglcontextcreationerror",n,!1);let i=r.failIfMajorPerformanceCaveat!==!0,s={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=t.getContext("webgl2",s),!a&&s.failIfMajorPerformanceCaveat&&(o||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&i&&(s.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",s),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,o||="Your browser only supports WebGL1")),!a)throw o||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${o}`);let l=bs(a);l.softwareRenderer=c;let{onContextLost:f,onContextRestored:u}=e;return t.addEventListener("webglcontextlost",d=>f(d),!1),t.addEventListener("webglcontextrestored",d=>u(d),!1),a}finally{t.removeEventListener("webglcontextcreationerror",n,!1)}}var sL=L(()=>{Dg()});function no(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}var _u=L(()=>{});function aL(t,e){let r=t.getParameter(7936),o=t.getParameter(7937);no(t,"WEBGL_debug_renderer_info",e);let n=e.WEBGL_debug_renderer_info,i=t.getParameter(n?n.UNMASKED_VENDOR_WEBGL:7936),s=t.getParameter(n?n.UNMASKED_RENDERER_WEBGL:7937),a=i||r,c=s||o,l=t.getParameter(7938),f=cL(a,c),u=rZ(a,c),d=oZ(a,c);return{type:"webgl",gpu:f,gpuType:d,gpuBackend:u,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function cL(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function rZ(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function oZ(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(cL(t,e)){case"apple":return nZ(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function nZ(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}var lL=L(()=>{_u()});function Vg(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}var u1=L(()=>{});function dL(t){return t in Hg}function g1(t,e,r){return hL(t,e,r,new Set)}function hL(t,e,r,o){let n=Hg[e];if(!n||o.has(e))return!1;o.add(e);let i=(n.features||[]).every(s=>hL(t,s,r,o));return o.delete(e),i?(n.extensions||[]).every(s=>Boolean(no(t,s,r))):!1}function pL(t,e,r){let o=e.create,n=jg[e.format];n?.gl===void 0&&(o=!1),n?.x&&(o=o&&Boolean(no(t,n.x,r))),e.format==="stencil8"&&(o=!1);let i=n?.r===!1?!1:n?.r===void 0||g1(t,n.r,r),s=o&&e.render&&i&&dZ(t,e.format,r);return{format:e.format,create:o&&e.create,render:s,filter:o&&e.filter,blend:o&&e.blend,store:o&&e.store}}function dZ(t,e,r){let o=jg[e],n=o?.gl;if(n===void 0||o?.x&&!no(t,o.x,r))return!1;let i=t.getParameter(32873),s=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;let l=Number(0),f=Number(t.getError());for(;f!==l;)f=t.getError();let u=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,n,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),u=Number(t.checkFramebufferStatus(36160))===Number(36053)&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,s),t.deleteFramebuffer(c),t.bindTexture(3553,i),t.deleteTexture(a)}return u}function Wg(t){let e=jg[t],r=pZ(t),o=bt.getInfo(t);return o.compressed&&(e.dataFormat=r),{internalFormat:r,format:e?.dataFormat||hZ(o.channels,o.integer,o.normalized,r),type:o.dataType?Vg(o.dataType):e?.types?.[0]||5121,compressed:o.compressed||!1}}function mL(t){switch(bt.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function hZ(t,e,r,o){if(o===6408||o===6407)return o;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function pZ(t){let r=jg[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var yu,xu,pc,mc,iZ,sZ,aZ,cZ,lZ,fZ,fL,uL,d1,h1,p1,m1,zg,uZ,Hg,jg,gc=L(()=>{q();_u();u1();yu="WEBGL_compressed_texture_s3tc",xu="WEBGL_compressed_texture_s3tc_srgb",pc="EXT_texture_compression_rgtc",mc="EXT_texture_compression_bptc",iZ="WEBGL_compressed_texture_etc",sZ="WEBGL_compressed_texture_astc",aZ="WEBGL_compressed_texture_etc1",cZ="WEBGL_compressed_texture_pvrtc",lZ="WEBGL_compressed_texture_atc",fZ="EXT_texture_norm16",fL="EXT_render_snorm",uL="EXT_color_buffer_float",d1="snorm8-renderable-webgl",h1="norm16-renderable-webgl",p1="snorm16-renderable-webgl",m1="float16-renderable-webgl",zg="float32-renderable-webgl",uZ="rgb9e5ufloat-renderable-webgl",Hg={"float32-renderable-webgl":{extensions:[uL]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[fL]},"norm16-webgl":{extensions:[fZ]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[fL]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[yu,xu,pc,mc]},"texture-compression-bc5-webgl":{extensions:[pc]},"texture-compression-bc7-webgl":{extensions:[mc]},"texture-compression-etc2":{extensions:[iZ]},"texture-compression-astc":{extensions:[sZ]},"texture-compression-etc1-webgl":{extensions:[aZ]},"texture-compression-pvrtc-webgl":{extensions:[cZ]},"texture-compression-atc-webgl":{extensions:[lZ]}};jg={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:d1},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:d1},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:m1},r16unorm:{gl:33322,rb:!0,r:h1},r16snorm:{gl:36760,r:p1},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:d1},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:m1},rg16unorm:{gl:33324,r:h1},rg16snorm:{gl:36761,r:p1},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:zg},rgb9e5ufloat:{gl:35901,r:uZ},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:zg},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:m1},rgba16unorm:{gl:32859,rb:!0,r:h1},rgba16snorm:{gl:36763,r:p1},"rgb32float-webgl":{gl:34837,x:uL,r:zg,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:zg},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:yu},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:xu},"bc1-rgba-unorm":{gl:33777,x:yu},"bc1-rgba-unorm-srgb":{gl:35916,x:xu},"bc2-rgba-unorm":{gl:33778,x:yu},"bc2-rgba-unorm-srgb":{gl:35918,x:xu},"bc3-rgba-unorm":{gl:33779,x:yu},"bc3-rgba-unorm-srgb":{gl:35919,x:xu},"bc4-r-unorm":{gl:36283,x:pc},"bc4-r-snorm":{gl:36284,x:pc},"bc5-rg-unorm":{gl:36285,x:pc},"bc5-rg-snorm":{gl:36286,x:pc},"bc6h-rgb-ufloat":{gl:36495,x:mc},"bc6h-rgb-float":{gl:36494,x:mc},"bc7-rgba-unorm":{gl:36492,x:mc},"bc7-rgba-unorm-srgb":{gl:36493,x:mc},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var gL,Gg,_L=L(()=>{q();_u();gc();gL={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Gg=class extends Ef{gl;extensions;testedFeatures=new Set;constructor(e,r,o){super([],o),this.gl=e,this.extensions=r,no(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),dL(e)&&g1(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(gL),...Object.keys(Hg)]}getWebGLFeature(e){let r=gL[e];return Boolean(typeof r=="string"?no(this.gl,r,this.extensions):r)}}});var $g,yL=L(()=>{q();$g=class extends Cf{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function mZ(t){return t<34069?t+34069:t}function gZ(t){switch(t){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${t}`}}var No,Xg=L(()=>{q();gc();No=class extends Eo{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let o=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||o?this.props.handle:this.gl.createFramebuffer(),o||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r<this.colorAttachments.length;++r){let o=this.colorAttachments[r];if(o){let n=36064+r;this._attachTextureView(n,o)}}if(this.depthStencilAttachment){let r=mL(this.depthStencilAttachment.props.format);this._attachTextureView(r,this.depthStencilAttachment)}if(this.device.props.debug){let r=this.gl.checkFramebufferStatus(36160);if(r!==36053)throw new Error(`Framebuffer ${gZ(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:o}=this.device,{texture:n}=r,i=r.props.baseMipLevel,s=r.props.baseArrayLayer;switch(o.bindTexture(n.glTarget,n.handle),n.glTarget){case 35866:case 32879:o.framebufferTextureLayer(36160,e,n.handle,i,s);break;case 34067:let a=mZ(s);o.framebufferTexture2D(36160,e,a,n.handle,i);break;case 3553:o.framebufferTexture2D(36160,e,3553,n.handle,i);break;default:throw new Error("Illegal texture type")}o.bindTexture(n.glTarget,null)}resizeAttachments(e,r){if(this.handle===null){this.width=e,this.height=r;return}super.resizeAttachments(e,r)}}});var Yg,xL=L(()=>{q();Xg();Yg=class extends Da{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new No(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Kg,bL=L(()=>{q();Kg=class extends Mf{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,r={}){super(r),this.device=e;let o=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${o}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let i=this.canvas.getContext("2d");if(!i)throw new Error(`${o}: Failed to create 2d presentation context`);this.context2d=i,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[r,o]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||o===0||e.canvas.width===0||e.canvas.height===0)){if(r!==this.drawingBufferWidth||o!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${o} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(e)}}});function AL(t="id"){_1[t]=_1[t]||1;let e=_1[t]++;return`${t}-${e}`}var _1,TL=L(()=>{_1={}});function _Z(t){return t&K.INDEX?34963:t&K.VERTEX?34962:t&K.UNIFORM?35345:34962}function yZ(t){return t&K.INDEX||t&K.VERTEX?35044:t&K.UNIFORM?35048:35044}var io,qg=L(()=>{q();io=class extends K{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let o=typeof r=="object"?r.handle:void 0;this.handle=o||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=_Z(this.props.usage),this.glUsage=yZ(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,r=0,o=e.byteLength+r){let n=this.glTarget;this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,o,this.glUsage),this.gl.bufferSubData(n,r,e),this.gl.bindBuffer(n,null),this.bytesUsed=o,this.byteLength=o,this._setDebugData(e,r,o),this.props.handle?this.trackReferencedMemory(o,"Buffer"):this.trackAllocatedMemory(o)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let o=this.glTarget;return this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,r,this.glUsage),this.gl.bindBuffer(o,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,r=0){let o=ArrayBuffer.isView(e)?e:new Uint8Array(e),n=0,i=void 0,s=36663;this.gl.bindBuffer(s,this.handle),n!==0||i!==void 0?this.gl.bufferSubData(s,r,o,n,i):this.gl.bufferSubData(s,r,o),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async mapAndWriteAsync(e,r=0,o=this.byteLength-r){let n=new ArrayBuffer(o);await e(n,"copied"),this.write(n,r)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}async mapAndReadAsync(e,r=0,o){let n=await this.readAsync(r,o);return await e(n.buffer,"copied")}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let o=new Uint8Array(r),n=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,o,n,r),this.gl.bindBuffer(36662,null),this._setDebugData(o,e,r),o}}});function vL(t){let e=t.split(/\r?\n/),r=[];for(let o of e){if(o.length<=1)continue;let n=o.trim(),i=o.split(":"),s=i[0]?.trim();if(i.length===2){let[h,p]=i;if(!h||!p){r.push({message:n,type:Zg(s||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:Zg(h),lineNum:0,linePos:0});continue}let[a,c,l,...f]=i;if(!a||!c||!l){r.push({message:i.slice(1).join(":").trim()||n,type:Zg(s||"info"),lineNum:0,linePos:0});continue}let u=parseInt(l,10);Number.isNaN(u)&&(u=0);let d=parseInt(c,10);Number.isNaN(d)&&(d=0),r.push({message:f.join(":").trim(),type:Zg(a),lineNum:u,linePos:d})}return r}function Zg(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var SL=L(()=>{});var Jg,CL=L(()=>{q();SL();Jg=class extends oi{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let o=this._compile(this.source);o&&typeof o.catch=="function"&&o.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?vL(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es
${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return P.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{P.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async n=>await new Promise(i=>setTimeout(i,n));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:o}=this.device;for(;;){if(o.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function wL(t,e,r,o){if(TZ(e))return o(t);let n=t;n.pushState();try{return xZ(t,e),ro(n.gl,r),o(t)}finally{n.popState()}}function xZ(t,e){let r=t,{gl:o}=r;if(e.cullMode)switch(e.cullMode){case"none":o.disable(2884);break;case"front":o.enable(2884),o.cullFace(1028);break;case"back":o.enable(2884),o.cullFace(1029);break}if(e.frontFace&&o.frontFace(As("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&o.enable(34383),e.depthBias!==void 0&&(o.enable(32823),o.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let i=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=As("provokingVertex",e.provokingVertex,{first:36429,last:36430});i?.provokingVertexWEBGL(s)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let i=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=As("polygonMode",e.polygonMode,{fill:6914,line:6913});i?.polygonModeWEBGL(1028,s),i?.polygonModeWEBGL(1029,s)}e.polygonOffsetLine&&o.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&o.enable(12288),e.clipDistance1&&o.enable(12289),e.clipDistance2&&o.enable(12290),e.clipDistance3&&o.enable(12291),e.clipDistance4&&o.enable(12292),e.clipDistance5&&o.enable(12293),e.clipDistance6&&o.enable(12294),e.clipDistance7&&o.enable(12295)),e.depthWriteEnabled!==void 0&&o.depthMask(AZ("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?o.enable(2929):o.disable(2929),o.depthFunc(e_("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&o.clearDepth(e.clearDepth),e.stencilWriteMask){let n=e.stencilWriteMask;o.stencilMaskSeparate(1028,n),o.stencilMaskSeparate(1029,n)}if(e.stencilReadMask&&P.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let n=e.stencilReadMask||4294967295,i=e_("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?o.enable(2960):o.disable(2960),o.stencilFuncSeparate(1028,i,0,n),o.stencilFuncSeparate(1029,i,0,n)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let n=y1("stencilPassOperation",e.stencilPassOperation),i=y1("stencilFailOperation",e.stencilFailOperation),s=y1("stencilDepthFailOperation",e.stencilDepthFailOperation);o.stencilOpSeparate(1028,i,s,n),o.stencilOpSeparate(1029,i,s,n)}switch(e.blend){case!0:o.enable(3042);break;case!1:o.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let n=EL("blendColorOperation",e.blendColorOperation||"add"),i=EL("blendAlphaOperation",e.blendAlphaOperation||"add");o.blendEquationSeparate(n,i);let s=Qg("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Qg("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=Qg("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=Qg("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");o.blendFuncSeparate(s,a,c,l)}}function e_(t,e){return As(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function y1(t,e){return As(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function EL(t,e){return As(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Qg(t,e,r="color"){return As(t,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function bZ(t,e){return`Illegal parameter ${e} for ${t}`}function As(t,e,r){if(!(e in r))throw new Error(bZ(t,e));return r[e]}function AZ(t,e){return e}function TZ(t){let e=!0;for(let r in t){e=!1;break}return e}var x1=L(()=>{q();hc()});function t_(t){let e={};return t.addressModeU&&(e[10242]=b1(t.addressModeU)),t.addressModeV&&(e[10243]=b1(t.addressModeV)),t.addressModeW&&(e[32882]=b1(t.addressModeW)),t.magFilter&&(e[10240]=A1(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=vZ(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=e_("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function b1(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function A1(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function vZ(t,e="none"){if(!e)return A1(t);switch(e){case"none":return A1(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}var T1=L(()=>{x1()});var r_,PL=L(()=>{q();T1();r_=class extends Pt{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=t_(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,o]of Object.entries(e)){let n=Number(r);switch(n){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,n,o);break;default:this.device.gl.samplerParameteri(this.handle,n,o);break}}}}});function Do(t,e,r){if(SZ(e))return r(t);let{nocatch:o=!0}=e,n=oo.get(t);n.push(),ro(t,e);let i;if(o)i=r(t),n.pop();else try{i=r(t)}finally{n.pop()}return i}function SZ(t){for(let e in t)return!1;return!0}var o_=L(()=>{hc();f1()});var Uo,v1=L(()=>{q();Uo=class extends wr{device;gl;handle;texture;constructor(e,r){super(e,{...Y.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function n_(t){return CZ[t]}var CZ,S1=L(()=>{CZ={[5124]:"sint32",[5125]:"uint32",[5122]:"sint16",[5123]:"uint16",[5120]:"sint8",[5121]:"uint8",[5126]:"float32",[5131]:"float16",[33635]:"uint16",[32819]:"uint16",[32820]:"uint16",[33640]:"uint32",[35899]:"uint32",[35902]:"uint32",[34042]:"uint32",[36269]:"uint32"}});function EZ(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function wZ(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function PZ(t){switch(t){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(t)}function i_(t,e,r){return e==="cube"?34069+r:t}var ko,s_=L(()=>{q();gc();T1();o_();v1();S1();ko=class extends Y{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,r){super(e,r,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let o=Wg(this.props.format);this.glTarget=PZ(this.props.dimension),this.glInternalFormat=o.internalFormat,this.glFormat=o.format,this.glType=o.type,this.compressed=o.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:n,width:i,height:s,depth:a,mipLevels:c,glTarget:l,glInternalFormat:f}=this;if(!this.compressed)switch(n){case"2d":case"cube":this.gl.texStorage2D(l,c,f,i,s);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,f,i,s,a);break;default:throw new Error(n)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new Uo(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new Uo(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let r=t_(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(e){let r=this._normalizeCopyExternalImageOptions(e);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:o,glType:n}=this,{image:i,depth:s,mipLevel:a,x:c,y:l,z:f,width:u,height:d}=r,h=i_(this.glTarget,this.dimension,f),p=r.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Do(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(h,a,c,l,u,d,o,n,i);break;case"2d-array":case"3d":this.gl.texSubImage3D(h,a,c,l,f,u,d,s,o,n,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let o=this._getSupportedColorReadOptions(e),n=e.byteOffset??0,i=this.computeMemoryLayout(o);if(r.byteLength<n+i.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${n+i.byteLength})`);let s=r;this.gl.bindBuffer(35051,s.handle);try{this._readColorTextureLayers(o,i,a=>{this.gl.readPixels(o.x,o.y,o.width,o.height,this.glFormat,this.glType,n+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,r={}){let o=this._normalizeTextureWriteOptions(r),{width:n,height:i,depthOrArrayLayers:s,mipLevel:a,byteOffset:c,x:l,y:f,z:u}=o,{glFormat:d,glType:h,compressed:p}=this,m=i_(this.glTarget,this.dimension,u);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:g}=this.device.getTextureFormatInfo(this.format),_=g?o.bytesPerRow/g:void 0,x={[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:o.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),Do(this.gl,x,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,a,l,f,n,i,d,h,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,a,l,f,u,n,i,s,d,h,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,r={}){let o=this._normalizeTextureWriteOptions(r),n=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:i,height:s,depthOrArrayLayers:a,mipLevel:c,x:l,y:f,z:u,byteOffset:d}=o,{glFormat:h,glType:p,compressed:m}=this,g=i_(this.glTarget,this.dimension,u),_;if(!m){let{bytesPerPixel:w}=this.device.getTextureFormatInfo(this.format);w&&(_=o.bytesPerRow/w)}let x=this.compressed?{}:{[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:o.rowsPerImage},y=wZ(n,d),b=m?EZ(n,d):n,T=this._getMipLevelSize(c),v=l===0&&f===0&&u===0&&i===T.width&&s===T.height&&a===T.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),Do(this.gl,x,()=>{switch(this.dimension){case"2d":case"cube":m?v?this.gl.compressedTexImage2D(g,c,h,i,s,0,b):this.gl.compressedTexSubImage2D(g,c,l,f,i,s,h,b):this.gl.texSubImage2D(g,c,l,f,i,s,h,p,n,y);break;case"2d-array":case"3d":m?v?this.gl.compressedTexImage3D(g,c,h,i,s,a,0,b):this.gl.compressedTexSubImage3D(g,c,l,f,u,i,s,a,h,b):this.gl.texSubImage3D(g,c,l,f,u,i,s,a,h,p,n,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let r=this._getSupportedColorReadOptions(e),o=this.computeMemoryLayout(r),n=n_(this.glType),i=Lf(n),s=new i(o.byteLength/i.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,o,a=>{let c=new i(s.buffer,s.byteOffset+a,o.bytesPerImage/i.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),s.buffer}_readColorTextureLayers(e,r,o){let n=this._getFramebuffer(),i=r.bytesPerRow/r.bytesPerPixel,s={[3333]:this.byteAlignment,...i!==e.width?{[3330]:i}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,n.handle);try{this.gl.readBuffer(36064),Do(this.gl,s,()=>{for(let l=0;l<e.depthOrArrayLayers;l++)this._attachReadSubresource(n,e.mipLevel,e.z+l),o(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,r,o){let n=`${r}:${o}`;if(this._framebufferAttachmentKey!==n){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,i_(this.glTarget,this.dimension,o),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,o);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let i=Number(this.gl.checkFramebufferStatus(36160));if(i!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${i})`)}this._framebufferAttachmentKey=n}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(P.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(o){P.warn(`Error generating mipmap for ${this}: ${o.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){P.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,o]of Object.entries(e)){let n=Number(r),i=o;switch(n){case 33082:case 33083:this.gl.texParameterf(this.glTarget,n,i);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,n,i);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,n,i);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,n,i);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,n,i);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,null),e}}});function ML(t,e,r,o){let n=t,i=o;i===!0&&(i=1),i===!1&&(i=0);let s=typeof i=="number"?[i]:i;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof o!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,o);case 5126:return t.uniform1fv(e,s);case 35664:return t.uniform2fv(e,s);case 35665:return t.uniform3fv(e,s);case 35666:return t.uniform4fv(e,s);case 5124:return t.uniform1iv(e,s);case 35667:return t.uniform2iv(e,s);case 35668:return t.uniform3iv(e,s);case 35669:return t.uniform4iv(e,s);case 35670:return t.uniform1iv(e,s);case 35671:return t.uniform2iv(e,s);case 35672:return t.uniform3iv(e,s);case 35673:return t.uniform4iv(e,s);case 5125:return n.uniform1uiv(e,s,1);case 36294:return n.uniform2uiv(e,s,2);case 36295:return n.uniform3uiv(e,s,3);case 36296:return n.uniform4uiv(e,s,4);case 35674:return t.uniformMatrix2fv(e,!1,s);case 35675:return t.uniformMatrix3fv(e,!1,s);case 35676:return t.uniformMatrix4fv(e,!1,s);case 35685:return n.uniformMatrix2x3fv(e,!1,s);case 35686:return n.uniformMatrix2x4fv(e,!1,s);case 35687:return n.uniformMatrix3x2fv(e,!1,s);case 35688:return n.uniformMatrix3x4fv(e,!1,s);case 35689:return n.uniformMatrix4x2fv(e,!1,s);case 35690:return n.uniformMatrix4x3fv(e,!1,s)}throw new Error("Illegal uniform")}var RL=L(()=>{});function IL(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(t)}}function LL(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(t)}}var C1=L(()=>{});function MZ(t,e){let r={...t,attributes:t.attributes.map(o=>({...o})),bindings:t.bindings.map(o=>({...o}))};for(let o of e?.attributes||[]){let n=r.attributes.find(i=>i.name===o.name);n?(n.type=o.type||n.type,n.stepMode=o.stepMode||n.stepMode):P.warn(`shader layout attribute ${o.name} not present in shader`)}for(let o of e?.bindings||[]){let n=OL(r,o.name);if(!n){P.warn(`shader layout binding ${o.name} not present in shader`);continue}Object.assign(n,o)}return r}function OL(t,e){return t.bindings.find(r=>r.name===e||r.name===`${e}Uniforms`||`${r.name}Uniforms`===e)}function BL(t,e){return t[e]||t[`${e}Uniforms`]||t[e.replace(/Uniforms$/,"")]}var a_,FL=L(()=>{q();x1();RL();qg();Xg();s_();v1();C1();a_=class extends fr{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,r){super(e,r),this.device=e;let o=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=o,this.handle=o.handle,this.vs=o.vs,this.fs=o.fs,this.linkStatus=o.linkStatus,this.introspectedLayout=o.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?MZ(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,r){let o=Dm(If(this.shaderLayout,e));for(let[n,i]of Object.entries(o)){let s=OL(this.shaderLayout,n);if(s){switch(i||P.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),s.type){case"uniform":if(!(i instanceof io)&&!(i.buffer instanceof io))throw new Error("buffer value");break;case"texture":if(!(i instanceof Uo||i instanceof ko||i instanceof No))throw new Error(`${this} Bad texture binding for ${n}`);break;case"sampler":P.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(s.type)}this.bindings[n]=i}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||P.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${a}`,i)()}}}draw(e){this._syncLinkStatus();let r=e.bindGroups?Dm(e.bindGroups):e.bindings||this.bindings,{renderPass:o,parameters:n=this.props.parameters,topology:i=this.props.topology,vertexArray:s,vertexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:f=0,transformFeedback:u,uniforms:d=this.uniforms}=e,h=IL(i),p=Boolean(s.indexBuffer),m=s.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return P.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(r))return P.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),s.bindBeforeRender(o),u&&u.begin(this.props.topology),this._applyBindings(r,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(d);let g=o;return wL(this.device,n,g.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(h,a||0,m,f,c||0):p?this.device.gl.drawElements(h,a||0,m,f):l?this.device.gl.drawArraysInstanced(h,f,a||0,c||0):this.device.gl.drawArrays(h,f,a||0),u&&u.end()}),s.unbindAfterRender(o),!0}_areTexturesRenderable(e){let r=!0;for(let o of this.shaderLayout.bindings)BL(e,o.name)||(P.warn(`Binding ${o.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(e,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:o}=this.device;o.useProgram(this.handle);let n=0,i=0;for(let s of this.shaderLayout.bindings){let a=BL(e,s.name);if(!a)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:c}=s,l=o.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(o.uniformBlockBinding(this.handle,l,i),a instanceof io)o.bindBufferBase(35345,i,a.handle);else{let u=a;o.bindBufferRange(35345,i,u.buffer.handle,u.offset||0,u.size||u.buffer.byteLength-(u.offset||0))}i+=1;break;case"texture":if(!(a instanceof Uo||a instanceof ko||a instanceof No))throw new Error("texture");let f;if(a instanceof Uo)f=a.texture;else if(a instanceof ko)f=a;else if(a instanceof No&&a.colorAttachments[0]instanceof Uo)P.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=a.colorAttachments[0].texture;else throw new Error("No texture");o.activeTexture(33984+n),o.bindTexture(f.glTarget,f.handle),n+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let r of this.shaderLayout.uniforms||[]){let{name:o,location:n,type:i,textureUnit:s}=r,a=e[o]??s;a!==void 0&&ML(this.device.gl,n,i,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function NL(t){return IZ[t]}function c_(t){return RZ[t]}function l_(t){return Boolean(UL[t])}function DL(t){return UL[t]}var RZ,UL,IZ,f_=L(()=>{RZ={[5126]:"f32",[35664]:"vec2<f32>",[35665]:"vec3<f32>",[35666]:"vec4<f32>",[5124]:"i32",[35667]:"vec2<i32>",[35668]:"vec3<i32>",[35669]:"vec4<i32>",[5125]:"u32",[36294]:"vec2<u32>",[36295]:"vec3<u32>",[36296]:"vec4<u32>",[35670]:"f32",[35671]:"vec2<f32>",[35672]:"vec3<f32>",[35673]:"vec4<f32>",[35674]:"mat2x2<f32>",[35685]:"mat2x3<f32>",[35686]:"mat2x4<f32>",[35687]:"mat3x2<f32>",[35675]:"mat3x3<f32>",[35688]:"mat3x4<f32>",[35689]:"mat4x2<f32>",[35690]:"mat4x3<f32>",[35676]:"mat4x4<f32>"},UL={[35678]:{viewDimension:"2d",sampleType:"float"},[35680]:{viewDimension:"cube",sampleType:"float"},[35679]:{viewDimension:"3d",sampleType:"float"},[35682]:{viewDimension:"3d",sampleType:"depth"},[36289]:{viewDimension:"2d-array",sampleType:"float"},[36292]:{viewDimension:"2d-array",sampleType:"depth"},[36293]:{viewDimension:"cube",sampleType:"float"},[36298]:{viewDimension:"2d",sampleType:"sint"},[36299]:{viewDimension:"3d",sampleType:"sint"},[36300]:{viewDimension:"cube",sampleType:"sint"},[36303]:{viewDimension:"2d-array",sampleType:"uint"},[36306]:{viewDimension:"2d",sampleType:"uint"},[36307]:{viewDimension:"3d",sampleType:"uint"},[36308]:{viewDimension:"cube",sampleType:"uint"},[36311]:{viewDimension:"2d-array",sampleType:"uint"}},IZ={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function kL(t,e){let r={attributes:[],bindings:[]};r.attributes=LZ(t,e);let o=FZ(t,e);for(let a of o){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let n=OZ(t,e),i=0;for(let a of n)if(l_(a.type)){let{viewDimension:c,sampleType:l}=DL(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:i,viewDimension:c,sampleType:l}),a.textureUnit=i,i+=1}n.length&&(r.uniforms=n);let s=BZ(t,e);return s?.length&&(r.varyings=s),r}function LZ(t,e){let r=[],o=t.getProgramParameter(e,35721);for(let n=0;n<o;n++){let i=t.getActiveAttrib(e,n);if(!i)throw new Error("activeInfo");let{name:s,type:a}=i,c=t.getAttribLocation(e,s);if(c>=0){let l=c_(a),f=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:c,stepMode:f,type:l})}}return r.sort((n,i)=>n.location-i.location),r}function BZ(t,e){let r=[],o=t.getProgramParameter(e,35971);for(let n=0;n<o;n++){let i=t.getTransformFeedbackVarying(e,n);if(!i)throw new Error("activeInfo");let{name:s,type:a,size:c}=i,l=c_(a),{type:f,components:u}=ja(l);r.push({location:n,name:s,type:f,size:c*u})}return r.sort((n,i)=>n.location-i.location),r}function OZ(t,e){let r=[],o=t.getProgramParameter(e,35718);for(let n=0;n<o;n++){let i=t.getActiveUniform(e,n);if(!i)throw new Error("activeInfo");let{name:s,size:a,type:c}=i,{name:l,isArray:f}=NZ(s),u=t.getUniformLocation(e,l),d={location:u,name:l,size:a,type:c,isArray:f};if(r.push(d),d.size>1)for(let h=0;h<d.size;h++){let p=`${l}[${h}]`;u=t.getUniformLocation(e,p);let m={...d,name:p,location:u};r.push(m)}}return r}function FZ(t,e){let r=(i,s)=>t.getActiveUniformBlockParameter(e,i,s),o=[],n=t.getProgramParameter(e,35382);for(let i=0;i<n;i++){let s={name:t.getActiveUniformBlockName(e,i)||"",location:r(i,35391),byteLength:r(i,35392),vertex:r(i,35396),fragment:r(i,35398),uniformCount:r(i,35394),uniforms:[]},a=r(i,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),u=t.getActiveUniforms(e,a,35388);for(let p=0;p<s.uniformCount;++p){let m=a[p];if(m!==void 0){let g=t.getActiveUniform(e,m);if(!g)throw new Error("activeInfo");let _=c_(c[p]);s.uniforms.push({name:g.name,format:_,type:c[p],arrayLength:l[p],byteOffset:f[p],byteStride:u[p]})}}let d=new Set(s.uniforms.map(p=>p.name.split(".")[0]).filter(p=>Boolean(p))),h=s.name.replace(/Uniforms$/,"");if(d.size===1&&!d.has(s.name)&&!d.has(h)){let[p]=d;P.warn(`Uniform block "${s.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${s.name}") and alias ("${h}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}o.push(s)}return o.sort((i,s)=>i.location-s.location),o}function NZ(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:os(r?.[1],`Failed to parse GLSL uniform name ${t}`),length:r?.[2]?1:0,isArray:Boolean(r?.[2])}}var VL=L(()=>{q();f_()});var zL,u_,HL=L(()=>{q();VL();f_();zL=4,u_=class extends Rf{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(e,r){super(e,r),this.device=e,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders(),P.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=kL(this.device.gl,this.handle),P.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),P.time(zL,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),P.timeEnd(zL,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let o=this._getLinkStatus();this._reportLinkStatus(o);return}P.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),P.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(e){switch(e){case"success":return;default:let r=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let o=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${e}: ${o}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let r=0,o=e.getProgramParameter(this.handle,35718);for(let n=0;n<o;n++){let i=e.getActiveUniform(this.handle,n);if(i&&l_(i.type)){let s=i.name.endsWith("[0]"),a=s?i.name.slice(0,-3):i.name,c=e.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,i,s,r))}}}_assignSamplerUniform(e,r,o,n){let{gl:i}=this.device;if(o&&r.size>1){let s=Int32Array.from({length:r.size},(a,c)=>n+c);return i.uniform1iv(e,s),n+r.size}return i.uniform1i(e,n),n+1}async _waitForLinkComplete(){let e=async n=>await new Promise(i=>setTimeout(i,n));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:o}=this.device;for(;;){if(o.getProgramParameter(this.handle,37297))return;await e(10)}}}});function DZ(t,e){let r=e.sourceBuffer,o=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,o.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function UZ(t,e){throw new Error("copyBufferToTexture is not supported in WebGL")}function kZ(t,e){let{sourceTexture:r,mipLevel:o=0,aspect:n="all",width:i=e.sourceTexture.width,height:s=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:u,rowsPerImage:d}=e;if(r instanceof Y){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:i,height:s,depthOrArrayLayers:a,mipLevel:o,aspect:n,byteOffset:f},l);return}if(n!=="all")throw new Error("aspect not supported in WebGL");if(o!==0||a!==void 0||u||d)throw new Error("not implemented");let{framebuffer:h,destroyFramebuffer:p}=jL(r),m;try{let g=l,_=i||h.width,x=s||h.height,y=os(h.colorAttachments[0]),b=Wg(y.texture.props.format),T=b.format,v=b.type;t.gl.bindBuffer(35051,g.handle),m=t.gl.bindFramebuffer(36160,h.handle),t.gl.readPixels(c[0],c[1],_,x,T,v,f)}finally{t.gl.bindBuffer(35051,null),m!==void 0&&t.gl.bindFramebuffer(36160,m),p&&h.destroy()}}function VZ(t,e){let{sourceTexture:r,destinationMipLevel:o=0,origin:n=[0,0],destinationOrigin:i=[0,0,0],destinationTexture:s}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:f}=jL(r),[u=0,d=0]=n,[h,p,m]=i,g=t.gl.bindFramebuffer(36160,l.handle),_,x;if(s instanceof ko)_=s,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),x=_.glTarget;else throw new Error("invalid destination");switch(x){case 3553:case 34067:t.gl.copyTexSubImage2D(x,o,h,p,u,d,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(x,o,h,p,m,u,d,a,c);break;default:}_&&_._unbind(),t.gl.bindFramebuffer(36160,g),f&&l.destroy()}function jL(t){if(t instanceof Y){let{width:e,height:r,id:o}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${o}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var d_,WL=L(()=>{q();gc();s_();d_=class extends Ha{device;handle=null;commands=[];constructor(e,r={}){super(e,r),this.device=e}_executeCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":DZ(this.device,r.options);break;case"copy-buffer-to-texture":UZ(this.device,r.options);break;case"copy-texture-to-buffer":kZ(this.device,r.options);break;case"copy-texture-to-texture":VZ(this.device,r.options);break;default:throw new Error(r.name)}}}});var zZ,h_,$L=L(()=>{q();o_();hc();zZ=[1,2,4,8],h_=class extends on{device;handle=null;glParameters={};constructor(e,r){super(e,r),this.device=e;let o=this.props.framebuffer,n=!o||o.handle===null;n&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let i;if(!r?.parameters?.viewport)if(!n&&o){let{width:s,height:a}=o;i=[0,0,s,a]}else{let[s,a]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,s,a]}if(this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters}),!n&&o?.colorAttachments.length){let s=o.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(s)}else n&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference!==void 0&&(r[2967]=e.stencilReference,r[36003]=e.stencilReference),"colorMask"in e&&(r.colorMask=zZ.map(o=>Boolean(o&e.colorMask))),this.glParameters=r,ro(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((o,n)=>{o&&this.clearColorBuffer(n,o)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,e.clearStencil=this.props.clearStencil),r!==0&&Do(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){Do(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var bu,XL=L(()=>{q();WL();$L();bu=class extends za{device;handle=null;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new d_(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new h_(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,o){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,r){e.writeTimestamp(r)}}});function YL(t){let{target:e,source:r,start:o=0,count:n=1}=t,i=r.length,s=n*i,a=0;for(let c=o;a<i;a++)e[c++]=r[a]??0;for(;a<s;)a<s-a?(e.copyWithin(o+a,o,o+a),a*=2):(e.copyWithin(o+a,o,o+s-a),a=s);return t.target}var KL=L(()=>{});function HZ(t){return Array.isArray(t)?new Float32Array(t):t}function jZ(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var _c,qL=L(()=>{q();Vn();u1();KL();_c=class extends Wa{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return bb()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let o=r;if(o.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:n,type:i,stride:s,offset:a,normalized:c,integer:l,divisor:f}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,o.handle),l?this.device.gl.vertexAttribIPointer(e,n,i,s,a):this.device.gl.vertexAttribPointer(e,n,i,c,s,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,f||0),this.attributes[e]=o,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let o=Vg(r.bufferDataType);return{size:r.bufferComponents,type:o,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let n=_c.isConstantAttributeZeroSupported(this.device)||e!==0;(r||n)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let o=HZ(r),n=o.byteLength*e,i=o.length*e;if(this.buffer&&n!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${n} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:n}),s||=!jZ(o,this.bufferValue),s){let a=uv(r.constructor,i);YL({target:a,source:o,start:0,count:i}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function ZL(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var p_,JL=L(()=>{q();Au();C1();p_=class extends Ga{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(LL(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,o]of Object.entries(e))this.setBuffer(r,o)})}setBuffer(e,r){let o=this._getVaryingIndex(e),{buffer:n,byteLength:i,byteOffset:s}=this._getBufferRange(r);if(o<0){this.unusedBuffers[e]=n,P.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[o]={buffer:n,byteLength:i,byteOffset:s},this.bindOnUse||this._bindBuffer(o,n,s,i)}getBuffer(e){if(ZL(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return this.buffers[r]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof io)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:o=0,byteLength:n=e.buffer.byteLength}=e;return{buffer:r,byteOffset:o,byteLength:n}}_getVaryingIndex(e){if(ZL(e))return Number(e);for(let r of this.layout.varyings||[])if(e===r.name)return r.location;return-1}_bindBuffers(){for(let[e,r]of Object.entries(this.buffers)){let{buffer:o,byteLength:n,byteOffset:i}=this._getBufferRange(r);this._bindBuffer(Number(e),o,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,o=0,n){let i=r&&r.handle;!i||n===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,o,n)}}});var m_,QL=L(()=>{q();m_=class extends $a{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){if(super(e,r),this.device=e,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let o=this.device.gl.createQuery();if(!o)throw new Error("WebGL query not supported");this.handle=o}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let r of e.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((r,o)=>this._isTimestampPairAvailable(o)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let r=e?.firstQuery||0,o=e?.queryCount||this.props.count-r;if(this._validateRange(r,o),this.props.type==="timestamp"){let n=new Array(o).fill(0n),i=Math.floor(r/2),s=Math.floor((r+o-1)/2);for(let a=i;a<=s;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,f=l+1;l>=r&&l<r+o&&(n[l-r]=0n),f>=r&&f<r+o&&(n[f-r]=c)}return n}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||r>=this.props.count||r<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||r!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let o=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(o)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(e),o=this._timestampPairs[r];if(e%2===0){if(o.activeQuery)throw new Error("Timestamp query pair is already active");let n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");let i={handle:n,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,n),o.activeQuery=i;return}if(!o.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),o.completedQueries.push(o.activeQuery),o.activeQuery=null}_validateRange(e,r){if(e<0||r<0||e+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let r=this._timestampPairs[e];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let o=Boolean(this.device.gl.getParameter(36795));return e.disjoint=o,e.result=o?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let r=this._timestampPairs[e];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let o=r.completedQueries.shift();try{return await this._consumeQueryResult(o)}finally{this.device.gl.deleteQuery(o.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((r,o)=>{e.resolve=r,e.reject=o;let n=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,r(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(n);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?o(new Error("GPU timestamp query was invalidated by a disjoint event")):r(e.result||0n)};n()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let r=e.resolve;e.promise=null,e.resolve=null,e.reject=null,r(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var g_,eB=L(()=>{q();g_=class extends Xa{device;gl;handle;signaled;_signaled=!1;constructor(e,r={}){super(e,{}),this.device=e,this.gl=e.gl;let o=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!o)throw new Error("Failed to create WebGL fence");this.handle=o,this.signaled=new Promise(n=>{let i=()=>{let s=this.gl.clientWaitSync(this.handle,0,0);s===this.gl.ALREADY_SIGNALED||s===this.gl.CONDITION_SATISFIED?(this._signaled=!0,n()):setTimeout(i,1)};i()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function E1(t){switch(t){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function tB(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var rB=L(()=>{});function oB(t,e){let{sourceX:r=0,sourceY:o=0,sourceAttachment:n=0}=e||{},{target:i=null,sourceWidth:s,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{},{framebuffer:u,deleteFramebuffer:d}=iB(t),{gl:h,handle:p}=u;s||=u.width,a||=u.height;let m=u.colorAttachments[n]?.texture;if(!m)throw new Error(`Invalid framebuffer attachment ${n}`);c=m?.depth||1,l||=m?.glFormat||6408,f||=m?.glType||5121,i=GZ(i,f,l,s,a,c);let g=Dt.getDataType(i);f=f||NL(g);let _=h.bindFramebuffer(36160,p);return h.readBuffer(36064+n),h.readPixels(r,o,s,a,l,f,i),h.readBuffer(36064),h.bindFramebuffer(36160,_||null),d&&u.destroy(),i}function nB(t,e){let{target:r,sourceX:o=0,sourceY:n=0,sourceFormat:i=6408,targetByteOffset:s=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:f,deleteFramebuffer:u}=iB(t);a=a||f.width,c=c||f.height;let d=f;l=l||5121;let h=r;if(!h){let m=E1(i),g=tB(l),_=s+a*c*m*g;h=d.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[o,n],destinationBuffer:h,byteOffset:s}),p.destroy(),u&&f.destroy(),h}function iB(t){return t instanceof Eo?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:WZ(t),deleteFramebuffer:!0}}function WZ(t,e){let{device:r,width:o,height:n,id:i}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${i}`,width:o,height:n,colorAttachments:[t]})}function GZ(t,e,r,o,n,i){if(t)return t;e||=5121;let s=n_(e),a=Dt.getTypedArrayConstructor(s),c=E1(r);return new a(o*n*c)}var sB=L(()=>{q();f_();rB();S1()});var w1={};ze(w1,{WebGLDevice:()=>Zt});function $Z(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:}}function XZ(t,e,r){t.gl.vertexAttribI4iv(e,r)}function YZ(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function KZ(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Zt,__=L(()=>{q();f1();sL();Dg();lL();_L();yL();xL();bL();n1();i1();gc();TL();qg();CL();PL();s_();Xg();FL();HL();XL();qL();JL();QL();eB();sB();hc();o_();_u();Zt=class extends Xt{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||AL("webgl-device")});let r=Xt._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let o=r.canvas?.gl??null,n=Zt.getDeviceFromContext(o);if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new Yg(this,r),this.lost=new Promise(f=>{this._resolveContextLost=f});let i={...e.webgl};r.alphaMode==="premultiplied"&&(i.premultipliedAlpha=!0),e.powerPreference!==void 0&&(i.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(i.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||iL(this.canvasContext.canvas,{onContextLost:f=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:f=>console.log("WebGL context restored")},i);if(!a)throw new Error("WebGL context creation failed");if(n=Zt.getDeviceFromContext(a),n){if(e._reuseDevices)return P.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),this.canvasContext.destroy(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=a,this.gl=a,this.spectorJS=W3({...this.props,gl:this.handle});let c=bs(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=aL(this.gl,this.extensions),this.limits=new $g(this.gl),this.features=new Gg(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new oo(this.gl,{log:(...f)=>P.log(1,...f)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=Y3(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),P.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(P.level=Math.max(P.level,1)),this.commandEncoder=new bu(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=bs(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Kg(this,e||{})}createBuffer(e){let r=this._normalizeBufferProps(e);return new io(this,r)}createTexture(e){return new ko(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new r_(this,e)}createShader(e){return new Jg(this,e)}createFramebuffer(e){return new No(this,e)}createVertexArray(e){return new _c(this,e)}createTransformFeedback(e){return new p_(this,e)}createQuerySet(e){return new m_(this,e)}createFence(){return new g_(this)}createRenderPipeline(e){return new a_(this,e)}_createSharedRenderPipelineWebGL(e){return new u_(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new bu(this,e)}submit(e){let r=null;e||({submittedCommandEncoder:r,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,r=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:r}}readPixelsToArrayWebGL(e,r){return oB(e,r)}readPixelsToBufferWebGL(e,r){return nB(e,r)}setParametersWebGL(e){ro(this.gl,e)}getParametersWebGL(e){return kg(this.gl,e)}withParametersWebGL(e,r){return Do(this.gl,e,r)}resetWebGL(){P.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),eL(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return pL(this.gl,e,this.extensions)}loseDevice(){let e=!1,o=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return o&&(e=!0,o.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){oo.get(this.gl).push()}popState(){oo.get(this.gl).pop()}getGLKey(e,r){let o=Number(e);for(let n in this.gl)if(this.gl[n]===o)return`GL.${n}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((o,[n,i])=>(o[`${n}:${this.getGLKey(n,r)}`]=`${i}:${this.getGLKey(i,r)}`,o),{})}setConstantAttributeWebGL(e,r){let o=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(o).fill(null);let n=this._constants[e];switch(n&&KZ(n,r)&&P.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:$Z(this,e,r);break;case Int32Array:XZ(this,e,r);break;case Uint32Array:YZ(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return no(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,r,o){e.luma=r;let n={props:o.spector,id:o.spector.id};e.__SPECTOR_Metadata=n}}});function qZ(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&typeof t.createVertexArray=="function")}var Tu,P1,vu,aB=L(()=>{q();z3();n1();i1();Tu=1,P1=class extends wf{type="webgl";constructor(){super(),Xt.defaultProps={...Xt.defaultProps,...Ug}}enforceWebGL2(e){V3(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&P.warn("WebGL1 is not supported",e)(),!1)}async attach(e,r={}){let{WebGLDevice:o}=await Promise.resolve().then(()=>(__(),w1));if(e instanceof o)return e;let n=o.getDeviceFromContext(e);if(n)return n;if(!qZ(e))throw new Error("Invalid WebGL2RenderingContext");let i=r.createCanvasContext===!0?{}:r.createCanvasContext;return new o({...r,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...i}})}async create(e={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(__(),w1)),o=[];(e.debugWebGL||e.debug)&&o.push(X3()),e.debugSpectorJS&&o.push(j3(e));let n=await Promise.allSettled(o);for(let i of n)i.status==="rejected"&&P.error(`Failed to initialize debug libraries ${i.reason}`)();try{let i=new r(e);P.groupCollapsed(Tu,`WebGLDevice ${i.id} created`)();let s=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return P.probe(Tu,s)(),P.table(Tu,i.info)(),i}finally{P.groupEnd(Tu)(),P.info(Tu,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};vu=new P1});var Au=L(()=>{aB();__();qg()});var DF=jl((Vje,PS)=>{"use strict";PS.exports=f0;PS.exports.default=f0;function f0(t,e,r){r=r||2;var o=e&&e.length,n=o?e[0]*r:t.length,i=OF(t,0,n,r,!0),s=[];if(!i||i.next===i.prev)return s;var a,c,l,f,u,d,h;if(o&&(i=ite(t,e,i,r)),t.length>80*r){a=l=t[0],c=f=t[1];for(var p=r;p<n;p+=r)u=t[p],d=t[p+1],u<a&&(a=u),d<c&&(c=d),u>l&&(l=u),d>f&&(f=d);h=Math.max(l-a,f-c),h=h!==0?32767/h:0}return yd(i,s,r,a,c,h,0),s}function OF(t,e,r,o,n){var i,s;if(n===wS(t,e,r,o)>0)for(i=e;i<r;i+=o)s=BF(i,t[i],t[i+1],s);else for(i=r-o;i>=e;i-=o)s=BF(i,t[i],t[i+1],s);return s&&u0(s,s.next)&&(bd(s),s=s.next),s}function Ls(t,e){if(!t)return t;e||(e=t);var r=t,o;do if(o=!1,!r.steiner&&(u0(r,r.next)||Ve(r.prev,r,r.next)===0)){if(bd(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function yd(t,e,r,o,n,i,s){if(t){!s&&i&&fte(t,o,n,i);for(var a=t,c,l;t.prev!==t.next;){if(c=t.prev,l=t.next,i?rte(t,o,n,i):tte(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),bd(t),t=l.next,a=l.next;continue}if(t=l,t===a){s?s===1?(t=ote(Ls(t),e,r),yd(t,e,r,o,n,i,2)):s===2&&nte(t,e,r,o,n,i):yd(Ls(t),e,r,o,n,i,1);break}}}}function tte(t){var e=t.prev,r=t,o=t.next;if(Ve(e,r,o)>=0)return!1;for(var n=e.x,i=r.x,s=o.x,a=e.y,c=r.y,l=o.y,f=n<i?n<s?n:s:i<s?i:s,u=a<c?a<l?a:l:c<l?c:l,d=n>i?n>s?n:s:i>s?i:s,h=a>c?a>l?a:l:c>l?c:l,p=o.next;p!==e;){if(p.x>=f&&p.x<=d&&p.y>=u&&p.y<=h&&Mc(n,a,i,c,s,l,p.x,p.y)&&Ve(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function rte(t,e,r,o){var n=t.prev,i=t,s=t.next;if(Ve(n,i,s)>=0)return!1;for(var a=n.x,c=i.x,l=s.x,f=n.y,u=i.y,d=s.y,h=a<c?a<l?a:l:c<l?c:l,p=f<u?f<d?f:d:u<d?u:d,m=a>c?a>l?a:l:c>l?c:l,g=f>u?f>d?f:d:u>d?u:d,_=CS(h,p,e,r,o),x=CS(m,g,e,r,o),y=t.prevZ,b=t.nextZ;y&&y.z>=_&&b&&b.z<=x;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Mc(a,f,c,u,l,d,y.x,y.y)&&Ve(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Mc(a,f,c,u,l,d,b.x,b.y)&&Ve(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Mc(a,f,c,u,l,d,y.x,y.y)&&Ve(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=x;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Mc(a,f,c,u,l,d,b.x,b.y)&&Ve(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ote(t,e,r){var o=t;do{var n=o.prev,i=o.next.next;!u0(n,i)&&FF(n,o,o.next,i)&&xd(n,i)&&xd(i,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(i.i/r|0),bd(o),bd(o.next),o=t=i),o=o.next}while(o!==t);return Ls(o)}function nte(t,e,r,o,n,i){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&hte(s,a)){var c=NF(s,a);s=Ls(s,s.next),c=Ls(c,c.next),yd(s,e,r,o,n,i,0),yd(c,e,r,o,n,i,0);return}a=a.next}s=s.next}while(s!==t)}function ite(t,e,r,o){var n=[],i,s,a,c,l;for(i=0,s=e.length;i<s;i++)a=e[i]*o,c=i<s-1?e[i+1]*o:t.length,l=OF(t,a,c,o,!1),l===l.next&&(l.steiner=!0),n.push(dte(l));for(n.sort(ste),i=0;i<n.length;i++)r=ate(n[i],r);return r}function ste(t,e){return t.x-e.x}function ate(t,e){var r=cte(t,e);if(!r)return e;var o=NF(r,t);return Ls(o,o.next),Ls(r,r.next)}function cte(t,e){var r=e,o=t.x,n=t.y,i=-1/0,s;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=o&&a>i&&(i=a,s=r.x<r.next.x?r:r.next,a===o))return s}r=r.next}while(r!==e);if(!s)return null;var c=s,l=s.x,f=s.y,u=1/0,d;r=s;do o>=r.x&&r.x>=l&&o!==r.x&&Mc(n<f?o:i,n,l,f,n<f?i:o,n,r.x,r.y)&&(d=Math.abs(n-r.y)/(o-r.x),xd(r,t)&&(d<u||d===u&&(r.x>s.x||r.x===s.x&<e(s,r)))&&(s=r,u=d)),r=r.next;while(r!==c);return s}function lte(t,e){return Ve(t.prev,t,e.prev)<0&&Ve(e.next,t,t.next)<0}function fte(t,e,r,o){var n=t;do n.z===0&&(n.z=CS(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,ute(n)}function ute(t){var e,r,o,n,i,s,a,c,l=1;do{for(r=t,t=null,i=null,s=0;r;){for(s++,o=r,a=0,e=0;e<l&&(a++,o=o.nextZ,!!o);e++);for(c=l;a>0||c>0&&o;)a!==0&&(c===0||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,c--),i?i.nextZ=n:t=n,n.prevZ=i,i=n;r=o}i.nextZ=null,l*=2}while(s>1);return t}function CS(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function dte(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Mc(t,e,r,o,n,i,s,a){return(n-s)*(e-a)>=(t-s)*(i-a)&&(t-s)*(o-a)>=(r-s)*(e-a)&&(r-s)*(i-a)>=(n-s)*(o-a)}function hte(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!pte(t,e)&&(xd(t,e)&&xd(e,t)&&mte(t,e)&&(Ve(t.prev,t,e.prev)||Ve(t,e.prev,e))||u0(t,e)&&Ve(t.prev,t,t.next)>0&&Ve(e.prev,e,e.next)>0)}function Ve(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function u0(t,e){return t.x===e.x&&t.y===e.y}function FF(t,e,r,o){var n=l0(Ve(t,e,r)),i=l0(Ve(t,e,o)),s=l0(Ve(r,o,t)),a=l0(Ve(r,o,e));return!!(n!==i&&s!==a||n===0&&c0(t,r,e)||i===0&&c0(t,o,e)||s===0&&c0(r,t,o)||a===0&&c0(r,e,o))}function c0(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function l0(t){return t>0?1:t<0?-1:0}function pte(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&FF(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function xd(t,e){return Ve(t.prev,t,t.next)<0?Ve(t,e,t.next)>=0&&Ve(t,t.prev,e)>=0:Ve(t,e,t.prev)<0||Ve(t,t.next,e)<0}function mte(t,e){var r=t,o=!1,n=(t.x+e.x)/2,i=(t.y+e.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&n<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function NF(t,e){var r=new ES(t.i,t.x,t.y),o=new ES(e.i,e.x,e.y),n=t.next,i=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,i.next=o,o.prev=i,o}function BF(t,e,r,o){var n=new ES(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function bd(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ES(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}f0.deviation=function(t,e,r,o){var n=e&&e.length,i=n?e[0]*r:t.length,s=Math.abs(wS(t,0,i,r));if(n)for(var a=0,c=e.length;a<c;a++){var l=e[a]*r,f=a<c-1?e[a+1]*r:t.length;s-=Math.abs(wS(t,l,f,r))}var u=0;for(a=0;a<o.length;a+=3){var d=o[a]*r,h=o[a+1]*r,p=o[a+2]*r;u+=Math.abs((t[d]-t[p])*(t[h+1]-t[d+1])-(t[d]-t[h])*(t[p+1]-t[d+1]))}return s===0&&u===0?0:Math.abs((u-s)/s)};function wS(t,e,r,o){for(var n=0,i=e,s=r-o;i<r;i+=o)n+=(t[s]-t[i])*(t[i+1]+t[s+1]),s=i;return n}f0.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},o=0,n=0;n<t.length;n++){for(var i=0;i<t[n].length;i++)for(var s=0;s<e;s++)r.vertices.push(t[n][i][s]);n>0&&(o+=t[n-1].length,r.holes.push(o))}return r}});var kd=jl((qGe,GD)=>{GD.exports=globalThis.h3||{}});var uC=jl((pU,Zd)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof qw=="function"&&typeof Zd=="object"&&Zd&&Zd.exports?Zd.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(pU,function(){"use strict";function t(S,A,M){this.low=S|0,this.high=A|0,this.unsigned=!!M}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(S){return(S&&S.__isLong__)===!0}t.isLong=e;var r={},o={};function n(S,A){var M,B,O;return A?(S>>>=0,(O=0<=S&&S<256)&&(B=o[S],B)?B:(M=s(S,(S|0)<0?-1:0,!0),O&&(o[S]=M),M)):(S|=0,(O=-128<=S&&S<128)&&(B=r[S],B)?B:(M=s(S,S<0?-1:0,!1),O&&(r[S]=M),M))}t.fromInt=n;function i(S,A){if(isNaN(S)||!isFinite(S))return A?_:g;if(A){if(S<0)return _;if(S>=h)return v}else{if(S<=-p)return w;if(S+1>=p)return T}return S<0?i(-S,A).neg():s(S%d|0,S/d|0,A)}t.fromNumber=i;function s(S,A,M){return new t(S,A,M)}t.fromBits=s;var a=Math.pow;function c(S,A,M){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return g;if(typeof A=="number"?(M=A,A=!1):A=!!A,M=M||10,M<2||36<M)throw RangeError("radix");var B;if((B=S.indexOf("-"))>0)throw Error("interior hyphen");if(B===0)return c(S.substring(1),A,M).neg();for(var O=i(a(M,8)),F=g,X=0;X<S.length;X+=8){var G=Math.min(8,S.length-X),j=parseInt(S.substring(X,X+G),M);if(G<8){var se=i(a(M,G));F=F.mul(se).add(i(j))}else F=F.mul(O),F=F.add(i(j))}return F.unsigned=A,F}t.fromString=c;function l(S){return S instanceof t?S:typeof S=="number"?i(S):typeof S=="string"?c(S):s(S.low,S.high,S.unsigned)}t.fromValue=l;var f=1<<16,u=1<<24,d=f*f,h=d*d,p=h/2,m=n(u),g=n(0);t.ZERO=g;var _=n(0,!0);t.UZERO=_;var x=n(1);t.ONE=x;var y=n(1,!0);t.UONE=y;var b=n(-1);t.NEG_ONE=b;var T=s(-1,2147483647,!1);t.MAX_VALUE=T;var v=s(-1,-1,!0);t.MAX_UNSIGNED_VALUE=v;var w=s(0,-2147483648,!1);t.MIN_VALUE=w;var C=t.prototype;return C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},C.toString=function(A){if(A=A||10,A<2||36<A)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(w)){var M=i(A),B=this.div(M),O=B.mul(M).sub(this);return B.toString(A)+O.toInt().toString(A)}else return"-"+this.neg().toString(A);for(var F=i(a(A,6),this.unsigned),X=this,G="";;){var j=X.div(F),se=X.sub(j.mul(F)).toInt()>>>0,ne=se.toString(A);if(X=j,X.isZero())return ne+G;for(;ne.length<6;)ne="0"+ne;G=""+ne+G}},C.getHighBits=function(){return this.high},C.getHighBitsUnsigned=function(){return this.high>>>0},C.getLowBits=function(){return this.low},C.getLowBitsUnsigned=function(){return this.low>>>0},C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var A=this.high!=0?this.high:this.low,M=31;M>0&&!(A&1<<M);M--);return this.high!=0?M+33:M+1},C.isZero=function(){return this.high===0&&this.low===0},C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return(this.low&1)===1},C.isEven=function(){return(this.low&1)===0},C.equals=function(A){return e(A)||(A=l(A)),this.unsigned!==A.unsigned&&this.high>>>31===1&&A.high>>>31===1?!1:this.high===A.high&&this.low===A.low},C.eq=C.equals,C.notEquals=function(A){return!this.eq(A)},C.neq=C.notEquals,C.lessThan=function(A){return this.comp(A)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(A){return this.comp(A)<=0},C.lte=C.lessThanOrEqual,C.greaterThan=function(A){return this.comp(A)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(A){return this.comp(A)>=0},C.gte=C.greaterThanOrEqual,C.compare=function(A){if(e(A)||(A=l(A)),this.eq(A))return 0;var M=this.isNegative(),B=A.isNegative();return M&&!B?-1:!M&&B?1:this.unsigned?A.high>>>0>this.high>>>0||A.high===this.high&&A.low>>>0>this.low>>>0?-1:1:this.sub(A).isNegative()?-1:1},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(x)},C.neg=C.negate,C.add=function(A){e(A)||(A=l(A));var M=this.high>>>16,B=this.high&65535,O=this.low>>>16,F=this.low&65535,X=A.high>>>16,G=A.high&65535,j=A.low>>>16,se=A.low&65535,ne=0,pe=0,U=0,re=0;return re+=F+se,U+=re>>>16,re&=65535,U+=O+j,pe+=U>>>16,U&=65535,pe+=B+G,ne+=pe>>>16,pe&=65535,ne+=M+X,ne&=65535,s(U<<16|re,ne<<16|pe,this.unsigned)},C.subtract=function(A){return e(A)||(A=l(A)),this.add(A.neg())},C.sub=C.subtract,C.multiply=function(A){if(this.isZero()||(e(A)||(A=l(A)),A.isZero()))return g;if(this.eq(w))return A.isOdd()?w:g;if(A.eq(w))return this.isOdd()?w:g;if(this.isNegative())return A.isNegative()?this.neg().mul(A.neg()):this.neg().mul(A).neg();if(A.isNegative())return this.mul(A.neg()).neg();if(this.lt(m)&&A.lt(m))return i(this.toNumber()*A.toNumber(),this.unsigned);var M=this.high>>>16,B=this.high&65535,O=this.low>>>16,F=this.low&65535,X=A.high>>>16,G=A.high&65535,j=A.low>>>16,se=A.low&65535,ne=0,pe=0,U=0,re=0;return re+=F*se,U+=re>>>16,re&=65535,U+=O*se,pe+=U>>>16,U&=65535,U+=F*j,pe+=U>>>16,U&=65535,pe+=B*se,ne+=pe>>>16,pe&=65535,pe+=O*j,ne+=pe>>>16,pe&=65535,pe+=F*G,ne+=pe>>>16,pe&=65535,ne+=M*se+B*j+O*G+F*X,ne&=65535,s(U<<16|re,ne<<16|pe,this.unsigned)},C.mul=C.multiply,C.divide=function(A){if(e(A)||(A=l(A)),A.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?_:g;var M,B,O;if(this.unsigned){if(A.unsigned||(A=A.toUnsigned()),A.gt(this))return _;if(A.gt(this.shru(1)))return y;O=_}else{if(this.eq(w)){if(A.eq(x)||A.eq(b))return w;if(A.eq(w))return x;var F=this.shr(1);return M=F.div(A).shl(1),M.eq(g)?A.isNegative()?x:b:(B=this.sub(A.mul(M)),O=M.add(B.div(A)),O)}else if(A.eq(w))return this.unsigned?_:g;if(this.isNegative())return A.isNegative()?this.neg().div(A.neg()):this.neg().div(A).neg();if(A.isNegative())return this.div(A.neg()).neg();O=g}for(B=this;B.gte(A);){M=Math.max(1,Math.floor(B.toNumber()/A.toNumber()));for(var X=Math.ceil(Math.log(M)/Math.LN2),G=X<=48?1:a(2,X-48),j=i(M),se=j.mul(A);se.isNegative()||se.gt(B);)M-=G,j=i(M,this.unsigned),se=j.mul(A);j.isZero()&&(j=x),O=O.add(j),B=B.sub(se)}return O},C.div=C.divide,C.modulo=function(A){return e(A)||(A=l(A)),this.sub(this.div(A).mul(A))},C.mod=C.modulo,C.not=function(){return s(~this.low,~this.high,this.unsigned)},C.and=function(A){return e(A)||(A=l(A)),s(this.low&A.low,this.high&A.high,this.unsigned)},C.or=function(A){return e(A)||(A=l(A)),s(this.low|A.low,this.high|A.high,this.unsigned)},C.xor=function(A){return e(A)||(A=l(A)),s(this.low^A.low,this.high^A.high,this.unsigned)},C.shiftLeft=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?s(this.low<<A,this.high<<A|this.low>>>32-A,this.unsigned):s(0,this.low<<A-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(A){return e(A)&&(A=A.toInt()),(A&=63)===0?this:A<32?s(this.low>>>A|this.high<<32-A,this.high>>A,this.unsigned):s(this.high>>A-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(A){if(e(A)&&(A=A.toInt()),A&=63,A===0)return this;var M=this.high;if(A<32){var B=this.low;return s(B>>>A|M<<32-A,M>>>A,this.unsigned)}else return A===32?s(M,0,this.unsigned):s(M>>>A-32,0,this.unsigned)},C.shru=C.shiftRightUnsigned,C.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},C.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},C.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},C.toBytesLE=function(){var S=this.high,A=this.low;return[A&255,A>>>8&255,A>>>16&255,A>>>24&255,S&255,S>>>8&255,S>>>16&255,S>>>24&255]},C.toBytesBE=function(){var S=this.high,A=this.low;return[S>>>24&255,S>>>16&255,S>>>8&255,S&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255]},t})});var kV=jl(tw=>{tw.read=function(t,e,r,o,n){var i,s,a=n*8-o-1,c=(1<<a)-1,l=c>>1,f=-7,u=r?n-1:0,d=r?-1:1,h=t[e+u];for(u+=d,i=h&(1<<-f)-1,h>>=-f,f+=a;f>0;i=i*256+t[e+u],u+=d,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=o;f>0;s=s*256+t[e+u],u+=d,f-=8);if(i===0)i=1-l;else{if(i===c)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,o),i=i-l}return(h?-1:1)*s*Math.pow(2,i-o)};tw.write=function(t,e,r,o,n,i){var s,a,c,l=i*8-n-1,f=(1<<l)-1,u=f>>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,p=o?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+u>=1?e+=d/c:e+=d*Math.pow(2,1-u),e*c>=2&&(s++,c/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(e*c-1)*Math.pow(2,n),s=s+u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;t[r+h]=a&255,h+=p,a/=256,n-=8);for(s=s<<n|a,l+=n;l>0;t[r+h]=s&255,h+=p,s/=256,l-=8);t[r+h-p]|=m*128}});var GV=jl((sit,WV)=>{"use strict";WV.exports=Ae;var mx=kV();function Ae(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ae.Varint=0;Ae.Fixed64=1;Ae.Bytes=2;Ae.Fixed32=5;var rw=(1<<16)*(1<<16),VV=1/rw,Wpe=12,jV=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");Ae.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var o=this.readVarint(),n=o>>3,i=this.pos;this.type=o&7,t(n,e,this),this.pos===i&&this.skip(o)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=gx(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=HV(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=gx(this.buf,this.pos)+gx(this.buf,this.pos+4)*rw;return this.pos+=8,t},readSFixed64:function(){var t=gx(this.buf,this.pos)+HV(this.buf,this.pos+4)*rw;return this.pos+=8,t},readFloat:function(){var t=mx.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=mx.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,o;return o=e[this.pos++],r=o&127,o<128||(o=e[this.pos++],r|=(o&127)<<7,o<128)||(o=e[this.pos++],r|=(o&127)<<14,o<128)||(o=e[this.pos++],r|=(o&127)<<21,o<128)?r:(o=e[this.pos],r|=(o&15)<<28,Gpe(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=Wpe&&jV?ime(this.buf,e,t):nme(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Ae.Bytes)return t.push(this.readVarint(e));var r=Bn(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Ae.Bytes)return t.push(this.readSVarint());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Ae.Bytes)return t.push(this.readBoolean());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Ae.Bytes)return t.push(this.readFloat());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Ae.Bytes)return t.push(this.readDouble());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Ae.Bytes)return t.push(this.readFixed32());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Ae.Bytes)return t.push(this.readSFixed32());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Ae.Bytes)return t.push(this.readFixed64());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Ae.Bytes)return t.push(this.readSFixed64());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===Ae.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ae.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ae.Fixed32)this.pos+=4;else if(e===Ae.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),_l(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),_l(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),_l(this.buf,t&-1,this.pos),_l(this.buf,Math.floor(t*VV),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),_l(this.buf,t&-1,this.pos),_l(this.buf,Math.floor(t*VV),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){$pe(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=sme(this.buf,t,this.pos);var r=this.pos-e;r>=128&&zV(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),mx.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),mx.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var o=this.pos-r;o>=128&&zV(r,o,this),this.pos=r-1,this.writeVarint(o),this.pos+=o},writeMessage:function(t,e,r){this.writeTag(t,Ae.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Kpe,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,qpe,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Qpe,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Zpe,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Jpe,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,eme,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,tme,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,rme,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,ome,e)},writeBytesField:function(t,e){this.writeTag(t,Ae.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ae.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ae.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ae.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ae.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ae.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ae.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ae.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ae.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ae.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function Gpe(t,e,r){var o=r.buf,n,i;if(i=o[r.pos++],n=(i&112)>>4,i<128||(i=o[r.pos++],n|=(i&127)<<3,i<128)||(i=o[r.pos++],n|=(i&127)<<10,i<128)||(i=o[r.pos++],n|=(i&127)<<17,i<128)||(i=o[r.pos++],n|=(i&127)<<24,i<128)||(i=o[r.pos++],n|=(i&1)<<31,i<128))return gl(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function Bn(t){return t.type===Ae.Bytes?t.readVarint()+t.pos:t.pos+1}function gl(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function $pe(t,e){var r,o;if(t>=0?(r=t%4294967296|0,o=t/4294967296|0):(r=~(-t%4294967296),o=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,o=o+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),Xpe(r,o,e),Ype(o,e)}function Xpe(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function Ype(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function zV(t,e,r){var o=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(o);for(var n=r.pos-1;n>=t;n--)r.buf[n+o]=r.buf[n]}function Kpe(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function qpe(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Zpe(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Jpe(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function Qpe(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function eme(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function tme(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function rme(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function ome(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function gx(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function _l(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function HV(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function nme(t,e,r){for(var o="",n=e;n<r;){var i=t[n],s=null,a=i>239?4:i>223?3:i>191?2:1;if(n+a>r)break;var c,l,f;a===1?i<128&&(s=i):a===2?(c=t[n+1],(c&192)===128&&(s=(i&31)<<6|c&63,s<=127&&(s=null))):a===3?(c=t[n+1],l=t[n+2],(c&192)===128&&(l&192)===128&&(s=(i&15)<<12|(c&63)<<6|l&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(c=t[n+1],l=t[n+2],f=t[n+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(s=(i&15)<<18|(c&63)<<12|(l&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,o+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),o+=String.fromCharCode(s),n+=a}return o}function ime(t,e,r){return jV.decode(t.subarray(e,r))}function sme(t,e,r){for(var o=0,n,i;o<e.length;o++){if(n=e.charCodeAt(o),n>55295&&n<57344)if(i)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}else n=i-55296<<10|n-56320|65536,i=null;else{n>56319||o+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var F_e={};ze(F_e,{A5Layer:()=>XD,AmbientLight:()=>oc,ArcLayer:()=>z_,Attribute:()=>Tn,AttributeManager:()=>pr,BitmapLayer:()=>H_,BrushingExtension:()=>rV,COORDINATE_SYSTEM:()=>Be,CPUAggregator:()=>$t,ClipExtension:()=>ax,CollisionFilterExtension:()=>PV,ColumnLayer:()=>Wo,CompassWidget:()=>lp,CompositeLayer:()=>Ne,ContextMenuWidget:()=>Tp,ContourLayer:()=>yH,Controller:()=>zt,DarkGlassTheme:()=>gb,DarkTheme:()=>n5,DataFilterExtension:()=>mV,Deck:()=>An,DeckGL:()=>Gh,DeckRenderer:()=>ys,DirectionalLight:()=>fn,FillStyleExtension:()=>CV,FirstPersonController:()=>Ss,FirstPersonView:()=>FB,FirstPersonViewport:()=>B_,FlyToInterpolator:()=>so,Fp64Extension:()=>_V,FullscreenWidget:()=>dp,GeoJsonLayer:()=>Os,GeohashLayer:()=>uz,GimbalWidget:()=>cp,GoogleMapsOverlay:()=>ep,GreatCircleLayer:()=>hU,GridCellLayer:()=>CF,GridLayer:()=>vH,H3ClusterLayer:()=>YU,H3HexagonLayer:()=>$c,HeatmapLayer:()=>zH,HexagonLayer:()=>kz,IconLayer:()=>Ec,IconWidget:()=>Cp,InfoWidget:()=>bp,Layer:()=>_e,LayerExtension:()=>st,LayerManager:()=>gs,LightGlassTheme:()=>mb,LightTheme:()=>o5,LightingEffect:()=>ai,LineLayer:()=>ZO,LinearInterpolator:()=>Ue,LoadingWidget:()=>Ip,MVTLayer:()=>az,MapController:()=>xn,MapView:()=>di,MapboxOverlay:()=>op,MaskExtension:()=>IV,OPERATION:()=>NI,OrbitController:()=>Cs,OrbitView:()=>NB,OrbitViewport:()=>R_,OrthographicController:()=>Es,OrthographicView:()=>D_,OrthographicViewport:()=>Ac,PathLayer:()=>Go,PathStyleExtension:()=>TV,PointCloudLayer:()=>e0,PointLight:()=>cc,PolygonLayer:()=>vi,PopupWidget:()=>Ap,PostProcessEffect:()=>nu,QuadkeyLayer:()=>wU,ResetViewWidget:()=>ap,S2Layer:()=>CU,ScatterplotLayer:()=>t0,ScenegraphLayer:()=>My,ScreenGridLayer:()=>Pz,ScreenshotWidget:()=>Mp,ScrollbarWidget:()=>da,SelectorWidget:()=>wp,SimpleMeshLayer:()=>Gs,SolidPolygonLayer:()=>Ti,TRANSITION_EVENTS:()=>cu,TerrainController:()=>ku,TerrainLayer:()=>Q6,Tesselator:()=>vn,TextLayer:()=>T0,ThemeWidget:()=>Rp,Tile3DLayer:()=>$6,TileLayer:()=>Ws,ToggleWidget:()=>Ep,TransitionInterpolator:()=>gn,TripsLayer:()=>$U,UNIT:()=>Pe,VERSION:()=>em,View:()=>Vt,Viewport:()=>ot,WebGLAggregator:()=>Qe,WebMercatorViewport:()=>Mt,Widget:()=>$,ZoomWidget:()=>sp,_AggregationLayer:()=>Zo,_ButtonGroup:()=>Yx,_CameraLight:()=>Kf,_Component:()=>bc,_ComponentState:()=>Ts,_CoordinatesGeocoder:()=>Ol,_CurrentLocationGeocoder:()=>nb,_DropdownMenu:()=>Qx,_GeoCellLayer:()=>Or,_GeocoderWidget:()=>up,_GlobeController:()=>ws,_GlobeView:()=>k_,_GlobeViewport:()=>Oo,_GoogleGeocoder:()=>tb,_IconButton:()=>Me,_LayersPass:()=>At,_MapboxGeocoder:()=>rb,_MultiIconLayer:()=>x0,_OpenCageGeocoder:()=>ob,_PickLayersPass:()=>Jr,_RangeInput:()=>Vl,_ScaleWidget:()=>fp,_SimpleMenu:()=>sa,_SplitterWidget:()=>hp,_StatsWidget:()=>Lp,_SunLight:()=>qf,_TerrainExtension:()=>FV,_TextBackgroundLayer:()=>A0,_Tile2DHeader:()=>Hs,_Tileset2D:()=>js,_TimelineWidget:()=>Pp,_WMSLayer:()=>Wc,_applyStyles:()=>xs,_compareProps:()=>xc,_count:()=>E_,_deepEqual:()=>ie,_fillArray:()=>Cg,_flatten:()=>kt,_getURLFromTemplate:()=>Yo,_memoize:()=>Yt,_mergeShaders:()=>mi,_registerLoggers:()=>Qp,_removeStyles:()=>Fg,assert:()=>ge,color:()=>Yr,createIterable:()=>Fe,fp64LowPart:()=>sc,getShaderAssembler:()=>hg,gouraudMaterial:()=>Xr,log:()=>N,phongMaterial:()=>nn,picking:()=>Se,project:()=>We,project32:()=>fe,project64:()=>ix,shadow:()=>rc});async function nr(t,e,r,o){return o._parse(t,e,r,o)}function le(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var _o={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},m5=_o.self||_o.window||_o.global||{},g5=_o.window||_o.self||_o.global||{},_5=_o.global||_o.self||_o.window||{},y5=_o.document||{};var Qo=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Jw=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),x5=Jw&&parseFloat(Jw[1])||0;zn();var wb="4.4.3",w5=wb[0]>="0"&&wb[0]<="9"?`v${wb}`:"";function P5(){let t=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=w5,globalThis.probe||={},globalThis.probe.loaders=t,t}var Wl=P5();var M5=t=>typeof t=="boolean",yo=t=>typeof t=="function",xo=t=>t!==null&&typeof t=="object",Vp=t=>xo(t)&&t.constructor==={}.constructor;var Pb=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,ba=t=>xo(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var Mb=t=>Boolean(t)&&yo(t[Symbol.iterator]),Rb=t=>Boolean(t)&&yo(t[Symbol.asyncIterator]);var ir=t=>typeof Response<"u"&&t instanceof Response||xo(t)&&yo(t.arrayBuffer)&&yo(t.text)&&yo(t.json);var sr=t=>typeof Blob<"u"&&t instanceof Blob;var mP=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||xo(t)&&yo(t.tee)&&yo(t.cancel)&&yo(t.getReader);var gP=t=>xo(t)&&yo(t.read)&&yo(t.pipe)&&M5(t.readable),Gl=t=>mP(t)||gP(t);function ji(t,e){return _P(t||{},e)}function _P(t,e,r=0){if(r>3)return e;let o={...t};for(let[n,i]of Object.entries(e))i&&typeof i=="object"&&!Array.isArray(i)?o[n]=_P(o[n]||{},e[n],r+1):o[n]=e[n];return o}function zp(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function Ib(t){return globalThis.loaders?.modules?.[t]||null}var yP="latest";function R5(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.3"),globalThis._loadersgl_.version}var Hp=R5();function yt(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var bo={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},L0e=bo.self||bo.window||bo.global||{},B0e=bo.window||bo.self||bo.global||{},O0e=bo.global||bo.self||bo.window||{},F0e=bo.document||{};var tt=typeof process!="object"||String(process)!=="[object process]"||process.browser,$l=typeof importScripts=="function",bP=typeof window<"u"&&typeof window.orientation<"u",xP=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),N0e=xP&&parseFloat(xP[1])||0;var Xl=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((o,n)=>{this._resolve=o,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){yt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){yt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Aa=class{terminate(){}};var Lb=new Map;function AP(t){yt(t.source&&!t.url||!t.source&&t.url);let e=Lb.get(t.source||t.url);return e||(t.url&&(e=I5(t.url),Lb.set(t.url,e)),t.source&&(e=TP(t.source),Lb.set(t.source,e))),yt(e),e}function I5(t){if(!t.startsWith("http"))return t;let e=L5(t);return TP(e)}function TP(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function L5(t){return`try {
importScripts('${t}');
} catch (error) {
console.error(error);
throw error;
}`}function Bb(t,e=!0,r){let o=r||new Set;if(t){if(vP(t))o.add(t);else if(vP(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let n in t)Bb(t[n],e,o)}}return r===void 0?Array.from(o):[]}function vP(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Ob=()=>{},Hn=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&tt||typeof Aa<"u"&&!tt}constructor(e){let{name:r,source:o,url:n}=e;yt(o||n),this.name=r,this.source=o,this.url=n,this.onMessage=Ob,this.onError=i=>console.log(i),this.worker=tt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ob,this.onError=Ob,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||Bb(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=AP({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let o=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Aa(o,{eval:!1,type:n})}else if(this.source)e=new Aa(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var Yl=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Hn.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},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(n,i,s)=>n.done(s),o=(n,i)=>n.error(i)){let n=new Promise(i=>(this.jobQueue.push({name:e,onMessage:r,onError:o,onStart:i}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let o=new Xl(r.name,e);e.onMessage=n=>r.onMessage(o,n.type,n.payload),e.onError=n=>r.onError(o,n),r.onStart(o);try{await o.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!tt||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++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Hn({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return bP?this.maxMobileConcurrency:this.maxConcurrency}};var B5={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Wi=class{props;workerPools=new Map;static isSupported(){return Hn.isSupported()}static getWorkerFarm(e={}){return Wi._workerFarm=Wi._workerFarm||new Wi({}),Wi._workerFarm.setProps(e),Wi._workerFarm}constructor(e){this.props={...B5},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:o,url:n}=e,i=this.workerPools.get(r);return i||(i=new Yl({name:r,source:o,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},jn=Wi;k(jn,"_workerFarm");function Fb(t,e={}){let r=e[t.id]||{},o=tt?`${t.id}-worker.js`:`${t.id}-worker-node.js`,n=r.workerUrl;if(!n&&t.id==="compression"&&(n=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(tt?n=`modules/${t.module}/dist/${o}`:n=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!n){let s=t.version;s==="latest"&&(s=yP);let a=s?`@${s}`:"";n=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${o}`}return yt(n),n}function Nb(t,e=Hp){yt(t,"no worker provided");let r=t.version;return!(!e||!r)}var Db={};function Kl(t={}){let e=t.useLocalLibraries??t.core?.useLocalLibraries,r=t.CDN??t.core?.CDN,o=t.modules;return{...e!==void 0?{useLocalLibraries:e}:{},...r!==void 0?{CDN:r}:{},...o!==void 0?{modules:o}:{}}}async function br(t,e=null,r={},o=null){return e&&(t=SP(t,e,r,o)),Db[t]=Db[t]||O5(t),await Db[t]}function SP(t,e,r={},o=null){if(r?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!r.useLocalLibraries&&t.startsWith("http"))return t;o=o||t;let n=r.modules||{};return n[o]?n[o]:tt?r.CDN?(yt(r.CDN.startsWith("http")),`${r.CDN}/${e}@${Hp}/dist/libs/${o}`):$l?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function O5(t){if(t.endsWith("wasm"))return await N5(t);if(!tt){let{requireFromFile:r}=globalThis.loaders||{};try{let o=await r?.(t);return o||!t.includes("/dist/libs/")?o:await r?.(t.replace("/dist/libs/","/src/libs/"))}catch(o){if(t.includes("/dist/libs/"))try{return await r?.(t.replace("/dist/libs/","/src/libs/"))}catch{}return console.error(o),null}}if($l)return importScripts(t);let e=await D5(t);return F5(e,t)}function F5(t,e){if(!tt){let{requireFromString:o}=globalThis.loaders||{};return o?.(t,e)}if($l)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function N5(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};if(tt||!e||t.startsWith("http"))return await(await fetch(t)).arrayBuffer();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${t}`)}}async function D5(t){let{readFileAsText:e}=globalThis.loaders||{};if(tt||!e||t.startsWith("http"))return await(await fetch(t)).text();try{return await e(t)}catch{if(t.includes("/dist/libs/"))return await e(t.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${t}`)}}function Ub(t,e){if(!jn.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!tt&&!r)return!1;let o=e?.worker??e?.core?.worker;return Boolean(t.worker&&o)}async function kb(t,e,r,o,n){let i=t.id,s=Fb(t,r),c=jn.getWorkerFarm(r?.core).getWorkerPool({name:i,url:s});r=JSON.parse(JSON.stringify(r)),o=JSON.parse(JSON.stringify(o||{}));let l=await c.startJob("process-on-worker",U5.bind(null,n));return l.postMessage("process",{input:e,options:r,context:o}),await(await l.result).result}async function U5(t,e,r,o){switch(r){case"done":e.done(o);break;case"error":e.error(new Error(o.error));break;case"process":let{id:n,input:i,options:s}=o;try{let a=await t(i,s);e.postMessage("done",{id:n,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:n,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function EP(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?CP(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?CP(t,0,e):""}function CP(t,e,r){if(t.byteLength<=e+r)return"";let o=new DataView(t),n="";for(let i=0;i<r;i++)n+=String.fromCharCode(o.getUint8(e+i));return n}function Vb(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${EP(t)}"`)}}function zb(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let o=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<o.length;++i)if(o[i]!==n[i])return!1;return!0}function Hb(...t){return wP(t)}function wP(t){let e=t.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),r=e.reduce((i,s)=>i+s.byteLength,0),o=new Uint8Array(r),n=0;for(let i of e)o.set(i,n),n+=i.byteLength;return o.buffer}function ql(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let o=e.reduce((s,a)=>s+a.length,0),n=new r(o),i=0;for(let s of e)n.set(s,i),i+=s.length;return n}function Gi(t,e,r){let o=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(o).buffer}function Wn(t,e){return le(t>=0),le(e>0),t+(e-1)&~(e-1)}function jb(t,e,r){let o;if(t instanceof ArrayBuffer)o=new Uint8Array(t);else{let n=t.byteOffset,i=t.byteLength;o=new Uint8Array(t.buffer||t.arrayBuffer,n,i)}return e.set(o,r),r+Wn(o.byteLength,4)}async function Wb(t){let e=[];for await(let r of t)e.push(k5(r));return Hb(...e)}function k5(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:o}=t;return PP(e,r,o)}return PP(t)}function PP(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}Xi();var V5="Queued Requests",z5="Active Requests",H5="Cancelled Requests",j5="Queued Requests Ever",W5="Active Requests Ever",G5={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Gn=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...G5,...e},this.stats=new Et({id:this.props.id}),this.stats.get(V5),this.stats.get(z5),this.stats.get(H5),this.stats.get(j5),this.stats.get(W5)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let o={handle:e,priority:0,getPriority:r},n=new Promise(i=>(o.resolve=i,o));return this.requestQueue.push(o),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){let{handle:r,resolve:o}=e,n=!1,i=()=>{n||(n=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,o?o({done:i}):Promise.resolve({done:i})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let o=this.requestQueue.shift();o&&this._issueRequest(o)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let o=e[r];this._updateRequest(o)||(e.splice(r,1),this.requestMap.delete(o.handle),r--)}e.sort((r,o)=>r.priority-o.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var $5="",RP={};function Jl(t){for(let e in RP)if(t.startsWith(e)){let r=RP[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${$5}${t}`),t}function jp(t){return t&&typeof t=="object"&&t.isBuffer}function va(t){if(jp(t))return t;if(t instanceof ArrayBuffer)return t;if(Pb(t))return Ta(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Ar(t){if(t instanceof ArrayBuffer)return t;if(Pb(t))return Ta(t);let{buffer:e,byteOffset:r,byteLength:o}=t;return e instanceof ArrayBuffer&&r===0&&o===e.byteLength?e:Ta(e,r,o)}function Ta(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}function Xb(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Ft={};ze(Ft,{dirname:()=>Y5,filename:()=>X5,join:()=>K5,resolve:()=>q5});function IP(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function X5(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function Y5(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function K5(...t){let e="/";return t=t.map((r,o)=>(o&&(r=r.replace(new RegExp(`^${e}`),"")),o!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function q5(...t){let e=[];for(let i=0;i<t.length;i++)e[i]=t[i];let r="",o=!1,n;for(let i=e.length-1;i>=-1&&!o;i--){let s;i>=0?s=e[i]:(n===void 0&&(n=IP()),s=n),s.length!==0&&(r=`${s}/${r}`,o=s.charCodeAt(0)===Ql)}return r=Z5(r,!o),o?`/${r}`:r.length>0?r:"."}var Ql=47,Yb=46;function Z5(t,e){let r="",o=-1,n=0,i,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)i=t.charCodeAt(a);else{if(i===Ql)break;i=Ql}if(i===Ql){if(!(o===a-1||n===1))if(o!==a-1&&n===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==Yb||r.charCodeAt(r.length-2)!==Yb){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Ql;--l);if(l!==c){r=l===-1?"":r.slice(0,l),o=a,n=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",o=a,n=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(o+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}o=a,n=0}else i===Yb&&n!==-1?++n:n=-1}return r}var Kb=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,r,o){o?this.options=ji({...o,core:Kb.defaultOptions},r):this.options={...r},this.data=e,this.url=typeof e=="string"?Jl(e):"",this.loadOptions=Q5(this.options.core?.loadOptions),this.fetch=J5(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}},Sa=Kb;k(Sa,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function J5(t){let e=t?.core?.fetch;if(e&&typeof e=="function")return(o,n)=>e(o,n);let r=t?.fetch;return r&&typeof r!="function"?o=>fetch(o,r):o=>fetch(o)}function Q5(t){let e={...t};t?.core&&(e.core={...t.core});let r=typeof e.baseUri=="string"?e.baseUri:void 0,o=typeof e.baseUrl=="string"?e.baseUrl:void 0;return(r!==void 0||o!==void 0)&&(e.core||={},e.core.baseUrl===void 0&&(e.core.baseUrl=o??r),delete e.baseUri,delete e.baseUrl),e}var $n=class{};k($n,"type","template"),k($n,"testURL",e=>!1);var Wp=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var rj=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,oj=/^([-\w.]+\/[-\w.+]+)/;function qb(t,e){return t.toLowerCase()===e.toLowerCase()}function LP(t){let e=oj.exec(t);return e?e[1]:t}function Zb(t){let e=rj.exec(t);return e?e[1]:""}var BP=/\?.*/;function OP(t){let e=t.match(BP);return e&&e[0]}function Xn(t){return t.replace(BP,"")}function FP(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Yi(t){return ir(t)?t.url:sr(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Ca(t){if(ir(t)){let e=t.headers.get("content-type")||"",r=Xn(t.url);return LP(e)||Zb(r)}return sr(t)?t.type||"":typeof t=="string"?Zb(t):""}function NP(t){return ir(t)?t.headers["content-length"]||-1:sr(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Gp(t){if(ir(t))return t;let e={},r=NP(t);r>=0&&(e["content-length"]=String(r));let o=Yi(t),n=Ca(t);n&&(e["content-type"]=n);let i=await ij(t);i&&(e["x-first-bytes"]=i),typeof t=="string"&&(t=new TextEncoder().encode(t));let s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:o}),s}async function DP(t){if(!t.ok)throw await nj(t)}async function nj(t){let e=FP(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let o={reason:t.statusText,url:t.url,response:t};try{let n=t.headers.get("Content-Type");o.reason=!t.bodyUsed&&n?.includes("application/json")?await t.json():await t.text()}catch{}return new Wp(r,o)}async function ij(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(o=>{let n=new FileReader;n.onload=i=>o(i?.target?.result),n.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${sj(r)}`}return null}function sj(t){let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);return btoa(e)}function aj(t){return!cj(t)&&!lj(t)}function cj(t){return t.startsWith("http:")||t.startsWith("https:")}function lj(t){return t.startsWith("data:")}async function Ea(t,e){if(typeof t=="string"){let r=Jl(t);return aj(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await Gp(t)}zn();var ef=new ct({id:"loaders.gl"}),$p=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Xp=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)}};var Yp={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new Xp,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Qo,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},UP={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"};var Jb=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Qb(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function eA(){let t=Qb();return t.globalOptions=t.globalOptions||{...Yp,core:{...Yp.core}},en(t.globalOptions)}function zP(t,e,r,o){return r=r||[],r=Array.isArray(r)?r:[r],fj(t,r),en(dj(e,t,o))}function en(t){let e=pj(t);HP(e);for(let r of Jb)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function fj(t,e){kP(t,null,Yp,UP,e);for(let r of e){let o=t&&t[r.id]||{},n=r.options&&r.options[r.id]||{},i=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};kP(o,r.id,n,i,e)}}function kP(t,e,r,o,n){let i=e||"Top level",s=e?`${e}.`:"";for(let a in t){let c=!e&&xo(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in o)ef.level>0&&ef.warn(`${i} loader option '${s}${a}' no longer supported, use '${o[a]}'`)();else if(!c&&ef.level>0){let u=uj(a,n);ef.warn(`${i} loader option '${s}${a}' not recognized. ${u}`)()}}}}function uj(t,e){let r=t.toLowerCase(),o="";for(let n of e)for(let i in n.options){if(t===i)return`Did you mean '${n.id}.${i}'?`;let s=i.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(o=o||`Did you mean '${n.id}.${i}'?`)}return o}function dj(t,e,r){let o=t.options||{},n={...o};o.core&&(n.core={...o.core}),HP(n),n.core?.log===null&&(n.core={...n.core,log:new $p}),VP(n,en(eA()));let i=en(e);return VP(n,i),hj(n,r),mj(n),n}function VP(t,e){for(let r in e)if(r in e){let o=e[r];Vp(o)&&Vp(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function hj(t,e){if(!e)return;t.core?.baseUrl!==void 0||(t.core||={},t.core.baseUrl=Ft.dirname(Xn(e)))}function pj(t){let e={...t};return t.core&&(e.core={...t.core}),e}function HP(t){t.baseUri!==void 0&&(t.core||={},t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(let r of Jb)if(t[r]!==void 0){let n=t.core=t.core||{};n[r]===void 0&&(n[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function mj(t){let e=t.core;if(e)for(let r of Jb)e[r]!==void 0&&(t[r]=e[r])}function tf(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function rf(t){le(t,"null loader"),le(tf(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var jP=()=>{let t=Qb();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function of(t){let e=jP();t=Array.isArray(t)?t:[t];for(let r of t){let o=rf(r);e.find(n=>o===n)||e.unshift(o)}}function WP(){return jP()}var gj=/\.([^.]+)$/;async function XP(t,e=[],r,o){if(!YP(t))return null;let n=en(r||{});if(n.core||={},t instanceof Response&&GP(t)){let s=await t.clone().text(),a=Kp(s,e,{...n,core:{...n.core,nothrow:!0}},o);if(a)return a}let i=Kp(t,e,{...n,core:{...n.core,nothrow:!0}},o);if(i)return i;if(sr(t)&&(t=await t.slice(0,10).arrayBuffer(),i=Kp(t,e,n,o)),!i&&t instanceof Response&&GP(t)){let s=await t.clone().text();i=Kp(s,e,n,o)}if(!i&&!n.core.nothrow)throw new Error(KP(t));return i}function GP(t){let e=Ca(t);return Boolean(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function Kp(t,e=[],r,o){if(!YP(t))return null;let n=en(r||{});if(n.core||={},e&&!Array.isArray(e))return rf(e);let i=[];e&&(i=i.concat(e)),n.core.ignoreRegisteredLoaders||i.push(...WP()),yj(i);let s=_j(t,i,n,o);if(!s&&!n.core.nothrow)throw new Error(KP(t));return s}function _j(t,e,r,o){let n=Yi(t),i=Ca(t),s=Xn(n)||o?.url,a=null,c="";return r?.core?.mimeType&&(a=tA(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||xj(e,s),c=c||(a?`matched url ${s}`:""),a=a||tA(e,i),c=c||(a?`matched MIME type ${i}`:""),a=a||Aj(e,t),c=c||(a?`matched initial data ${qP(t)}`:""),r?.core?.fallbackMimeType&&(a=a||tA(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${i}`:"")),c&&Wl.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function YP(t){return!(t instanceof Response&&t.status===204)}function KP(t){let e=Yi(t),r=Ca(t),o="No valid loader found (";o+=e?`${Ft.filename(e)}, `:"no url provided, ",o+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let n=t?qP(t):"";return o+=n?` first bytes: "${n}"`:"first bytes: not available",o+=")",o}function yj(t){for(let e of t)rf(e)}function xj(t,e){let r=e&&gj.exec(e),o=r&&r[1];return o?bj(t,o):null}function bj(t,e){e=e.toLowerCase();for(let r of t)for(let o of r.extensions)if(o.toLowerCase()===e)return r;return null}function tA(t,e){for(let r of t)if(r.mimeTypes?.some(o=>qb(e,o))||qb(e,`application/x.${r.id}`))return r;return null}function Aj(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(Tj(e,r))return r}else if(ArrayBuffer.isView(e)){if($P(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&$P(e,0,r))return r;return null}function Tj(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(o=>t.startsWith(o))}function $P(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>vj(t,e,r,n))}function vj(t,e,r,o){if(ba(o))return zb(o,t,o.byteLength);switch(typeof o){case"function":return o(Ar(t));case"string":let n=rA(t,e,o.length);return o===n;default:return!1}}function qP(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?rA(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?rA(t,0,e):""}function rA(t,e,r){if(t.byteLength<e+r)return"";let o=new DataView(t),n="";for(let i=0;i<r;i++)n+=String.fromCharCode(o.getUint8(e+i));return n}var Sj=256*1024;function*ZP(t,e){let r=e?.chunkSize||Sj,o=0,n=new TextEncoder;for(;o<t.length;){let i=Math.min(t.length-o,r),s=t.slice(o,o+i);o+=i,yield Ar(n.encode(s))}}function*JP(t,e={}){let{chunkSize:r=262144}=e,o=0;for(;o<t.byteLength;){let n=Math.min(t.byteLength-o,r),i=new ArrayBuffer(n),s=new Uint8Array(t,o,n);new Uint8Array(i).set(s),o+=n,yield i}}async function*QP(t,e){let r=e?.chunkSize||1048576,o=0;for(;o<t.size;){let n=o+r,i=await t.slice(o,n).arrayBuffer();o=n,yield i}}function oA(t,e){return Qo?Cj(t,e):Ej(t,e)}async function*Cj(t,e){let r=t.getReader(),o;try{for(;;){let n=o||r.read();e?._streamReadAhead&&(o=r.read());let{done:i,value:s}=await n;if(i)return;yield va(s)}}catch{r.releaseLock()}}async function*Ej(t,e){for await(let r of t)yield va(r)}function eM(t,e){if(typeof t=="string")return ZP(t,e);if(t instanceof ArrayBuffer)return JP(t,e);if(sr(t))return QP(t,e);if(Gl(t))return oA(t,e);if(ir(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return oA(r,e)}throw new Error("makeIterator")}var tM="Cannot convert supplied data type";function wj(t,e,r){if(e.text&&typeof t=="string")return t;if(jp(t)&&(t=t.buffer),ba(t)){let o=Xb(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(o):va(o)}throw new Error(tM)}async function rM(t,e,r){if(typeof t=="string"||ba(t))return wj(t,e,r);if(sr(t)&&(t=await Gp(t)),ir(t))return await DP(t),e.binary?await t.arrayBuffer():await t.text();if(Gl(t)&&(t=eM(t,r)),Mb(t)||Rb(t))return Wb(t);throw new Error(tM)}function qp(t,e){let r=eA(),o=t||r,n=o.fetch??o.core?.fetch;return typeof n=="function"?n:xo(n)?i=>Ea(i,n):e?.fetch?e?.fetch:Ea}function oM(t,e,r){if(r)return r;let o={fetch:qp(e,t),...t};if(o.url){let n=Xn(o.url);o.baseUrl=n,o.queryString=OP(o.url),o.filename=Ft.filename(n),o.baseUrl=Ft.dirname(n)}return Array.isArray(o.loaders)||(o.loaders=null),o}function nM(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let o=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...o]:o}return r&&r.length?r:void 0}async function Yn(t,e,r,o){e&&!Array.isArray(e)&&!tf(e)&&(o=void 0,r=e,e=void 0),t=await t,r=r||{};let n=Yi(t),s=nM(e,o),a=await XP(t,s,r);if(!a)return null;let c=zP(r,a,s,n);return o=oM({url:n,_parse:Yn,loaders:s},c,o||null),await Pj(a,t,c,o)}async function Pj(t,e,r,o){if(Nb(t),r=ji(t.options,r),ir(e)){let{ok:i,redirected:s,status:a,statusText:c,type:l,url:f}=e,u=Object.fromEntries(e.headers.entries());o.response={headers:u,ok:i,redirected:s,status:a,statusText:c,type:l,url:f}}e=await rM(e,t,r);let n=t;if(n.parseTextSync&&typeof e=="string")return n.parseTextSync(e,r,o);if(Ub(t,r))return await kb(t,e,r,o,Yn);if(n.parseText&&typeof e=="string")return await n.parseText(e,r,o);if(n.parse)return await n.parse(e,r,o);throw yt(!n.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}function iM(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function sM(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function aM(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function nA(t){return sM(t)||aM(t)}function Ki(t){let e=1/0,r=1/0,o=1/0,n=-1/0,i=-1/0,s=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],d=a[l+2];e=f<e?f:e,r=u<r?u:r,o=d<o?d:o,n=f>n?f:n,i=u>i?u:i,s=d>s?d:s}return[[e,r,o],[n,i,s]]}function iA(t,e,r){let o=iM(e.value),n=r||cM(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:o}]},nullable:!1,metadata:n}}function cM(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}async function Kn(t,e,r,o){let n,i;!Array.isArray(e)&&!tf(e)?(n=[],i=e,o=void 0):(n=e,i=r);let s=qp(i),a=t;return typeof t=="string"&&(a=await s(t)),sr(t)&&(a=await s(t)),typeof t=="string"&&(en(i||{}).core?.baseUrl||(i={...i,core:{...i?.core,baseUrl:t}})),Array.isArray(n)?await Yn(a,n,i):await Yn(a,n,i)}var lM="4.4.3";var Mj=globalThis.loaders?.parseImageNode,sA=typeof Image<"u",aA=typeof ImageBitmap<"u",Rj=Boolean(Mj),cA=Qo?!0:Rj;function fM(t){switch(t){case"auto":return aA||sA||cA;case"imagebitmap":return aA;case"image":return sA;case"data":return cA;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function uM(){if(aA)return"imagebitmap";if(sA)return"image";if(cA)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function dM(t){let e=Ij(t);if(!e)throw new Error("Not an image");return e}function nf(t){switch(dM(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function Ij(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var Lj=/^data:image\/svg\+xml/,Bj=/\.svg((\?|#).*)?$/;function Zp(t){return t&&(Lj.test(t)||Bj.test(t))}function hM(t,e){if(Zp(e)){let o=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(o=unescape(encodeURIComponent(o)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(o)}`}return lA(t,e)}function lA(t,e){if(Zp(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Jp(t,e,r){let o=hM(t,r),n=self.URL||self.webkitURL,i=typeof o!="string"&&n.createObjectURL(o);try{return await Oj(i||o,e)}finally{i&&n.revokeObjectURL(i)}}async function Oj(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((o,n)=>{try{r.onload=()=>o(r),r.onerror=i=>{let s=i instanceof Error?i.message:"error";n(new Error(s))}}catch(i){n(i)}})}var pM=!0;async function mM(t,e,r){let o;Zp(r)?o=await Jp(t,e,r):o=lA(t,r);let n=e&&e.imagebitmap;return await Fj(o,n)}async function Fj(t,e=null){if((Nj(e)||!pM)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),pM=!1}return await createImageBitmap(t)}function Nj(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function gM(t){return!Vj(t,"ftyp",4)||!(t[8]&96)?null:Dj(t)}function Dj(t){switch(Uj(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Uj(t,e,r){return String.fromCharCode(...t.slice(e,r))}function kj(t){return[...t].map(e=>e.charCodeAt(0))}function Vj(t,e,r=0){let o=kj(e);for(let n=0;n<o.length;++n)if(o[n]!==t[n+r])return!1;return!0}var Ao=!1,sf=!0;function qi(t){let e=af(t);return Hj(e)||Gj(e)||jj(e)||Wj(e)||zj(e)}function zj(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=gM(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function Hj(t){let e=af(t);return e.byteLength>=24&&e.getUint32(0,Ao)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Ao),height:e.getUint32(20,Ao)}:null}function jj(t){let e=af(t);return e.byteLength>=10&&e.getUint32(0,Ao)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,sf),height:e.getUint16(8,sf)}:null}function Wj(t){let e=af(t);return e.byteLength>=14&&e.getUint16(0,Ao)===16973&&e.getUint32(2,sf)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,sf),height:e.getUint32(22,sf)}:null}function Gj(t){let e=af(t);if(!(e.byteLength>=3&&e.getUint16(0,Ao)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:o,sofMarkers:n}=$j(),i=2;for(;i+9<e.byteLength;){let s=e.getUint16(i,Ao);if(n.has(s))return{mimeType:"image/jpeg",height:e.getUint16(i+5,Ao),width:e.getUint16(i+7,Ao)};if(!o.has(s))return null;i+=2,i+=e.getUint16(i,Ao)}return null}function $j(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function af(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function _M(t,e){let{mimeType:r}=qi(t)||{},o=globalThis.loaders?.parseImageNode;return le(o),await o(t,r)}async function yM(t,e,r){e=e||{};let n=(e.image||{}).type||"auto",{url:i}=r||{},s=Xj(n),a;switch(s){case"imagebitmap":a=await mM(t,e,i);break;case"image":a=await Jp(t,e,i);break;case"data":a=await _M(t,e);break;default:le(!1)}return n==="data"&&(a=nf(a)),a}function Xj(t){switch(t){case"auto":case"data":return uM();default:return fM(t),t}}var Yj=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],Kj=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],qj={image:{type:"auto",decode:!0}},qn={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:lM,mimeTypes:Kj,extensions:Yj,parse:yM,tests:[t=>Boolean(qi(new DataView(t)))],options:qj};var fA={};function uA(t){if(fA[t]===void 0){let e=Qo?Jj(t):Zj(t);fA[t]=e}return fA[t]}function Zj(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,o=globalThis.loaders?.parseImageNode;return Boolean(o)&&r.includes(t)}function Jj(t){switch(t){case"image/avif":case"image/webp":return Qj(t);default:return!0}}function Qj(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}zn();var eW=new ct({id:"deck"}),N=eW;var dA={};function Qp(t){dA=t}function He(t,e,r,o){N.level>0&&dA[t]&&dA[t].call(null,e,r,o)}function tW(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var xM={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:tW,parseTextSync:JSON.parse};function rW(){let t="9.3.7",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(N.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:N,_registerLoggers:Qp},of([xM,[qn,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var em=rW();function Zi(t,e){if(!t){let r=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,Zi),r}}var hA={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function AM(t){let e={};for(let[r,o]of Object.entries(t))e[r]=oW(o);return e}function oW(t){let e=bM(t);if(e!=="object")return{value:t,...hA[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...hA[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=bM(t.value),{...t,...hA[e],type:e}):{type:"object",value:null};throw new Error("props")}function bM(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var TM=`#ifdef MODULE_LOGDEPTH
logdepth_adjustPosition(gl_Position);
#endif
`,vM=`#ifdef MODULE_MATERIAL
fragColor = material_filterColor(fragColor);
#endif
#ifdef MODULE_LIGHTING
fragColor = lighting_filterColor(fragColor);
#endif
#ifdef MODULE_FOG
fragColor = fog_filterColor(fragColor);
#endif
#ifdef MODULE_PICKING
fragColor = picking_filterHighlightColor(fragColor);
fragColor = picking_filterPickingColor(fragColor);
#endif
#ifdef MODULE_LOGDEPTH
logdepth_setFragDepth();
#endif
`;var nW={vertex:TM,fragment:vM},SM=/void\s+main\s*\([^)]*\)\s*\{\n?/,CM=/}\n?[^{}]*$/,pA=[],cf="__LUMA_INJECT_DECLARATIONS__";function EM(t){let e={vertex:{},fragment:{}};for(let r in t){let o=t[r],n=iW(r);typeof o=="string"&&(o={order:0,injection:o}),e[n][r]=o}return e}function iW(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function lf(t,e,r,o=!1){let n=e==="vertex";for(let i in r){let s=r[i];s.sort((c,l)=>c.order-l.order),pA.length=s.length;for(let c=0,l=s.length;c<l;++c)pA[c]=s[c].injection;let a=`${pA.join(`
`)}
`;switch(i){case"vs:#decl":n&&(t=t.replace(cf,a));break;case"vs:#main-start":n&&(t=t.replace(SM,c=>c+a));break;case"vs:#main-end":n&&(t=t.replace(CM,c=>a+c));break;case"fs:#decl":n||(t=t.replace(cf,a));break;case"fs:#main-start":n||(t=t.replace(SM,c=>c+a));break;case"fs:#main-end":n||(t=t.replace(CM,c=>a+c));break;default:t=t.replace(i,c=>c+a)}}return t=t.replace(cf,""),o&&(t=t.replace(/\}\s*$/,i=>i+nW[e])),t}function Ji(t){t.map(e=>tm(e))}function tm(t){if(t.instance)return;Ji(t.dependencies||[]);let{propTypes:e={},deprecations:r=[],inject:o={}}=t,n={normalizedInjections:EM(o),parsedDeprecations:sW(r)};e&&(n.propValidators=AM(e)),t.instance=n;let i={};e&&(i=Object.entries(e).reduce((s,[a,c])=>{let l=c?.value;return l&&(s[a]=l),s},{})),t.defaultUniforms={...t.defaultUniforms,...i}}function mA(t,e,r){t.deprecations?.forEach(o=>{o.regex?.test(e)&&(o.deprecated?r.deprecated(o.old,o.new)():r.removed(o.old,o.new)())})}function sW(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function wa(t){Ji(t);let e={},r={};wM({modules:t,level:0,moduleMap:e,moduleDepth:r});let o=Object.keys(r).sort((n,i)=>r[i]-r[n]).map(n=>e[n]);return Ji(o),o}function wM(t){let{modules:e,level:r,moduleMap:o,moduleDepth:n}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)o[i.name]=i,(n[i.name]===void 0||n[i.name]<r)&&(n[i.name]=r);for(let i of e)i.dependencies&&wM({modules:i.dependencies,level:r+1,moduleMap:o,moduleDepth:n})}var aW=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,cW=/((?: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 MM(t){return`${t.name}Uniforms`}function lW(t,e){let r=e==="wgsl"?t.source:e==="vertex"?t.vs:t.fs;if(!r)return null;let o=MM(t);return uW(r,e==="wgsl"?"wgsl":"glsl",o)}function fW(t,e){let r=Object.keys(t.uniformTypes||{});if(!r.length)return null;let o=lW(t,e);return o?{moduleName:t.name,uniformBlockName:MM(t),stage:e,expectedUniformNames:r,actualUniformNames:o,matches:pW(r,o)}:null}function RM(t,e,r={}){let o=fW(t,e);if(!o||o.matches)return o;let n=mW(o);return r.log?.error?.(n,o)(),r.throwOnError!==!1&&Zi(!1,n),o}function IM(t){let e=[],r=gW(t);for(let o of r.matchAll(cW)){let n=o[1]?.trim()||null;e.push({blockName:o[2],body:o[3],instanceName:o[4]||null,layoutQualifier:n,hasLayoutQualifier:Boolean(n),isStd140:Boolean(n&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(n))})}return e}function LM(t,e,r,o){let n=IM(t).filter(s=>!s.isStd140),i=new Set;for(let s of n){if(i.has(s.blockName))continue;i.add(s.blockName);let a=o?.label?`${o.label} `:"",c=s.hasLayoutQualifier?`declares ${_W(s.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${s.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(l,s)()}return n}function uW(t,e,r){let o=e==="wgsl"?dW(t,r):hW(t,r);if(!o)return null;let n=[];for(let i of o.split(`
`)){let s=i.replace(/\/\/.*$/,"").trim();if(!s||s.startsWith("#"))continue;let a=e==="wgsl"?s.match(/^([A-Za-z0-9_]+)\s*:/):s.match(aW);a&&n.push(a[1])}return n}function dW(t,e){let r=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(t);if(!r)return null;let o=t.indexOf("{",r.index);if(o<0)return null;let n=0;for(let i=o;i<t.length;i++){let s=t[i];if(s==="{"){n++;continue}if(s==="}"&&(n--,n===0))return t.slice(o+1,i)}return null}function hW(t,e){return IM(t).find(o=>o.blockName===e)?.body||null}function pW(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function mW(t){let{expectedUniformNames:e,actualUniformNames:r}=t,o=e.filter(a=>!r.includes(a)),n=r.filter(a=>!e.includes(a)),i=[`Expected ${e.length} fields, found ${r.length}.`],s=yW(e,r);return s&&i.push(s),o.length&&i.push(`Missing from shader block (${o.length}): ${PM(o)}.`),n.length&&i.push(`Unexpected in shader block (${n.length}): ${PM(n)}.`),e.length<=12&&r.length<=12&&(o.length||n.length)&&(i.push(`Expected: ${e.join(", ")}.`),i.push(`Actual: ${r.join(", ")}.`)),`${t.moduleName}: ${t.stage} shader uniform block ${t.uniformBlockName} does not match module.uniformTypes. ${i.join(" ")}`}function gW(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function _W(t){return t.replace(/\s+/g," ").trim()}function yW(t,e){let r=Math.min(t.length,e.length);for(let o=0;o<r;o++)if(t[o]!==e[o])return`First mismatch at field ${o+1}: expected ${t[o]}, found ${e[o]}.`;return t.length>e.length?`Shader block ends after field ${e.length}; expected next field ${t[e.length]}.`:e.length>t.length?`Shader block has extra field ${e.length}: ${e[t.length]}.`:null}function PM(t,e=8){if(t.length<=e)return t.join(", ");let r=t.length-e;return`${t.slice(0,e).join(", ")}, ... (${r} more)`}function BM(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
// Apple optimizes away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`;case"nvidia":return`#define NVIDIA_GPU
// Nvidia optimizes away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
`;case"intel":return`#define INTEL_GPU
// Intel optimizes away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
// Intel's built-in 'tan' function doesn't have acceptable precision
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`;case"amd":return`#define AMD_GPU
`;default:return`#define DEFAULT_GPU
// Prevent driver from optimizing away the calculation necessary for emulated fp64
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
// Headless Chrome's software shader 'tan' function doesn't have acceptable precision
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
// If the GPU doesn't have full 32 bits precision, will causes overflow
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`}}function FM(t,e){if(Number(t.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return t=OM(t,xW),t;case"fragment":return t=OM(t,bW),t;default:throw new Error(e)}}var NM=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],xW=[...NM,[gA("attribute"),"in $1"],[gA("varying"),"out $1"]],bW=[...NM,[gA("varying"),"in $1"]];function OM(t,e){for(let[r,o]of e)t=t.replace(r,o);return t}function gA(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function _A(t,e){let r="";for(let o in t){let n=t[o];if(r+=`void ${n.signature} {
`,n.header&&(r+=` ${n.header}`),e[o]){let i=e[o];i.sort((s,a)=>s.order-a.order);for(let s of i)r+=` ${s.injection}
`}n.footer&&(r+=` ${n.footer}`),r+=`}
`}return r}function yA(t){let e={vertex:{},fragment:{}};for(let r of t){let o,n;typeof r!="string"?(o=r,n=o.hook):(o={},n=r),n=n.trim();let[i,s]=n.split(":"),a=n.replace(/\(.+/,""),c=Object.assign(o,{signature:s});switch(i){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(i)}}return e}function DM(t,e){return{name:AW(t,e),language:"glsl",version:TW(t)}}function AW(t,e="unnamed"){let o=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return o?o[1]:e}function TW(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let o=parseInt(r[1],10);Number.isFinite(o)&&(e=o)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var ar="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Tr="\\s*",Pa=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}@group\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Tr}@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}${ar}`,"g")],rm=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}@group\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Tr}@binding\\(\\s*(auto|\\d+)\\s*\\)${Tr}${ar}`,"g")],UM=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Tr}@group\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Tr}@binding\\(\\s*(\\d+)\\s*\\)${Tr}${ar}`,"g")],vW=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${ar}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ar}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${ar}`,"g")];function om(t){let e=t.split(""),r=0,o=0,n=!1,i=!1,s=!1;for(;r<t.length;){let a=t[r],c=t[r+1];if(i){s?s=!1:a==="\\"?s=!0:a==='"'&&(i=!1),r++;continue}if(n){a===`
`||a==="\r"?n=!1:e[r]=" ",r++;continue}if(o>0){if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",o++,r+=2;continue}if(a==="*"&&c==="/"){e[r]=" ",e[r+1]=" ",o--,r+=2;continue}a!==`
`&&a!=="\r"&&(e[r]=" "),r++;continue}if(a==='"'){i=!0,r++;continue}if(a==="/"&&c==="/"){e[r]=" ",e[r+1]=" ",n=!0,r+=2;continue}if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",o=1,r+=2;continue}r++}return e.join("")}function Qi(t,e){let r=om(t),o=[];for(let n of e){n.lastIndex=0;let i;for(i=n.exec(r);i;){let s=n===e[0],a=i.index,c=i[0].length;o.push({match:t.slice(a,a+c),index:a,length:c,bindingToken:i[s?1:2],groupToken:i[s?2:1],accessDeclaration:i[3]?.trim(),name:i[4]}),i=n.exec(r)}}return o.sort((n,i)=>n.index-i.index)}function xA(t,e,r){let o=Qi(t,e);if(!o.length)return t;let n="",i=0;for(let s of o)n+=t.slice(i,s.index),n+=r(s),i=s.index+s.length;return n+=t.slice(i),n}function bA(t){return/@binding\(\s*auto\s*\)/.test(om(t))}function kM(t,e){return Qi(t,e===Pa||e===rm?vW:e).find(o=>o.bindingToken==="auto")}var VM=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${ar}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${ar}\\s*:\\s*([^;]+);`,"g")];function nm(t,e=[]){let r=om(t),o=new Map;for(let i of e)o.set(zM(i.name,i.group,i.location),i.moduleName);let n=[];for(let i of VM){i.lastIndex=0;let s;for(s=i.exec(r);s;){let a=i===VM[0],c=Number(s[a?1:2]),l=Number(s[a?2:1]),f=s[3]?.trim(),u=s[4],d=s[5].trim(),h=o.get(zM(u,l,c));n.push(SW({name:u,group:l,binding:c,owner:h?"module":"application",moduleName:h,accessDeclaration:f,resourceType:d})),s=i.exec(r)}}return n.sort((i,s)=>i.group!==s.group?i.group-s.group:i.binding!==s.binding?i.binding-s.binding:i.name.localeCompare(s.name))}function SW(t){let e={name:t.name,group:t.group,binding:t.binding,owner:t.owner,kind:"unknown",moduleName:t.moduleName,resourceType:t.resourceType};if(t.accessDeclaration){let r=t.accessDeclaration.split(",").map(o=>o.trim());if(r[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let o=r[1]||"read_write";return{...e,kind:o==="read"?"read-only-storage":"storage",access:o}}}return t.resourceType==="sampler"||t.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:t.resourceType==="sampler_comparison"?"comparison":"filtering"}:t.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:EW(t.resourceType),viewDimension:HM(t.resourceType)}:t.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:HM(t.resourceType),sampleType:CW(t.resourceType),multisampled:t.resourceType.startsWith("texture_multisampled_")}:e}function zM(t,e,r){return`${e}:${r}:${t}`}function HM(t){if(t.includes("cube_array"))return"cube-array";if(t.includes("2d_array"))return"2d-array";if(t.includes("cube"))return"cube";if(t.includes("3d"))return"3d";if(t.includes("2d"))return"2d";if(t.includes("1d"))return"1d"}function CW(t){if(t.startsWith("texture_depth_"))return"depth";if(t.includes("<i32>"))return"sint";if(t.includes("<u32>"))return"uint";if(t.includes("<f32>"))return"float"}function EW(t){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(t)?.[1]}var AA=`
${cf}
`,ff=100,wW=`precision highp float;
`;function $M(t){let e=wa(t.modules||[]),{source:r,bindingAssignments:o}=PW(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e});return{source:r,getUniforms:YM(e),bindingAssignments:o,bindingTable:nm(r,o)}}function XM(t){let{vs:e,fs:r}=t,o=wa(t.modules||[]);return{vs:jM(t.platformInfo,{...t,source:e,stage:"vertex",modules:o}),fs:jM(t.platformInfo,{...t,source:r,stage:"fragment",modules:o}),getUniforms:YM(o)}}function PW(t,e){let{source:r,stage:o,modules:n,hookFunctions:i=[],inject:s={},log:a}=e;Zi(typeof r=="string","shader source must be a string");let c=r,l="",f=yA(i),u={},d={},h={};for(let y in s){let b=typeof s[y]=="string"?{injection:s[y],order:0}:s[y],T=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(T){let v=T[2],w=T[3];v?w==="decl"?d[y]=[b]:h[y]=[b]:u[y]=[b]}else h[y]=[b]}let p=n,m=IW(c),g=RW(m.source),_=FW(p,e._bindingRegistry,g),x=[];for(let y of p){a&&mA(y,c,a);let b=LW(KM(y,"wgsl",a),y,{usedBindingsByGroup:g,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:_});x.push(...b.bindingAssignments);let T=b.source;l+=T;let v=y.injections?.[o]||{};for(let w in v){let C=/^(v|f)s:#([\w-]+)$/.exec(w);if(C){let A=C[2]==="decl"?d:h;A[w]=A[w]||[],A[w].push(v[w])}else u[w]=u[w]||[],u[w].push(v[w])}}return l+=AA,l=lf(l,o,d),l+=_A(f[o],u),l+=VW(x),l+=m.source,l=lf(l,o,h),kW(l),{source:l,bindingAssignments:x}}function jM(t,e){let{source:r,stage:o,language:n="glsl",modules:i,defines:s={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:f}=e;Zi(typeof r=="string","shader source must be a string");let u=n==="glsl"?DM(r).version:-1,d=t.shaderLanguageVersion,h=u===100?"#version 100":"#version 300 es",m=r.split(`
`).slice(1).join(`
`),g={};i.forEach(v=>{Object.assign(g,v.defines)}),Object.assign(g,s);let _="";switch(n){case"wgsl":break;case"glsl":_=l?`${h}
// ----- PROLOGUE -------------------------
${`#define SHADER_TYPE_${o.toUpperCase()}`}
${BM(t)}
${o==="fragment"?wW:""}
// ----- APPLICATION DEFINES -------------------------
${MW(g)}
`:`${h}
`;break}let x=yA(a),y={},b={},T={};for(let v in c){let w=typeof c[v]=="string"?{injection:c[v],order:0}:c[v],C=/^(v|f)s:(#)?([\w-]+)$/.exec(v);if(C){let S=C[2],A=C[3];S?A==="decl"?b[v]=[w]:T[v]=[w]:y[v]=[w]}else T[v]=[w]}for(let v of i){f&&mA(v,m,f);let w=KM(v,o,f);_+=w;let C=v.instance?.normalizedInjections[o]||{};for(let S in C){let A=/^(v|f)s:#([\w-]+)$/.exec(S);if(A){let B=A[2]==="decl"?b:T;B[S]=B[S]||[],B[S].push(C[S])}else y[S]=y[S]||[],y[S].push(C[S])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=AA,_=lf(_,o,b),_+=_A(x[o],y),_+=m,_=lf(_,o,T),n==="glsl"&&u!==d&&(_=FM(_,o)),n==="glsl"&&LM(_,o,f),_.trim()}function YM(t){return function(r){let o={};for(let n of t){let i=n.getUniforms?.(r,o);Object.assign(o,i)}return o}}function MW(t={}){let e="";for(let r in t){let o=t[r];(o||Number.isFinite(o))&&(e+=`#define ${r.toUpperCase()} ${t[r]}
`)}return e}function KM(t,e,r){let o;switch(e){case"vertex":o=t.vs||"";break;case"fragment":o=t.fs||"";break;case"wgsl":o=t.source||"";break;default:Zi(!1)}if(!t.name)throw new Error("Shader module must have a name");RM(t,e,{log:r});let n=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),i=`// ----- MODULE ${t.name} ---------------
`;return e!=="wgsl"&&(i+=`#define MODULE_${n}
`),i+=`${o}
`,i}function RW(t){let e=new Map;for(let r of Qi(t,UM)){let o=Number(r.bindingToken),n=Number(r.groupToken);TA(n,o,r.name),Ma(e,n,o,`application binding "${r.name}"`)}return e}function IW(t){let e=Qi(t,rm),r=new Map;for(let i of e){if(i.bindingToken==="auto")continue;let s=Number(i.bindingToken),a=Number(i.groupToken);TA(a,s,i.name),Ma(r,a,s,`application binding "${i.name}"`)}let o={sawSupportedBindingDeclaration:e.length>0},n=xA(t,rm,i=>OW(i,r,o));if(bA(t)&&!o.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:n}}function LW(t,e,r){let o=[],i={sawSupportedBindingDeclaration:Qi(t,Pa).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},s=xA(t,Pa,a=>BW(a,{module:e,context:r,bindingAssignments:o,relocationState:i}));if(bA(t)&&!i.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:s,bindingAssignments:o}}function BW(t,e){let{module:r,context:o,bindingAssignments:n,relocationState:i}=e,{match:s,bindingToken:a,groupToken:c,name:l}=t,f=Number(c);if(a==="auto"){let d=qM(f,r.name,l),h=o.bindingRegistry?.get(d),p=h!==void 0?h:i.nextHintedBindingLocation===null?GM(f,o.usedBindingsByGroup):GM(f,o.usedBindingsByGroup,i.nextHintedBindingLocation);return WM(r.name,f,p,l),h!==void 0&&NW(o.reservedBindingKeysByGroup,f,p,d)?(n.push({moduleName:r.name,name:l,group:f,location:p}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Ma(o.usedBindingsByGroup,f,p,`module "${r.name}" binding "${l}"`),o.bindingRegistry?.set(d,p),n.push({moduleName:r.name,name:l,group:f,location:p}),i.nextHintedBindingLocation!==null&&h===void 0&&(i.nextHintedBindingLocation=p+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let u=Number(a);return WM(r.name,f,u,l),Ma(o.usedBindingsByGroup,f,u,`module "${r.name}" binding "${l}"`),n.push({moduleName:r.name,name:l,group:f,location:u}),s}function OW(t,e,r){let{match:o,bindingToken:n,groupToken:i,name:s}=t,a=Number(i);if(n==="auto"){let c=UW(a,e);return TA(a,c,s),Ma(e,a,c,`application binding "${s}"`),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return r.sawSupportedBindingDeclaration=!0,o}function FW(t,e,r){let o=new Map;if(!e)return o;for(let n of t)for(let i of DW(n)){let s=qM(i.group,n.name,i.name),a=e.get(s);if(a!==void 0){let c=o.get(i.group)||new Map,l=c.get(a);if(l&&l!==s)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${s}": group ${i.group}, binding ${a}.`);Ma(r,i.group,a,`registered module binding "${s}"`),c.set(a,s),o.set(i.group,c)}}return o}function NW(t,e,r,o){let n=t.get(e);if(!n)return!1;let i=n.get(r);if(!i)return!1;if(i!==o)throw new Error(`Registered module binding "${o}" collided with "${i}": group ${e}, binding ${r}.`);return!0}function DW(t){let e=[],r=t.source||"";for(let o of Qi(r,Pa))e.push({name:o.name,group:Number(o.groupToken)});return e}function TA(t,e,r){if(t===0&&e>=ff)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${ff}.`)}function WM(t,e,r,o){if(e===0&&r<ff)throw new Error(`Module "${t}" binding "${o}" in group 0 uses reserved application binding ${r}. Module-owned explicit group-0 bindings must be ${ff} or higher.`)}function Ma(t,e,r,o){let n=t.get(e)||new Set;if(n.has(r))throw new Error(`Duplicate WGSL binding assignment for ${o}: group ${e}, binding ${r}.`);n.add(r),t.set(e,n)}function GM(t,e,r){let o=e.get(t)||new Set,n=r??(t===0?ff:o.size>0?Math.max(...o)+1:0);for(;o.has(n);)n++;return n}function UW(t,e){let r=e.get(t)||new Set,o=0;for(;r.has(o);)o++;return o}function kW(t){let e=kM(t,Pa);if(!e)return;let r=zW(t,e.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${e.name}" remained in assembled WGSL source.`):HW(t,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${jW(e.match)}".`)}function VW(t){if(t.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
`;for(let r of t)e+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location})
`;return e+=`
`,e}function qM(t,e,r){return`${t}:${e}:${r}`}function zW(t,e){let r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,o,n;for(n=r.exec(t);n&&n.index<=e;)o=n[1],n=r.exec(t);return o}function HW(t,e){let r=t.indexOf(AA);return r>=0?e>r:!0}function jW(t){return t.replace(/\s+/g," ").trim()}var vA="([a-zA-Z_][a-zA-Z0-9_]*)",WW=new RegExp(`^\\s*\\#\\s*ifdef\\s*${vA}\\s*$`),GW=new RegExp(`^\\s*\\#\\s*ifndef\\s*${vA}\\s*(?:\\/\\/.*)?$`),$W=/^\s*\#\s*else\s*(?:\/\/.*)?$/,XW=/^\s*\#\s*endif\s*$/,YW=new RegExp(`^\\s*\\#\\s*ifdef\\s*${vA}\\s*(?:\\/\\/.*)?$`),KW=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function ZM(t,e){let r=t.split(`
`),o=[],n=[],i=!0;for(let s of r){let a=s.match(YW)||s.match(WW),c=s.match(GW),l=s.match($W),f=s.match(KW)||s.match(XW);if(a||c){let u=(a||c)?.[1],d=Boolean(e?.defines?.[u]),h=a?d:!d,p=i&&h;n.push({parentActive:i,branchTaken:h,active:p}),i=p}else if(l){let u=n[n.length-1];if(!u)throw new Error("Encountered #else without matching #ifdef or #ifndef");u.active=u.parentActive&&!u.branchTaken,u.branchTaken=!0,i=u.active}else f?(n.pop(),i=n.length?n[n.length-1].active:!0):i&&o.push(s)}if(n.length>0)throw new Error("Unterminated conditional block in shader source");return o.join(`
`)}var Ra=class{_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return Ra.defaultShaderAssembler=Ra.defaultShaderAssembler||new Ra,Ra.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(o=>o.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let r=this._getModuleList(e.modules),o=this._hookFunctions,{source:n,getUniforms:i,bindingAssignments:s}=$M({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:r,hookFunctions:o}),a={...r.reduce((l,f)=>(Object.assign(l,f.defines),l),{}),...e.defines},c=e.platformInfo.shaderLanguage==="wgsl"?ZM(n,{defines:a}):n;return{source:c,getUniforms:i,modules:r,bindingAssignments:s,bindingTable:nm(c,s)}}assembleGLSLShaderPair(e){let r=this._getModuleList(e.modules),o=this._hookFunctions;return{...XM({...e,vs:e.vs,fs:e.fs,modules:r,hookFunctions:o}),modules:r}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),o={},n=0;for(let i=0,s=this._defaultModules.length;i<s;++i){let a=this._defaultModules[i],c=a.name;r[n++]=a,o[c]=!0}for(let i=0,s=e.length;i<s;++i){let a=e[i],c=a.name;o[c]||(r[n++]=a,o[c]=!0)}return r.length=n,Ji(r),r}},Zn=Ra;k(Zn,"defaultShaderAssembler");var qW=`out vec4 transform_output;
void main() {
transform_output = vec4(0);
}`,ZW=`#version 300 es
${qW}`;function uf(t){let{input:e,inputChannels:r,output:o}=t||{};if(!e)return ZW;if(!r)throw new Error("inputChannels");let n=JW(r),i=JM(e,r);return`#version 300 es
in ${n} ${e};
out vec4 ${o};
void main() {
${o} = ${i};
}`}function JW(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function JM(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var QW=1/Math.PI*180,eG=1/180*Math.PI,tG={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...tG}};var ve=globalThis.mathgl.config;function df(t,{precision:e=ve.precision}={}){return t=rG(t),`${parseFloat(t.toPrecision(e))}`}function cr(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function SA(t){return es(t)}function CA(t){return rt(t)}function es(t,e){return EA(t,r=>r*eG,e)}function rt(t,e){return EA(t,r=>r*QW,e)}function ee(t,e,r){return EA(t,o=>Math.max(e,Math.min(r,o)))}function lt(t,e,r){return cr(t)?t.map((o,n)=>lt(o,e[n],r)):r*e+(1-r)*t}function Ce(t,e,r){let o=ve.EPSILON;r&&(ve.EPSILON=r);try{if(t===e)return!0;if(cr(t)&&cr(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(!Ce(t[n],e[n]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=ve.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{ve.EPSILON=o}}function rG(t){return Math.round(t/ve.EPSILON)*ve.EPSILON}function oG(t){return t.clone?t.clone():new Array(t.length)}function EA(t,e,r){if(cr(t)){let o=t;r=r||oG(o);for(let n=0;n<r.length&&n<o.length;++n){let i=typeof t=="number"?t:t[n];r[n]=e(i,n,r)}return r}return e(t)}var Jn=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let o=0;o<this.ELEMENTS;++o)this[o]=e[o+r];return this.check()}toArray(e=[],r=0){for(let o=0;o<this.ELEMENTS;++o)e[r+o]=this[o];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:cr(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(ve)}formatString(e){let r="";for(let o=0;o<this.ELEMENTS;++o)r+=(o>0?", ":"")+df(this[o],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Ce(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,o){if(o===void 0)return this.lerp(this,e,r);for(let n=0;n<this.ELEMENTS;++n){let i=e[n],s=typeof r=="number"?r:r[n];this[n]=i+o*(s-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],e[o]),r[o]);return this.check()}add(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]+=r[o];return this.check()}subtract(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]-=r[o];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(ve.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 r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],e),r);return this.check()}get elements(){return this}};function nG(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function he(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Qn(t,e,r=""){if(ve.debug&&!nG(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function ht(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var ei=class extends Jn{get x(){return this[0]}set x(e){this[0]=he(e)}get y(){return this[1]}set y(e){this[1]=he(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let o=0;o<this.ELEMENTS;++o){let n=this[o]-e[o];r+=n*n}return he(r)}dot(e){let r=0;for(let o=0;o<this.ELEMENTS;++o)r+=this[o]*e[o];return he(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]*=r[o];return this.check()}divide(...e){for(let r of e)for(let o=0;o<this.ELEMENTS;++o)this[o]/=r[o];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return ht(e>=0&&e<this.ELEMENTS,"index is out of range"),he(this[e])}setComponent(e,r){return ht(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var Ye={};ze(Ye,{add:()=>lG,angle:()=>CG,ceil:()=>fG,clone:()=>iG,copy:()=>aG,create:()=>QM,cross:()=>AG,dist:()=>OG,distance:()=>oR,div:()=>BG,divide:()=>rR,dot:()=>bG,equals:()=>MG,exactEquals:()=>PG,floor:()=>uG,forEach:()=>DG,fromValues:()=>sG,inverse:()=>yG,len:()=>RG,length:()=>iR,lerp:()=>TG,max:()=>hG,min:()=>dG,mul:()=>LG,multiply:()=>tR,negate:()=>_G,normalize:()=>xG,random:()=>vG,rotate:()=>SG,round:()=>pG,scale:()=>mG,scaleAndAdd:()=>gG,set:()=>cG,sqrDist:()=>FG,sqrLen:()=>NG,squaredDistance:()=>nR,squaredLength:()=>sR,str:()=>wG,sub:()=>IG,subtract:()=>eR,transformMat2:()=>wA,transformMat2d:()=>PA,transformMat3:()=>hf,transformMat4:()=>pf,zero:()=>EG});var Ee=typeof Float32Array<"u"?Float32Array:Array,To=Math.random;function vr(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var uve=Math.PI/180;function QM(){let t=new Ee(2);return Ee!=Float32Array&&(t[0]=0,t[1]=0),t}function iG(t){let e=new Ee(2);return e[0]=t[0],e[1]=t[1],e}function sG(t,e){let r=new Ee(2);return r[0]=t,r[1]=e,r}function aG(t,e){return t[0]=e[0],t[1]=e[1],t}function cG(t,e,r){return t[0]=e,t[1]=r,t}function lG(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function eR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function tR(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function rR(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function fG(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function uG(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function dG(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function hG(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function pG(t,e){return t[0]=vr(e[0]),t[1]=vr(e[1]),t}function mG(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function gG(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t}function oR(t,e){let r=e[0]-t[0],o=e[1]-t[1];return Math.sqrt(r*r+o*o)}function nR(t,e){let r=e[0]-t[0],o=e[1]-t[1];return r*r+o*o}function iR(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function sR(t){let e=t[0],r=t[1];return e*e+r*r}function _G(t,e){return t[0]=-e[0],t[1]=-e[1],t}function yG(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function xG(t,e){let r=e[0],o=e[1],n=r*r+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t}function bG(t,e){return t[0]*e[0]+t[1]*e[1]}function AG(t,e,r){let o=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=o,t}function TG(t,e,r,o){let n=e[0],i=e[1];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t}function vG(t,e){e=e===void 0?1:e;let r=To()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function wA(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t}function PA(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n+r[4],t[1]=r[1]*o+r[3]*n+r[5],t}function hf(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[3]*n+r[6],t[1]=r[1]*o+r[4]*n+r[7],t}function pf(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[4]*n+r[12],t[1]=r[1]*o+r[5]*n+r[13],t}function SG(t,e,r,o){let n=e[0]-r[0],i=e[1]-r[1],s=Math.sin(o),a=Math.cos(o);return t[0]=n*a-i*s+r[0],t[1]=n*s+i*a+r[1],t}function CG(t,e){let r=t[0],o=t[1],n=e[0],i=e[1],s=Math.sqrt((r*r+o*o)*(n*n+i*i)),a=s&&(r*n+o*i)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function EG(t){return t[0]=0,t[1]=0,t}function wG(t){return`vec2(${t[0]}, ${t[1]})`}function PG(t,e){return t[0]===e[0]&&t[1]===e[1]}function MG(t,e){let r=t[0],o=t[1],n=e[0],i=e[1];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(o-i)<=1e-6*Math.max(1,Math.abs(o),Math.abs(i))}var RG=iR,IG=eR,LG=tR,BG=rR,OG=oR,FG=nR,NG=sR,DG=function(){let t=QM();return function(e,r,o,n,i,s){let a,c;for(r||(r=2),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],i(t,t,s),e[a]=t[0],e[a+1]=t[1];return e}}();function im(t,e,r){let o=e[0],n=e[1],i=r[3]*o+r[7]*n||1;return t[0]=(r[0]*o+r[4]*n)/i,t[1]=(r[1]*o+r[5]*n)/i,t}function sm(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[3]*o+r[7]*n+r[11]*i||1;return t[0]=(r[0]*o+r[4]*n+r[8]*i)/s,t[1]=(r[1]*o+r[5]*n+r[9]*i)/s,t[2]=(r[2]*o+r[6]*n+r[10]*i)/s,t}function aR(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t[2]=e[2],t}function cR(t,e,r){let o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t[2]=e[2],t[3]=e[3],t}function am(t,e,r){let o=e[0],n=e[1],i=e[2];return t[0]=r[0]*o+r[3]*n+r[6]*i,t[1]=r[1]*o+r[4]*n+r[7]*i,t[2]=r[2]*o+r[5]*n+r[8]*i,t[3]=e[3],t}var Gr=class extends ei{constructor(e=0,r=0){super(2),cr(e)&&arguments.length===1?this.copy(e):(ve.debug&&(he(e),he(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return ve.debug&&(he(e.x),he(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return pf(this,this,e),this.check()}transformAsVector(e){return im(this,this,e),this.check()}transformByMatrix3(e){return hf(this,this,e),this.check()}transformByMatrix2x3(e){return PA(this,this,e),this.check()}transformByMatrix2(e){return wA(this,this,e),this.check()}};var Ke={};ze(Ke,{add:()=>zG,angle:()=>BA,bezier:()=>e9,ceil:()=>HG,clone:()=>UG,copy:()=>kG,create:()=>cm,cross:()=>ts,dist:()=>l9,distance:()=>dR,div:()=>c9,divide:()=>uR,dot:()=>mf,equals:()=>i9,exactEquals:()=>n9,floor:()=>jG,forEach:()=>d9,fromValues:()=>fm,hermite:()=>QG,inverse:()=>qG,len:()=>OA,length:()=>lm,lerp:()=>ZG,max:()=>GG,min:()=>WG,mul:()=>a9,multiply:()=>fR,negate:()=>KG,normalize:()=>MA,random:()=>t9,rotateX:()=>RA,rotateY:()=>IA,rotateZ:()=>LA,round:()=>$G,scale:()=>XG,scaleAndAdd:()=>YG,set:()=>VG,slerp:()=>JG,sqrDist:()=>f9,sqrLen:()=>u9,squaredDistance:()=>hR,squaredLength:()=>pR,str:()=>o9,sub:()=>s9,subtract:()=>lR,transformMat3:()=>gf,transformMat4:()=>rs,transformQuat:()=>_f,zero:()=>r9});function cm(){let t=new Ee(3);return Ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function UG(t){let e=new Ee(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function lm(t){let e=t[0],r=t[1],o=t[2];return Math.sqrt(e*e+r*r+o*o)}function fm(t,e,r){let o=new Ee(3);return o[0]=t,o[1]=e,o[2]=r,o}function kG(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function VG(t,e,r,o){return t[0]=e,t[1]=r,t[2]=o,t}function zG(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function lR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function fR(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function uR(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function HG(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function jG(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function WG(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function GG(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function $G(t,e){return t[0]=vr(e[0]),t[1]=vr(e[1]),t[2]=vr(e[2]),t}function XG(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function YG(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t}function dR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return Math.sqrt(r*r+o*o+n*n)}function hR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return r*r+o*o+n*n}function pR(t){let e=t[0],r=t[1],o=t[2];return e*e+r*r+o*o}function KG(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function qG(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function MA(t,e){let r=e[0],o=e[1],n=e[2],i=r*r+o*o+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function mf(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ts(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[0],a=r[1],c=r[2];return t[0]=n*c-i*a,t[1]=i*s-o*c,t[2]=o*a-n*s,t}function ZG(t,e,r,o){let n=e[0],i=e[1],s=e[2];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t}function JG(t,e,r,o){let n=Math.acos(Math.min(Math.max(mf(e,r),-1),1)),i=Math.sin(n),s=Math.sin((1-o)*n)/i,a=Math.sin(o*n)/i;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function QG(t,e,r,o,n,i){let s=i*i,a=s*(2*i-3)+1,c=s*(i-2)+i,l=s*(i-1),f=s*(3-2*i);return t[0]=e[0]*a+r[0]*c+o[0]*l+n[0]*f,t[1]=e[1]*a+r[1]*c+o[1]*l+n[1]*f,t[2]=e[2]*a+r[2]*c+o[2]*l+n[2]*f,t}function e9(t,e,r,o,n,i){let s=1-i,a=s*s,c=i*i,l=a*s,f=3*i*a,u=3*c*s,d=c*i;return t[0]=e[0]*l+r[0]*f+o[0]*u+n[0]*d,t[1]=e[1]*l+r[1]*f+o[1]*u+n[1]*d,t[2]=e[2]*l+r[2]*f+o[2]*u+n[2]*d,t}function t9(t,e){e=e===void 0?1:e;let r=To()*2*Math.PI,o=To()*2-1,n=Math.sqrt(1-o*o)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=o*e,t}function rs(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[3]*o+r[7]*n+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*o+r[4]*n+r[8]*i+r[12])/s,t[1]=(r[1]*o+r[5]*n+r[9]*i+r[13])/s,t[2]=(r[2]*o+r[6]*n+r[10]*i+r[14])/s,t}function gf(t,e,r){let o=e[0],n=e[1],i=e[2];return t[0]=o*r[0]+n*r[3]+i*r[6],t[1]=o*r[1]+n*r[4]+i*r[7],t[2]=o*r[2]+n*r[5]+i*r[8],t}function _f(t,e,r){let o=r[0],n=r[1],i=r[2],s=r[3],a=e[0],c=e[1],l=e[2],f=n*l-i*c,u=i*a-o*l,d=o*c-n*a,h=n*d-i*u,p=i*f-o*d,m=o*u-n*f,g=s*2;return f*=g,u*=g,d*=g,h*=2,p*=2,m*=2,t[0]=a+f+h,t[1]=c+u+p,t[2]=l+d+m,t}function RA(t,e,r,o){let n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0],i[1]=n[1]*Math.cos(o)-n[2]*Math.sin(o),i[2]=n[1]*Math.sin(o)+n[2]*Math.cos(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function IA(t,e,r,o){let n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[2]*Math.sin(o)+n[0]*Math.cos(o),i[1]=n[1],i[2]=n[2]*Math.cos(o)-n[0]*Math.sin(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function LA(t,e,r,o){let n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0]*Math.cos(o)-n[1]*Math.sin(o),i[1]=n[0]*Math.sin(o)+n[1]*Math.cos(o),i[2]=n[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function BA(t,e){let r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+o*o+n*n)*(i*i+s*s+a*a)),l=c&&mf(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function r9(t){return t[0]=0,t[1]=0,t[2]=0,t}function o9(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function n9(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function i9(t,e){let r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(o-s)<=1e-6*Math.max(1,Math.abs(o),Math.abs(s))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))}var s9=lR,a9=fR,c9=uR,l9=dR,f9=hR,OA=lm,u9=pR,d9=function(){let t=cm();return function(e,r,o,n,i,s){let a,c;for(r||(r=3),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var FA=[0,0,0],um,E=class extends ei{static get ZERO(){return um||(um=new E(0,0,0),Object.freeze(um)),um}constructor(e=0,r=0,o=0){super(-0,-0,-0),arguments.length===1&&cr(e)?this.copy(e):(ve.debug&&(he(e),he(r),he(o)),this[0]=e,this[1]=r,this[2]=o)}set(e,r,o){return this[0]=e,this[1]=r,this[2]=o,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return ve.debug&&(he(e.x),he(e.y),he(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]=he(e)}angle(e){return BA(this,e)}cross(e){return ts(this,this,e),this.check()}rotateX({radians:e,origin:r=FA}){return RA(this,this,r,e),this.check()}rotateY({radians:e,origin:r=FA}){return IA(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=FA}){return LA(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return rs(this,this,e),this.check()}transformAsVector(e){return sm(this,this,e),this.check()}transformByMatrix3(e){return gf(this,this,e),this.check()}transformByMatrix2(e){return aR(this,this,e),this.check()}transformByQuaternion(e){return _f(this,this,e),this.check()}};var dm,La=class extends ei{static get ZERO(){return dm||(dm=new La(0,0,0,0),Object.freeze(dm)),dm}constructor(e=0,r=0,o=0,n=0){super(-0,-0,-0,-0),cr(e)&&arguments.length===1?this.copy(e):(ve.debug&&(he(e),he(r),he(o),he(n)),this[0]=e,this[1]=r,this[2]=o,this[3]=n)}set(e,r,o,n){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return ve.debug&&(he(e.x),he(e.y),he(e.z),he(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=he(e)}get w(){return this[3]}set w(e){this[3]=he(e)}transform(e){return rs(this,this,e),this.check()}transformByMatrix3(e){return am(this,this,e),this.check()}transformByMatrix2(e){return cR(this,this,e),this.check()}transformByQuaternion(e){return _f(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Ba=class extends Jn{toString(){let e="[";if(ve.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let o=0;o<this.RANK;++o)e+=` ${this[o*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,o){return this[r*this.RANK+e]=he(o),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let o=e*this.RANK;for(let n=0;n<this.RANK;++n)r[n]=this[o+n];return r}setColumn(e,r){let o=e*this.RANK;for(let n=0;n<this.RANK;++n)this[o+n]=r[n];return this}};function mR(){let t=new Ee(9);return Ee!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function gR(t,e){if(t===e){let r=e[1],o=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=o,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function _R(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*s-a*l,d=-f*i+a*c,h=l*i-s*c,p=r*u+o*d+n*h;return p?(p=1/p,t[0]=u*p,t[1]=(-f*o+n*l)*p,t[2]=(a*o-n*s)*p,t[3]=d*p,t[4]=(f*r-n*c)*p,t[5]=(-a*r+n*i)*p,t[6]=h*p,t[7]=(-l*r+o*c)*p,t[8]=(s*r-o*i)*p,t):null}function yR(t){let e=t[0],r=t[1],o=t[2],n=t[3],i=t[4],s=t[5],a=t[6],c=t[7],l=t[8];return e*(l*i-s*c)+r*(-l*n+s*a)+o*(c*n-i*a)}function NA(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=r[0],h=r[1],p=r[2],m=r[3],g=r[4],_=r[5],x=r[6],y=r[7],b=r[8];return t[0]=d*o+h*s+p*l,t[1]=d*n+h*a+p*f,t[2]=d*i+h*c+p*u,t[3]=m*o+g*s+_*l,t[4]=m*n+g*a+_*f,t[5]=m*i+g*c+_*u,t[6]=x*o+y*s+b*l,t[7]=x*n+y*a+b*f,t[8]=x*i+y*c+b*u,t}function xR(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=r[0],h=r[1];return t[0]=o,t[1]=n,t[2]=i,t[3]=s,t[4]=a,t[5]=c,t[6]=d*o+h*s+l,t[7]=d*n+h*a+f,t[8]=d*i+h*c+u,t}function bR(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=Math.sin(r),h=Math.cos(r);return t[0]=h*o+d*s,t[1]=h*n+d*a,t[2]=h*i+d*c,t[3]=h*s-d*o,t[4]=h*a-d*n,t[5]=h*c-d*i,t[6]=l,t[7]=f,t[8]=u,t}function DA(t,e,r){let o=r[0],n=r[1];return t[0]=o*e[0],t[1]=o*e[1],t[2]=o*e[2],t[3]=n*e[3],t[4]=n*e[4],t[5]=n*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function AR(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r+r,a=o+o,c=n+n,l=r*s,f=o*s,u=o*a,d=n*s,h=n*a,p=n*c,m=i*s,g=i*a,_=i*c;return t[0]=1-u-p,t[3]=f-_,t[6]=d+g,t[1]=f+_,t[4]=1-l-p,t[7]=h-m,t[2]=d-g,t[5]=h+m,t[8]=1-l-u,t}var UA;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(UA||(UA={}));var p9=Object.freeze([1,0,0,0,1,0,0,0,1]),ue=class extends Ba{static get IDENTITY(){return g9()}static get ZERO(){return m9()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return UA}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):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.check()}identity(){return this.copy(p9)}fromObject(e){return this.check()}fromQuaternion(e){return AR(this,e),this.check()}set(e,r,o,n,i,s,a,c,l){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,o,n,i,s,a,c,l){return this[0]=e,this[1]=n,this[2]=a,this[3]=r,this[4]=i,this[5]=c,this[6]=o,this[7]=s,this[8]=l,this.check()}determinant(){return yR(this)}transpose(){return gR(this,this),this.check()}invert(){return _R(this,this),this.check()}multiplyLeft(e){return NA(this,e,this),this.check()}multiplyRight(e){return NA(this,this,e),this.check()}rotate(e){return bR(this,this,e),this.check()}scale(e){return Array.isArray(e)?DA(this,this,e):DA(this,this,[e,e]),this.check()}translate(e){return xR(this,this,e),this.check()}transform(e,r){let o;switch(e.length){case 2:o=hf(r||[-0,-0],e,this);break;case 3:o=gf(r||[-0,-0,-0],e,this);break;case 4:o=am(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Qn(o,e.length),o}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},hm,pm=null;function m9(){return hm||(hm=new ue([0,0,0,0,0,0,0,0,0]),Object.freeze(hm)),hm}function g9(){return pm||(pm=new ue,Object.freeze(pm)),pm}var je={};ze(je,{add:()=>z9,adjoint:()=>T9,clone:()=>y9,copy:()=>x9,create:()=>_9,decompose:()=>L9,determinant:()=>zA,equals:()=>G9,exactEquals:()=>W9,frob:()=>V9,fromQuat:()=>YA,fromQuat2:()=>M9,fromRotation:()=>C9,fromRotationTranslation:()=>vR,fromRotationTranslationScale:()=>B9,fromRotationTranslationScaleOrigin:()=>O9,fromScaling:()=>S9,fromTranslation:()=>v9,fromValues:()=>b9,fromXRotation:()=>E9,fromYRotation:()=>w9,fromZRotation:()=>P9,frustum:()=>KA,getRotation:()=>I9,getScaling:()=>SR,getTranslation:()=>R9,identity:()=>TR,invert:()=>VA,lookAt:()=>JA,mul:()=>$9,multiply:()=>yf,multiplyScalar:()=>H9,multiplyScalarAndAdd:()=>j9,ortho:()=>ZA,orthoNO:()=>ER,orthoZO:()=>D9,perspective:()=>qA,perspectiveFromFieldOfView:()=>N9,perspectiveNO:()=>CR,perspectiveZO:()=>F9,rotate:()=>WA,rotateX:()=>GA,rotateY:()=>$A,rotateZ:()=>XA,scale:()=>jA,set:()=>A9,str:()=>k9,sub:()=>X9,subtract:()=>wR,targetTo:()=>U9,translate:()=>HA,transpose:()=>kA});function _9(){let t=new Ee(16);return Ee!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function y9(t){let e=new Ee(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],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}function x9(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function b9(t,e,r,o,n,i,s,a,c,l,f,u,d,h,p,m){let g=new Ee(16);return g[0]=t,g[1]=e,g[2]=r,g[3]=o,g[4]=n,g[5]=i,g[6]=s,g[7]=a,g[8]=c,g[9]=l,g[10]=f,g[11]=u,g[12]=d,g[13]=h,g[14]=p,g[15]=m,g}function A9(t,e,r,o,n,i,s,a,c,l,f,u,d,h,p,m,g){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t[4]=i,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=d,t[12]=h,t[13]=p,t[14]=m,t[15]=g,t}function TR(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function kA(t,e){if(t===e){let r=e[1],o=e[2],n=e[3],i=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=o,t[9]=i,t[11]=e[14],t[12]=n,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function VA(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],_=e[15],x=r*a-o*s,y=r*c-n*s,b=r*l-i*s,T=o*c-n*a,v=o*l-i*a,w=n*l-i*c,C=f*m-u*p,S=f*g-d*p,A=f*_-h*p,M=u*g-d*m,B=u*_-h*m,O=d*_-h*g,F=x*O-y*B+b*M+T*A-v*S+w*C;return F?(F=1/F,t[0]=(a*O-c*B+l*M)*F,t[1]=(n*B-o*O-i*M)*F,t[2]=(m*w-g*v+_*T)*F,t[3]=(d*v-u*w-h*T)*F,t[4]=(c*A-s*O-l*S)*F,t[5]=(r*O-n*A+i*S)*F,t[6]=(g*b-p*w-_*y)*F,t[7]=(f*w-d*b+h*y)*F,t[8]=(s*B-a*A+l*C)*F,t[9]=(o*A-r*B-i*C)*F,t[10]=(p*v-m*b+_*x)*F,t[11]=(u*b-f*v-h*x)*F,t[12]=(a*S-s*M-c*C)*F,t[13]=(r*M-o*S+n*C)*F,t[14]=(m*y-p*T-g*x)*F,t[15]=(f*T-u*y+d*x)*F,t):null}function T9(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],p=e[12],m=e[13],g=e[14],_=e[15],x=r*a-o*s,y=r*c-n*s,b=r*l-i*s,T=o*c-n*a,v=o*l-i*a,w=n*l-i*c,C=f*m-u*p,S=f*g-d*p,A=f*_-h*p,M=u*g-d*m,B=u*_-h*m,O=d*_-h*g;return t[0]=a*O-c*B+l*M,t[1]=n*B-o*O-i*M,t[2]=m*w-g*v+_*T,t[3]=d*v-u*w-h*T,t[4]=c*A-s*O-l*S,t[5]=r*O-n*A+i*S,t[6]=g*b-p*w-_*y,t[7]=f*w-d*b+h*y,t[8]=s*B-a*A+l*C,t[9]=o*A-r*B-i*C,t[10]=p*v-m*b+_*x,t[11]=u*b-f*v-h*x,t[12]=a*S-s*M-c*C,t[13]=r*M-o*S+n*C,t[14]=m*y-p*T-g*x,t[15]=f*T-u*y+d*x,t}function zA(t){let e=t[0],r=t[1],o=t[2],n=t[3],i=t[4],s=t[5],a=t[6],c=t[7],l=t[8],f=t[9],u=t[10],d=t[11],h=t[12],p=t[13],m=t[14],g=t[15],_=e*s-r*i,x=e*a-o*i,y=r*a-o*s,b=l*p-f*h,T=l*m-u*h,v=f*m-u*p,w=e*v-r*T+o*b,C=i*v-s*T+a*b,S=l*y-f*x+u*_,A=h*y-p*x+m*_;return c*w-n*C+g*S-d*A}function yf(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=e[9],h=e[10],p=e[11],m=e[12],g=e[13],_=e[14],x=e[15],y=r[0],b=r[1],T=r[2],v=r[3];return t[0]=y*o+b*a+T*u+v*m,t[1]=y*n+b*c+T*d+v*g,t[2]=y*i+b*l+T*h+v*_,t[3]=y*s+b*f+T*p+v*x,y=r[4],b=r[5],T=r[6],v=r[7],t[4]=y*o+b*a+T*u+v*m,t[5]=y*n+b*c+T*d+v*g,t[6]=y*i+b*l+T*h+v*_,t[7]=y*s+b*f+T*p+v*x,y=r[8],b=r[9],T=r[10],v=r[11],t[8]=y*o+b*a+T*u+v*m,t[9]=y*n+b*c+T*d+v*g,t[10]=y*i+b*l+T*h+v*_,t[11]=y*s+b*f+T*p+v*x,y=r[12],b=r[13],T=r[14],v=r[15],t[12]=y*o+b*a+T*u+v*m,t[13]=y*n+b*c+T*d+v*g,t[14]=y*i+b*l+T*h+v*_,t[15]=y*s+b*f+T*p+v*x,t}function HA(t,e,r){let o=r[0],n=r[1],i=r[2],s,a,c,l,f,u,d,h,p,m,g,_;return e===t?(t[12]=e[0]*o+e[4]*n+e[8]*i+e[12],t[13]=e[1]*o+e[5]*n+e[9]*i+e[13],t[14]=e[2]*o+e[6]*n+e[10]*i+e[14],t[15]=e[3]*o+e[7]*n+e[11]*i+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],f=e[4],u=e[5],d=e[6],h=e[7],p=e[8],m=e[9],g=e[10],_=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=d,t[7]=h,t[8]=p,t[9]=m,t[10]=g,t[11]=_,t[12]=s*o+f*n+p*i+e[12],t[13]=a*o+u*n+m*i+e[13],t[14]=c*o+d*n+g*i+e[14],t[15]=l*o+h*n+_*i+e[15]),t}function jA(t,e,r){let o=r[0],n=r[1],i=r[2];return t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function WA(t,e,r,o){let n=o[0],i=o[1],s=o[2],a=Math.sqrt(n*n+i*i+s*s),c,l,f,u,d,h,p,m,g,_,x,y,b,T,v,w,C,S,A,M,B,O,F,X;return a<1e-6?null:(a=1/a,n*=a,i*=a,s*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,u=e[0],d=e[1],h=e[2],p=e[3],m=e[4],g=e[5],_=e[6],x=e[7],y=e[8],b=e[9],T=e[10],v=e[11],w=n*n*f+c,C=i*n*f+s*l,S=s*n*f-i*l,A=n*i*f-s*l,M=i*i*f+c,B=s*i*f+n*l,O=n*s*f+i*l,F=i*s*f-n*l,X=s*s*f+c,t[0]=u*w+m*C+y*S,t[1]=d*w+g*C+b*S,t[2]=h*w+_*C+T*S,t[3]=p*w+x*C+v*S,t[4]=u*A+m*M+y*B,t[5]=d*A+g*M+b*B,t[6]=h*A+_*M+T*B,t[7]=p*A+x*M+v*B,t[8]=u*O+m*F+y*X,t[9]=d*O+g*F+b*X,t[10]=h*O+_*F+T*X,t[11]=p*O+x*F+v*X,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function GA(t,e,r){let o=Math.sin(r),n=Math.cos(r),i=e[4],s=e[5],a=e[6],c=e[7],l=e[8],f=e[9],u=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*n+l*o,t[5]=s*n+f*o,t[6]=a*n+u*o,t[7]=c*n+d*o,t[8]=l*n-i*o,t[9]=f*n-s*o,t[10]=u*n-a*o,t[11]=d*n-c*o,t}function $A(t,e,r){let o=Math.sin(r),n=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[8],f=e[9],u=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*n-l*o,t[1]=s*n-f*o,t[2]=a*n-u*o,t[3]=c*n-d*o,t[8]=i*o+l*n,t[9]=s*o+f*n,t[10]=a*o+u*n,t[11]=c*o+d*n,t}function XA(t,e,r){let o=Math.sin(r),n=Math.cos(r),i=e[0],s=e[1],a=e[2],c=e[3],l=e[4],f=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*n+l*o,t[1]=s*n+f*o,t[2]=a*n+u*o,t[3]=c*n+d*o,t[4]=l*n-i*o,t[5]=f*n-s*o,t[6]=u*n-a*o,t[7]=d*n-c*o,t}function v9(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function S9(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function C9(t,e,r){let o=r[0],n=r[1],i=r[2],s=Math.sqrt(o*o+n*n+i*i),a,c,l;return s<1e-6?null:(s=1/s,o*=s,n*=s,i*=s,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=o*o*l+a,t[1]=n*o*l+i*c,t[2]=i*o*l-n*c,t[3]=0,t[4]=o*n*l-i*c,t[5]=n*n*l+a,t[6]=i*n*l+o*c,t[7]=0,t[8]=o*i*l+n*c,t[9]=n*i*l-o*c,t[10]=i*i*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function E9(t,e){let r=Math.sin(e),o=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function w9(t,e){let r=Math.sin(e),o=Math.cos(e);return t[0]=o,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function P9(t,e){let r=Math.sin(e),o=Math.cos(e);return t[0]=o,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function vR(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=o+o,c=n+n,l=i+i,f=o*a,u=o*c,d=o*l,h=n*c,p=n*l,m=i*l,g=s*a,_=s*c,x=s*l;return t[0]=1-(h+m),t[1]=u+x,t[2]=d-_,t[3]=0,t[4]=u-x,t[5]=1-(f+m),t[6]=p+g,t[7]=0,t[8]=d+_,t[9]=p-g,t[10]=1-(f+h),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function M9(t,e){let r=new Ee(3),o=-e[0],n=-e[1],i=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=o*o+n*n+i*i+s*s;return u>0?(r[0]=(a*s+f*o+c*i-l*n)*2/u,r[1]=(c*s+f*n+l*o-a*i)*2/u,r[2]=(l*s+f*i+a*n-c*o)*2/u):(r[0]=(a*s+f*o+c*i-l*n)*2,r[1]=(c*s+f*n+l*o-a*i)*2,r[2]=(l*s+f*i+a*n-c*o)*2),vR(t,e,r),t}function R9(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function SR(t,e){let r=e[0],o=e[1],n=e[2],i=e[4],s=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+o*o+n*n),t[1]=Math.sqrt(i*i+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function I9(t,e){let r=new Ee(3);SR(r,e);let o=1/r[0],n=1/r[1],i=1/r[2],s=e[0]*o,a=e[1]*n,c=e[2]*i,l=e[4]*o,f=e[5]*n,u=e[6]*i,d=e[8]*o,h=e[9]*n,p=e[10]*i,m=s+f+p,g=0;return m>0?(g=Math.sqrt(m+1)*2,t[3]=.25*g,t[0]=(u-h)/g,t[1]=(d-c)/g,t[2]=(a-l)/g):s>f&&s>p?(g=Math.sqrt(1+s-f-p)*2,t[3]=(u-h)/g,t[0]=.25*g,t[1]=(a+l)/g,t[2]=(d+c)/g):f>p?(g=Math.sqrt(1+f-s-p)*2,t[3]=(d-c)/g,t[0]=(a+l)/g,t[1]=.25*g,t[2]=(u+h)/g):(g=Math.sqrt(1+p-s-f)*2,t[3]=(a-l)/g,t[0]=(d+c)/g,t[1]=(u+h)/g,t[2]=.25*g),t}function L9(t,e,r,o){e[0]=o[12],e[1]=o[13],e[2]=o[14];let n=o[0],i=o[1],s=o[2],a=o[4],c=o[5],l=o[6],f=o[8],u=o[9],d=o[10];r[0]=Math.sqrt(n*n+i*i+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+u*u+d*d);let h=1/r[0],p=1/r[1],m=1/r[2],g=n*h,_=i*p,x=s*m,y=a*h,b=c*p,T=l*m,v=f*h,w=u*p,C=d*m,S=g+b+C,A=0;return S>0?(A=Math.sqrt(S+1)*2,t[3]=.25*A,t[0]=(T-w)/A,t[1]=(v-x)/A,t[2]=(_-y)/A):g>b&&g>C?(A=Math.sqrt(1+g-b-C)*2,t[3]=(T-w)/A,t[0]=.25*A,t[1]=(_+y)/A,t[2]=(v+x)/A):b>C?(A=Math.sqrt(1+b-g-C)*2,t[3]=(v-x)/A,t[0]=(_+y)/A,t[1]=.25*A,t[2]=(T+w)/A):(A=Math.sqrt(1+C-g-b)*2,t[3]=(_-y)/A,t[0]=(v+x)/A,t[1]=(T+w)/A,t[2]=.25*A),t}function B9(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=e[3],c=n+n,l=i+i,f=s+s,u=n*c,d=n*l,h=n*f,p=i*l,m=i*f,g=s*f,_=a*c,x=a*l,y=a*f,b=o[0],T=o[1],v=o[2];return t[0]=(1-(p+g))*b,t[1]=(d+y)*b,t[2]=(h-x)*b,t[3]=0,t[4]=(d-y)*T,t[5]=(1-(u+g))*T,t[6]=(m+_)*T,t[7]=0,t[8]=(h+x)*v,t[9]=(m-_)*v,t[10]=(1-(u+p))*v,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function O9(t,e,r,o,n){let i=e[0],s=e[1],a=e[2],c=e[3],l=i+i,f=s+s,u=a+a,d=i*l,h=i*f,p=i*u,m=s*f,g=s*u,_=a*u,x=c*l,y=c*f,b=c*u,T=o[0],v=o[1],w=o[2],C=n[0],S=n[1],A=n[2],M=(1-(m+_))*T,B=(h+b)*T,O=(p-y)*T,F=(h-b)*v,X=(1-(d+_))*v,G=(g+x)*v,j=(p+y)*w,se=(g-x)*w,ne=(1-(d+m))*w;return t[0]=M,t[1]=B,t[2]=O,t[3]=0,t[4]=F,t[5]=X,t[6]=G,t[7]=0,t[8]=j,t[9]=se,t[10]=ne,t[11]=0,t[12]=r[0]+C-(M*C+F*S+j*A),t[13]=r[1]+S-(B*C+X*S+se*A),t[14]=r[2]+A-(O*C+G*S+ne*A),t[15]=1,t}function YA(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r+r,a=o+o,c=n+n,l=r*s,f=o*s,u=o*a,d=n*s,h=n*a,p=n*c,m=i*s,g=i*a,_=i*c;return t[0]=1-u-p,t[1]=f+_,t[2]=d-g,t[3]=0,t[4]=f-_,t[5]=1-l-p,t[6]=h+m,t[7]=0,t[8]=d+g,t[9]=h-m,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function KA(t,e,r,o,n,i,s){let a=1/(r-e),c=1/(n-o),l=1/(i-s);return t[0]=i*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(n+o)*c,t[10]=(s+i)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*i*2*l,t[15]=0,t}function CR(t,e,r,o,n){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let s=1/(o-n);t[10]=(n+o)*s,t[14]=2*n*o*s}else t[10]=-1,t[14]=-2*o;return t}var qA=CR;function F9(t,e,r,o,n){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let s=1/(o-n);t[10]=n*s,t[14]=n*o*s}else t[10]=-1,t[14]=-o;return t}function N9(t,e,r,o){let n=Math.tan(e.upDegrees*Math.PI/180),i=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(n+i);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(n-i)*l*.5,t[10]=o/(r-o),t[11]=-1,t[12]=0,t[13]=0,t[14]=o*r/(r-o),t[15]=0,t}function ER(t,e,r,o,n,i,s){let a=1/(e-r),c=1/(o-n),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(n+o)*c,t[14]=(s+i)*l,t[15]=1,t}var ZA=ER;function D9(t,e,r,o,n,i,s){let a=1/(e-r),c=1/(o-n),l=1/(i-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(n+o)*c,t[14]=i*l,t[15]=1,t}function JA(t,e,r,o){let n,i,s,a,c,l,f,u,d,h,p=e[0],m=e[1],g=e[2],_=o[0],x=o[1],y=o[2],b=r[0],T=r[1],v=r[2];return Math.abs(p-b)<1e-6&&Math.abs(m-T)<1e-6&&Math.abs(g-v)<1e-6?TR(t):(u=p-b,d=m-T,h=g-v,n=1/Math.sqrt(u*u+d*d+h*h),u*=n,d*=n,h*=n,i=x*h-y*d,s=y*u-_*h,a=_*d-x*u,n=Math.sqrt(i*i+s*s+a*a),n?(n=1/n,i*=n,s*=n,a*=n):(i=0,s=0,a=0),c=d*a-h*s,l=h*i-u*a,f=u*s-d*i,n=Math.sqrt(c*c+l*l+f*f),n?(n=1/n,c*=n,l*=n,f*=n):(c=0,l=0,f=0),t[0]=i,t[1]=c,t[2]=u,t[3]=0,t[4]=s,t[5]=l,t[6]=d,t[7]=0,t[8]=a,t[9]=f,t[10]=h,t[11]=0,t[12]=-(i*p+s*m+a*g),t[13]=-(c*p+l*m+f*g),t[14]=-(u*p+d*m+h*g),t[15]=1,t)}function U9(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=o[0],c=o[1],l=o[2],f=n-r[0],u=i-r[1],d=s-r[2],h=f*f+u*u+d*d;h>0&&(h=1/Math.sqrt(h),f*=h,u*=h,d*=h);let p=c*d-l*u,m=l*f-a*d,g=a*u-c*f;return h=p*p+m*m+g*g,h>0&&(h=1/Math.sqrt(h),p*=h,m*=h,g*=h),t[0]=p,t[1]=m,t[2]=g,t[3]=0,t[4]=u*g-d*m,t[5]=d*p-f*g,t[6]=f*m-u*p,t[7]=0,t[8]=f,t[9]=u,t[10]=d,t[11]=0,t[12]=n,t[13]=i,t[14]=s,t[15]=1,t}function k9(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function V9(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function z9(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function wR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function H9(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function j9(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t[3]=e[3]+r[3]*o,t[4]=e[4]+r[4]*o,t[5]=e[5]+r[5]*o,t[6]=e[6]+r[6]*o,t[7]=e[7]+r[7]*o,t[8]=e[8]+r[8]*o,t[9]=e[9]+r[9]*o,t[10]=e[10]+r[10]*o,t[11]=e[11]+r[11]*o,t[12]=e[12]+r[12]*o,t[13]=e[13]+r[13]*o,t[14]=e[14]+r[14]*o,t[15]=e[15]+r[15]*o,t}function W9(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function G9(t,e){let r=t[0],o=t[1],n=t[2],i=t[3],s=t[4],a=t[5],c=t[6],l=t[7],f=t[8],u=t[9],d=t[10],h=t[11],p=t[12],m=t[13],g=t[14],_=t[15],x=e[0],y=e[1],b=e[2],T=e[3],v=e[4],w=e[5],C=e[6],S=e[7],A=e[8],M=e[9],B=e[10],O=e[11],F=e[12],X=e[13],G=e[14],j=e[15];return Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-y)<=1e-6*Math.max(1,Math.abs(o),Math.abs(y))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-T)<=1e-6*Math.max(1,Math.abs(i),Math.abs(T))&&Math.abs(s-v)<=1e-6*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-C)<=1e-6*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(l-S)<=1e-6*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(f-A)<=1e-6*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(u-M)<=1e-6*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(d-B)<=1e-6*Math.max(1,Math.abs(d),Math.abs(B))&&Math.abs(h-O)<=1e-6*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(m-X)<=1e-6*Math.max(1,Math.abs(m),Math.abs(X))&&Math.abs(g-G)<=1e-6*Math.max(1,Math.abs(g),Math.abs(G))&&Math.abs(_-j)<=1e-6*Math.max(1,Math.abs(_),Math.abs(j))}var $9=yf,X9=wR;var Nt={};ze(Nt,{add:()=>QA,ceil:()=>Y9,clone:()=>MR,copy:()=>IR,create:()=>PR,cross:()=>r$,dist:()=>f$,distance:()=>NR,div:()=>l$,divide:()=>FR,dot:()=>rT,equals:()=>s$,exactEquals:()=>UR,floor:()=>K9,forEach:()=>p$,fromValues:()=>RR,inverse:()=>t$,len:()=>d$,length:()=>mm,lerp:()=>oT,max:()=>Z9,min:()=>q9,mul:()=>c$,multiply:()=>OR,negate:()=>e$,normalize:()=>tT,random:()=>o$,round:()=>J9,scale:()=>eT,scaleAndAdd:()=>Q9,set:()=>LR,sqrDist:()=>u$,sqrLen:()=>h$,squaredDistance:()=>DR,squaredLength:()=>gm,str:()=>i$,sub:()=>a$,subtract:()=>BR,transformMat4:()=>nT,transformQuat:()=>iT,zero:()=>n$});function PR(){let t=new Ee(4);return Ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function MR(t){let e=new Ee(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function RR(t,e,r,o){let n=new Ee(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n}function IR(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function LR(t,e,r,o,n){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t}function QA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function BR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function OR(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function FR(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function Y9(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function K9(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function q9(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function Z9(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function J9(t,e){return t[0]=vr(e[0]),t[1]=vr(e[1]),t[2]=vr(e[2]),t[3]=vr(e[3]),t}function eT(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Q9(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t[3]=e[3]+r[3]*o,t}function NR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2],i=e[3]-t[3];return Math.sqrt(r*r+o*o+n*n+i*i)}function DR(t,e){let r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2],i=e[3]-t[3];return r*r+o*o+n*n+i*i}function mm(t){let e=t[0],r=t[1],o=t[2],n=t[3];return Math.sqrt(e*e+r*r+o*o+n*n)}function gm(t){let e=t[0],r=t[1],o=t[2],n=t[3];return e*e+r*r+o*o+n*n}function e$(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function t$(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function tT(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=o*s,t[2]=n*s,t[3]=i*s,t}function rT(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function r$(t,e,r,o){let n=r[0]*o[1]-r[1]*o[0],i=r[0]*o[2]-r[2]*o[0],s=r[0]*o[3]-r[3]*o[0],a=r[1]*o[2]-r[2]*o[1],c=r[1]*o[3]-r[3]*o[1],l=r[2]*o[3]-r[3]*o[2],f=e[0],u=e[1],d=e[2],h=e[3];return t[0]=u*l-d*c+h*a,t[1]=-(f*l)+d*s-h*i,t[2]=f*c-u*s+h*n,t[3]=-(f*a)+u*i-d*n,t}function oT(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=e[3];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t[3]=a+o*(r[3]-a),t}function o$(t,e){e=e===void 0?1:e;let r,o,n,i,s,a;do r=To()*2-1,o=To()*2-1,s=r*r+o*o;while(s>=1);do n=To()*2-1,i=To()*2-1,a=n*n+i*i;while(a>=1);let c=Math.sqrt((1-s)/a);return t[0]=e*r,t[1]=e*o,t[2]=e*n*c,t[3]=e*i*c,t}function nT(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3];return t[0]=r[0]*o+r[4]*n+r[8]*i+r[12]*s,t[1]=r[1]*o+r[5]*n+r[9]*i+r[13]*s,t[2]=r[2]*o+r[6]*n+r[10]*i+r[14]*s,t[3]=r[3]*o+r[7]*n+r[11]*i+r[15]*s,t}function iT(t,e,r){let o=e[0],n=e[1],i=e[2],s=r[0],a=r[1],c=r[2],l=r[3],f=l*o+a*i-c*n,u=l*n+c*o-s*i,d=l*i+s*n-a*o,h=-s*o-a*n-c*i;return t[0]=f*l+h*-s+u*-c-d*-a,t[1]=u*l+h*-a+d*-s-f*-c,t[2]=d*l+h*-c+f*-a-u*-s,t[3]=e[3],t}function n$(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function i$(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function UR(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function s$(t,e){let r=t[0],o=t[1],n=t[2],i=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(n-c)<=1e-6*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-l)<=1e-6*Math.max(1,Math.abs(i),Math.abs(l))}var a$=BR,c$=OR,l$=FR,f$=NR,u$=DR,d$=mm,h$=gm,p$=function(){let t=PR();return function(e,r,o,n,i,s){let a,c;for(r||(r=4),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var cT;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(cT||(cT={}));var m$=45*Math.PI/180,g$=1,sT=.1,aT=500,_$=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),V=class extends Ba{static get IDENTITY(){return x$()}static get ZERO(){return y$()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return cT}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&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,r,o,n,i,s,a,c,l,f,u,d,h,p,m,g){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=u,this[11]=d,this[12]=h,this[13]=p,this[14]=m,this[15]=g,this.check()}setRowMajor(e,r,o,n,i,s,a,c,l,f,u,d,h,p,m,g){return this[0]=e,this[1]=i,this[2]=l,this[3]=h,this[4]=r,this[5]=s,this[6]=f,this[7]=p,this[8]=o,this[9]=a,this[10]=u,this[11]=m,this[12]=n,this[13]=c,this[14]=d,this[15]=g,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(_$)}fromObject(e){return this.check()}fromQuaternion(e){return YA(this,e),this.check()}frustum(e){let{left:r,right:o,bottom:n,top:i,near:s=sT,far:a=aT}=e;return a===1/0?b$(this,r,o,n,i,s):KA(this,r,o,n,i,s,a),this.check()}lookAt(e){let{eye:r,center:o=[0,0,0],up:n=[0,1,0]}=e;return JA(this,r,o,n),this.check()}ortho(e){let{left:r,right:o,bottom:n,top:i,near:s=sT,far:a=aT}=e;return ZA(this,r,o,n,i,s,a),this.check()}orthographic(e){let{fovy:r=m$,aspect:o=g$,focalDistance:n=1,near:i=sT,far:s=aT}=e;kR(r);let a=r/2,c=n*Math.tan(a),l=c*o;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:s})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:o=1,near:n=.1,far:i=500}=e;return kR(r),qA(this,r,o,n,i),this.check()}determinant(){return zA(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,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let o=this.getScale(r),n=1/o[0],i=1/o[1],s=1/o[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*n,e[5]=this[5]*i,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*n,e[9]=this[9]*i,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let o=this.getScale(r),n=1/o[0],i=1/o[1],s=1/o[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*s,e[3]=this[4]*n,e[4]=this[5]*i,e[5]=this[6]*s,e[6]=this[8]*n,e[7]=this[9]*i,e[8]=this[10]*s,e}transpose(){return kA(this,this),this.check()}invert(){return VA(this,this),this.check()}multiplyLeft(e){return yf(this,e,this),this.check()}multiplyRight(e){return yf(this,this,e),this.check()}rotateX(e){return GA(this,this,e),this.check()}rotateY(e){return $A(this,this,e),this.check()}rotateZ(e){return XA(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return WA(this,this,e,r),this.check()}scale(e){return jA(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return HA(this,this,e),this.check()}transform(e,r){return e.length===4?(r=nT(r||[-0,-0,-0,-0],e,this),Qn(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:o}=e,n;switch(o){case 2:n=pf(r||[-0,-0],e,this);break;case 3:n=rs(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Qn(n,e.length),n}transformAsVector(e,r){let o;switch(e.length){case 2:o=im(r||[-0,-0],e,this);break;case 3:o=sm(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Qn(o,e.length),o}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,o){return this.identity().translate([e,r,o])}},_m,ym;function y$(){return _m||(_m=new V([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(_m)),_m}function x$(){return ym||(ym=new V,Object.freeze(ym)),ym}function kR(t){if(t>Math.PI*2)throw Error("expected radians")}function b$(t,e,r,o,n,i){let s=2*i/(r-e),a=2*i/(n-o),c=(r+e)/(r-e),l=(n+o)/(n-o),f=-1,u=-1,d=-2*i;return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=u,t[12]=0,t[13]=0,t[14]=d,t[15]=0,t}function VR(){let t=new Ee(4);return Ee!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function zR(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function lT(t,e,r){r=r*.5;let o=Math.sin(r);return t[0]=o*e[0],t[1]=o*e[1],t[2]=o*e[2],t[3]=Math.cos(r),t}function fT(t,e,r){let o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=o*f+s*a+n*l-i*c,t[1]=n*f+s*c+i*a-o*l,t[2]=i*f+s*l+o*c-n*a,t[3]=s*f-o*a-n*c-i*l,t}function HR(t,e,r){r*=.5;let o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+s*a,t[1]=n*c+i*a,t[2]=i*c-n*a,t[3]=s*c-o*a,t}function jR(t,e,r){r*=.5;let o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c-i*a,t[1]=n*c+s*a,t[2]=i*c+o*a,t[3]=s*c-n*a,t}function WR(t,e,r){r*=.5;let o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+n*a,t[1]=n*c-o*a,t[2]=i*c+s*a,t[3]=s*c-i*a,t}function GR(t,e){let r=e[0],o=e[1],n=e[2];return t[0]=r,t[1]=o,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-o*o-n*n)),t}function xf(t,e,r,o){let n=e[0],i=e[1],s=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],d,h,p,m,g;return d=n*c+i*l+s*f+a*u,d<0&&(d=-d,c=-c,l=-l,f=-f,u=-u),1-d>1e-6?(h=Math.acos(d),g=Math.sin(h),p=Math.sin((1-o)*h)/g,m=Math.sin(o*h)/g):(p=1-o,m=o),t[0]=p*n+m*c,t[1]=p*i+m*l,t[2]=p*s+m*f,t[3]=p*a+m*u,t}function $R(t,e){let r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i,a=s?1/s:0;return t[0]=-r*a,t[1]=-o*a,t[2]=-n*a,t[3]=i*a,t}function XR(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function uT(t,e){let r=e[0]+e[4]+e[8],o;if(r>0)o=Math.sqrt(r+1),t[3]=.5*o,o=.5/o,t[0]=(e[5]-e[7])*o,t[1]=(e[6]-e[2])*o,t[2]=(e[1]-e[3])*o;else{let n=0;e[4]>e[0]&&(n=1),e[8]>e[n*3+n]&&(n=2);let i=(n+1)%3,s=(n+2)%3;o=Math.sqrt(e[n*3+n]-e[i*3+i]-e[s*3+s]+1),t[n]=.5*o,o=.5/o,t[3]=(e[i*3+s]-e[s*3+i])*o,t[i]=(e[i*3+n]+e[n*3+i])*o,t[s]=(e[s*3+n]+e[n*3+s])*o}return t}var YR=QA;var KR=eT,qR=rT,ZR=oT,JR=mm;var QR=gm;var e2=tT;var t2=function(){let t=cm(),e=fm(1,0,0),r=fm(0,1,0);return function(o,n,i){let s=mf(n,i);return s<-.999999?(ts(t,e,n),OA(t)<1e-6&&ts(t,r,n),MA(t,t),lT(o,t,Math.PI),o):s>.999999?(o[0]=0,o[1]=0,o[2]=0,o[3]=1,o):(ts(t,n,i),o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=1+s,e2(o,o))}}(),qve=function(){let t=VR(),e=VR();return function(r,o,n,i,s,a){return xf(t,o,s,a),xf(e,n,i,a),xf(r,t,e,2*a*(1-a)),r}}(),Zve=function(){let t=mR();return function(e,r,o,n){return t[0]=o[0],t[3]=o[1],t[6]=o[2],t[1]=n[0],t[4]=n[1],t[7]=n[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],e2(e,uT(e,t))}}();var A$=[0,0,0,1],Sr=class extends Jn{constructor(e=0,r=0,o=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,o,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,o,n){return this[0]=e,this[1]=r,this[2]=o,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return uT(this,e),this.check()}fromAxisRotation(e,r){return lT(this,e,r),this.check()}identity(){return zR(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=he(e)}get y(){return this[1]}set y(e){this[1]=he(e)}get z(){return this[2]}set z(e){this[2]=he(e)}get w(){return this[3]}set w(e){this[3]=he(e)}len(){return JR(this)}lengthSquared(){return QR(this)}dot(e){return qR(this,e)}rotationTo(e,r){return t2(this,e,r),this.check()}add(e){return YR(this,this,e),this.check()}calculateW(){return GR(this,this),this.check()}conjugate(){return XR(this,this),this.check()}invert(){return $R(this,this),this.check()}lerp(e,r,o){return o===void 0?this.lerp(this,e,r):(ZR(this,e,r,o),this.check())}multiplyRight(e){return fT(this,this,e),this.check()}multiplyLeft(e){return fT(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return HR(this,this,e),this.check()}rotateY(e){return jR(this,this,e),this.check()}rotateZ(e){return WR(this,this,e),this.check()}scale(e){return KR(this,this,e),this.check()}slerp(e,r,o){let n,i,s;switch(arguments.length){case 1:({start:n=A$,target:i,ratio:s}=e);break;case 2:n=this,i=e,s=r;break;default:n=e,i=r,s=o}return xf(this,n,i,s),this.check()}transformVector4(e,r=new La){return iT(r,e,this),Qn(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var r2=1e-6,T$=6371e3,$r=class{constructor({phi:e=0,theta:r=0,radius:o=1,bearing:n,pitch:i,altitude:s,radiusScale:a=T$}={}){this.phi=e,this.theta=r,this.radius=o||s||1,this.radiusScale=a||1,n!==void 0&&(this.bearing=n),i!==void 0&&(this.pitch=i),this.check()}toString(){return this.formatString(ve)}formatString({printTypes:e=!1}){let r=df;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Ce(this.radius,e.radius)&&Ce(this.theta,e.theta)&&Ce(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-rt(this.phi)}set bearing(e){this.phi=Math.PI-es(e)}get pitch(){return rt(this.theta)}set pitch(e){this.theta=es(e)}get longitude(){return rt(this.phi)}get latitude(){return rt(this.theta)}get lng(){return rt(this.phi)}get lat(){return rt(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,o){return this.radius=e,this.phi=r,this.theta=o,this.check()}clone(){return new $r().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,o]){return this.radius=1+o/this.radiusScale,this.phi=es(r),this.theta=es(e),this.check()}fromVector3(e){return this.radius=lm(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(ee(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new E(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(r2,Math.min(Math.PI-r2,this.phi)),this}check(){if(!Number.isFinite(this.phi)||!Number.isFinite(this.theta)||!(this.radius>0))throw new Error("SphericalCoordinates: some fields set to invalid numbers");return this}};var Cr={};ze(Cr,{EPSILON1:()=>v$,EPSILON10:()=>L$,EPSILON11:()=>B$,EPSILON12:()=>O$,EPSILON13:()=>F$,EPSILON14:()=>N$,EPSILON15:()=>D$,EPSILON16:()=>U$,EPSILON17:()=>k$,EPSILON18:()=>V$,EPSILON19:()=>z$,EPSILON2:()=>S$,EPSILON20:()=>H$,EPSILON3:()=>C$,EPSILON4:()=>E$,EPSILON5:()=>w$,EPSILON6:()=>P$,EPSILON7:()=>M$,EPSILON8:()=>R$,EPSILON9:()=>I$,PI_OVER_FOUR:()=>W$,PI_OVER_SIX:()=>G$,PI_OVER_TWO:()=>j$,TWO_PI:()=>$$});var v$=.1,S$=.01,C$=.001,E$=1e-4,w$=1e-5,P$=1e-6,M$=1e-7,R$=1e-8,I$=1e-9,L$=1e-10,B$=1e-11,O$=1e-12,F$=1e-13,N$=1e-14,D$=1e-15,U$=1e-16,k$=1e-17,V$=1e-18,z$=1e-19,H$=1e-20,j$=Math.PI/2,W$=Math.PI/4,G$=Math.PI/6,$$=Math.PI*2;function xm(t,e=[],r=0){let o=Math.fround(t),n=t-o;return e[r]=o,e[r+1]=n,e}function dT(t){return t-Math.fround(t)}function hT(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let o=0;o<4;++o){let n=r*4+o;xm(t[o*4+r],e,n*2)}return e}function bf(t,e=!0){return t??e}function Oa(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}function pT(t,e=!0){let r=Oa(t.slice(0,3),e),o=Number.isFinite(t[3]),n=o?t[3]:1;return[r[0],r[1],r[2],e&&o?n/255:n]}var X$=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
// All these functions are for substituting tan() function from Intel GPU only
const float TWO_PI = 6.2831854820251465;
const float PI_2 = 1.5707963705062866;
const float PI_16 = 0.1963495463132858;
const float SIN_TABLE_0 = 0.19509032368659973;
const float SIN_TABLE_1 = 0.3826834261417389;
const float SIN_TABLE_2 = 0.5555702447891235;
const float SIN_TABLE_3 = 0.7071067690849304;
const float COS_TABLE_0 = 0.9807852506637573;
const float COS_TABLE_1 = 0.9238795042037964;
const float COS_TABLE_2 = 0.8314695954322815;
const float COS_TABLE_3 = 0.7071067690849304;
const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!
const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!
const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!
const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!
float sin_taylor_fp32(float a) {
float r, s, t, x;
if (a == 0.0) {
return 0.0;
}
x = -a * a;
s = a;
r = a;
r = r * x;
t = r * INVERSE_FACTORIAL_3;
s = s + t;
r = r * x;
t = r * INVERSE_FACTORIAL_5;
s = s + t;
r = r * x;
t = r * INVERSE_FACTORIAL_7;
s = s + t;
r = r * x;
t = r * INVERSE_FACTORIAL_9;
s = s + t;
return s;
}
void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {
if (a == 0.0) {
sin_t = 0.0;
cos_t = 1.0;
}
sin_t = sin_taylor_fp32(a);
cos_t = sqrt(1.0 - sin_t * sin_t);
}
float tan_taylor_fp32(float a) {
float sin_a;
float cos_a;
if (a == 0.0) {
return 0.0;
}
// 2pi range reduction
float z = floor(a / TWO_PI);
float r = a - TWO_PI * z;
float t;
float q = floor(r / PI_2 + 0.5);
int j = int(q);
if (j < -2 || j > 2) {
return 1.0 / 0.0;
}
t = r - PI_2 * q;
q = floor(t / PI_16 + 0.5);
int k = int(q);
int abs_k = int(abs(float(k)));
if (abs_k > 4) {
return 1.0 / 0.0;
} else {
t = t - PI_16 * q;
}
float u = 0.0;
float v = 0.0;
float sin_t, cos_t;
float s, c;
sincos_taylor_fp32(t, sin_t, cos_t);
if (k == 0) {
s = sin_t;
c = cos_t;
} else {
if (abs(float(abs_k) - 1.0) < 0.5) {
u = COS_TABLE_0;
v = SIN_TABLE_0;
} else if (abs(float(abs_k) - 2.0) < 0.5) {
u = COS_TABLE_1;
v = SIN_TABLE_1;
} else if (abs(float(abs_k) - 3.0) < 0.5) {
u = COS_TABLE_2;
v = SIN_TABLE_2;
} else if (abs(float(abs_k) - 4.0) < 0.5) {
u = COS_TABLE_3;
v = SIN_TABLE_3;
}
if (k > 0) {
s = u * sin_t + v * cos_t;
c = u * cos_t - v * sin_t;
} else {
s = u * sin_t - v * cos_t;
c = u * cos_t + v * sin_t;
}
}
if (j == 0) {
sin_a = s;
cos_a = c;
} else if (j == 1) {
sin_a = c;
cos_a = -s;
} else if (j == -1) {
sin_a = -c;
cos_a = s;
} else {
sin_a = -s;
cos_a = -c;
}
return sin_a / cos_a;
}
#endif
float tan_fp32(float a) {
#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
return tan_taylor_fp32(a);
#else
return tan(a);
#endif
}
`,mT={name:"fp32",vs:X$};var gT=`
layout(std140) uniform fp64arithmeticUniforms {
uniform float ONE;
uniform float SPLIT;
} fp64;
/*
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
The purpose of this workaround is to prevent shader compilers from
optimizing away necessary arithmetic operations by swapping their sequences
or transform the equation to some 'equivalent' form.
These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
folds constants or reassociates the arithmetic, the high/low split can stop
tracking the rounding error correctly. That failure mode tends to look fine in
simple coordinate setup, but then breaks down inside iterative arithmetic such
as fp64 Mandelbrot loops.
The method is to multiply an artifical variable, ONE, which will be known to
the compiler to be 1 only at runtime. The whole expression is then represented
as a polynomial with respective to ONE. In the coefficients of all terms, only one a
and one b should appear
err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
*/
float prevent_fp64_optimization(float value) {
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
return value + fp64.ONE * 0.0;
#else
return value;
#endif
}
// Divide float number to high and low floats to extend fraction bits
vec2 split(float a) {
// Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
// split into a constant expression and reassociate the recovery steps.
float split = prevent_fp64_optimization(fp64.SPLIT);
float t = prevent_fp64_optimization(a * split);
float temp = t - a;
float a_hi = t - temp;
float a_lo = a - a_hi;
return vec2(a_hi, a_lo);
}
// Divide float number again when high float uses too many fraction bits
vec2 split2(vec2 a) {
vec2 b = split(a.x);
b.y += a.y;
return b;
}
// Special sum operation when a > b
vec2 quickTwoSum(float a, float b) {
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
float sum = (a + b) * fp64.ONE;
float err = b - (sum - a) * fp64.ONE;
#else
float sum = a + b;
float err = b - (sum - a);
#endif
return vec2(sum, err);
}
// General sum operation
vec2 twoSum(float a, float b) {
float s = (a + b);
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
float v = (s * fp64.ONE - a) * fp64.ONE;
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);
#else
float v = s - a;
float err = (a - (s - v)) + (b - v);
#endif
return vec2(s, err);
}
vec2 twoSub(float a, float b) {
float s = (a - b);
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
float v = (s * fp64.ONE - a) * fp64.ONE;
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);
#else
float v = s - a;
float err = (a - (s - v)) - (b + v);
#endif
return vec2(s, err);
}
vec2 twoSqr(float a) {
float prod = a * a;
vec2 a_fp64 = split(a);
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *
a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;
#else
float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
#endif
return vec2(prod, err);
}
vec2 twoProd(float a, float b) {
float prod = a * b;
vec2 a_fp64 = split(a);
vec2 b_fp64 = split(b);
// twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
// on the split terms and cross terms staying in the original evaluation
// order. If the compiler folds or reassociates them, the low part tends to
// collapse to zero or NaN on some drivers.
float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
float err1 = (highProduct - prod) * fp64.ONE;
float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
#else
float err1 = highProduct - prod;
float err2 = crossProduct1;
float err3 = crossProduct2;
float err4 = lowProduct;
#endif
float err = ((err1 + err2) + err3) + err4;
return vec2(prod, err);
}
vec2 sum_fp64(vec2 a, vec2 b) {
vec2 s, t;
s = twoSum(a.x, b.x);
t = twoSum(a.y, b.y);
s.y += t.x;
s = quickTwoSum(s.x, s.y);
s.y += t.y;
s = quickTwoSum(s.x, s.y);
return s;
}
vec2 sub_fp64(vec2 a, vec2 b) {
vec2 s, t;
s = twoSub(a.x, b.x);
t = twoSub(a.y, b.y);
s.y += t.x;
s = quickTwoSum(s.x, s.y);
s.y += t.y;
s = quickTwoSum(s.x, s.y);
return s;
}
vec2 mul_fp64(vec2 a, vec2 b) {
vec2 prod = twoProd(a.x, b.x);
// y component is for the error
prod.y += a.x * b.y;
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
prod = split2(prod);
#endif
prod = quickTwoSum(prod.x, prod.y);
prod.y += a.y * b.x;
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
prod = split2(prod);
#endif
prod = quickTwoSum(prod.x, prod.y);
return prod;
}
vec2 div_fp64(vec2 a, vec2 b) {
float xn = 1.0 / b.x;
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
vec2 yn = mul_fp64(a, vec2(xn, 0));
#else
vec2 yn = a * xn;
#endif
float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
vec2 prod = twoProd(xn, diff);
return sum_fp64(yn, prod);
}
vec2 sqrt_fp64(vec2 a) {
if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
float x = 1.0 / sqrt(a.x);
float yn = a.x * x;
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
vec2 yn_sqr = twoSqr(yn) * fp64.ONE;
#else
vec2 yn_sqr = twoSqr(yn);
#endif
float diff = sub_fp64(a, yn_sqr).x;
vec2 prod = twoProd(x * 0.5, diff);
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
return sum_fp64(split(yn), prod);
#else
return sum_fp64(vec2(yn, 0.0), prod);
#endif
}
`;var o2=`struct Fp64ArithmeticUniforms {
ONE: f32,
SPLIT: f32,
};
@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
fn fp64_nan(seed: f32) -> f32 {
let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
return bitcast<f32>(nanBits);
}
fn fp64_runtime_zero() -> f32 {
return fp64arithmetic.ONE * 0.0;
}
fn prevent_fp64_optimization(value: f32) -> f32 {
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
return value + fp64_runtime_zero();
#else
return value;
#endif
}
fn split(a: f32) -> vec2f {
let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
let t = prevent_fp64_optimization(a * splitValue);
let temp = prevent_fp64_optimization(t - a);
let aHi = prevent_fp64_optimization(t - temp);
let aLo = prevent_fp64_optimization(a - aHi);
return vec2f(aHi, aLo);
}
fn split2(a: vec2f) -> vec2f {
var b = split(a.x);
b.y = b.y + a.y;
return b;
}
fn quickTwoSum(a: f32, b: f32) -> vec2f {
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);
let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);
#else
let sum = prevent_fp64_optimization(a + b);
let err = prevent_fp64_optimization(b - (sum - a));
#endif
return vec2f(sum, err);
}
fn twoSum(a: f32, b: f32) -> vec2f {
let s = prevent_fp64_optimization(a + b);
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
let err =
prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
fp64arithmetic.ONE *
fp64arithmetic.ONE *
fp64arithmetic.ONE) +
prevent_fp64_optimization(b - v);
#else
let v = prevent_fp64_optimization(s - a);
let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);
#endif
return vec2f(s, err);
}
fn twoSub(a: f32, b: f32) -> vec2f {
let s = prevent_fp64_optimization(a - b);
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
let err =
prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
fp64arithmetic.ONE *
fp64arithmetic.ONE *
fp64arithmetic.ONE) -
prevent_fp64_optimization(b + v);
#else
let v = prevent_fp64_optimization(s - a);
let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);
#endif
return vec2f(s, err);
}
fn twoSqr(a: f32) -> vec2f {
let prod = prevent_fp64_optimization(a * a);
let aFp64 = split(a);
let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);
let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);
let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
let err =
(prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +
crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +
lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
#else
let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);
#endif
return vec2f(prod, err);
}
fn twoProd(a: f32, b: f32) -> vec2f {
let prod = prevent_fp64_optimization(a * b);
let aFp64 = split(a);
let bFp64 = split(b);
let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);
let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);
let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);
let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
let err1 = (highProduct - prod) * fp64arithmetic.ONE;
let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;
let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
let err4 =
lowProduct *
fp64arithmetic.ONE *
fp64arithmetic.ONE *
fp64arithmetic.ONE *
fp64arithmetic.ONE;
#else
let err1 = highProduct - prod;
let err2 = crossProduct1;
let err3 = crossProduct2;
let err4 = lowProduct;
#endif
let err12InputA = prevent_fp64_optimization(err1);
let err12InputB = prevent_fp64_optimization(err2);
let err12 = prevent_fp64_optimization(err12InputA + err12InputB);
let err123InputA = prevent_fp64_optimization(err12);
let err123InputB = prevent_fp64_optimization(err3);
let err123 = prevent_fp64_optimization(err123InputA + err123InputB);
let err1234InputA = prevent_fp64_optimization(err123);
let err1234InputB = prevent_fp64_optimization(err4);
let err = prevent_fp64_optimization(err1234InputA + err1234InputB);
return vec2f(prod, err);
}
fn sum_fp64(a: vec2f, b: vec2f) -> vec2f {
var s = twoSum(a.x, b.x);
let t = twoSum(a.y, b.y);
s.y = prevent_fp64_optimization(s.y + t.x);
s = quickTwoSum(s.x, s.y);
s.y = prevent_fp64_optimization(s.y + t.y);
s = quickTwoSum(s.x, s.y);
return s;
}
fn sub_fp64(a: vec2f, b: vec2f) -> vec2f {
var s = twoSub(a.x, b.x);
let t = twoSub(a.y, b.y);
s.y = prevent_fp64_optimization(s.y + t.x);
s = quickTwoSum(s.x, s.y);
s.y = prevent_fp64_optimization(s.y + t.y);
s = quickTwoSum(s.x, s.y);
return s;
}
fn mul_fp64(a: vec2f, b: vec2f) -> vec2f {
var prod = twoProd(a.x, b.x);
let crossProduct1 = prevent_fp64_optimization(a.x * b.y);
prod.y = prevent_fp64_optimization(prod.y + crossProduct1);
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
prod = split2(prod);
#endif
prod = quickTwoSum(prod.x, prod.y);
let crossProduct2 = prevent_fp64_optimization(a.y * b.x);
prod.y = prevent_fp64_optimization(prod.y + crossProduct2);
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
prod = split2(prod);
#endif
prod = quickTwoSum(prod.x, prod.y);
return prod;
}
fn div_fp64(a: vec2f, b: vec2f) -> vec2f {
let xn = prevent_fp64_optimization(1.0 / b.x);
let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));
let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);
let prod = twoProd(xn, diff);
return sum_fp64(yn, prod);
}
fn sqrt_fp64(a: vec2f) -> vec2f {
if (a.x == 0.0 && a.y == 0.0) {
return vec2f(0.0, 0.0);
}
if (a.x < 0.0) {
let nanValue = fp64_nan(a.x);
return vec2f(nanValue, nanValue);
}
let x = prevent_fp64_optimization(1.0 / sqrt(a.x));
let yn = prevent_fp64_optimization(a.x * x);
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;
#else
let ynSqr = twoSqr(yn);
#endif
let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);
let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
return sum_fp64(split(yn), prod);
#else
return sum_fp64(vec2f(yn, 0.0), prod);
#endif
}
`;var n2=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
const vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8);
const vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8);
const vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9);
const vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8);
const vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9);
const vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10);
const vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9);
const vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9);
const vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8);
const vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8);
const vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8);
const vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8);
const vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8);
const vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8);
const vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09); // 1/3!
const vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09); // 1/4!
const vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10); // 1/5!
const vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11); // 1/6!
const vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12); // 1/7!
const vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13); // 1/8!
const vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14); // 1/9!
const vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15); // 1/10!
float nint(float d) {
if (d == floor(d)) return d;
return floor(d + 0.5);
}
vec2 nint_fp64(vec2 a) {
float hi = nint(a.x);
float lo;
vec2 tmp;
if (hi == a.x) {
lo = nint(a.y);
tmp = quickTwoSum(hi, lo);
} else {
lo = 0.0;
if (abs(hi - a.x) == 0.5 && a.y < 0.0) {
hi -= 1.0;
}
tmp = vec2(hi, lo);
}
return tmp;
}
/* k_power controls how much range reduction we would like to have
Range reduction uses the following method:
assume a = k_power * r + m * log(2), k and m being integers.
Set k_power = 4 (we can choose other k to trade accuracy with performance.
we only need to calculate exp(r) and using exp(a) = 2^m * exp(r)^k_power;
*/
vec2 exp_fp64(vec2 a) {
// We need to make sure these two numbers match
// as bit-wise shift is not available in GLSL 1.0
const int k_power = 4;
const float k = 16.0;
const float inv_k = 1.0 / k;
if (a.x <= -88.0) return vec2(0.0, 0.0);
if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0);
if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0);
if (a.x == 1.0 && a.y == 0.0) return E_FP64;
float m = floor(a.x / LOG2_FP64.x + 0.5);
vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k;
vec2 s, t, p;
p = mul_fp64(r, r);
s = sum_fp64(r, p * 0.5);
p = mul_fp64(p, r);
t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64);
s = sum_fp64(s, t);
p = mul_fp64(p, r);
t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64);
s = sum_fp64(s, t);
p = mul_fp64(p, r);
t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64);
// s = sum_fp64(s, t);
// p = mul_fp64(p, r);
// t = mul_fp64(p, INVERSE_FACTORIAL_6_FP64);
// s = sum_fp64(s, t);
// p = mul_fp64(p, r);
// t = mul_fp64(p, INVERSE_FACTORIAL_7_FP64);
s = sum_fp64(s, t);
// At this point, s = exp(r) - 1; but after following 4 recursions, we will get exp(r) ^ 512 - 1.
for (int i = 0; i < k_power; i++) {
s = sum_fp64(s * 2.0, mul_fp64(s, s));
}
#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
s = sum_fp64(s, vec2(fp64.ONE, 0.0));
#else
s = sum_fp64(s, vec2(1.0, 0.0));
#endif
return s * pow(2.0, m);
// return r;
}
vec2 log_fp64(vec2 a)
{
if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0);
if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
vec2 x = vec2(log(a.x), 0.0);
vec2 s;
#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
s = vec2(fp64.ONE, 0.0);
#else
s = vec2(1.0, 0.0);
#endif
x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s);
return x;
}
vec2 sin_taylor_fp64(vec2 a) {
vec2 r, s, t, x;
if (a.x == 0.0 && a.y == 0.0) {
return vec2(0.0, 0.0);
}
x = -mul_fp64(a, a);
s = a;
r = a;
r = mul_fp64(r, x);
t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64);
s = sum_fp64(s, t);
r = mul_fp64(r, x);
t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64);
s = sum_fp64(s, t);
/* keep the following commented code in case we need them
for extra accuracy from the Taylor expansion*/
// r = mul_fp64(r, x);
// t = mul_fp64(r, INVERSE_FACTORIAL_7_FP64);
// s = sum_fp64(s, t);
// r = mul_fp64(r, x);
// t = mul_fp64(r, INVERSE_FACTORIAL_9_FP64);
// s = sum_fp64(s, t);
return s;
}
vec2 cos_taylor_fp64(vec2 a) {
vec2 r, s, t, x;
if (a.x == 0.0 && a.y == 0.0) {
return vec2(1.0, 0.0);
}
x = -mul_fp64(a, a);
r = x;
s = sum_fp64(vec2(1.0, 0.0), r * 0.5);
r = mul_fp64(r, x);
t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64);
s = sum_fp64(s, t);
r = mul_fp64(r, x);
t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64);
s = sum_fp64(s, t);
/* keep the following commented code in case we need them
for extra accuracy from the Taylor expansion*/
// r = mul_fp64(r, x);
// t = mul_fp64(r, INVERSE_FACTORIAL_8_FP64);
// s = sum_fp64(s, t);
// r = mul_fp64(r, x);
// t = mul_fp64(r, INVERSE_FACTORIAL_10_FP64);
// s = sum_fp64(s, t);
return s;
}
void sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) {
if (a.x == 0.0 && a.y == 0.0) {
sin_t = vec2(0.0, 0.0);
cos_t = vec2(1.0, 0.0);
}
sin_t = sin_taylor_fp64(a);
cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t)));
}
vec2 sin_fp64(vec2 a) {
if (a.x == 0.0 && a.y == 0.0) {
return vec2(0.0, 0.0);
}
// 2pi range reduction
vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
vec2 t;
float q = floor(r.x / PI_2_FP64.x + 0.5);
int j = int(q);
if (j < -2 || j > 2) {
return vec2(0.0 / 0.0, 0.0 / 0.0);
}
t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
q = floor(t.x / PI_16_FP64.x + 0.5);
int k = int(q);
if (k == 0) {
if (j == 0) {
return sin_taylor_fp64(t);
} else if (j == 1) {
return cos_taylor_fp64(t);
} else if (j == -1) {
return -cos_taylor_fp64(t);
} else {
return -sin_taylor_fp64(t);
}
}
int abs_k = int(abs(float(k)));
if (abs_k > 4) {
return vec2(0.0 / 0.0, 0.0 / 0.0);
} else {
t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
}
vec2 u = vec2(0.0, 0.0);
vec2 v = vec2(0.0, 0.0);
#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
if (abs(float(abs_k) - 1.0) < 0.5) {
u = COS_TABLE_0_FP64;
v = SIN_TABLE_0_FP64;
} else if (abs(float(abs_k) - 2.0) < 0.5) {
u = COS_TABLE_1_FP64;
v = SIN_TABLE_1_FP64;
} else if (abs(float(abs_k) - 3.0) < 0.5) {
u = COS_TABLE_2_FP64;
v = SIN_TABLE_2_FP64;
} else if (abs(float(abs_k) - 4.0) < 0.5) {
u = COS_TABLE_3_FP64;
v = SIN_TABLE_3_FP64;
}
#else
if (abs_k == 1) {
u = COS_TABLE_0_FP64;
v = SIN_TABLE_0_FP64;
} else if (abs_k == 2) {
u = COS_TABLE_1_FP64;
v = SIN_TABLE_1_FP64;
} else if (abs_k == 3) {
u = COS_TABLE_2_FP64;
v = SIN_TABLE_2_FP64;
} else if (abs_k == 4) {
u = COS_TABLE_3_FP64;
v = SIN_TABLE_3_FP64;
}
#endif
vec2 sin_t, cos_t;
sincos_taylor_fp64(t, sin_t, cos_t);
vec2 result = vec2(0.0, 0.0);
if (j == 0) {
if (k > 0) {
result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
} else {
result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
}
} else if (j == 1) {
if (k > 0) {
result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
} else {
result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
}
} else if (j == -1) {
if (k > 0) {
result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
} else {
result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
}
} else {
if (k > 0) {
result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
} else {
result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));
}
}
return result;
}
vec2 cos_fp64(vec2 a) {
if (a.x == 0.0 && a.y == 0.0) {
return vec2(1.0, 0.0);
}
// 2pi range reduction
vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
vec2 t;
float q = floor(r.x / PI_2_FP64.x + 0.5);
int j = int(q);
if (j < -2 || j > 2) {
return vec2(0.0 / 0.0, 0.0 / 0.0);
}
t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
q = floor(t.x / PI_16_FP64.x + 0.5);
int k = int(q);
if (k == 0) {
if (j == 0) {
return cos_taylor_fp64(t);
} else if (j == 1) {
return -sin_taylor_fp64(t);
} else if (j == -1) {
return sin_taylor_fp64(t);
} else {
return -cos_taylor_fp64(t);
}
}
int abs_k = int(abs(float(k)));
if (abs_k > 4) {
return vec2(0.0 / 0.0, 0.0 / 0.0);
} else {
t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
}
vec2 u = vec2(0.0, 0.0);
vec2 v = vec2(0.0, 0.0);
#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
if (abs(float(abs_k) - 1.0) < 0.5) {
u = COS_TABLE_0_FP64;
v = SIN_TABLE_0_FP64;
} else if (abs(float(abs_k) - 2.0) < 0.5) {
u = COS_TABLE_1_FP64;
v = SIN_TABLE_1_FP64;
} else if (abs(float(abs_k) - 3.0) < 0.5) {
u = COS_TABLE_2_FP64;
v = SIN_TABLE_2_FP64;
} else if (abs(float(abs_k) - 4.0) < 0.5) {
u = COS_TABLE_3_FP64;
v = SIN_TABLE_3_FP64;
}
#else
if (abs_k == 1) {
u = COS_TABLE_0_FP64;
v = SIN_TABLE_0_FP64;
} else if (abs_k == 2) {
u = COS_TABLE_1_FP64;
v = SIN_TABLE_1_FP64;
} else if (abs_k == 3) {
u = COS_TABLE_2_FP64;
v = SIN_TABLE_2_FP64;
} else if (abs_k == 4) {
u = COS_TABLE_3_FP64;
v = SIN_TABLE_3_FP64;
}
#endif
vec2 sin_t, cos_t;
sincos_taylor_fp64(t, sin_t, cos_t);
vec2 result = vec2(0.0, 0.0);
if (j == 0) {
if (k > 0) {
result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
} else {
result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
}
} else if (j == 1) {
if (k > 0) {
result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
} else {
result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t));
}
} else if (j == -1) {
if (k > 0) {
result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
} else {
result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
}
} else {
if (k > 0) {
result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t));
} else {
result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
}
}
return result;
}
vec2 tan_fp64(vec2 a) {
vec2 sin_a;
vec2 cos_a;
if (a.x == 0.0 && a.y == 0.0) {
return vec2(0.0, 0.0);
}
// 2pi range reduction
vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64));
vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z));
vec2 t;
float q = floor(r.x / PI_2_FP64.x + 0.5);
int j = int(q);
if (j < -2 || j > 2) {
return vec2(0.0 / 0.0, 0.0 / 0.0);
}
t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0)));
q = floor(t.x / PI_16_FP64.x + 0.5);
int k = int(q);
int abs_k = int(abs(float(k)));
// We just can't get PI/16 * 3.0 very accurately.
// so let's just store it
if (abs_k > 4) {
return vec2(0.0 / 0.0, 0.0 / 0.0);
} else {
t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0)));
}
vec2 u = vec2(0.0, 0.0);
vec2 v = vec2(0.0, 0.0);
vec2 sin_t, cos_t;
vec2 s, c;
sincos_taylor_fp64(t, sin_t, cos_t);
if (k == 0) {
s = sin_t;
c = cos_t;
} else {
#if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND)
if (abs(float(abs_k) - 1.0) < 0.5) {
u = COS_TABLE_0_FP64;
v = SIN_TABLE_0_FP64;
} else if (abs(float(abs_k) - 2.0) < 0.5) {
u = COS_TABLE_1_FP64;
v = SIN_TABLE_1_FP64;
} else if (abs(float(abs_k) - 3.0) < 0.5) {
u = COS_TABLE_2_FP64;
v = SIN_TABLE_2_FP64;
} else if (abs(float(abs_k) - 4.0) < 0.5) {
u = COS_TABLE_3_FP64;
v = SIN_TABLE_3_FP64;
}
#else
if (abs_k == 1) {
u = COS_TABLE_0_FP64;
v = SIN_TABLE_0_FP64;
} else if (abs_k == 2) {
u = COS_TABLE_1_FP64;
v = SIN_TABLE_1_FP64;
} else if (abs_k == 3) {
u = COS_TABLE_2_FP64;
v = SIN_TABLE_2_FP64;
} else if (abs_k == 4) {
u = COS_TABLE_3_FP64;
v = SIN_TABLE_3_FP64;
}
#endif
if (k > 0) {
s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
} else {
s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t));
c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t));
}
}
if (j == 0) {
sin_a = s;
cos_a = c;
} else if (j == 1) {
sin_a = c;
cos_a = -s;
} else if (j == -1) {
sin_a = -c;
cos_a = s;
} else {
sin_a = -s;
cos_a = -c;
}
return div_fp64(sin_a, cos_a);
}
vec2 radians_fp64(vec2 degree) {
return mul_fp64(degree, PI_180_FP64);
}
vec2 mix_fp64(vec2 a, vec2 b, float x) {
vec2 range = sub_fp64(b, a);
return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));
}
// Vector functions
// vec2 functions
void vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
out_val[0] = sum_fp64(a[0], b[0]);
out_val[1] = sum_fp64(a[1], b[1]);
}
void vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
out_val[0] = sub_fp64(a[0], b[0]);
out_val[1] = sub_fp64(a[1], b[1]);
}
void vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
out_val[0] = mul_fp64(a[0], b[0]);
out_val[1] = mul_fp64(a[1], b[1]);
}
void vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) {
out_val[0] = div_fp64(a[0], b[0]);
out_val[1] = div_fp64(a[1], b[1]);
}
void vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) {
vec2 range[2];
vec2_sub_fp64(y, x, range);
vec2 portion[2];
portion[0] = range[0] * a;
portion[1] = range[1] * a;
vec2_sum_fp64(x, portion, out_val);
}
vec2 vec2_length_fp64(vec2 x[2]) {
return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])));
}
void vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) {
vec2 length = vec2_length_fp64(x);
vec2 length_vec2[2];
length_vec2[0] = length;
length_vec2[1] = length;
vec2_div_fp64(x, length_vec2, out_val);
}
vec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) {
vec2 diff[2];
vec2_sub_fp64(x, y, diff);
return vec2_length_fp64(diff);
}
vec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) {
vec2 v[2];
v[0] = mul_fp64(a[0], b[0]);
v[1] = mul_fp64(a[1], b[1]);
return sum_fp64(v[0], v[1]);
}
// vec3 functions
void vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {
for (int i = 0; i < 3; i++) {
out_val[i] = sum_fp64(a[i], b[i]);
}
}
void vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) {
for (int i = 0; i < 3; i++) {
out_val[i] = sum_fp64(a[i], b[i]);
}
}
vec2 vec3_length_fp64(vec2 x[3]) {
return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])),
mul_fp64(x[2], x[2])));
}
vec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) {
vec2 diff[3];
vec3_sub_fp64(x, y, diff);
return vec3_length_fp64(diff);
}
// vec4 functions
void vec4_fp64(vec4 a, out vec2 out_val[4]) {
out_val[0].x = a[0];
out_val[0].y = 0.0;
out_val[1].x = a[1];
out_val[1].y = 0.0;
out_val[2].x = a[2];
out_val[2].y = 0.0;
out_val[3].x = a[3];
out_val[3].y = 0.0;
}
void vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) {
out_val[0] = mul_fp64(a[0], b);
out_val[1] = mul_fp64(a[1], b);
out_val[2] = mul_fp64(a[2], b);
out_val[3] = mul_fp64(a[3], b);
}
void vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) {
for (int i = 0; i < 4; i++) {
out_val[i] = sum_fp64(a[i], b[i]);
}
}
void vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) {
vec2 v[4];
v[0] = mul_fp64(a[0], b[0]);
v[1] = mul_fp64(a[1], b[1]);
v[2] = mul_fp64(a[2], b[2]);
v[3] = mul_fp64(a[3], b[3]);
out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3]));
}
void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
vec2 tmp[4];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
tmp[j] = b[j + i * 4];
}
vec4_dot_fp64(a, tmp, out_val[i]);
}
}
`;var Y$={ONE:1,SPLIT:4097},bm={name:"fp64arithmetic",source:o2,fs:gT,vs:gT,defaultUniforms:Y$,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:xm,fp64LowPart:dT,fp64ifyMatrix4:hT},Am={name:"fp64",vs:n2,dependencies:[bm],fp64ify:xm,fp64LowPart:dT,fp64ifyMatrix4:hT};var i2=`layout(std140) uniform floatColorsUniforms {
float useByteColors;
} floatColors;
vec3 floatColors_normalize(vec3 inputColor) {
return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;
}
vec4 floatColors_normalize(vec4 inputColor) {
return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;
}
vec4 floatColors_premultiplyAlpha(vec4 inputColor) {
return vec4(inputColor.rgb * inputColor.a, inputColor.a);
}
vec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {
return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);
}
vec4 floatColors_premultiply_alpha(vec4 inputColor) {
return floatColors_premultiplyAlpha(inputColor);
}
vec4 floatColors_unpremultiply_alpha(vec4 inputColor) {
return floatColors_unpremultiplyAlpha(inputColor);
}
`,K$=`struct floatColorsUniforms {
useByteColors: f32
};
@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;
fn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {
return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);
}
fn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {
return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);
}
fn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {
return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);
}
fn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {
return select(
vec4<f32>(0.0),
vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),
inputColor.a > 0.0
);
}
fn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
return floatColors_premultiplyAlpha(inputColor);
}
fn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
return floatColors_unpremultiplyAlpha(inputColor);
}
`,Tm={name:"floatColors",props:{},uniforms:{},vs:i2,fs:i2,source:K$,uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}};var q$=[0,1,1,1],Z$=`layout(std140) uniform pickingUniforms {
float isActive;
float isAttribute;
float isHighlightActive;
float useByteColors;
vec3 highlightedObjectColor;
vec4 highlightColor;
} picking;
out vec4 picking_vRGBcolor_Avalid;
// Normalize unsigned byte color to 0-1 range
vec3 picking_normalizeColor(vec3 color) {
return picking.useByteColors > 0.5 ? color / 255.0 : color;
}
// Normalize unsigned byte color to 0-1 range
vec4 picking_normalizeColor(vec4 color) {
return picking.useByteColors > 0.5 ? color / 255.0 : color;
}
bool picking_isColorZero(vec3 color) {
return dot(color, vec3(1.0)) < 0.00001;
}
bool picking_isColorValid(vec3 color) {
return dot(color, vec3(1.0)) > 0.00001;
}
// Check if this vertex is highlighted
bool isVertexHighlighted(vec3 vertexColor) {
vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
return
bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));
}
// Set the current picking color
void picking_setPickingColor(vec3 pickingColor) {
pickingColor = picking_normalizeColor(pickingColor);
if (bool(picking.isActive)) {
// Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable
picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));
if (!bool(picking.isAttribute)) {
// Stores the picking color so that the fragment shader can render it during picking
picking_vRGBcolor_Avalid.rgb = pickingColor;
}
} else {
// Do the comparison with selected item color in vertex shader as it should mean fewer compares
picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));
}
}
void picking_setPickingAttribute(float value) {
if (bool(picking.isAttribute)) {
picking_vRGBcolor_Avalid.r = value;
}
}
void picking_setPickingAttribute(vec2 value) {
if (bool(picking.isAttribute)) {
picking_vRGBcolor_Avalid.rg = value;
}
}
void picking_setPickingAttribute(vec3 value) {
if (bool(picking.isAttribute)) {
picking_vRGBcolor_Avalid.rgb = value;
}
}
`,J$=`layout(std140) uniform pickingUniforms {
float isActive;
float isAttribute;
float isHighlightActive;
float useByteColors;
vec3 highlightedObjectColor;
vec4 highlightColor;
} picking;
in vec4 picking_vRGBcolor_Avalid;
/*
* Returns highlight color if this item is selected.
*/
vec4 picking_filterHighlightColor(vec4 color) {
// If we are still picking, we don't highlight
if (picking.isActive > 0.5) {
return color;
}
bool selected = bool(picking_vRGBcolor_Avalid.a);
if (selected) {
// Blend in highlight color based on its alpha value
float highLightAlpha = picking.highlightColor.a;
float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
float highLightRatio = highLightAlpha / blendedAlpha;
vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);
return vec4(blendedRGB, blendedAlpha);
} else {
return color;
}
}
/*
* Returns picking color if picking enabled else unmodified argument.
*/
vec4 picking_filterPickingColor(vec4 color) {
if (bool(picking.isActive)) {
if (picking_vRGBcolor_Avalid.a == 0.0) {
discard;
}
return picking_vRGBcolor_Avalid;
}
return color;
}
/*
* Returns picking color if picking is enabled if not
* highlight color if this item is selected, otherwise unmodified argument.
*/
vec4 picking_filterColor(vec4 color) {
vec4 highlightColor = picking_filterHighlightColor(color);
return picking_filterPickingColor(highlightColor);
}
`,vm={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:q$},vs:Z$,fs:J$,getUniforms:Q$};function Q$(t={},e){let r={},o=bf(t.useByteColors,!0);if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let n=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=n}return t.highlightColor&&(r.highlightColor=pT(t.highlightColor,o)),t.isActive!==void 0&&(r.isActive=Boolean(t.isActive),r.isAttribute=Boolean(t.isAttribute)),t.useByteColors!==void 0&&(r.useByteColors=Boolean(t.useByteColors)),r}var Af=20,eX=`
struct skinUniforms {
jointMatrix: array<mat4x4<f32>, ${Af}>,
};
@group(0) @binding(auto) var<uniform> skin: skinUniforms;
fn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {
return (weights.x * skin.jointMatrix[joints.x])
+ (weights.y * skin.jointMatrix[joints.y])
+ (weights.z * skin.jointMatrix[joints.z])
+ (weights.w * skin.jointMatrix[joints.w]);
}
`,tX=`
layout(std140) uniform skinUniforms {
mat4 jointMatrix[SKIN_MAX_JOINTS];
} skin;
mat4 getSkinMatrix(vec4 weights, uvec4 joints) {
return (weights.x * skin.jointMatrix[joints.x])
+ (weights.y * skin.jointMatrix[joints.y])
+ (weights.z * skin.jointMatrix[joints.z])
+ (weights.w * skin.jointMatrix[joints.w]);
}
`,rX="",_T={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:eX,vs:tX,fs:rX,defines:{SKIN_MAX_JOINTS:Af},getUniforms:(t={},e)=>{let{scenegraphsFromGLTF:r}=t;if(!r?.gltf?.skins?.[0])return{jointMatrix:[]};let{inverseBindMatrices:o,joints:n,skeleton:i}=r.gltf.skins[0],s=[],a=o.value.length/16;for(let u=0;u<a;u++){let d=o.value.subarray(u*16,u*16+16);s.push(new V(Array.from(d)))}let c=r.gltfNodeIndexToNodeMap.get(i),l={};c.preorderTraversal((u,{worldMatrix:d})=>{l[u.id]=d});let f=new Float32Array(Af*16);for(let u=0;u<Af;++u){let d=n[u];if(d===void 0)break;let h=l[r.gltfNodeIndexToNodeMap.get(d).id],p=s[u],m=new V().copy(h).multiplyRight(p),g=u*16;for(let _=0;_<16;_++)f[g+_]=m[_]}return{jointMatrix:f}},uniformTypes:{jointMatrix:["mat4x4<f32>",Af]}};q();var pv=`precision highp int;
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
struct AmbientLight {
vec3 color;
};
struct PointLight {
vec3 color;
vec3 position;
vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
};
struct SpotLight {
vec3 color;
vec3 position;
vec3 direction;
vec3 attenuation;
vec2 coneCos;
};
struct DirectionalLight {
vec3 color;
vec3 direction;
};
struct UniformLight {
vec3 color;
vec3 position;
vec3 direction;
vec3 attenuation;
vec2 coneCos;
};
layout(std140) uniform lightingUniforms {
int enabled;
int directionalLightCount;
int pointLightCount;
int spotLightCount;
vec3 ambientColor;
UniformLight lights[5];
} lighting;
PointLight lighting_getPointLight(int index) {
UniformLight light = lighting.lights[index];
return PointLight(light.color, light.position, light.attenuation);
}
SpotLight lighting_getSpotLight(int index) {
UniformLight light = lighting.lights[lighting.pointLightCount + index];
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
}
DirectionalLight lighting_getDirectionalLight(int index) {
UniformLight light =
lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
return DirectionalLight(light.color, light.direction);
}
float getPointLightAttenuation(PointLight pointLight, float distance) {
return pointLight.attenuation.x
+ pointLight.attenuation.y * distance
+ pointLight.attenuation.z * distance * distance;
}
float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
vec3 light_direction = normalize(positionWorldspace - spotLight.position);
float coneFactor = smoothstep(
spotLight.coneCos.y,
spotLight.coneCos.x,
dot(normalize(spotLight.direction), light_direction)
);
float distanceAttenuation = getPointLightAttenuation(
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
distance(spotLight.position, positionWorldspace)
);
return distanceAttenuation / max(coneFactor, 0.0001);
}
// #endif
`;var aI=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
const MAX_LIGHTS: i32 = 5;
struct AmbientLight {
color: vec3<f32>,
};
struct PointLight {
color: vec3<f32>,
position: vec3<f32>,
attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
};
struct SpotLight {
color: vec3<f32>,
position: vec3<f32>,
direction: vec3<f32>,
attenuation: vec3<f32>,
coneCos: vec2<f32>,
};
struct DirectionalLight {
color: vec3<f32>,
direction: vec3<f32>,
};
struct UniformLight {
color: vec3<f32>,
position: vec3<f32>,
direction: vec3<f32>,
attenuation: vec3<f32>,
coneCos: vec2<f32>,
};
struct lightingUniforms {
enabled: i32,
directionalLightCount: i32,
pointLightCount: i32,
spotLightCount: i32,
ambientColor: vec3<f32>,
lights: array<UniformLight, 5>,
};
@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
fn lighting_getPointLight(index: i32) -> PointLight {
let light = lighting.lights[index];
return PointLight(light.color, light.position, light.attenuation);
}
fn lighting_getSpotLight(index: i32) -> SpotLight {
let light = lighting.lights[lighting.pointLightCount + index];
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
}
fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
return DirectionalLight(light.color, light.direction);
}
fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
return pointLight.attenuation.x
+ pointLight.attenuation.y * distance
+ pointLight.attenuation.z * distance * distance;
}
fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
let lightDirection = normalize(positionWorldspace - spotLight.position);
let coneFactor = smoothstep(
spotLight.coneCos.y,
spotLight.coneCos.x,
dot(normalize(spotLight.direction), lightDirection)
);
let distanceAttenuation = getPointLightAttenuation(
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
distance(spotLight.position, positionWorldspace)
);
return distanceAttenuation / max(coneFactor, 0.0001);
}
`;var ss=5,y7={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},Ka={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[y7,ss]},defaultUniforms:Gm(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:aI,vs:pv,fs:pv,getUniforms:x7};function x7(t,e={}){if(t=t&&{...t},!t)return Gm();t.lights&&(t={...t,...A7(t.lights),lights:void 0});let{useByteColors:r,ambientLight:o,pointLights:n,spotLights:i,directionalLights:s}=t||{};if(!(o||n&&n.length>0||i&&i.length>0||s&&s.length>0))return{...Gm(),enabled:0};let c={...Gm(),...b7({useByteColors:r,ambientLight:o,pointLights:n,spotLights:i,directionalLights:s})};return t.enabled!==void 0&&(c.enabled=t.enabled?1:0),c}function b7({useByteColors:t,ambientLight:e,pointLights:r=[],spotLights:o=[],directionalLights:n=[]}){let i=cI(),s=0,a=0,c=0,l=0;for(let f of r){if(s>=ss)break;i[s]={...i[s],color:Wm(f,t),position:f.position,attenuation:f.attenuation||[1,0,0]},s++,a++}for(let f of o){if(s>=ss)break;i[s]={...i[s],color:Wm(f,t),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:v7(f)},s++,c++}for(let f of n){if(s>=ss)break;i[s]={...i[s],color:Wm(f,t),direction:f.direction},s++,l++}return r.length+o.length+n.length>ss&&P.warn(`MAX_LIGHTS exceeded, truncating to ${ss}`)(),{ambientColor:Wm(e,t),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:i}}function A7(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function Wm(t={},e){let{color:r=[0,0,0],intensity:o=1}=t;return Oa(r,bf(e,!0)).map(i=>i*o)}function Gm(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:cI()}}function cI(){return Array.from({length:ss},()=>T7())}function T7(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function v7(t){let e=t.innerConeAngle??0,r=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(r)]}var S7=`#ifdef USE_IBL
@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;
@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;
@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;
@group(2) @binding(auto) var pbr_specularEnvSamplerSampler: sampler;
@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;
@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;
#endif
`,lI=`#ifdef USE_IBL
uniform samplerCube pbr_diffuseEnvSampler;
uniform samplerCube pbr_specularEnvSampler;
uniform sampler2D pbr_brdfLUT;
#endif
`,fI={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:S7,vs:lI,fs:lI};var $m=`layout(std140) uniform phongMaterialUniforms {
uniform bool unlit;
uniform float ambient;
uniform float diffuse;
uniform float shininess;
uniform vec3 specularColor;
} material;
`,Xm=`layout(std140) uniform phongMaterialUniforms {
uniform bool unlit;
uniform float ambient;
uniform float diffuse;
uniform float shininess;
uniform vec3 specularColor;
} material;
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
vec3 halfway_direction = normalize(light_direction + view_direction);
float lambertian = dot(light_direction, normal_worldspace);
float specular = 0.0;
if (lambertian > 0.0) {
float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
specular = pow(specular_angle, material.shininess);
}
lambertian = max(lambertian, 0.0);
return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;
}
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
vec3 lightColor = surfaceColor;
if (material.unlit) {
return surfaceColor;
}
if (lighting.enabled == 0) {
return lightColor;
}
vec3 view_direction = normalize(cameraPosition - position_worldspace);
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
for (int i = 0; i < lighting.pointLightCount; i++) {
PointLight pointLight = lighting_getPointLight(i);
vec3 light_position_worldspace = pointLight.position;
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
}
for (int i = 0; i < lighting.spotLightCount; i++) {
SpotLight spotLight = lighting_getSpotLight(i);
vec3 light_position_worldspace = spotLight.position;
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);
}
for (int i = 0; i < lighting.directionalLightCount; i++) {
DirectionalLight directionalLight = lighting_getDirectionalLight(i);
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
}
return lightColor;
}
`;var Ym=`struct phongMaterialUniforms {
unlit: u32,
ambient: f32,
diffuse: f32,
shininess: f32,
specularColor: vec3<f32>,
};
@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;
fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);
var lambertian: f32 = dot(light_direction, normal_worldspace);
var specular: f32 = 0.0;
if (lambertian > 0.0) {
let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
specular = pow(specular_angle, phongMaterial.shininess);
}
lambertian = max(lambertian, 0.0);
return (
lambertian * phongMaterial.diffuse * surfaceColor +
specular * floatColors_normalize(phongMaterial.specularColor)
) * color;
}
fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
var lightColor: vec3<f32> = surfaceColor;
if (phongMaterial.unlit != 0u) {
return surfaceColor;
}
if (lighting.enabled == 0) {
return lightColor;
}
let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);
lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;
for (var i: i32 = 0; i < lighting.pointLightCount; i++) {
let pointLight: PointLight = lighting_getPointLight(i);
let light_position_worldspace: vec3<f32> = pointLight.position;
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
let light_attenuation = getPointLightAttenuation(
pointLight,
distance(light_position_worldspace, position_worldspace)
);
lightColor += lighting_getLightColor(
surfaceColor,
light_direction,
view_direction,
normal_worldspace,
pointLight.color / light_attenuation
);
}
for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
let spotLight: SpotLight = lighting_getSpotLight(i);
let light_position_worldspace: vec3<f32> = spotLight.position;
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
lightColor += lighting_getLightColor(
surfaceColor,
light_direction,
view_direction,
normal_worldspace,
spotLight.color / light_attenuation
);
}
for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
}
return lightColor;
}
fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{
var lightColor = vec3<f32>(0, 0, 0);
let surfaceColor = vec3<f32>(0, 0, 0);
if (lighting.enabled != 0) {
let view_direction = normalize(cameraPosition - position_worldspace);
for (var i: i32 = 0; i < lighting.pointLightCount; i++) {
let pointLight: PointLight = lighting_getPointLight(i);
let light_position_worldspace: vec3<f32> = pointLight.position;
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
let light_attenuation = getPointLightAttenuation(
pointLight,
distance(light_position_worldspace, position_worldspace)
);
lightColor += lighting_getLightColor(
surfaceColor,
light_direction,
view_direction,
normal_worldspace,
pointLight.color / light_attenuation
);
}
for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
let spotLight: SpotLight = lighting_getSpotLight(i);
let light_position_worldspace: vec3<f32> = spotLight.position;
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
lightColor += lighting_getLightColor(
surfaceColor,
light_direction,
view_direction,
normal_worldspace,
spotLight.color / light_attenuation
);
}
for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
}
}
return lightColor;
}
`;var C7=[38.25,38.25,38.25],Xr={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Xm.replace("phongMaterial","gouraudMaterial"),fs:$m.replace("phongMaterial","gouraudMaterial"),source:Ym.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Ka,Tm],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:C7},getUniforms(t){return{...Xr.defaultUniforms,...t}}};var E7=[38.25,38.25,38.25],nn={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[Ka,Tm],source:Ym,vs:$m,fs:Xm,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:E7},getUniforms(t){return{...nn.defaultUniforms,...t}}};var uI=`out vec3 pbr_vPosition;
out vec2 pbr_vUV0;
out vec2 pbr_vUV1;
#ifdef HAS_NORMALS
# ifdef HAS_TANGENTS
out mat3 pbr_vTBN;
# else
out vec3 pbr_vNormal;
# endif
#endif
void pbr_setPositionNormalTangentUV(
vec4 position,
vec4 normal,
vec4 tangent,
vec2 uv0,
vec2 uv1
)
{
vec4 pos = pbrProjection.modelMatrix * position;
pbr_vPosition = vec3(pos.xyz) / pos.w;
#ifdef HAS_NORMALS
#ifdef HAS_TANGENTS
vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
pbr_vTBN = mat3(tangentW, bitangentW, normalW);
#else // HAS_TANGENTS != 1
pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
#endif
#endif
#ifdef HAS_UV
pbr_vUV0 = uv0;
#else
pbr_vUV0 = vec2(0.,0.);
#endif
pbr_vUV1 = uv1;
}
`,dI=`precision highp float;
layout(std140) uniform pbrMaterialUniforms {
// Material is unlit
bool unlit;
// Base color map
bool baseColorMapEnabled;
vec4 baseColorFactor;
bool normalMapEnabled;
float normalScale; // #ifdef HAS_NORMALMAP
bool emissiveMapEnabled;
vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP
vec2 metallicRoughnessValues;
bool metallicRoughnessMapEnabled;
bool occlusionMapEnabled;
float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP
bool alphaCutoffEnabled;
float alphaCutoff; // #ifdef ALPHA_CUTOFF
vec3 specularColorFactor;
float specularIntensityFactor;
bool specularColorMapEnabled;
bool specularIntensityMapEnabled;
float ior;
float transmissionFactor;
bool transmissionMapEnabled;
float thicknessFactor;
float attenuationDistance;
vec3 attenuationColor;
float clearcoatFactor;
float clearcoatRoughnessFactor;
bool clearcoatMapEnabled;
bool clearcoatRoughnessMapEnabled;
vec3 sheenColorFactor;
float sheenRoughnessFactor;
bool sheenColorMapEnabled;
bool sheenRoughnessMapEnabled;
float iridescenceFactor;
float iridescenceIor;
vec2 iridescenceThicknessRange;
bool iridescenceMapEnabled;
float anisotropyStrength;
float anisotropyRotation;
vec2 anisotropyDirection;
bool anisotropyMapEnabled;
float emissiveStrength;
// IBL
bool IBLenabled;
vec2 scaleIBLAmbient; // #ifdef USE_IBL
// debugging flags used for shader output of intermediate PBR variables
// #ifdef PBR_DEBUG
vec4 scaleDiffBaseMR;
vec4 scaleFGDSpec;
// #endif
int baseColorUVSet;
mat3 baseColorUVTransform;
int metallicRoughnessUVSet;
mat3 metallicRoughnessUVTransform;
int normalUVSet;
mat3 normalUVTransform;
int occlusionUVSet;
mat3 occlusionUVTransform;
int emissiveUVSet;
mat3 emissiveUVTransform;
int specularColorUVSet;
mat3 specularColorUVTransform;
int specularIntensityUVSet;
mat3 specularIntensityUVTransform;
int transmissionUVSet;
mat3 transmissionUVTransform;
int thicknessUVSet;
mat3 thicknessUVTransform;
int clearcoatUVSet;
mat3 clearcoatUVTransform;
int clearcoatRoughnessUVSet;
mat3 clearcoatRoughnessUVTransform;
int clearcoatNormalUVSet;
mat3 clearcoatNormalUVTransform;
int sheenColorUVSet;
mat3 sheenColorUVTransform;
int sheenRoughnessUVSet;
mat3 sheenRoughnessUVTransform;
int iridescenceUVSet;
mat3 iridescenceUVTransform;
int iridescenceThicknessUVSet;
mat3 iridescenceThicknessUVTransform;
int anisotropyUVSet;
mat3 anisotropyUVTransform;
} pbrMaterial;
// Samplers
#ifdef HAS_BASECOLORMAP
uniform sampler2D pbr_baseColorSampler;
#endif
#ifdef HAS_NORMALMAP
uniform sampler2D pbr_normalSampler;
#endif
#ifdef HAS_EMISSIVEMAP
uniform sampler2D pbr_emissiveSampler;
#endif
#ifdef HAS_METALROUGHNESSMAP
uniform sampler2D pbr_metallicRoughnessSampler;
#endif
#ifdef HAS_OCCLUSIONMAP
uniform sampler2D pbr_occlusionSampler;
#endif
#ifdef HAS_SPECULARCOLORMAP
uniform sampler2D pbr_specularColorSampler;
#endif
#ifdef HAS_SPECULARINTENSITYMAP
uniform sampler2D pbr_specularIntensitySampler;
#endif
#ifdef HAS_TRANSMISSIONMAP
uniform sampler2D pbr_transmissionSampler;
#endif
#ifdef HAS_THICKNESSMAP
uniform sampler2D pbr_thicknessSampler;
#endif
#ifdef HAS_CLEARCOATMAP
uniform sampler2D pbr_clearcoatSampler;
#endif
#ifdef HAS_CLEARCOATROUGHNESSMAP
uniform sampler2D pbr_clearcoatRoughnessSampler;
#endif
#ifdef HAS_CLEARCOATNORMALMAP
uniform sampler2D pbr_clearcoatNormalSampler;
#endif
#ifdef HAS_SHEENCOLORMAP
uniform sampler2D pbr_sheenColorSampler;
#endif
#ifdef HAS_SHEENROUGHNESSMAP
uniform sampler2D pbr_sheenRoughnessSampler;
#endif
#ifdef HAS_IRIDESCENCEMAP
uniform sampler2D pbr_iridescenceSampler;
#endif
#ifdef HAS_IRIDESCENCETHICKNESSMAP
uniform sampler2D pbr_iridescenceThicknessSampler;
#endif
#ifdef HAS_ANISOTROPYMAP
uniform sampler2D pbr_anisotropySampler;
#endif
// Inputs from vertex shader
in vec3 pbr_vPosition;
in vec2 pbr_vUV0;
in vec2 pbr_vUV1;
#ifdef HAS_NORMALS
#ifdef HAS_TANGENTS
in mat3 pbr_vTBN;
#else
in vec3 pbr_vNormal;
#endif
#endif
// Encapsulate the various inputs used by the various functions in the shading equation
// We store values in this struct to simplify the integration of alternative implementations
// of the shading terms, outlined in the Readme.MD Appendix.
struct PBRInfo {
float NdotL; // cos angle between normal and light direction
float NdotV; // cos angle between normal and view direction
float NdotH; // cos angle between normal and half vector
float LdotH; // cos angle between light direction and half vector
float VdotH; // cos angle between view direction and half vector
float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)
float metalness; // metallic value at the surface
vec3 reflectance0; // full reflectance color (normal incidence angle)
vec3 reflectance90; // reflectance color at grazing angle
float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])
vec3 diffuseColor; // color contribution from diffuse lighting
vec3 specularColor; // color contribution from specular lighting
vec3 n; // normal at surface point
vec3 v; // vector from surface point to camera
};
const float M_PI = 3.141592653589793;
const float c_MinRoughness = 0.04;
vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor);
vec4 SRGBtoLINEAR(vec4 srgbIn)
{
#ifdef MANUAL_SRGB
#ifdef SRGB_FAST_APPROXIMATION
vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
#else // SRGB_FAST_APPROXIMATION
vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
#endif //SRGB_FAST_APPROXIMATION
return vec4(linOut,srgbIn.w);;
#else //MANUAL_SRGB
return srgbIn;
#endif //MANUAL_SRGB
}
vec2 getMaterialUV(int uvSet, mat3 uvTransform)
{
vec2 baseUV = uvSet == 1 ? pbr_vUV1 : pbr_vUV0;
return (uvTransform * vec3(baseUV, 1.0)).xy;
}
// Build the tangent basis from interpolated attributes or screen-space derivatives.
mat3 getTBN(vec2 uv)
{
#ifndef HAS_TANGENTS
vec3 pos_dx = dFdx(pbr_vPosition);
vec3 pos_dy = dFdy(pbr_vPosition);
vec3 tex_dx = dFdx(vec3(uv, 0.0));
vec3 tex_dy = dFdy(vec3(uv, 0.0));
vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
#ifdef HAS_NORMALS
vec3 ng = normalize(pbr_vNormal);
#else
vec3 ng = cross(pos_dx, pos_dy);
#endif
t = normalize(t - ng * dot(ng, t));
vec3 b = normalize(cross(ng, t));
mat3 tbn = mat3(t, b, ng);
#else // HAS_TANGENTS
mat3 tbn = pbr_vTBN;
#endif
return tbn;
}
// Find the normal for this fragment, pulling either from a predefined normal map
// or from the interpolated mesh normal and tangent attributes.
vec3 getMappedNormal(sampler2D normalSampler, mat3 tbn, float normalScale, vec2 uv)
{
vec3 n = texture(normalSampler, uv).rgb;
return normalize(tbn * ((2.0 * n - 1.0) * vec3(normalScale, normalScale, 1.0)));
}
vec3 getNormal(mat3 tbn, vec2 uv)
{
#ifdef HAS_NORMALMAP
vec3 n = getMappedNormal(pbr_normalSampler, tbn, pbrMaterial.normalScale, uv);
#else
// The tbn matrix is linearly interpolated, so we need to re-normalize
vec3 n = normalize(tbn[2].xyz);
#endif
return n;
}
vec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal, vec2 uv)
{
#ifdef HAS_CLEARCOATNORMALMAP
return getMappedNormal(pbr_clearcoatNormalSampler, tbn, 1.0, uv);
#else
return baseNormal;
#endif
}
// Calculation of the lighting contribution from an optional Image Based Light source.
// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
// See our README.md on Environment Maps [3] for additional discussion.
#ifdef USE_IBL
vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
{
float mipCount = 9.0; // resolution of 512x512
float lod = (pbrInfo.perceptualRoughness * mipCount);
// retrieve a scale and bias to F0. See [1], Figure 3
vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
#ifdef USE_TEX_LOD
vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
#else
vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
#endif
vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
// For presentation, this allows us to disable IBL terms
diffuse *= pbrMaterial.scaleIBLAmbient.x;
specular *= pbrMaterial.scaleIBLAmbient.y;
return diffuse + specular;
}
#endif
// Basic Lambertian diffuse
// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
// See also [1], Equation 1
vec3 diffuse(PBRInfo pbrInfo)
{
return pbrInfo.diffuseColor / M_PI;
}
// The following equation models the Fresnel reflectance term of the spec equation (aka F())
// Implementation of fresnel from [4], Equation 15
vec3 specularReflection(PBRInfo pbrInfo)
{
return pbrInfo.reflectance0 +
(pbrInfo.reflectance90 - pbrInfo.reflectance0) *
pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
}
// This calculates the specular geometric attenuation (aka G()),
// where rougher material will reflect less light back to the viewer.
// This implementation is based on [1] Equation 4, and we adopt their modifications to
// alphaRoughness as input as originally proposed in [2].
float geometricOcclusion(PBRInfo pbrInfo)
{
float NdotL = pbrInfo.NdotL;
float NdotV = pbrInfo.NdotV;
float r = pbrInfo.alphaRoughness;
float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
return attenuationL * attenuationV;
}
// The following equation(s) model the distribution of microfacet normals across
// the area being drawn (aka D())
// Implementation from "Average Irregularity Representation of a Roughened Surface
// for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
// Follows the distribution function recommended in the SIGGRAPH 2013 course notes
// from EPIC Games [1], Equation 3.
float microfacetDistribution(PBRInfo pbrInfo)
{
float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
return roughnessSq / (M_PI * f * f);
}
float maxComponent(vec3 value)
{
return max(max(value.r, value.g), value.b);
}
float getDielectricF0(float ior)
{
float clampedIor = max(ior, 1.0);
float ratio = (clampedIor - 1.0) / (clampedIor + 1.0);
return ratio * ratio;
}
vec2 normalizeDirection(vec2 direction)
{
float directionLength = length(direction);
return directionLength > 0.0001 ? direction / directionLength : vec2(1.0, 0.0);
}
vec2 rotateDirection(vec2 direction, float rotation)
{
float s = sin(rotation);
float c = cos(rotation);
return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c);
}
vec3 getIridescenceTint(float iridescence, float thickness, float NdotV)
{
if (iridescence <= 0.0) {
return vec3(1.0);
}
float phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;
vec3 thinFilmTint =
0.5 + 0.5 * cos(vec3(phase, phase + 2.0943951, phase + 4.1887902));
return mix(vec3(1.0), thinFilmTint, iridescence);
}
vec3 getVolumeAttenuation(float thickness)
{
if (thickness <= 0.0) {
return vec3(1.0);
}
vec3 attenuationCoefficient =
-log(max(pbrMaterial.attenuationColor, vec3(0.0001))) /
max(pbrMaterial.attenuationDistance, 0.0001);
return exp(-attenuationCoefficient * thickness);
}
PBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness)
{
float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
float alphaRoughness = perceptualRoughness * perceptualRoughness;
float NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);
return PBRInfo(
basePBRInfo.NdotL,
NdotV,
basePBRInfo.NdotH,
basePBRInfo.LdotH,
basePBRInfo.VdotH,
perceptualRoughness,
0.0,
vec3(0.04),
vec3(1.0),
alphaRoughness,
vec3(0.0),
vec3(0.04),
clearcoatNormal,
basePBRInfo.v
);
}
vec3 calculateClearcoatContribution(
PBRInfo pbrInfo,
vec3 lightColor,
vec3 clearcoatNormal,
float clearcoatFactor,
float clearcoatRoughness
) {
if (clearcoatFactor <= 0.0) {
return vec3(0.0);
}
PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;
}
#ifdef USE_IBL
vec3 calculateClearcoatIBLContribution(
PBRInfo pbrInfo,
vec3 clearcoatNormal,
vec3 reflection,
float clearcoatFactor,
float clearcoatRoughness
) {
if (clearcoatFactor <= 0.0) {
return vec3(0.0);
}
PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;
}
#endif
vec3 calculateSheenContribution(
PBRInfo pbrInfo,
vec3 lightColor,
vec3 sheenColor,
float sheenRoughness
) {
if (maxComponent(sheenColor) <= 0.0) {
return vec3(0.0);
}
float sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
float sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);
return pbrInfo.NdotL *
lightColor *
sheenColor *
(0.25 + 0.75 * sheenFresnel) *
sheenVisibility *
(1.0 - pbrInfo.metalness);
}
float calculateAnisotropyBoost(
PBRInfo pbrInfo,
vec3 anisotropyTangent,
float anisotropyStrength
) {
if (anisotropyStrength <= 0.0) {
return 1.0;
}
vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
float bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));
return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);
}
vec3 calculateMaterialLightColor(
PBRInfo pbrInfo,
vec3 lightColor,
vec3 clearcoatNormal,
float clearcoatFactor,
float clearcoatRoughness,
vec3 sheenColor,
float sheenRoughness,
vec3 anisotropyTangent,
float anisotropyStrength
) {
float anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
vec3 color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;
color += calculateClearcoatContribution(
pbrInfo,
lightColor,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness
);
color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);
return color;
}
void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {
pbrInfo.NdotL = 1.0;
pbrInfo.NdotH = 0.0;
pbrInfo.LdotH = 0.0;
pbrInfo.VdotH = 1.0;
}
void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {
vec3 n = pbrInfo.n;
vec3 v = pbrInfo.v;
vec3 l = normalize(lightDirection); // Vector from surface point to light
vec3 h = normalize(l+v); // Half vector between both l and v
pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);
pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);
pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);
pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);
}
void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {
vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
PBRInfo_setDirectionalLight(pbrInfo, light_direction);
}
void PBRInfo_setSpotLight(inout PBRInfo pbrInfo, SpotLight spotLight) {
vec3 light_direction = normalize(spotLight.position - pbr_vPosition);
PBRInfo_setDirectionalLight(pbrInfo, light_direction);
}
vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
// Calculate the shading terms for the microfacet specular shading model
vec3 F = specularReflection(pbrInfo);
float G = geometricOcclusion(pbrInfo);
float D = microfacetDistribution(pbrInfo);
// Calculation of analytical lighting contribution
vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
// Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
}
vec4 pbr_filterColor(vec4 colorUnused)
{
vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);
vec2 metallicRoughnessUV = getMaterialUV(
pbrMaterial.metallicRoughnessUVSet,
pbrMaterial.metallicRoughnessUVTransform
);
vec2 normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
vec2 occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);
vec2 emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);
vec2 specularColorUV = getMaterialUV(
pbrMaterial.specularColorUVSet,
pbrMaterial.specularColorUVTransform
);
vec2 specularIntensityUV = getMaterialUV(
pbrMaterial.specularIntensityUVSet,
pbrMaterial.specularIntensityUVTransform
);
vec2 transmissionUV = getMaterialUV(
pbrMaterial.transmissionUVSet,
pbrMaterial.transmissionUVTransform
);
vec2 thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);
vec2 clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);
vec2 clearcoatRoughnessUV = getMaterialUV(
pbrMaterial.clearcoatRoughnessUVSet,
pbrMaterial.clearcoatRoughnessUVTransform
);
vec2 clearcoatNormalUV = getMaterialUV(
pbrMaterial.clearcoatNormalUVSet,
pbrMaterial.clearcoatNormalUVTransform
);
vec2 sheenColorUV = getMaterialUV(
pbrMaterial.sheenColorUVSet,
pbrMaterial.sheenColorUVTransform
);
vec2 sheenRoughnessUV = getMaterialUV(
pbrMaterial.sheenRoughnessUVSet,
pbrMaterial.sheenRoughnessUVTransform
);
vec2 iridescenceUV = getMaterialUV(
pbrMaterial.iridescenceUVSet,
pbrMaterial.iridescenceUVTransform
);
vec2 iridescenceThicknessUV = getMaterialUV(
pbrMaterial.iridescenceThicknessUVSet,
pbrMaterial.iridescenceThicknessUVTransform
);
vec2 anisotropyUV = getMaterialUV(
pbrMaterial.anisotropyUVSet,
pbrMaterial.anisotropyUVTransform
);
// The albedo may be defined from a base texture or a flat color
#ifdef HAS_BASECOLORMAP
vec4 baseColor =
SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) * pbrMaterial.baseColorFactor;
#else
vec4 baseColor = pbrMaterial.baseColorFactor;
#endif
#ifdef ALPHA_CUTOFF
if (baseColor.a < pbrMaterial.alphaCutoff) {
discard;
}
#endif
vec3 color = vec3(0, 0, 0);
float transmission = 0.0;
if(pbrMaterial.unlit){
color.rgb = baseColor.rgb;
}
else{
// Metallic and Roughness material properties are packed together
// In glTF, these factors can be specified by fixed scalar values
// or from a metallic-roughness map
float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
float metallic = pbrMaterial.metallicRoughnessValues.x;
#ifdef HAS_METALROUGHNESSMAP
// Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
// This layout intentionally reserves the 'r' channel for (optional) occlusion map data
vec4 mrSample = texture(pbr_metallicRoughnessSampler, metallicRoughnessUV);
perceptualRoughness = mrSample.g * perceptualRoughness;
metallic = mrSample.b * metallic;
#endif
perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
metallic = clamp(metallic, 0.0, 1.0);
mat3 tbn = getTBN(normalUV);
vec3 n = getNormal(tbn, normalUV); // normal at surface point
vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
#ifdef USE_MATERIAL_EXTENSIONS
bool useExtendedPBR =
pbrMaterial.specularColorMapEnabled ||
pbrMaterial.specularIntensityMapEnabled ||
abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||
maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 ||
abs(pbrMaterial.ior - 1.5) > 0.0001 ||
pbrMaterial.transmissionMapEnabled ||
pbrMaterial.transmissionFactor > 0.0001 ||
pbrMaterial.clearcoatMapEnabled ||
pbrMaterial.clearcoatRoughnessMapEnabled ||
pbrMaterial.clearcoatFactor > 0.0001 ||
pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||
pbrMaterial.sheenColorMapEnabled ||
pbrMaterial.sheenRoughnessMapEnabled ||
maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||
pbrMaterial.sheenRoughnessFactor > 0.0001 ||
pbrMaterial.iridescenceMapEnabled ||
pbrMaterial.iridescenceFactor > 0.0001 ||
abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||
abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||
abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||
pbrMaterial.anisotropyMapEnabled ||
pbrMaterial.anisotropyStrength > 0.0001 ||
abs(pbrMaterial.anisotropyRotation) > 0.0001 ||
length(pbrMaterial.anisotropyDirection - vec2(1.0, 0.0)) > 0.0001;
#else
bool useExtendedPBR = false;
#endif
if (!useExtendedPBR) {
// Keep the baseline metallic-roughness implementation byte-for-byte equivalent in behavior.
float alphaRoughness = perceptualRoughness * perceptualRoughness;
vec3 f0 = vec3(0.04);
vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
diffuseColor *= 1.0 - metallic;
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
vec3 specularEnvironmentR0 = specularColor.rgb;
vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
vec3 reflection = -normalize(reflect(v, n));
PBRInfo pbrInfo = PBRInfo(
0.0, // NdotL
NdotV,
0.0, // NdotH
0.0, // LdotH
0.0, // VdotH
perceptualRoughness,
metallic,
specularEnvironmentR0,
specularEnvironmentR90,
alphaRoughness,
diffuseColor,
specularColor,
n,
v
);
#ifdef USE_LIGHTS
PBRInfo_setAmbientLight(pbrInfo);
color += calculateFinalColor(pbrInfo, lighting.ambientColor);
for(int i = 0; i < lighting.directionalLightCount; i++) {
if (i < lighting.directionalLightCount) {
PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
}
}
for(int i = 0; i < lighting.pointLightCount; i++) {
if (i < lighting.pointLightCount) {
PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
}
}
for(int i = 0; i < lighting.spotLightCount; i++) {
if (i < lighting.spotLightCount) {
PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));
float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);
color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);
}
}
#endif
#ifdef USE_IBL
if (pbrMaterial.IBLenabled) {
color += getIBLContribution(pbrInfo, n, reflection);
}
#endif
#ifdef HAS_OCCLUSIONMAP
if (pbrMaterial.occlusionMapEnabled) {
float ao = texture(pbr_occlusionSampler, occlusionUV).r;
color = mix(color, color * ao, pbrMaterial.occlusionStrength);
}
#endif
vec3 emissive = pbrMaterial.emissiveFactor;
#ifdef HAS_EMISSIVEMAP
if (pbrMaterial.emissiveMapEnabled) {
emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;
}
#endif
color += emissive * pbrMaterial.emissiveStrength;
#ifdef PBR_DEBUG
color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
#endif
return vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a);
}
float specularIntensity = pbrMaterial.specularIntensityFactor;
#ifdef HAS_SPECULARINTENSITYMAP
if (pbrMaterial.specularIntensityMapEnabled) {
specularIntensity *= texture(pbr_specularIntensitySampler, specularIntensityUV).a;
}
#endif
vec3 specularFactor = pbrMaterial.specularColorFactor;
#ifdef HAS_SPECULARCOLORMAP
if (pbrMaterial.specularColorMapEnabled) {
specularFactor *= SRGBtoLINEAR(texture(pbr_specularColorSampler, specularColorUV)).rgb;
}
#endif
transmission = pbrMaterial.transmissionFactor;
#ifdef HAS_TRANSMISSIONMAP
if (pbrMaterial.transmissionMapEnabled) {
transmission *= texture(pbr_transmissionSampler, transmissionUV).r;
}
#endif
transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);
float thickness = max(pbrMaterial.thicknessFactor, 0.0);
#ifdef HAS_THICKNESSMAP
thickness *= texture(pbr_thicknessSampler, thicknessUV).g;
#endif
float clearcoatFactor = pbrMaterial.clearcoatFactor;
float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;
#ifdef HAS_CLEARCOATMAP
if (pbrMaterial.clearcoatMapEnabled) {
clearcoatFactor *= texture(pbr_clearcoatSampler, clearcoatUV).r;
}
#endif
#ifdef HAS_CLEARCOATROUGHNESSMAP
if (pbrMaterial.clearcoatRoughnessMapEnabled) {
clearcoatRoughness *= texture(pbr_clearcoatRoughnessSampler, clearcoatRoughnessUV).g;
}
#endif
clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);
clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
vec3 clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);
vec3 sheenColor = pbrMaterial.sheenColorFactor;
float sheenRoughness = pbrMaterial.sheenRoughnessFactor;
#ifdef HAS_SHEENCOLORMAP
if (pbrMaterial.sheenColorMapEnabled) {
sheenColor *= SRGBtoLINEAR(texture(pbr_sheenColorSampler, sheenColorUV)).rgb;
}
#endif
#ifdef HAS_SHEENROUGHNESSMAP
if (pbrMaterial.sheenRoughnessMapEnabled) {
sheenRoughness *= texture(pbr_sheenRoughnessSampler, sheenRoughnessUV).a;
}
#endif
sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);
float iridescence = pbrMaterial.iridescenceFactor;
#ifdef HAS_IRIDESCENCEMAP
if (pbrMaterial.iridescenceMapEnabled) {
iridescence *= texture(pbr_iridescenceSampler, iridescenceUV).r;
}
#endif
iridescence = clamp(iridescence, 0.0, 1.0);
float iridescenceThickness = mix(
pbrMaterial.iridescenceThicknessRange.x,
pbrMaterial.iridescenceThicknessRange.y,
0.5
);
#ifdef HAS_IRIDESCENCETHICKNESSMAP
iridescenceThickness = mix(
pbrMaterial.iridescenceThicknessRange.x,
pbrMaterial.iridescenceThicknessRange.y,
texture(pbr_iridescenceThicknessSampler, iridescenceThicknessUV).g
);
#endif
float anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);
vec2 anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);
#ifdef HAS_ANISOTROPYMAP
if (pbrMaterial.anisotropyMapEnabled) {
vec3 anisotropySample = texture(pbr_anisotropySampler, anisotropyUV).rgb;
anisotropyStrength *= anisotropySample.b;
vec2 mappedDirection = anisotropySample.rg * 2.0 - 1.0;
if (length(mappedDirection) > 0.0001) {
anisotropyDirection = normalize(mappedDirection);
}
}
#endif
anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);
vec3 anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);
if (length(anisotropyTangent) < 0.0001) {
anisotropyTangent = normalize(tbn[0]);
}
float anisotropyViewAlignment = abs(dot(v, anisotropyTangent));
perceptualRoughness = mix(
perceptualRoughness,
clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),
anisotropyStrength
);
// Roughness is authored as perceptual roughness; as is convention,
// convert to material roughness by squaring the perceptual roughness [2].
float alphaRoughness = perceptualRoughness * perceptualRoughness;
float dielectricF0 = getDielectricF0(pbrMaterial.ior);
vec3 dielectricSpecularF0 = min(
vec3(dielectricF0) * specularFactor * specularIntensity,
vec3(1.0)
);
vec3 iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);
dielectricSpecularF0 = mix(
dielectricSpecularF0,
dielectricSpecularF0 * iridescenceTint,
iridescence
);
vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);
diffuseColor *= (1.0 - metallic) * (1.0 - transmission);
vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);
float baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;
diffuseColor *= baseLayerEnergy;
specularColor *= baseLayerEnergy;
// Compute reflectance.
float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
// For typical incident reflectance range (between 4% to 100%) set the grazing
// reflectance to 100% for typical fresnel effect.
// For very low reflectance range on highly diffuse objects (below 4%),
// incrementally reduce grazing reflecance to 0%.
float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
vec3 specularEnvironmentR0 = specularColor.rgb;
vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
vec3 reflection = -normalize(reflect(v, n));
PBRInfo pbrInfo = PBRInfo(
0.0, // NdotL
NdotV,
0.0, // NdotH
0.0, // LdotH
0.0, // VdotH
perceptualRoughness,
metallic,
specularEnvironmentR0,
specularEnvironmentR90,
alphaRoughness,
diffuseColor,
specularColor,
n,
v
);
#ifdef USE_LIGHTS
// Apply ambient light
PBRInfo_setAmbientLight(pbrInfo);
color += calculateMaterialLightColor(
pbrInfo,
lighting.ambientColor,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
// Apply directional light
for(int i = 0; i < lighting.directionalLightCount; i++) {
if (i < lighting.directionalLightCount) {
PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
color += calculateMaterialLightColor(
pbrInfo,
lighting_getDirectionalLight(i).color,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
}
}
// Apply point light
for(int i = 0; i < lighting.pointLightCount; i++) {
if (i < lighting.pointLightCount) {
PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
color += calculateMaterialLightColor(
pbrInfo,
lighting_getPointLight(i).color / attenuation,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
}
}
for(int i = 0; i < lighting.spotLightCount; i++) {
if (i < lighting.spotLightCount) {
PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));
float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);
color += calculateMaterialLightColor(
pbrInfo,
lighting_getSpotLight(i).color / attenuation,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
}
}
#endif
// Calculate lighting contribution from image based lighting source (IBL)
#ifdef USE_IBL
if (pbrMaterial.IBLenabled) {
color += getIBLContribution(pbrInfo, n, reflection) *
calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
color += calculateClearcoatIBLContribution(
pbrInfo,
clearcoatNormal,
-normalize(reflect(v, clearcoatNormal)),
clearcoatFactor,
clearcoatRoughness
);
color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;
}
#endif
// Apply optional PBR terms for additional (optional) shading
#ifdef HAS_OCCLUSIONMAP
if (pbrMaterial.occlusionMapEnabled) {
float ao = texture(pbr_occlusionSampler, occlusionUV).r;
color = mix(color, color * ao, pbrMaterial.occlusionStrength);
}
#endif
vec3 emissive = pbrMaterial.emissiveFactor;
#ifdef HAS_EMISSIVEMAP
if (pbrMaterial.emissiveMapEnabled) {
emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;
}
#endif
color += emissive * pbrMaterial.emissiveStrength;
if (transmission > 0.0) {
color = mix(color, color * getVolumeAttenuation(thickness), transmission);
}
// This section uses mix to override final color for reference app visualization
// of various parameters in the lighting equation.
#ifdef PBR_DEBUG
// TODO: Figure out how to debug multiple lights
// color = mix(color, F, pbr_scaleFGDSpec.x);
// color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
// color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
// color = mix(color, specContrib, pbr_scaleFGDSpec.w);
// color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
#endif
}
float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);
return vec4(pow(color,vec3(1.0/2.2)), alpha);
}
`;var hI=`struct PBRFragmentInputs {
pbr_vPosition: vec3f,
pbr_vUV0: vec2f,
pbr_vUV1: vec2f,
pbr_vTBN: mat3x3f,
pbr_vNormal: vec3f
};
var<private> fragmentInputs: PBRFragmentInputs;
fn pbr_setPositionNormalTangentUV(
position: vec4f,
normal: vec4f,
tangent: vec4f,
uv0: vec2f,
uv1: vec2f
)
{
var pos: vec4f = pbrProjection.modelMatrix * position;
fragmentInputs.pbr_vPosition = pos.xyz / pos.w;
fragmentInputs.pbr_vNormal = vec3f(0.0, 0.0, 1.0);
fragmentInputs.pbr_vTBN = mat3x3f(
vec3f(1.0, 0.0, 0.0),
vec3f(0.0, 1.0, 0.0),
vec3f(0.0, 0.0, 1.0)
);
fragmentInputs.pbr_vUV0 = vec2f(0.0, 0.0);
fragmentInputs.pbr_vUV1 = uv1;
#ifdef HAS_NORMALS
let normalW: vec3f = normalize((pbrProjection.normalMatrix * vec4f(normal.xyz, 0.0)).xyz);
fragmentInputs.pbr_vNormal = normalW;
#ifdef HAS_TANGENTS
let tangentW: vec3f = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);
let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;
fragmentInputs.pbr_vTBN = mat3x3f(tangentW, bitangentW, normalW);
#endif
#endif
#ifdef HAS_UV
fragmentInputs.pbr_vUV0 = uv0;
#endif
}
struct pbrMaterialUniforms {
// Material is unlit
unlit: u32,
// Base color map
baseColorMapEnabled: u32,
baseColorFactor: vec4f,
normalMapEnabled : u32,
normalScale: f32, // #ifdef HAS_NORMALMAP
emissiveMapEnabled: u32,
emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP
metallicRoughnessValues: vec2f,
metallicRoughnessMapEnabled: u32,
occlusionMapEnabled: i32,
occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP
alphaCutoffEnabled: i32,
alphaCutoff: f32, // #ifdef ALPHA_CUTOFF
specularColorFactor: vec3f,
specularIntensityFactor: f32,
specularColorMapEnabled: i32,
specularIntensityMapEnabled: i32,
ior: f32,
transmissionFactor: f32,
transmissionMapEnabled: i32,
thicknessFactor: f32,
attenuationDistance: f32,
attenuationColor: vec3f,
clearcoatFactor: f32,
clearcoatRoughnessFactor: f32,
clearcoatMapEnabled: i32,
clearcoatRoughnessMapEnabled: i32,
sheenColorFactor: vec3f,
sheenRoughnessFactor: f32,
sheenColorMapEnabled: i32,
sheenRoughnessMapEnabled: i32,
iridescenceFactor: f32,
iridescenceIor: f32,
iridescenceThicknessRange: vec2f,
iridescenceMapEnabled: i32,
anisotropyStrength: f32,
anisotropyRotation: f32,
anisotropyDirection: vec2f,
anisotropyMapEnabled: i32,
emissiveStrength: f32,
// IBL
IBLenabled: i32,
scaleIBLAmbient: vec2f, // #ifdef USE_IBL
// debugging flags used for shader output of intermediate PBR variables
// #ifdef PBR_DEBUG
scaleDiffBaseMR: vec4f,
scaleFGDSpec: vec4f,
// #endif
baseColorUVSet: i32,
baseColorUVTransform: mat3x3f,
metallicRoughnessUVSet: i32,
metallicRoughnessUVTransform: mat3x3f,
normalUVSet: i32,
normalUVTransform: mat3x3f,
occlusionUVSet: i32,
occlusionUVTransform: mat3x3f,
emissiveUVSet: i32,
emissiveUVTransform: mat3x3f,
specularColorUVSet: i32,
specularColorUVTransform: mat3x3f,
specularIntensityUVSet: i32,
specularIntensityUVTransform: mat3x3f,
transmissionUVSet: i32,
transmissionUVTransform: mat3x3f,
thicknessUVSet: i32,
thicknessUVTransform: mat3x3f,
clearcoatUVSet: i32,
clearcoatUVTransform: mat3x3f,
clearcoatRoughnessUVSet: i32,
clearcoatRoughnessUVTransform: mat3x3f,
clearcoatNormalUVSet: i32,
clearcoatNormalUVTransform: mat3x3f,
sheenColorUVSet: i32,
sheenColorUVTransform: mat3x3f,
sheenRoughnessUVSet: i32,
sheenRoughnessUVTransform: mat3x3f,
iridescenceUVSet: i32,
iridescenceUVTransform: mat3x3f,
iridescenceThicknessUVSet: i32,
iridescenceThicknessUVTransform: mat3x3f,
anisotropyUVSet: i32,
anisotropyUVTransform: mat3x3f,
}
@group(3) @binding(auto) var<uniform> pbrMaterial : pbrMaterialUniforms;
// Samplers
#ifdef HAS_BASECOLORMAP
@group(3) @binding(auto) var pbr_baseColorSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_baseColorSamplerSampler: sampler;
#endif
#ifdef HAS_NORMALMAP
@group(3) @binding(auto) var pbr_normalSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_normalSamplerSampler: sampler;
#endif
#ifdef HAS_EMISSIVEMAP
@group(3) @binding(auto) var pbr_emissiveSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_emissiveSamplerSampler: sampler;
#endif
#ifdef HAS_METALROUGHNESSMAP
@group(3) @binding(auto) var pbr_metallicRoughnessSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_metallicRoughnessSamplerSampler: sampler;
#endif
#ifdef HAS_OCCLUSIONMAP
@group(3) @binding(auto) var pbr_occlusionSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_occlusionSamplerSampler: sampler;
#endif
#ifdef HAS_SPECULARCOLORMAP
@group(3) @binding(auto) var pbr_specularColorSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_specularColorSamplerSampler: sampler;
#endif
#ifdef HAS_SPECULARINTENSITYMAP
@group(3) @binding(auto) var pbr_specularIntensitySampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_specularIntensitySamplerSampler: sampler;
#endif
#ifdef HAS_TRANSMISSIONMAP
@group(3) @binding(auto) var pbr_transmissionSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_transmissionSamplerSampler: sampler;
#endif
#ifdef HAS_THICKNESSMAP
@group(3) @binding(auto) var pbr_thicknessSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_thicknessSamplerSampler: sampler;
#endif
#ifdef HAS_CLEARCOATMAP
@group(3) @binding(auto) var pbr_clearcoatSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_clearcoatSamplerSampler: sampler;
#endif
#ifdef HAS_CLEARCOATROUGHNESSMAP
@group(3) @binding(auto) var pbr_clearcoatRoughnessSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_clearcoatRoughnessSamplerSampler: sampler;
#endif
#ifdef HAS_CLEARCOATNORMALMAP
@group(3) @binding(auto) var pbr_clearcoatNormalSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_clearcoatNormalSamplerSampler: sampler;
#endif
#ifdef HAS_SHEENCOLORMAP
@group(3) @binding(auto) var pbr_sheenColorSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_sheenColorSamplerSampler: sampler;
#endif
#ifdef HAS_SHEENROUGHNESSMAP
@group(3) @binding(auto) var pbr_sheenRoughnessSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_sheenRoughnessSamplerSampler: sampler;
#endif
#ifdef HAS_IRIDESCENCEMAP
@group(3) @binding(auto) var pbr_iridescenceSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_iridescenceSamplerSampler: sampler;
#endif
#ifdef HAS_IRIDESCENCETHICKNESSMAP
@group(3) @binding(auto) var pbr_iridescenceThicknessSampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_iridescenceThicknessSamplerSampler: sampler;
#endif
#ifdef HAS_ANISOTROPYMAP
@group(3) @binding(auto) var pbr_anisotropySampler: texture_2d<f32>;
@group(3) @binding(auto) var pbr_anisotropySamplerSampler: sampler;
#endif
// Encapsulate the various inputs used by the various functions in the shading equation
// We store values in this struct to simplify the integration of alternative implementations
// of the shading terms, outlined in the Readme.MD Appendix.
struct PBRInfo {
NdotL: f32, // cos angle between normal and light direction
NdotV: f32, // cos angle between normal and view direction
NdotH: f32, // cos angle between normal and half vector
LdotH: f32, // cos angle between light direction and half vector
VdotH: f32, // cos angle between view direction and half vector
perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader)
metalness: f32, // metallic value at the surface
reflectance0: vec3f, // full reflectance color (normal incidence angle)
reflectance90: vec3f, // reflectance color at grazing angle
alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2])
diffuseColor: vec3f, // color contribution from diffuse lighting
specularColor: vec3f, // color contribution from specular lighting
n: vec3f, // normal at surface point
v: vec3f, // vector from surface point to camera
};
const M_PI = 3.141592653589793;
const c_MinRoughness = 0.04;
fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
{
var linOut: vec3f = srgbIn.xyz;
#ifdef MANUAL_SRGB
let bLess: vec3f = step(vec3f(0.04045), srgbIn.xyz);
linOut = mix(
srgbIn.xyz / vec3f(12.92),
pow((srgbIn.xyz + vec3f(0.055)) / vec3f(1.055), vec3f(2.4)),
bLess
);
#ifdef SRGB_FAST_APPROXIMATION
linOut = pow(srgbIn.xyz, vec3f(2.2));
#endif
#endif
return vec4f(linOut, srgbIn.w);
}
fn getMaterialUV(uvSet: i32, uvTransform: mat3x3f) -> vec2f
{
var baseUV = fragmentInputs.pbr_vUV0;
if (uvSet == 1) {
baseUV = fragmentInputs.pbr_vUV1;
}
return (uvTransform * vec3f(baseUV, 1.0)).xy;
}
// Build the tangent basis from interpolated attributes or screen-space derivatives.
fn getTBN(uv: vec2f) -> mat3x3f
{
let pos_dx: vec3f = dpdx(fragmentInputs.pbr_vPosition);
let pos_dy: vec3f = dpdy(fragmentInputs.pbr_vPosition);
let tex_dx: vec3f = dpdx(vec3f(uv, 0.0));
let tex_dy: vec3f = dpdy(vec3f(uv, 0.0));
var t: vec3f = (tex_dy.y * pos_dx - tex_dx.y * pos_dy) / (tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y);
var ng: vec3f = cross(pos_dx, pos_dy);
#ifdef HAS_NORMALS
ng = normalize(fragmentInputs.pbr_vNormal);
#endif
t = normalize(t - ng * dot(ng, t));
var b: vec3f = normalize(cross(ng, t));
var tbn: mat3x3f = mat3x3f(t, b, ng);
#ifdef HAS_TANGENTS
tbn = fragmentInputs.pbr_vTBN;
#endif
return tbn;
}
// Find the normal for this fragment, pulling either from a predefined normal map
// or from the interpolated mesh normal and tangent attributes.
fn getMappedNormal(
normalSampler: texture_2d<f32>,
normalSamplerBinding: sampler,
tbn: mat3x3f,
normalScale: f32,
uv: vec2f
) -> vec3f
{
let n = textureSample(normalSampler, normalSamplerBinding, uv).rgb;
return normalize(tbn * ((2.0 * n - 1.0) * vec3f(normalScale, normalScale, 1.0)));
}
fn getNormal(tbn: mat3x3f, uv: vec2f) -> vec3f
{
// The tbn matrix is linearly interpolated, so we need to re-normalize
var n: vec3f = normalize(tbn[2].xyz);
#ifdef HAS_NORMALMAP
n = getMappedNormal(
pbr_normalSampler,
pbr_normalSamplerSampler,
tbn,
pbrMaterial.normalScale,
uv
);
#endif
return n;
}
fn getClearcoatNormal(tbn: mat3x3f, baseNormal: vec3f, uv: vec2f) -> vec3f
{
#ifdef HAS_CLEARCOATNORMALMAP
return getMappedNormal(
pbr_clearcoatNormalSampler,
pbr_clearcoatNormalSamplerSampler,
tbn,
1.0,
uv
);
#else
return baseNormal;
#endif
}
// Calculation of the lighting contribution from an optional Image Based Light source.
// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
// See our README.md on Environment Maps [3] for additional discussion.
#ifdef USE_IBL
fn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f
{
let mipCount: f32 = 9.0; // resolution of 512x512
let lod: f32 = pbrInfo.perceptualRoughness * mipCount;
// retrieve a scale and bias to F0. See [1], Figure 3
let brdf = SRGBtoLINEAR(
textureSampleLevel(
pbr_brdfLUT,
pbr_brdfLUTSampler,
vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),
0.0
)
).rgb;
let diffuseLight =
SRGBtoLINEAR(
textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n, 0.0)
).rgb;
var specularLight = SRGBtoLINEAR(
textureSampleLevel(
pbr_specularEnvSampler,
pbr_specularEnvSamplerSampler,
reflection,
0.0
)
).rgb;
#ifdef USE_TEX_LOD
specularLight = SRGBtoLINEAR(
textureSampleLevel(
pbr_specularEnvSampler,
pbr_specularEnvSamplerSampler,
reflection,
lod
)
).rgb;
#endif
let diffuse = diffuseLight * pbrInfo.diffuseColor * pbrMaterial.scaleIBLAmbient.x;
let specular =
specularLight * (pbrInfo.specularColor * brdf.x + brdf.y) * pbrMaterial.scaleIBLAmbient.y;
return diffuse + specular;
}
#endif
// Basic Lambertian diffuse
// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
// See also [1], Equation 1
fn diffuse(pbrInfo: PBRInfo) -> vec3<f32> {
return pbrInfo.diffuseColor / M_PI;
}
// The following equation models the Fresnel reflectance term of the spec equation (aka F())
// Implementation of fresnel from [4], Equation 15
fn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> {
return pbrInfo.reflectance0 +
(pbrInfo.reflectance90 - pbrInfo.reflectance0) *
pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
}
// This calculates the specular geometric attenuation (aka G()),
// where rougher material will reflect less light back to the viewer.
// This implementation is based on [1] Equation 4, and we adopt their modifications to
// alphaRoughness as input as originally proposed in [2].
fn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {
let NdotL: f32 = pbrInfo.NdotL;
let NdotV: f32 = pbrInfo.NdotV;
let r: f32 = pbrInfo.alphaRoughness;
let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
return attenuationL * attenuationV;
}
// The following equation(s) model the distribution of microfacet normals across
// the area being drawn (aka D())
// Implementation from "Average Irregularity Representation of a Roughened Surface
// for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
// Follows the distribution function recommended in the SIGGRAPH 2013 course notes
// from EPIC Games [1], Equation 3.
fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {
let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
return roughnessSq / (M_PI * f * f);
}
fn maxComponent(value: vec3f) -> f32 {
return max(max(value.r, value.g), value.b);
}
fn getDielectricF0(ior: f32) -> f32 {
let clampedIor = max(ior, 1.0);
let ratio = (clampedIor - 1.0) / (clampedIor + 1.0);
return ratio * ratio;
}
fn normalizeDirection(direction: vec2f) -> vec2f {
let directionLength = length(direction);
if (directionLength > 0.0001) {
return direction / directionLength;
}
return vec2f(1.0, 0.0);
}
fn rotateDirection(direction: vec2f, rotation: f32) -> vec2f {
let s = sin(rotation);
let c = cos(rotation);
return vec2f(direction.x * c - direction.y * s, direction.x * s + direction.y * c);
}
fn getIridescenceTint(iridescence: f32, thickness: f32, NdotV: f32) -> vec3f {
if (iridescence <= 0.0) {
return vec3f(1.0);
}
let phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;
let thinFilmTint =
0.5 +
0.5 *
cos(vec3f(phase, phase + 2.0943951, phase + 4.1887902));
return mix(vec3f(1.0), thinFilmTint, iridescence);
}
fn getVolumeAttenuation(thickness: f32) -> vec3f {
if (thickness <= 0.0) {
return vec3f(1.0);
}
let attenuationCoefficient =
-log(max(pbrMaterial.attenuationColor, vec3f(0.0001))) /
max(pbrMaterial.attenuationDistance, 0.0001);
return exp(-attenuationCoefficient * thickness);
}
fn createClearcoatPBRInfo(
basePBRInfo: PBRInfo,
clearcoatNormal: vec3f,
clearcoatRoughness: f32
) -> PBRInfo {
let perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
let alphaRoughness = perceptualRoughness * perceptualRoughness;
let NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);
return PBRInfo(
basePBRInfo.NdotL,
NdotV,
basePBRInfo.NdotH,
basePBRInfo.LdotH,
basePBRInfo.VdotH,
perceptualRoughness,
0.0,
vec3f(0.04),
vec3f(1.0),
alphaRoughness,
vec3f(0.0),
vec3f(0.04),
clearcoatNormal,
basePBRInfo.v
);
}
fn calculateClearcoatContribution(
pbrInfo: PBRInfo,
lightColor: vec3f,
clearcoatNormal: vec3f,
clearcoatFactor: f32,
clearcoatRoughness: f32
) -> vec3f {
if (clearcoatFactor <= 0.0) {
return vec3f(0.0);
}
let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;
}
#ifdef USE_IBL
fn calculateClearcoatIBLContribution(
pbrInfo: PBRInfo,
clearcoatNormal: vec3f,
reflection: vec3f,
clearcoatFactor: f32,
clearcoatRoughness: f32
) -> vec3f {
if (clearcoatFactor <= 0.0) {
return vec3f(0.0);
}
let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);
return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;
}
#endif
fn calculateSheenContribution(
pbrInfo: PBRInfo,
lightColor: vec3f,
sheenColor: vec3f,
sheenRoughness: f32
) -> vec3f {
if (maxComponent(sheenColor) <= 0.0) {
return vec3f(0.0);
}
let sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
let sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);
return pbrInfo.NdotL *
lightColor *
sheenColor *
(0.25 + 0.75 * sheenFresnel) *
sheenVisibility *
(1.0 - pbrInfo.metalness);
}
fn calculateAnisotropyBoost(
pbrInfo: PBRInfo,
anisotropyTangent: vec3f,
anisotropyStrength: f32
) -> f32 {
if (anisotropyStrength <= 0.0) {
return 1.0;
}
let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));
let bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));
return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);
}
fn calculateMaterialLightColor(
pbrInfo: PBRInfo,
lightColor: vec3f,
clearcoatNormal: vec3f,
clearcoatFactor: f32,
clearcoatRoughness: f32,
sheenColor: vec3f,
sheenRoughness: f32,
anisotropyTangent: vec3f,
anisotropyStrength: f32
) -> vec3f {
let anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
var color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;
color += calculateClearcoatContribution(
pbrInfo,
lightColor,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness
);
color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);
return color;
}
fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
(*pbrInfo).NdotL = 1.0;
(*pbrInfo).NdotH = 0.0;
(*pbrInfo).LdotH = 0.0;
(*pbrInfo).VdotH = 1.0;
}
fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {
let n = (*pbrInfo).n;
let v = (*pbrInfo).v;
let l = normalize(lightDirection); // Vector from surface point to light
let h = normalize(l + v); // Half vector between both l and v
(*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0);
(*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);
(*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);
(*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);
}
fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {
let light_direction = normalize(pointLight.position - fragmentInputs.pbr_vPosition);
PBRInfo_setDirectionalLight(pbrInfo, light_direction);
}
fn PBRInfo_setSpotLight(pbrInfo: ptr<function, PBRInfo>, spotLight: SpotLight) {
let light_direction = normalize(spotLight.position - fragmentInputs.pbr_vPosition);
PBRInfo_setDirectionalLight(pbrInfo, light_direction);
}
fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
// Calculate the shading terms for the microfacet specular shading model
let F = specularReflection(pbrInfo);
let G = geometricOcclusion(pbrInfo);
let D = microfacetDistribution(pbrInfo);
// Calculation of analytical lighting contribution
let diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
// Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
}
fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
let baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);
let metallicRoughnessUV = getMaterialUV(
pbrMaterial.metallicRoughnessUVSet,
pbrMaterial.metallicRoughnessUVTransform
);
let normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
let occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);
let emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);
let specularColorUV = getMaterialUV(
pbrMaterial.specularColorUVSet,
pbrMaterial.specularColorUVTransform
);
let specularIntensityUV = getMaterialUV(
pbrMaterial.specularIntensityUVSet,
pbrMaterial.specularIntensityUVTransform
);
let transmissionUV = getMaterialUV(
pbrMaterial.transmissionUVSet,
pbrMaterial.transmissionUVTransform
);
let thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);
let clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);
let clearcoatRoughnessUV = getMaterialUV(
pbrMaterial.clearcoatRoughnessUVSet,
pbrMaterial.clearcoatRoughnessUVTransform
);
let clearcoatNormalUV = getMaterialUV(
pbrMaterial.clearcoatNormalUVSet,
pbrMaterial.clearcoatNormalUVTransform
);
let sheenColorUV = getMaterialUV(
pbrMaterial.sheenColorUVSet,
pbrMaterial.sheenColorUVTransform
);
let sheenRoughnessUV = getMaterialUV(
pbrMaterial.sheenRoughnessUVSet,
pbrMaterial.sheenRoughnessUVTransform
);
let iridescenceUV = getMaterialUV(
pbrMaterial.iridescenceUVSet,
pbrMaterial.iridescenceUVTransform
);
let iridescenceThicknessUV = getMaterialUV(
pbrMaterial.iridescenceThicknessUVSet,
pbrMaterial.iridescenceThicknessUVTransform
);
let anisotropyUV = getMaterialUV(
pbrMaterial.anisotropyUVSet,
pbrMaterial.anisotropyUVTransform
);
// The albedo may be defined from a base texture or a flat color
var baseColor: vec4<f32> = pbrMaterial.baseColorFactor;
#ifdef HAS_BASECOLORMAP
baseColor = SRGBtoLINEAR(
textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV)
) * pbrMaterial.baseColorFactor;
#endif
#ifdef ALPHA_CUTOFF
if (baseColor.a < pbrMaterial.alphaCutoff) {
discard;
}
#endif
var color = vec3<f32>(0.0, 0.0, 0.0);
var transmission = 0.0;
if (pbrMaterial.unlit != 0u) {
color = baseColor.rgb;
} else {
// Metallic and Roughness material properties are packed together
// In glTF, these factors can be specified by fixed scalar values
// or from a metallic-roughness map
var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
var metallic = pbrMaterial.metallicRoughnessValues.x;
#ifdef HAS_METALROUGHNESSMAP
// Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
// This layout intentionally reserves the 'r' channel for (optional) occlusion map data
let mrSample = textureSample(
pbr_metallicRoughnessSampler,
pbr_metallicRoughnessSamplerSampler,
metallicRoughnessUV
);
perceptualRoughness = mrSample.g * perceptualRoughness;
metallic = mrSample.b * metallic;
#endif
perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
metallic = clamp(metallic, 0.0, 1.0);
let tbn = getTBN(normalUV);
let n = getNormal(tbn, normalUV); // normal at surface point
let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera
let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
var useExtendedPBR = false;
#ifdef USE_MATERIAL_EXTENSIONS
useExtendedPBR =
pbrMaterial.specularColorMapEnabled != 0 ||
pbrMaterial.specularIntensityMapEnabled != 0 ||
abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||
maxComponent(abs(pbrMaterial.specularColorFactor - vec3f(1.0))) > 0.0001 ||
abs(pbrMaterial.ior - 1.5) > 0.0001 ||
pbrMaterial.transmissionMapEnabled != 0 ||
pbrMaterial.transmissionFactor > 0.0001 ||
pbrMaterial.clearcoatMapEnabled != 0 ||
pbrMaterial.clearcoatRoughnessMapEnabled != 0 ||
pbrMaterial.clearcoatFactor > 0.0001 ||
pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||
pbrMaterial.sheenColorMapEnabled != 0 ||
pbrMaterial.sheenRoughnessMapEnabled != 0 ||
maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||
pbrMaterial.sheenRoughnessFactor > 0.0001 ||
pbrMaterial.iridescenceMapEnabled != 0 ||
pbrMaterial.iridescenceFactor > 0.0001 ||
abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||
abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||
abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||
pbrMaterial.anisotropyMapEnabled != 0 ||
pbrMaterial.anisotropyStrength > 0.0001 ||
abs(pbrMaterial.anisotropyRotation) > 0.0001 ||
length(pbrMaterial.anisotropyDirection - vec2f(1.0, 0.0)) > 0.0001;
#endif
if (!useExtendedPBR) {
let alphaRoughness = perceptualRoughness * perceptualRoughness;
let f0 = vec3<f32>(0.04);
var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);
diffuseColor *= 1.0 - metallic;
let specularColor = mix(f0, baseColor.rgb, metallic);
let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
let specularEnvironmentR0 = specularColor;
let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
let reflection = -normalize(reflect(v, n));
var pbrInfo = PBRInfo(
0.0, // NdotL
NdotV,
0.0, // NdotH
0.0, // LdotH
0.0, // VdotH
perceptualRoughness,
metallic,
specularEnvironmentR0,
specularEnvironmentR90,
alphaRoughness,
diffuseColor,
specularColor,
n,
v
);
#ifdef USE_LIGHTS
PBRInfo_setAmbientLight(&pbrInfo);
color += calculateFinalColor(pbrInfo, lighting.ambientColor);
for (var i = 0; i < lighting.directionalLightCount; i++) {
if (i < lighting.directionalLightCount) {
PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
}
}
for (var i = 0; i < lighting.pointLightCount; i++) {
if (i < lighting.pointLightCount) {
PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));
let attenuation = getPointLightAttenuation(
lighting_getPointLight(i),
distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)
);
color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
}
}
for (var i = 0; i < lighting.spotLightCount; i++) {
if (i < lighting.spotLightCount) {
PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));
let attenuation = getSpotLightAttenuation(
lighting_getSpotLight(i),
fragmentInputs.pbr_vPosition
);
color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);
}
}
#endif
#ifdef USE_IBL
if (pbrMaterial.IBLenabled != 0) {
color += getIBLContribution(pbrInfo, n, reflection);
}
#endif
#ifdef HAS_OCCLUSIONMAP
if (pbrMaterial.occlusionMapEnabled != 0) {
let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r;
color = mix(color, color * ao, pbrMaterial.occlusionStrength);
}
#endif
var emissive = pbrMaterial.emissiveFactor;
#ifdef HAS_EMISSIVEMAP
if (pbrMaterial.emissiveMapEnabled != 0u) {
emissive *= SRGBtoLINEAR(
textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV)
).rgb;
}
#endif
color += emissive * pbrMaterial.emissiveStrength;
#ifdef PBR_DEBUG
color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);
color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
#endif
return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);
}
var specularIntensity = pbrMaterial.specularIntensityFactor;
#ifdef HAS_SPECULARINTENSITYMAP
if (pbrMaterial.specularIntensityMapEnabled != 0) {
specularIntensity *= textureSample(
pbr_specularIntensitySampler,
pbr_specularIntensitySamplerSampler,
specularIntensityUV
).a;
}
#endif
var specularFactor = pbrMaterial.specularColorFactor;
#ifdef HAS_SPECULARCOLORMAP
if (pbrMaterial.specularColorMapEnabled != 0) {
specularFactor *= SRGBtoLINEAR(
textureSample(
pbr_specularColorSampler,
pbr_specularColorSamplerSampler,
specularColorUV
)
).rgb;
}
#endif
transmission = pbrMaterial.transmissionFactor;
#ifdef HAS_TRANSMISSIONMAP
if (pbrMaterial.transmissionMapEnabled != 0) {
transmission *= textureSample(
pbr_transmissionSampler,
pbr_transmissionSamplerSampler,
transmissionUV
).r;
}
#endif
transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);
var thickness = max(pbrMaterial.thicknessFactor, 0.0);
#ifdef HAS_THICKNESSMAP
thickness *= textureSample(
pbr_thicknessSampler,
pbr_thicknessSamplerSampler,
thicknessUV
).g;
#endif
var clearcoatFactor = pbrMaterial.clearcoatFactor;
var clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;
#ifdef HAS_CLEARCOATMAP
if (pbrMaterial.clearcoatMapEnabled != 0) {
clearcoatFactor *= textureSample(
pbr_clearcoatSampler,
pbr_clearcoatSamplerSampler,
clearcoatUV
).r;
}
#endif
#ifdef HAS_CLEARCOATROUGHNESSMAP
if (pbrMaterial.clearcoatRoughnessMapEnabled != 0) {
clearcoatRoughness *= textureSample(
pbr_clearcoatRoughnessSampler,
pbr_clearcoatRoughnessSamplerSampler,
clearcoatRoughnessUV
).g;
}
#endif
clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);
clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);
let clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);
var sheenColor = pbrMaterial.sheenColorFactor;
var sheenRoughness = pbrMaterial.sheenRoughnessFactor;
#ifdef HAS_SHEENCOLORMAP
if (pbrMaterial.sheenColorMapEnabled != 0) {
sheenColor *= SRGBtoLINEAR(
textureSample(
pbr_sheenColorSampler,
pbr_sheenColorSamplerSampler,
sheenColorUV
)
).rgb;
}
#endif
#ifdef HAS_SHEENROUGHNESSMAP
if (pbrMaterial.sheenRoughnessMapEnabled != 0) {
sheenRoughness *= textureSample(
pbr_sheenRoughnessSampler,
pbr_sheenRoughnessSamplerSampler,
sheenRoughnessUV
).a;
}
#endif
sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);
var iridescence = pbrMaterial.iridescenceFactor;
#ifdef HAS_IRIDESCENCEMAP
if (pbrMaterial.iridescenceMapEnabled != 0) {
iridescence *= textureSample(
pbr_iridescenceSampler,
pbr_iridescenceSamplerSampler,
iridescenceUV
).r;
}
#endif
iridescence = clamp(iridescence, 0.0, 1.0);
var iridescenceThickness = mix(
pbrMaterial.iridescenceThicknessRange.x,
pbrMaterial.iridescenceThicknessRange.y,
0.5
);
#ifdef HAS_IRIDESCENCETHICKNESSMAP
iridescenceThickness = mix(
pbrMaterial.iridescenceThicknessRange.x,
pbrMaterial.iridescenceThicknessRange.y,
textureSample(
pbr_iridescenceThicknessSampler,
pbr_iridescenceThicknessSamplerSampler,
iridescenceThicknessUV
).g
);
#endif
var anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);
var anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);
#ifdef HAS_ANISOTROPYMAP
if (pbrMaterial.anisotropyMapEnabled != 0) {
let anisotropySample = textureSample(
pbr_anisotropySampler,
pbr_anisotropySamplerSampler,
anisotropyUV
).rgb;
anisotropyStrength *= anisotropySample.b;
let mappedDirection = anisotropySample.rg * 2.0 - 1.0;
if (length(mappedDirection) > 0.0001) {
anisotropyDirection = normalize(mappedDirection);
}
}
#endif
anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);
var anisotropyTangent =
normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);
if (length(anisotropyTangent) < 0.0001) {
anisotropyTangent = normalize(tbn[0]);
}
let anisotropyViewAlignment = abs(dot(v, anisotropyTangent));
perceptualRoughness = mix(
perceptualRoughness,
clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),
anisotropyStrength
);
// Roughness is authored as perceptual roughness; as is convention,
// convert to material roughness by squaring the perceptual roughness [2].
let alphaRoughness = perceptualRoughness * perceptualRoughness;
let dielectricF0 = getDielectricF0(pbrMaterial.ior);
var dielectricSpecularF0 = min(
vec3f(dielectricF0) * specularFactor * specularIntensity,
vec3f(1.0)
);
let iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);
dielectricSpecularF0 = mix(
dielectricSpecularF0,
dielectricSpecularF0 * iridescenceTint,
iridescence
);
var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);
diffuseColor *= (1.0 - metallic) * (1.0 - transmission);
var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);
let baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;
diffuseColor *= baseLayerEnergy;
specularColor *= baseLayerEnergy;
// Compute reflectance.
let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
// For typical incident reflectance range (between 4% to 100%) set the grazing
// reflectance to 100% for typical fresnel effect.
// For very low reflectance range on highly diffuse objects (below 4%),
// incrementally reduce grazing reflectance to 0%.
let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
let specularEnvironmentR0 = specularColor;
let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
let reflection = -normalize(reflect(v, n));
var pbrInfo = PBRInfo(
0.0, // NdotL
NdotV,
0.0, // NdotH
0.0, // LdotH
0.0, // VdotH
perceptualRoughness,
metallic,
specularEnvironmentR0,
specularEnvironmentR90,
alphaRoughness,
diffuseColor,
specularColor,
n,
v
);
#ifdef USE_LIGHTS
// Apply ambient light
PBRInfo_setAmbientLight(&pbrInfo);
color += calculateMaterialLightColor(
pbrInfo,
lighting.ambientColor,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
// Apply directional light
for (var i = 0; i < lighting.directionalLightCount; i++) {
if (i < lighting.directionalLightCount) {
PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
color += calculateMaterialLightColor(
pbrInfo,
lighting_getDirectionalLight(i).color,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
}
}
// Apply point light
for (var i = 0; i < lighting.pointLightCount; i++) {
if (i < lighting.pointLightCount) {
PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));
let attenuation = getPointLightAttenuation(
lighting_getPointLight(i),
distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)
);
color += calculateMaterialLightColor(
pbrInfo,
lighting_getPointLight(i).color / attenuation,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
}
}
for (var i = 0; i < lighting.spotLightCount; i++) {
if (i < lighting.spotLightCount) {
PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));
let attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), fragmentInputs.pbr_vPosition);
color += calculateMaterialLightColor(
pbrInfo,
lighting_getSpotLight(i).color / attenuation,
clearcoatNormal,
clearcoatFactor,
clearcoatRoughness,
sheenColor,
sheenRoughness,
anisotropyTangent,
anisotropyStrength
);
}
}
#endif
// Calculate lighting contribution from image based lighting source (IBL)
#ifdef USE_IBL
if (pbrMaterial.IBLenabled != 0) {
color += getIBLContribution(pbrInfo, n, reflection) *
calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);
color += calculateClearcoatIBLContribution(
pbrInfo,
clearcoatNormal,
-normalize(reflect(v, clearcoatNormal)),
clearcoatFactor,
clearcoatRoughness
);
color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;
}
#endif
// Apply optional PBR terms for additional (optional) shading
#ifdef HAS_OCCLUSIONMAP
if (pbrMaterial.occlusionMapEnabled != 0) {
let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r;
color = mix(color, color * ao, pbrMaterial.occlusionStrength);
}
#endif
var emissive = pbrMaterial.emissiveFactor;
#ifdef HAS_EMISSIVEMAP
if (pbrMaterial.emissiveMapEnabled != 0u) {
emissive *= SRGBtoLINEAR(
textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV)
).rgb;
}
#endif
color += emissive * pbrMaterial.emissiveStrength;
if (transmission > 0.0) {
color = mix(color, color * getVolumeAttenuation(thickness), transmission);
}
// This section uses mix to override final color for reference app visualization
// of various parameters in the lighting equation.
#ifdef PBR_DEBUG
// TODO: Figure out how to debug multiple lights
// color = mix(color, F, pbr_scaleFGDSpec.x);
// color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
// color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
// color = mix(color, specContrib, pbr_scaleFGDSpec.w);
// color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);
color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
#endif
}
let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);
return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), alpha);
}
`;var pI=`layout(std140) uniform pbrProjectionUniforms {
mat4 modelViewProjectionMatrix;
mat4 modelMatrix;
mat4 normalMatrix;
vec3 camera;
} pbrProjection;
`,w7=`struct pbrProjectionUniforms {
modelViewProjectionMatrix: mat4x4<f32>,
modelMatrix: mat4x4<f32>,
normalMatrix: mat4x4<f32>,
camera: vec3<f32>
};
@group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
`,mI={name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:w7,vs:pI,fs:pI,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}};var Po={props:{},uniforms:{},defaultUniforms:{unlit:!1,baseColorMapEnabled:!1,baseColorFactor:[1,1,1,1],normalMapEnabled:!1,normalScale:1,emissiveMapEnabled:!1,emissiveFactor:[0,0,0],metallicRoughnessValues:[1,1],metallicRoughnessMapEnabled:!1,occlusionMapEnabled:!1,occlusionStrength:1,alphaCutoffEnabled:!1,alphaCutoff:.5,IBLenabled:!1,scaleIBLAmbient:[1,1],scaleDiffBaseMR:[0,0,0,0],scaleFGDSpec:[0,0,0,0],specularColorFactor:[1,1,1],specularIntensityFactor:1,specularColorMapEnabled:!1,specularIntensityMapEnabled:!1,ior:1.5,transmissionFactor:0,transmissionMapEnabled:!1,thicknessFactor:0,attenuationDistance:1e9,attenuationColor:[1,1,1],clearcoatFactor:0,clearcoatRoughnessFactor:0,clearcoatMapEnabled:!1,clearcoatRoughnessMapEnabled:!1,sheenColorFactor:[0,0,0],sheenRoughnessFactor:0,sheenColorMapEnabled:!1,sheenRoughnessMapEnabled:!1,iridescenceFactor:0,iridescenceIor:1.3,iridescenceThicknessRange:[100,400],iridescenceMapEnabled:!1,anisotropyStrength:0,anisotropyRotation:0,anisotropyDirection:[1,0],anisotropyMapEnabled:!1,emissiveStrength:1,baseColorUVSet:0,baseColorUVTransform:[1,0,0,0,1,0,0,0,1],metallicRoughnessUVSet:0,metallicRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],normalUVSet:0,normalUVTransform:[1,0,0,0,1,0,0,0,1],occlusionUVSet:0,occlusionUVTransform:[1,0,0,0,1,0,0,0,1],emissiveUVSet:0,emissiveUVTransform:[1,0,0,0,1,0,0,0,1],specularColorUVSet:0,specularColorUVTransform:[1,0,0,0,1,0,0,0,1],specularIntensityUVSet:0,specularIntensityUVTransform:[1,0,0,0,1,0,0,0,1],transmissionUVSet:0,transmissionUVTransform:[1,0,0,0,1,0,0,0,1],thicknessUVSet:0,thicknessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatUVSet:0,clearcoatUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatRoughnessUVSet:0,clearcoatRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],clearcoatNormalUVSet:0,clearcoatNormalUVTransform:[1,0,0,0,1,0,0,0,1],sheenColorUVSet:0,sheenColorUVTransform:[1,0,0,0,1,0,0,0,1],sheenRoughnessUVSet:0,sheenRoughnessUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceUVSet:0,iridescenceUVTransform:[1,0,0,0,1,0,0,0,1],iridescenceThicknessUVSet:0,iridescenceThicknessUVTransform:[1,0,0,0,1,0,0,0,1],anisotropyUVSet:0,anisotropyUVTransform:[1,0,0,0,1,0,0,0,1]},name:"pbrMaterial",firstBindingSlot:0,bindingLayout:[{name:"pbrMaterial",group:3},{name:"pbr_baseColorSampler",group:3},{name:"pbr_normalSampler",group:3},{name:"pbr_emissiveSampler",group:3},{name:"pbr_metallicRoughnessSampler",group:3},{name:"pbr_occlusionSampler",group:3},{name:"pbr_specularColorSampler",group:3},{name:"pbr_specularIntensitySampler",group:3},{name:"pbr_transmissionSampler",group:3},{name:"pbr_thicknessSampler",group:3},{name:"pbr_clearcoatSampler",group:3},{name:"pbr_clearcoatRoughnessSampler",group:3},{name:"pbr_clearcoatNormalSampler",group:3},{name:"pbr_sheenColorSampler",group:3},{name:"pbr_sheenRoughnessSampler",group:3},{name:"pbr_iridescenceSampler",group:3},{name:"pbr_iridescenceThicknessSampler",group:3},{name:"pbr_anisotropySampler",group:3}],dependencies:[Ka,fI,mI],source:hI,vs:uI,fs:dI,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,HAS_SPECULARCOLORMAP:!1,HAS_SPECULARINTENSITYMAP:!1,HAS_TRANSMISSIONMAP:!1,HAS_THICKNESSMAP:!1,HAS_CLEARCOATMAP:!1,HAS_CLEARCOATROUGHNESSMAP:!1,HAS_CLEARCOATNORMALMAP:!1,HAS_SHEENCOLORMAP:!1,HAS_SHEENROUGHNESSMAP:!1,HAS_IRIDESCENCEMAP:!1,HAS_IRIDESCENCETHICKNESSMAP:!1,HAS_ANISOTROPYMAP:!1,USE_MATERIAL_EXTENSIONS:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",specularColorFactor:"vec3<f32>",specularIntensityFactor:"f32",specularColorMapEnabled:"i32",specularIntensityMapEnabled:"i32",ior:"f32",transmissionFactor:"f32",transmissionMapEnabled:"i32",thicknessFactor:"f32",attenuationDistance:"f32",attenuationColor:"vec3<f32>",clearcoatFactor:"f32",clearcoatRoughnessFactor:"f32",clearcoatMapEnabled:"i32",clearcoatRoughnessMapEnabled:"i32",sheenColorFactor:"vec3<f32>",sheenRoughnessFactor:"f32",sheenColorMapEnabled:"i32",sheenRoughnessMapEnabled:"i32",iridescenceFactor:"f32",iridescenceIor:"f32",iridescenceThicknessRange:"vec2<f32>",iridescenceMapEnabled:"i32",anisotropyStrength:"f32",anisotropyRotation:"f32",anisotropyDirection:"vec2<f32>",anisotropyMapEnabled:"i32",emissiveStrength:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>",baseColorUVSet:"i32",baseColorUVTransform:"mat3x3<f32>",metallicRoughnessUVSet:"i32",metallicRoughnessUVTransform:"mat3x3<f32>",normalUVSet:"i32",normalUVTransform:"mat3x3<f32>",occlusionUVSet:"i32",occlusionUVTransform:"mat3x3<f32>",emissiveUVSet:"i32",emissiveUVTransform:"mat3x3<f32>",specularColorUVSet:"i32",specularColorUVTransform:"mat3x3<f32>",specularIntensityUVSet:"i32",specularIntensityUVTransform:"mat3x3<f32>",transmissionUVSet:"i32",transmissionUVTransform:"mat3x3<f32>",thicknessUVSet:"i32",thicknessUVTransform:"mat3x3<f32>",clearcoatUVSet:"i32",clearcoatUVTransform:"mat3x3<f32>",clearcoatRoughnessUVSet:"i32",clearcoatRoughnessUVTransform:"mat3x3<f32>",clearcoatNormalUVSet:"i32",clearcoatNormalUVTransform:"mat3x3<f32>",sheenColorUVSet:"i32",sheenColorUVTransform:"mat3x3<f32>",sheenRoughnessUVSet:"i32",sheenRoughnessUVTransform:"mat3x3<f32>",iridescenceUVSet:"i32",iridescenceUVTransform:"mat3x3<f32>",iridescenceThicknessUVSet:"i32",iridescenceThicknessUVTransform:"mat3x3<f32>",anisotropyUVSet:"i32",anisotropyUVTransform:"mat3x3<f32>"}};var P7=`struct LayerUniforms {
opacity: f32,
};
@group(0) @binding(auto)
var<uniform> layer: LayerUniforms;
`,gI=`layout(std140) uniform layerUniforms {
uniform float opacity;
} layer;
`,mv={name:"layer",source:P7,vs:gI,fs:gI,getUniforms:t=>({opacity:Math.pow(t.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var M7=`
@must_use
fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
return vec4(fragColor.rgb * fragColor.a, fragColor.a);
};
`,Yr={name:"color",dependencies:[],source:M7,getUniforms:t=>({})};var R7=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
struct VertexGeometry {
position: vec4<f32>,
worldPosition: vec3<f32>,
worldPositionAlt: vec3<f32>,
normal: vec3<f32>,
uv: vec2<f32>,
pickingColor: vec3<f32>,
};
var<private> geometry_: VertexGeometry = VertexGeometry(
vec4<f32>(0.0, 0.0, 1.0, 0.0),
vec3<f32>(0.0, 0.0, 0.0),
vec3<f32>(0.0, 0.0, 0.0),
vec3<f32>(0.0, 0.0, 0.0),
vec2<f32>(0.0, 0.0),
vec3<f32>(0.0, 0.0, 0.0)
);
struct FragmentGeometry {
uv: vec2<f32>,
};
var<private> fragmentGeometry: FragmentGeometry;
fn smoothedge(edge: f32, x: f32) -> f32 {
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
}
`,_I="#define SMOOTH_EDGE_RADIUS 0.5",I7=`${_I}
struct VertexGeometry {
vec4 position;
vec3 worldPosition;
vec3 worldPositionAlt;
vec3 normal;
vec2 uv;
vec3 pickingColor;
} geometry = VertexGeometry(
vec4(0.0, 0.0, 1.0, 0.0),
vec3(0.0),
vec3(0.0),
vec3(0.0),
vec2(0.0),
vec3(0.0)
);
`,L7=`${_I}
struct FragmentGeometry {
vec2 uv;
} geometry;
float smoothedge(float edge, float x) {
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
}
`,Km={name:"geometry",source:R7,vs:I7,fs:L7};var Te;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})(Te||(Te={}));var Le;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(Le||(Le={}));var Z;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})(Z||(Z={}));var yI="compute",gv="auto",Of="manipulation",as="none",Ff="pan-x",Nf="pan-y";function _v(t){if(t.includes(as))return as;let e=t.includes(Ff),r=t.includes(Nf);return e&&r?as:e||r?e?Ff:Nf:t.includes(Of)?Of:gv}var Df=class{constructor(e,r){this.actions="",this.manager=e,this.set(r)}set(e){e===yI&&(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(let r of this.manager.recognizers)r.options.enable&&(e=e.concat(r.getTouchAction()));return _v(e.join(" "))}};function qa(t){return t.trim().split(/\s+/g)}function qm(t,e,r){if(t)for(let o of qa(e))t.addEventListener(o,r,!1)}function Zm(t,e,r){if(t)for(let o of qa(e))t.removeEventListener(o,r,!1)}function yv(t){return(t.ownerDocument||t).defaultView}function xv(t,e){let r=t;for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function Jm(t){let e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let r=0,o=0,n=0;for(;n<e;)r+=t[n].clientX,o+=t[n].clientY,n++;return{x:Math.round(r/e),y:Math.round(o/e)}}function bv(t){let e=[],r=0;for(;r<t.pointers.length;)e[r]={clientX:Math.round(t.pointers[r].clientX),clientY:Math.round(t.pointers[r].clientY)},r++;return{timeStamp:Date.now(),pointers:e,center:Jm(e),deltaX:t.deltaX,deltaY:t.deltaY}}function Qm(t,e){let r=e.x-t.x,o=e.y-t.y;return Math.sqrt(r*r+o*o)}function Av(t,e){let r=e.clientX-t.clientX,o=e.clientY-t.clientY;return Math.sqrt(r*r+o*o)}function xI(t,e){let r=e.x-t.x,o=e.y-t.y;return Math.atan2(o,r)*180/Math.PI}function Tv(t,e){let r=e.clientX-t.clientX,o=e.clientY-t.clientY;return Math.atan2(o,r)*180/Math.PI}function eg(t,e){return t===e?Le.None:Math.abs(t)>=Math.abs(e)?t<0?Le.Left:Le.Right:e<0?Le.Up:Le.Down}function bI(t,e){let r=e.center,o=t.offsetDelta,n=t.prevDelta,i=t.prevInput;return(e.eventType===Te.Start||i?.eventType===Te.End)&&(n=t.prevDelta={x:i?.deltaX||0,y:i?.deltaY||0},o=t.offsetDelta={x:r.x,y:r.y}),{deltaX:n.x+(r.x-o.x),deltaY:n.y+(r.y-o.y)}}function tg(t,e,r){return{x:e/t||0,y:r/t||0}}function AI(t,e){return Av(e[0],e[1])/Av(t[0],t[1])}function TI(t,e){return Tv(e[1],e[0])-Tv(t[1],t[0])}function vI(t,e){let r=t.lastInterval||e,o=e.timeStamp-r.timeStamp,n,i,s,a;if(e.eventType!==Te.Cancel&&(o>25||r.velocity===void 0)){let c=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,f=tg(o,c,l);i=f.x,s=f.y,n=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=eg(c,l),t.lastInterval=e}else n=r.velocity,i=r.velocityX,s=r.velocityY,a=r.direction;e.velocity=n,e.velocityX=i,e.velocityY=s,e.direction=a}function SI(t,e){let{session:r}=t,{pointers:o}=e,{length:n}=o;r.firstInput||(r.firstInput=bv(e)),n>1&&!r.firstMultiple?r.firstMultiple=bv(e):n===1&&(r.firstMultiple=!1);let{firstInput:i,firstMultiple:s}=r,a=s?s.center:i.center,c=e.center=Jm(o);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-i.timeStamp,e.angle=xI(a,c),e.distance=Qm(a,c);let{deltaX:l,deltaY:f}=bI(r,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=eg(e.deltaX,e.deltaY);let u=tg(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=u.x,e.overallVelocityY=u.y,e.overallVelocity=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,e.scale=s?AI(s.pointers,o):1,e.rotation=s?TI(s.pointers,o):0,e.maxPointers=r.prevInput?e.pointers.length>r.prevInput.maxPointers?e.pointers.length:r.prevInput.maxPointers:e.pointers.length;let d=t.element;return xv(e.srcEvent.target,d)&&(d=e.srcEvent.target),e.target=d,vI(r,e),e}function CI(t,e,r){let o=r.pointers.length,n=r.changedPointers.length,i=e&Te.Start&&o-n===0,s=e&(Te.End|Te.Cancel)&&o-n===0;r.isFirst=Boolean(i),r.isFinal=Boolean(s),i&&(t.session={}),r.eventType=e;let a=SI(t,r);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}var Uf=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,r){CI(this.manager,e,r)}init(){qm(this.element,this.evEl,this.domHandler),qm(this.target,this.evTarget,this.domHandler),qm(yv(this.element),this.evWin,this.domHandler)}destroy(){Zm(this.element,this.evEl,this.domHandler),Zm(this.target,this.evTarget,this.domHandler),Zm(yv(this.element),this.evWin,this.domHandler)}};var O7={pointerdown:Te.Start,pointermove:Te.Move,pointerup:Te.End,pointercancel:Te.Cancel,pointerout:Te.Cancel},F7="pointerdown",N7="pointermove pointerup pointercancel",kf=class extends Uf{constructor(e){super(e),this.evEl=F7,this.evWin=N7,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:r}=this,o=!1,n=O7[e.type],i=e.pointerType,s=i==="touch",a=r.findIndex(c=>c.pointerId===e.pointerId);n&Te.Start&&(e.buttons||s)?a<0&&(r.push(e),a=r.length-1):n&(Te.End|Te.Cancel)&&(o=!0),!(a<0)&&(r[a]=e,this.callback(n,{pointers:r,changedPointers:[e],eventType:n,pointerType:i,srcEvent:e}),o&&r.splice(a,1))}};var D7=["","webkit","Moz","MS","ms","o"];function EI(t,e){let r=e[0].toUpperCase()+e.slice(1);for(let o of D7){let n=o?o+r:e;if(n in t)return n}}var U7=1,wI=2,PI={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Vf=class{constructor(e,r){this.options={...PI,...r,cssProps:{...PI.cssProps,...r.cssProps},inputTarget:r.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new kf(this),this.touchAction=new Df(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?wI:U7}recognize(e){let{session:r}=this;if(r.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let o,{recognizers:n}=this,{curRecognizer:i}=r;(!i||i&&i.state&Z.Recognized)&&(i=r.curRecognizer=null);let s=0;for(;s<n.length;)o=n[s],r.stopped!==wI&&(!i||o===i||o.canRecognizeWith(i))?o.recognize(e):o.reset(),!i&&o.state&(Z.Began|Z.Changed|Z.Ended)&&(i=r.curRecognizer=o),s++}get(e){let{recognizers:r}=this;for(let o=0;o<r.length;o++)if(r[o].options.event===e)return r[o];return null}add(e){if(Array.isArray(e)){for(let o of e)this.add(o);return this}let r=this.get(e.options.event);return r&&this.remove(r),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let o of e)this.remove(o);return this}let r=typeof e=="string"?this.get(e):e;if(r){let{recognizers:o}=this,n=o.indexOf(r);n!==-1&&(o.splice(n,1),this.touchAction.update())}return this}on(e,r){if(!e||!r)return;let{handlers:o}=this;for(let n of qa(e))o[n]=o[n]||[],o[n].push(r)}off(e,r){if(!e)return;let{handlers:o}=this;for(let n of qa(e))r?o[n]&&o[n].splice(o[n].indexOf(r),1):delete o[n]}emit(e,r){let o=this.handlers[e]&&this.handlers[e].slice();if(!o||!o.length)return;let n=r;n.type=e,n.preventDefault=function(){r.srcEvent.preventDefault()};let i=0;for(;i<o.length;)o[i](n),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:r}=this;if(r){for(let[o,n]of Object.entries(this.options.cssProps)){let i=EI(r.style,o);e?(this.oldCssProps[i]=r.style[i],r.style[i]=n):r.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}};var k7=1;function MI(){return k7++}function vv(t){return t&Z.Cancelled?"cancel":t&Z.Ended?"end":t&Z.Changed?"move":t&Z.Began?"start":""}var sn=class{constructor(e){this.options=e,this.id=MI(),this.state=Z.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(let n of e)this.recognizeWith(n);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{simultaneous:o}=this;return o[r.id]||(o[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let o of e)this.dropRecognizeWith(o);return this}let r;return typeof e=="string"?r=this.manager.get(e):r=e,r&&delete this.simultaneous[r.id],this}requireFailure(e){if(Array.isArray(e)){for(let n of e)this.requireFailure(n);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{requireFail:o}=this;return o.indexOf(r)===-1&&(o.push(r),r.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let o of e)this.dropRequireFailure(o);return this}let r;if(typeof e=="string"?r=this.manager.get(e):r=e,r){let o=this.requireFail.indexOf(r);o>-1&&this.requireFail.splice(o,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;let{state:r}=this;r<Z.Ended&&this.manager.emit(this.options.event+vv(r),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),r>=Z.Ended&&this.manager.emit(this.options.event+vv(r),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=Z.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(Z.Failed|Z.Possible)))return!1;e++}return!0}recognize(e){let r={...e};if(!this.options.enable){this.reset(),this.state=Z.Failed;return}this.state&(Z.Recognized|Z.Cancelled|Z.Failed)&&(this.state=Z.Possible),this.state=this.process(r),this.state&(Z.Began|Z.Changed|Z.Ended|Z.Cancelled)&&this.tryEmit(r)}getEventNames(){return[this.options.event]}reset(){}};var an=class extends sn{attrTest(e){let r=this.options.pointers;return r===0||e.pointers.length===r}process(e){let{state:r}=this,{eventType:o}=e,n=r&(Z.Began|Z.Changed),i=this.attrTest(e);return n&&(o&Te.Cancel||!i)?r|Z.Cancelled:n||i?o&Te.End?r|Z.Ended:r&Z.Began?r|Z.Changed:Z.Began:Z.Failed}};var cs=class extends sn{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[Of]}process(e){let{options:r}=this,o=e.pointers.length===r.pointers,n=e.distance<r.threshold,i=e.deltaTime<r.time;if(this.reset(),e.eventType&Te.Start&&this.count===0)return this.failTimeout();if(n&&i&&o){if(e.eventType!==Te.End)return this.failTimeout();let s=this.pTime?e.timeStamp-this.pTime<r.interval:!0,a=!this.pCenter||Qm(this.pCenter,e.center)<r.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!s?this.count=1:this.count+=1,this._input=e,this.count%r.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=Z.Recognized,this.tryEmit(this._input)},r.interval),Z.Began):Z.Recognized}return Z.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=Z.Failed},this.options.interval),Z.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===Z.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var V7=["","start","move","end","cancel","up","down","left","right"],ii=class extends an{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Le.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,r=[];return e&Le.Horizontal&&r.push(Nf),e&Le.Vertical&&r.push(Ff),r}getEventNames(){return V7.map(e=>this.options.event+e)}directionTest(e){let{options:r}=this,o=!0,{distance:n}=e,{direction:i}=e,s=e.deltaX,a=e.deltaY;return i&r.direction||(r.direction&Le.Horizontal?(i=s===0?Le.None:s<0?Le.Left:Le.Right,o=s!==this.pX,n=Math.abs(e.deltaX)):(i=a===0?Le.None:a<0?Le.Up:Le.Down,o=a!==this.pY,n=Math.abs(e.deltaY))),e.direction=i,o&&n>r.threshold&&Boolean(i&r.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&Z.Began)||!(this.state&Z.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let r=Le[e.direction].toLowerCase();r&&(e.additionalEvent=this.options.event+r),super.emit(e)}};var z7=["","start","move","end","cancel","in","out"],Za=class extends an{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[as]}getEventNames(){return z7.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&Z.Began))}emit(e){if(e.scale!==1){let r=e.scale<1?"in":"out";e.additionalEvent=this.options.event+r}super.emit(e)}};var Mo=class{constructor(e,r,o){this.element=e,this.callback=r,this.options=o}};var RI=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",sRe=typeof window<"u"?window:global;var G7=RI.indexOf("firefox")!==-1,II=4.000244140625,$7=40,X7=.25,rg=class extends Mo{constructor(e,r,o){super(e,r,{enable:!0,...o}),this.handleEvent=n=>{if(!this.options.enable)return;let i=n.deltaY;globalThis.WheelEvent&&(G7&&n.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(i/=globalThis.devicePixelRatio),n.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(i*=$7)),i!==0&&i%II===0&&(i=Math.floor(i/II)),n.shiftKey&&i&&(i=i*X7),this.callback({type:"wheel",center:{x:n.clientX,y:n.clientY},delta:-i,srcEvent:n,pointerType:"mouse",target:n.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,r){e==="wheel"&&(this.options.enable=r)}};var LI=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],og=class extends Mo{constructor(e,r,o){super(e,r,{enable:!0,...o}),this.handleEvent=i=>{this.handleOverEvent(i),this.handleOutEvent(i),this.handleEnterEvent(i),this.handleLeaveEvent(i),this.handleMoveEvent(i)},this.pressed=!1;let{enable:n}=this.options;this.enableMoveEvent=n,this.enableLeaveEvent=n,this.enableEnterEvent=n,this.enableOutEvent=n,this.enableOverEvent=n,LI.forEach(i=>e.addEventListener(i,this.handleEvent))}destroy(){LI.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){switch(e){case"pointermove":this.enableMoveEvent=r;break;case"pointerover":this.enableOverEvent=r;break;case"pointerout":this.enableOutEvent=r;break;case"pointerenter":this.enableEnterEvent=r;break;case"pointerleave":this.enableLeaveEvent=r;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var BI=["keydown","keyup"],ng=class extends Mo{constructor(e,r,o){super(e,r,{enable:!0,tabIndex:0,...o}),this.handleEvent=n=>{let i=n.target||n.srcElement;i.tagName==="INPUT"&&i.type==="text"||i.tagName==="TEXTAREA"||(this.enableDownEvent&&n.type==="keydown"&&this.callback({type:"keydown",srcEvent:n,key:n.key,target:n.target}),this.enableUpEvent&&n.type==="keyup"&&this.callback({type:"keyup",srcEvent:n,key:n.key,target:n.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",BI.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){BI.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e==="keydown"&&(this.enableDownEvent=r),e==="keyup"&&(this.enableUpEvent=r)}};var ig=class extends Mo{constructor(e,r,o){super(e,r,o),this.handleEvent=n=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:n.clientX,y:n.clientY},srcEvent:n,pointerType:"mouse",target:n.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e==="contextmenu"&&(this.options.enable=r)}};var Y7={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},K7=0,q7=1,Z7=2,J7=1,Q7=2,eY=4;function OI(t){let e=Y7[t.srcEvent.type];if(!e)return null;let{buttons:r,button:o}=t.srcEvent,n=!1,i=!1,s=!1;return e===2?(n=Boolean(r&J7),i=Boolean(r&eY),s=Boolean(r&Q7)):(n=o===K7,i=o===q7,s=o===Z7),{leftButton:n,middleButton:i,rightButton:s}}function FI(t,e){let r=t.center;if(!r)return null;let o=e.getBoundingClientRect(),n=o.width/e.offsetWidth||1,i=o.height/e.offsetHeight||1,s={x:(r.x-o.left-e.clientLeft)/n,y:(r.y-o.top-e.clientTop)/i};return{center:r,offsetCenter:s}}var tY={srcElement:"root",priority:0},sg=class{constructor(e,r){this.handleEvent=o=>{if(this.isEmpty())return;let n=this._normalizeEvent(o),i=o.srcEvent.target;for(;i&&i!==n.rootElement;){if(this._emit(n,i),n.handled)return;i=i.parentNode}this._emit(n,"root")},this.eventManager=e,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,o,n=!1,i=!1){let{handlers:s,handlersByElement:a}=this,c={...tY,...o},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let f={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};n&&(f.once=!0),i&&(f.passive=!0),s.push(f),this._active=this._active||!f.passive;let u=l.length-1;for(;u>=0&&!(l[u].priority>=f.priority);)u--;l.splice(u+1,0,f)}remove(e,r){let{handlers:o,handlersByElement:n}=this;for(let i=o.length-1;i>=0;i--){let s=o[i];if(s.type===e&&s.handler===r){o.splice(i,1);let a=n.get(s.srcElement);a.splice(a.indexOf(s),1),a.length===0&&n.delete(s.srcElement)}}this._active=o.some(i=>!i.passive)}_emit(e,r){let o=this.handlersByElement.get(r);if(o){let n=!1,i=()=>{e.handled=!0},s=()=>{e.handled=!0,n=!0},a=[];for(let c=0;c<o.length;c++){let{type:l,handler:f,once:u}=o[c];if(f({...e,type:l,stopPropagation:i,stopImmediatePropagation:s}),u&&a.push(o[c]),n)break}for(let c=0;c<a.length;c++){let{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){let r=this.eventManager.getElement();return{...e,...OI(e),...FI(e,r),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function rY(t){if("recognizer"in t)return t;let e,r=Array.isArray(t)?[...t]:[t];if(typeof r[0]=="function"){let o=r.shift(),n=r.shift()||{};e=new o(n)}else e=r.shift();return{recognizer:e,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var zf=class{constructor(e=null,r={}){if(this._onBasicInput=o=>{this.manager.emit(o.srcEvent.type,o)},this._onOtherEvent=o=>{this.manager.emit(o.type,o)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=e,!!e){this.manager=new Vf(e,this.options);for(let o of this.options.recognizers){let{recognizer:n,recognizeWith:i,requireFailure:s}=rY(o);this.manager.add(n),i&&n.recognizeWith(i),s&&n.requireFailure(s)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new rg(e,this._onOtherEvent,{enable:!1}),this.moveInput=new og(e,this._onOtherEvent,{enable:!1}),this.keyInput=new ng(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new ig(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,r,o){this._addEventHandler(e,r,o,!1)}once(e,r,o){this._addEventHandler(e,r,o,!0)}watch(e,r,o){this._addEventHandler(e,r,o,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:o}=this;if(!o)return;let n=o.get(e);n&&(n.set({enable:r}),o.touchAction.update()),this.wheelInput?.enableEventType(e,r),this.moveInput?.enableEventType(e,r),this.keyInput?.enableEventType(e,r),this.contextmenuInput?.enableEventType(e,r)}_addEventHandler(e,r,o,n,i){if(typeof e!="string"){o=r;for(let[l,f]of Object.entries(e))this._addEventHandler(l,f,o,n,i);return}let{manager:s,events:a}=this;if(!s)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new sg(this,l),a.set(e,c),s&&s.on(e,c.handleEvent)}c.add(e,r,o,n,i),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let[i,s]of Object.entries(e))this._removeEventHandler(i,s);return}let{events:o}=this,n=o.get(e);if(n&&(n.remove(e,r),n.isEmpty())){let{recognizerName:i}=n,s=!1;for(let a of o.values())if(a.recognizerName===i&&!a.isEmpty()){s=!0;break}s||this._toggleRecognizer(i,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(r=>r.getEventNames().includes(e))?.options.event}};var Be={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(Be,"IDENTITY",{get:()=>(N.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),Be.CARTESIAN)});var ft={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Pe={common:0,meters:1,pixels:2},Ja={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Sv={multipan:[ii,{threshold:10,direction:Le.Vertical,pointers:2}],pinch:[Za,{},null,["multipan"]],pan:[ii,{threshold:1},["pinch"],["multipan"]],dblclick:[cs,{event:"dblclick",taps:2}],click:[cs,{event:"click"},null,["dblclick"]]},NI={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function oY(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let o=0;o<r;o++)if(t[o]!==e[o])return!1;return!0}return!1}function Yt(t){let e={},r;return o=>{for(let n in o)if(!oY(o[n],e[n])){r=t(o),e=o;break}return r}}var DI=[0,0,0,0],nY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],UI=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],iY=[0,0,0],kI=[0,0,0],sY={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function ls(t){let e=sY[t];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${t}`);return e}var aY=Yt(lY);function Cv(t,e,r=kI){r.length<3&&(r=[r[0],r[1],0]);let o=r,n,i=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?n=r:n=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case ft.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(n=[0,0,0],i=!1);break;case ft.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?o=n:e==="cartesian"&&(o=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],n=t.unprojectPosition(o),o[0]-=r[0],o[1]-=r[1],o[2]-=r[2]);break;case ft.IDENTITY:o=t.position.map(Math.fround),o[2]=o[2]||0;break;case ft.GLOBE:i=!1,n=null;break;default:i=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:o,offsetMode:i}}function cY(t,e,r){let{viewMatrixUncentered:o,projectionMatrix:n}=t,{viewMatrix:i,viewProjectionMatrix:s}=t,a=DI,c=DI,l=t.cameraPosition,{geospatialOrigin:f,shaderCoordinateOrigin:u,offsetMode:d}=Cv(t,e,r);return d&&(c=t.projectPosition(f||u),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Nt.transformMat4([],c,s),i=o||i,s=je.multiply([],n,i),s=je.multiply([],s,nY)),{viewMatrix:i,viewProjectionMatrix:s,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:u,geospatialOrigin:f}}function ag({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:o="default",coordinateOrigin:n=kI,autoWrapLongitude:i=!1}){o==="default"&&(o=t.isGeospatial?"lnglat":"cartesian");let s=aY({viewport:t,devicePixelRatio:e,coordinateSystem:o,coordinateOrigin:n});return s.wrapLongitude=i,s.modelMatrix=r||UI,s}function lY({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:o}){let{projectionCenter:n,viewProjectionMatrix:i,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=cY(t,r,o),f=t.getDistanceScales(),u=[t.width*e,t.height*e],d=Nt.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,h={coordinateSystem:ls(r),projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:s.slice(0,3),center:n,pseudoMeters:Boolean(t._pseudoMeters),viewportSize:u,devicePixelRatio:e,focalDistance:d,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:iY,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:i,modelMatrix:UI,cameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case"meter-offsets":h.commonUnitsPerWorldUnit=p.unitsPerMeter,h.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":t._pseudoMeters||(h.commonUnitsPerMeter=p.unitsPerMeter),h.commonUnitsPerWorldUnit=p.unitsPerDegree,h.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":h.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],h.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return h}var fY=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],uY=fY.map(t=>`const COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")}: i32 = ${ls(t)};`).join(""),dY=Object.keys(ft).map(t=>`const PROJECTION_MODE_${t}: i32 = ${ft[t]};`).join(""),hY=Object.keys(Pe).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${Pe[t]};`).join(""),pY=`${uY}
${dY}
${hY}
const TILE_SIZE: f32 = 512.0;
const PI: f32 = 3.1415926536;
const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0);
const ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);
const EARTH_RADIUS: f32 = 6370972.0; // meters
const GLOBE_RADIUS: f32 = 256.0;
// -----------------------------------------------------------------------------
// Uniform block (converted from GLSL uniform block)
// -----------------------------------------------------------------------------
struct ProjectUniforms {
wrapLongitude: i32,
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: i32,
};
@group(0) @binding(auto)
var<uniform> project: ProjectUniforms;
// -----------------------------------------------------------------------------
// Geometry data shared across the project helpers.
// The active layer shader is responsible for populating this private module
// state before calling the project functions below.
// -----------------------------------------------------------------------------
// Structure to carry additional geometry data used by deck.gl filters.
struct Geometry {
worldPosition: vec3<f32>,
worldPositionAlt: vec3<f32>,
position: vec4<f32>,
normal: vec3<f32>,
uv: vec2<f32>,
pickingColor: vec3<f32>,
};
var<private> geometry: Geometry;
`,VI=`${pY}
// -----------------------------------------------------------------------------
// Functions
// -----------------------------------------------------------------------------
// Returns an adjustment factor for commonUnitsPerMeter
fn _project_size_at_latitude(lat: f32) -> f32 {
let y = clamp(lat, -89.9, 89.9);
return 1.0 / cos(radians(y));
}
// Overloaded version: scales a value in meters at a given latitude.
fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 {
return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat);
}
// Computes a non-linear scale factor based on geometry.
// (Note: This function relies on "geometry" being provided.)
fn project_size() -> f32 {
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
project.pseudoMeters == 0) {
if (geometry.position.w == 0.0) {
return _project_size_at_latitude(geometry.worldPosition.y);
}
let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
let y2 = y * y;
let y4 = y2 * y2;
let y6 = y4 * y2;
return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
}
return 1.0;
}
// Overloads to scale offsets (meters to world units)
fn project_size_float(meters: f32) -> f32 {
return meters * project.commonUnitsPerMeter.z * project_size();
}
fn project_size_vec2(meters: vec2<f32>) -> vec2<f32> {
return meters * project.commonUnitsPerMeter.xy * project_size();
}
fn project_size_vec3(meters: vec3<f32>) -> vec3<f32> {
return meters * project.commonUnitsPerMeter * project_size();
}
fn project_size_vec4(meters: vec4<f32>) -> vec4<f32> {
return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w);
}
// Returns a rotation matrix aligning the z\u2011axis with the given up vector.
fn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> {
let uz = normalize(up);
let ux = select(
vec3<f32>(1.0, 0.0, 0.0),
normalize(vec3<f32>(uz.y, -uz.x, 0.0)),
abs(uz.z) == 1.0
);
let uy = cross(uz, ux);
return mat3x3<f32>(ux, uy, uz);
}
// Since WGSL does not support "out" parameters, we return a struct.
struct RotationResult {
needsRotation: bool,
transform: mat3x3<f32>,
};
fn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult {
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
return RotationResult(true, project_get_orientation_matrix(commonPosition));
} else {
return RotationResult(false, mat3x3<f32>()); // identity alternative if needed
};
}
// Projects a normal vector from the current coordinate system to world space.
fn project_normal(vector: vec3<f32>) -> vec3<f32> {
let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0);
var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
let rotResult = project_needs_rotation(geometry.position.xyz);
if (rotResult.needsRotation) {
n = rotResult.transform * n;
}
return n;
}
// Applies a scale offset based on y-offset (dy)
fn project_offset_(offset: vec4<f32>) -> vec4<f32> {
let dy: f32 = offset.y;
let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w);
}
// Projects lng/lat coordinates to a unit tile [0,1]
fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> {
var x = lnglat.x;
if (project.wrapLongitude != 0) {
x = ((x + 180.0) % 360.0) - 180.0;
}
let y = clamp(lnglat.y, -89.9, 89.9);
return vec2<f32>(
radians(x) + PI,
PI + log(tan(PI * 0.25 + radians(y) * 0.5))
) * WORLD_SCALE;
}
// Projects lng/lat/z coordinates for a globe projection.
fn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> {
let lambda = radians(lnglatz.x);
let phi = radians(lnglatz.y);
let cosPhi = cos(phi);
let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
return vec3<f32>(
sin(lambda) * cosPhi,
-cos(lambda) * cosPhi,
sin(phi)
) * D;
}
// Projects positions (with an optional 64-bit low part) from the input
// coordinate system to the common space.
fn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> {
var position_world = project.modelMatrix * position;
// Work around for a Mac+NVIDIA bug:
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
return vec4<f32>(
project_mercator_(position_world.xy),
_project_size_at_latitude_m(position_world.z, position_world.y),
position_world.w
);
}
if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w);
}
}
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
return vec4<f32>(
project_globe_(position_world.xyz),
position_world.w
);
}
}
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
return vec4<f32>(
project_mercator_(position_world.xy) - project.commonOrigin.xy,
project_size_float(position_world.z),
position_world.w
);
}
}
}
if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w);
}
return project_offset_(position_world) +
project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0));
}
// Overloaded versions for different input types.
fn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> {
return project_position_vec4_f64(position, ZERO_64_LOW);
}
fn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> {
let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low);
return projected_position.xyz;
}
fn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> {
let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW);
return projected_position.xyz;
}
fn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> {
let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW);
return projected_position.xy;
}
// Transforms a common space position to clip space.
fn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> {
return viewProjectionMatrix * position + center;
}
// Uses the project viewProjectionMatrix and center.
fn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> {
return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center);
}
// Returns a clip space offset corresponding to a given number of screen pixels.
fn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> {
let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
return offset * project.focalDistance;
}
fn project_meter_size_to_pixel(meters: f32) -> f32 {
return project_size_float(meters) * project.scale;
}
fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 {
if (unit == UNIT_METERS) {
return project_meter_size_to_pixel(size);
} else if (unit == UNIT_COMMON) {
return size * project.scale;
}
// UNIT_PIXELS: no scaling applied.
return size;
}
fn project_pixel_size_float(pixels: f32) -> f32 {
return pixels / project.scale;
}
fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
return pixels / project.scale;
}
`;var mY=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],gY=mY.map(t=>`const int COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")} = ${ls(t)};`).join(""),_Y=Object.keys(ft).map(t=>`const int PROJECTION_MODE_${t} = ${ft[t]};`).join(""),yY=Object.keys(Pe).map(t=>`const int UNIT_${t.toUpperCase()} = ${Pe[t]};`).join(""),zI=`${gY}
${_Y}
${yY}
layout(std140) uniform projectUniforms {
bool wrapLongitude;
int coordinateSystem;
vec3 commonUnitsPerMeter;
int projectionMode;
float scale;
vec3 commonUnitsPerWorldUnit;
vec3 commonUnitsPerWorldUnit2;
vec4 center;
mat4 modelMatrix;
mat4 viewProjectionMatrix;
vec2 viewportSize;
float devicePixelRatio;
float focalDistance;
vec3 cameraPosition;
vec3 coordinateOrigin;
vec3 commonOrigin;
bool pseudoMeters;
} project;
const float TILE_SIZE = 512.0;
const float PI = 3.1415926536;
const float WORLD_SCALE = TILE_SIZE / (PI * 2.0);
const vec3 ZERO_64_LOW = vec3(0.0);
const float EARTH_RADIUS = 6370972.0;
const float GLOBE_RADIUS = 256.0;
float project_size_at_latitude(float lat) {
float y = clamp(lat, -89.9, 89.9);
return 1.0 / cos(radians(y));
}
float project_size() {
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
project.pseudoMeters == false) {
if (geometry.position.w == 0.0) {
return project_size_at_latitude(geometry.worldPosition.y);
}
float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
float y2 = y * y;
float y4 = y2 * y2;
float y6 = y4 * y2;
return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
}
return 1.0;
}
float project_size_at_latitude(float meters, float lat) {
return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);
}
float project_size(float meters) {
return meters * project.commonUnitsPerMeter.z * project_size();
}
vec2 project_size(vec2 meters) {
return meters * project.commonUnitsPerMeter.xy * project_size();
}
vec3 project_size(vec3 meters) {
return meters * project.commonUnitsPerMeter * project_size();
}
vec4 project_size(vec4 meters) {
return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);
}
mat3 project_get_orientation_matrix(vec3 up) {
vec3 uz = normalize(up);
vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));
vec3 uy = cross(uz, ux);
return mat3(ux, uy, uz);
}
bool project_needs_rotation(vec3 commonPosition, out mat3 transform) {
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
transform = project_get_orientation_matrix(commonPosition);
return true;
}
return false;
}
vec3 project_normal(vec3 vector) {
vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);
vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
mat3 rotation;
if (project_needs_rotation(geometry.position.xyz, rotation)) {
n = rotation * n;
}
return n;
}
vec4 project_offset_(vec4 offset) {
float dy = offset.y;
vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);
}
vec2 project_mercator_(vec2 lnglat) {
float x = lnglat.x;
if (project.wrapLongitude) {
x = mod(x + 180., 360.0) - 180.;
}
float y = clamp(lnglat.y, -89.9, 89.9);
return vec2(
radians(x) + PI,
PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
) * WORLD_SCALE;
}
vec3 project_globe_(vec3 lnglatz) {
float lambda = radians(lnglatz.x);
float phi = radians(lnglatz.y);
float cosPhi = cos(phi);
float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
return vec3(
sin(lambda) * cosPhi,
-cos(lambda) * cosPhi,
sin(phi)
) * D;
}
vec4 project_position(vec4 position, vec3 position64Low) {
vec4 position_world = project.modelMatrix * position;
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
return vec4(
project_mercator_(position_world.xy),
project_size_at_latitude(position_world.z, position_world.y),
position_world.w
);
}
if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
position_world.xyz += project.coordinateOrigin;
}
}
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
return vec4(
project_globe_(position_world.xyz),
position_world.w
);
}
}
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
return vec4(
project_mercator_(position_world.xy) - project.commonOrigin.xy,
project_size(position_world.z),
position_world.w
);
}
}
}
if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
position_world.xyz -= project.coordinateOrigin;
}
return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));
}
vec4 project_position(vec4 position) {
return project_position(position, ZERO_64_LOW);
}
vec3 project_position(vec3 position, vec3 position64Low) {
vec4 projected_position = project_position(vec4(position, 1.0), position64Low);
return projected_position.xyz;
}
vec3 project_position(vec3 position) {
vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);
return projected_position.xyz;
}
vec2 project_position(vec2 position) {
vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);
return projected_position.xy;
}
vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {
return viewProjectionMatrix * position + center;
}
vec4 project_common_position_to_clipspace(vec4 position) {
return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);
}
vec2 project_pixel_size_to_clipspace(vec2 pixels) {
vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
return offset * project.focalDistance;
}
float project_size_to_pixel(float meters) {
return project_size(meters) * project.scale;
}
vec2 project_size_to_pixel(vec2 meters) {
return project_size(meters) * project.scale;
}
float project_size_to_pixel(float size, int unit) {
if (unit == UNIT_METERS) return project_size_to_pixel(size);
if (unit == UNIT_COMMON) return size * project.scale;
return size;
}
float project_pixel_size(float pixels) {
return pixels / project.scale;
}
vec2 project_pixel_size(vec2 pixels) {
return pixels / project.scale;
}
`;var xY={};function bY(t=xY){return"viewport"in t?ag(t):{}}var We={name:"project",dependencies:[mT,Km],source:VI,vs:zI,getUniforms:bY,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"}};var AY=`// Define a structure to hold both the clip-space position and the common position.
struct ProjectResult {
clipPosition: vec4<f32>,
commonPosition: vec4<f32>,
};
// This function mimics the GLSL version with the 'out' parameter by returning both values.
fn project_position_to_clipspace_and_commonspace(
position: vec3<f32>,
position64Low: vec3<f32>,
offset: vec3<f32>
) -> ProjectResult {
// Compute the projected position.
let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);
// Start with the provided offset.
var finalOffset: vec3<f32> = offset;
// Get whether a rotation is needed and the rotation matrix.
let rotationResult = project_needs_rotation(projectedPosition);
// If rotation is needed, update the offset.
if (rotationResult.needsRotation) {
finalOffset = rotationResult.transform * offset;
}
// Compute the common position.
let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);
// Convert to clip-space.
let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition);
return ProjectResult(clipPosition, commonPosition);
}
// A convenience overload that returns only the clip-space position.
fn project_position_to_clipspace(
position: vec3<f32>,
position64Low: vec3<f32>,
offset: vec3<f32>
) -> vec4<f32> {
return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;
}
`,TY=`vec4 project_position_to_clipspace(
vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
) {
vec3 projectedPosition = project_position(position, position64Low);
mat3 rotation;
if (project_needs_rotation(projectedPosition, rotation)) {
// offset is specified as ENU
// when in globe projection, rotate offset so that the ground alighs with the surface of the globe
offset = rotation * offset;
}
commonPosition = vec4(projectedPosition + offset, 1.0);
return project_common_position_to_clipspace(commonPosition);
}
vec4 project_position_to_clipspace(
vec3 position, vec3 position64Low, vec3 offset
) {
vec4 commonPosition;
return project_position_to_clipspace(position, position64Low, offset, commonPosition);
}
`,fe={name:"project32",dependencies:[We],source:AY,vs:TY};function Ev(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function si(t,e){let r=Nt.transformMat4([],e,t);return Nt.scale(r,r,1/r[3]),r}function HI(t,e,r){return r*e+(1-r)*t}function Hf(t,e,r){return t<e?e:t>r?r:t}function vY(t){return Math.log(t)*Math.LOG2E}var jf=Math.log2||vY;function Kr(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var qr=Math.PI,jI=qr/4,Pr=qr/180,wv=180/qr,Qa=512,cg=4003e4,Ut=85.051129,WI=1.5;function Wf(t){return Math.pow(2,t)}function lg(t){return jf(t)}function Oe(t){let[e,r]=t;Kr(Number.isFinite(e)),Kr(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let o=e*Pr,n=r*Pr,i=Qa*(o+qr)/(2*qr),s=Qa*(qr+Math.log(Math.tan(jI+n*.5)))/(2*qr);return[i,s]}function pt(t){let[e,r]=t,o=e/Qa*(2*qr)-qr,n=2*(Math.atan(Math.exp(r/Qa*(2*qr)-qr))-jI);return[o*wv,n*wv]}function Gf(t){let{latitude:e}=t;Kr(Number.isFinite(e));let r=Math.cos(e*Pr);return lg(cg*r)-9}function fs(t){let e=Math.cos(t*Pr);return Qa/cg/e}function ec(t){let{latitude:e,longitude:r,highPrecision:o=!1}=t;Kr(Number.isFinite(e)&&Number.isFinite(r));let n=Qa,i=Math.cos(e*Pr),s=n/360,a=s/i,c=n/cg/i,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[s,a,c],degreesPerUnit:[1/s,1/a,1/c]};if(o){let f=Pr*Math.tan(e*Pr)/i,u=s*f/2,d=n/cg*f,h=d/a*c;l.unitsPerDegree2=[0,u,d],l.unitsPerMeter2=[h,0,h]}return l}function $f(t,e){let[r,o,n]=t,[i,s,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=ec({longitude:r,latitude:o,highPrecision:!0}),f=Oe(t);f[0]+=i*(c[0]+l[0]*s),f[1]+=s*(c[1]+l[1]*s);let u=pt(f),d=(n||0)+(a||0);return Number.isFinite(n)||Number.isFinite(a)?[u[0],u[1],d]:u}function fg(t){let{height:e,pitch:r,bearing:o,altitude:n,scale:i,center:s}=t,a=Ev();je.translate(a,a,[0,0,-n]),je.rotateX(a,a,-r*Pr),je.rotateZ(a,a,o*Pr);let c=i/e;return je.scale(a,a,[c,c,c]),s&&je.translate(a,a,Ke.negate([],s)),a}function Pv(t){let{width:e,height:r,altitude:o,pitch:n=0,offset:i,center:s,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:f=cn(WI)}=t;o!==void 0&&(f=cn(o));let u=f*Pr,d=n*Pr,h=ln(f),p=h;s&&(p+=s[2]*a/Math.cos(d)/r);let m=u*(.5+(i?i[1]:0)/r),g=Math.sin(m)*p/Math.sin(Hf(Math.PI/2-d-m,.01,Math.PI-.01)),_=Math.sin(d)*g+p,x=p*10,y=Math.min(_*l,x);return{fov:u,aspect:e/r,focalDistance:h,near:c,far:y}}function cn(t){return 2*Math.atan(.5/t)*wv}function ln(t){return .5/Math.tan(.5*t*Pr)}function tc(t,e){let[r,o,n=0]=t;return Kr(Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(n)),si(e,[r,o,n,1])}function Mr(t,e,r=0){let[o,n,i]=t;if(Kr(Number.isFinite(o)&&Number.isFinite(n),"invalid pixel coordinate"),Number.isFinite(i))return si(e,[o,n,i,1]);let s=si(e,[o,n,0,1]),a=si(e,[o,n,1,1]),c=s[2],l=a[2],f=c===l?0:((r||0)-c)/(l-c);return Ye.lerp([],s,a,f)}function ug(t){let{width:e,height:r,bounds:o,minExtent:n=0,maxZoom:i=24,offset:s=[0,0]}=t,[[a,c],[l,f]]=o,u=SY(t.padding),d=Oe([a,Hf(f,-Ut,Ut)]),h=Oe([l,Hf(c,-Ut,Ut)]),p=[Math.max(Math.abs(h[0]-d[0]),n),Math.max(Math.abs(h[1]-d[1]),n)],m=[e-u.left-u.right-Math.abs(s[0])*2,r-u.top-u.bottom-Math.abs(s[1])*2];Kr(m[0]>0&&m[1]>0);let g=m[0]/p[0],_=m[1]/p[1],x=(u.right-u.left)/2/g,y=(u.top-u.bottom)/2/_,b=[(h[0]+d[0])/2+x,(h[1]+d[1])/2+y],T=pt(b),v=Math.min(i,jf(Math.abs(Math.min(g,_))));return Kr(Number.isFinite(v)),{longitude:T[0],latitude:T[1],zoom:v}}function SY(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(Kr(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var GI=Math.PI/180;function dg(t,e=0){let{width:r,height:o,unproject:n}=t,i={targetZ:e},s=n([0,o],i),a=n([r,o],i),c,l,f=t.fovy?.5*t.fovy*GI:Math.atan(.5/t.altitude),u=(90-t.pitch)*GI;return f>u-.01?(c=$I(t,0,e),l=$I(t,r,e)):(c=n([0,0],i),l=n([r,0],i)),[s,a,l,c]}function $I(t,e,r){let{pixelUnprojectionMatrix:o}=t,n=si(o,[e,0,1,1]),i=si(o,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-n[2])/(i[2]-n[2]),c=Ye.lerp([],n,i,a),l=pt(c);return l.push(r),l}var XI=.01,EY=["longitude","latitude","zoom"],YI={curve:1.414,speed:1.2};function Mv(t,e,r,o){let{startZoom:n,startCenterXY:i,uDelta:s,w0:a,u1:c,S:l,rho:f,rho2:u,r0:d}=KI(t,e,o);if(c<XI){let b={};for(let T of EY){let v=t[T],w=e[T];b[T]=HI(v,w,r)}return b}let h=r*l,p=Math.cosh(d)/Math.cosh(d+f*h),m=a*((Math.cosh(d)*Math.tanh(d+f*h)-Math.sinh(d))/u)/c,g=1/p,_=n+lg(g),x=Ye.scale([],s,m);Ye.add(x,x,i);let y=pt(x);return{longitude:y[0],latitude:y[1],zoom:_}}function Rv(t,e,r){let o={...YI,...r},{screenSpeed:n,speed:i,maxDuration:s}=o,{S:a,rho:c}=KI(t,e,o),l=1e3*a,f;return Number.isFinite(n)?f=l/(n/c):f=l/i,Number.isFinite(s)&&f>s?0:f}function KI(t,e,r){r=Object.assign({},YI,r);let o=r.curve,n=t.zoom,i=[t.longitude,t.latitude],s=Wf(n),a=e.zoom,c=[e.longitude,e.latitude],l=Wf(a-n),f=Oe(i),u=Oe(c),d=Ye.sub([],u,f),h=Math.max(t.width,t.height),p=h/l,m=Ye.length(d)*s,g=Math.max(m,XI),_=o*o,x=(p*p-h*h+_*_*g*g)/(2*h*_*g),y=(p*p-h*h-_*_*g*g)/(2*p*_*g),b=Math.log(Math.sqrt(x*x+1)-x),T=Math.log(Math.sqrt(y*y+1)-y),v=(T-b)/o;return{startZoom:n,startCenterXY:f,uDelta:d,w0:h,u1:m,S:v,rho:o,rho2:_,r0:b,r1:T}}var qI=`
layout(std140) uniform shadowUniforms {
bool drawShadowMap;
bool useShadowMap;
vec4 color;
highp int lightId;
float lightCount;
mat4 viewProjectionMatrix0;
mat4 viewProjectionMatrix1;
vec4 projectCenter0;
vec4 projectCenter1;
} shadow;
`,PY=`
const int max_lights = 2;
out vec3 shadow_vPosition[max_lights];
vec4 shadow_setVertexPosition(vec4 position_commonspace) {
mat4 viewProjectionMatrices[max_lights];
viewProjectionMatrices[0] = shadow.viewProjectionMatrix0;
viewProjectionMatrices[1] = shadow.viewProjectionMatrix1;
vec4 projectCenters[max_lights];
projectCenters[0] = shadow.projectCenter0;
projectCenters[1] = shadow.projectCenter1;
if (shadow.drawShadowMap) {
return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]);
}
if (shadow.useShadowMap) {
for (int i = 0; i < max_lights; i++) {
if(i < int(shadow.lightCount)) {
vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]);
shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;
}
}
}
return gl_Position;
}
`,MY=`
${qI}
${PY}
`,RY=`
const int max_lights = 2;
uniform sampler2D shadow_uShadowMap0;
uniform sampler2D shadow_uShadowMap1;
in vec3 shadow_vPosition[max_lights];
const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);
const vec4 bitUnpackShift = 1.0 / bitPackShift;
const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {
vec4 rgbaDepth = texture(shadowMap, position.xy);
float z = dot(rgbaDepth, bitUnpackShift);
return smoothstep(0.001, 0.01, position.z - z);
}
vec4 shadow_filterShadowColor(vec4 color) {
if (shadow.drawShadowMap) {
vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);
rgbaDepth -= rgbaDepth.gbaa * bitMask;
return rgbaDepth;
}
if (shadow.useShadowMap) {
float shadowAlpha = 0.0;
shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);
if(shadow.lightCount > 1.0) {
shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);
}
shadowAlpha *= shadow.color.a / shadow.lightCount;
float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);
return vec4(
mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha),
blendedAlpha
);
}
return color;
}
`,IY=`
${qI}
${RY}
`,LY=Yt(DY),BY=Yt(UY),OY=[0,0,0,1],FY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function NY(t,e){let[r,o,n]=t,i=Mr([r,o,n],e);return Number.isFinite(n)?i:[i[0],i[1],0]}function DY({viewport:t,center:e}){return new V(t.viewProjectionMatrix).invert().transform(e)}function UY({viewport:t,shadowMatrices:e}){let r=[],o=t.pixelUnprojectionMatrix,n=t.isGeospatial?void 0:1,i=[[0,0,n],[t.width,0,n],[0,t.height,n],[t.width,t.height,n],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(s=>NY(s,o));for(let s of e){let a=s.clone().translate(new E(t.center).negate()),c=i.map(f=>a.transform(f)),l=new V().ortho({left:Math.min(...c.map(f=>f[0])),right:Math.max(...c.map(f=>f[0])),bottom:Math.min(...c.map(f=>f[1])),top:Math.max(...c.map(f=>f[1])),near:Math.min(...c.map(f=>-f[2])),far:Math.max(...c.map(f=>-f[2]))});r.push(l.multiplyRight(s))}return r}function kY(t){let{shadowEnabled:e=!0,project:r}=t;if(!e||!r||!t.shadowMatrices||!t.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let o=We.getUniforms(r),n=LY({viewport:r.viewport,center:o.center}),i=[],s=BY({shadowMatrices:t.shadowMatrices,viewport:r.viewport}).slice();for(let c=0;c<t.shadowMatrices.length;c++){let l=s[c],f=l.clone().translate(new E(r.viewport.center).negate());o.coordinateSystem===ls("lnglat")&&o.projectionMode===ft.WEB_MERCATOR?(s[c]=f,i[c]=n):(s[c]=l.clone().multiplyRight(FY),i[c]=f.transform(n))}let a={drawShadowMap:Boolean(t.drawToShadowMap),useShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,color:t.shadowColor||OY,lightId:t.shadowLightId||0,lightCount:t.shadowMatrices.length,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};for(let c=0;c<s.length;c++)a[`viewProjectionMatrix${c}`]=s[c],a[`projectCenter${c}`]=i[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=t.shadowMaps&&t.shadowMaps[c]||t.dummyShadowMap;return a}var rc={name:"shadow",dependencies:[We],vs:MY,fs:IY,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
position = shadow_setVertexPosition(geometry.position);
`,"fs:DECKGL_FILTER_COLOR":`
color = shadow_filterShadowColor(color);
`},getUniforms:kY,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}};var VY=`struct pickingUniforms {
isActive: f32,
isAttribute: f32,
isHighlightActive: f32,
useByteColors: f32,
highlightedObjectColor: vec3<f32>,
highlightColor: vec4<f32>,
};
@group(0) @binding(auto) var<uniform> picking: pickingUniforms;
fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {
return select(color, color / 255.0, picking.useByteColors > 0.5);
}
fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {
return select(color, color / 255.0, picking.useByteColors > 0.5);
}
fn picking_isColorZero(color: vec3<f32>) -> bool {
return dot(color, vec3<f32>(1.0)) < 0.00001;
}
fn picking_isColorValid(color: vec3<f32>) -> bool {
return dot(color, vec3<f32>(1.0)) > 0.00001;
}
`,Se={...vm,source:VY,defaultUniforms:{...vm.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
// for picking depth values
picking_setPickingAttribute(position.z / position.w);
`,"vs:DECKGL_FILTER_COLOR":`
picking_setPickingColor(geometry.pickingColor);
`,"fs:DECKGL_FILTER_COLOR":{order:99,injection:`
// use highlight color if this fragment belongs to the selected object.
color = picking_filterHighlightColor(color);
// use picking color if rendering to picking FBO.
color = picking_filterPickingColor(color);
`}}};var zY=[Km],HY=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],jY=[];function hg(t){let e=Zn.getDefaultShaderAssembler();for(let o of zY)e.addDefaultModule(o);e._hookFunctions.length=0;let r=t==="glsl"?HY:jY;for(let o of r)e.addShaderHook(o);return e}var WY=[255,255,255],GY=1,$Y=0,oc=class{constructor(e={}){this.type="ambient";let{color:r=WY}=e,{intensity:o=GY}=e;this.id=e.id||`ambient-${$Y++}`,this.color=r,this.intensity=o}};var XY=[255,255,255],YY=1,KY=[0,0,-1],qY=0,fn=class{constructor(e={}){this.type="directional";let{color:r=XY}=e,{intensity:o=YY}=e,{direction:n=KY}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${qY++}`,this.color=r,this.intensity=o,this.type="directional",this.direction=new E(n).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}};var us=class{constructor(e,r={id:"pass"}){let{id:o}=r;this.id=o,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var ZY={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one-minus-dst-alpha",blendAlphaDstFactor:"one"},At=class extends us{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let r=this.device.canvasContext,o=e.target??r.getCurrentFramebuffer(),[n,i]=r.getDrawingBufferSize(),s=e.clearCanvas??!0,a=e.clearColor??(s?[0,0,0,0]:!1),c=s?1:!1,l=s?0:!1,f=e.colorMask??15,u={viewport:[0,0,n,i]};e.colorMask&&(u.colorMask=f),e.scissorRect&&(u.scissorRect=e.scissorRect);let d=this.device.beginRenderPass({framebuffer:o,parameters:u,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(d,e)}finally{d.end(),this.device.submit()}}_drawLayers(e,r){let{target:o,shaderModuleProps:n,viewports:i,views:s,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let f of i){let u=s&&s[f.id];a?.(f);let d=this._getDrawLayerParams(f,r),h=f.subViewports||[f];for(let p of h){let m=this._drawLayersInViewport(e,{target:o,shaderModuleProps:n,viewport:p,view:u,pass:r.pass,layers:r.layers,isPicking:r.isPicking},d);l.push(m)}}return l}_getDrawLayerParams(e,{layers:r,pass:o,isPicking:n=!1,layerFilter:i,cullRect:s,views:a,effects:c,shaderModuleProps:l},f=!1){let u=[],d=JI(this._lastRenderIndex+1),h={layer:r[0],viewport:e,isPicking:n,renderPass:o,cullRect:s},p={};for(let m=0;m<r.length;m++){let g=r[m],_=this._shouldDrawLayer(g,h,i,p),x={shouldDrawLayer:_};if(_&&!f){x.shouldDrawLayer=!0,x.layerRenderIndex=d(g,_),x.shaderModuleProps=this._getShaderModuleProps(g,c,o,l);let y=g.context.device.type==="webgpu"?ZY:null;x.layerParameters={...y,...g.context.deck?.props.parameters,...a?.[e.id]?.props.parameters,...this.getLayerParameters(g,m,e)}}u[m]=x}return u}_drawLayersInViewport(e,{layers:r,shaderModuleProps:o,pass:n,target:i,viewport:s,view:a,isPicking:c},l){let f=JY(this.device,{shaderModuleProps:o,target:i,viewport:s});if(a){let{clear:d,clearColor:h,clearDepth:p,clearStencil:m}=a.props;if(d){let g=[0,0,0,0],_=1,x=0;Array.isArray(h)&&!c?g=[...h.slice(0,3),h[3]||255].map(b=>b/255):h===!1&&(g=!1),p!==void 0&&(_=p),m!==void 0&&(x=m),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:f,scissorRect:f},clearColor:g,clearDepth:_,clearStencil:x}).end()}}let u={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:f});for(let d=0;d<r.length;d++){let h=r[d],p=l[d],{shouldDrawLayer:m}=p;if(m&&h.props.pickable&&u.pickableCount++,h.isComposite&&u.compositeCount++,h.isDrawable&&p.shouldDrawLayer){let{layerRenderIndex:g,shaderModuleProps:_,layerParameters:x}=p;u.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,g),_.project&&(_.project.viewport=s),h.context.renderPass=e;try{h._drawLayer({renderPass:e,shaderModuleProps:_,uniforms:{layerIndex:g},parameters:x})}catch(y){h.raiseError(y,`drawing ${h} to ${n}`)}}}return u}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,o){return null}getLayerParameters(e,r,o){return e.props.parameters}_shouldDrawLayer(e,r,o,n){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let s=e.parent;for(;s;){if(!s.props.visible||!s.filterSubLayer(r))return!1;r.layer=s,s=s.parent}if(o){let a=r.layer.id;if(a in n||(n[a]=o(r)),!n[a])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,o,n){let i=this.device.canvasContext.cssToDeviceRatio(),s=e.internalState?.propsInTransition||e.props,a={layer:s,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:s.modelMatrix,coordinateSystem:s.coordinateSystem,coordinateOrigin:s.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let c of r)ZI(a,c.getShaderModuleProps?.(e,a));for(let c of e.context.defaultShaderModules)c.name in a||(a[c.name]={});return ZI(a,this.getShaderModuleProps(e,r,a),n)}};function JI(t=0,e={}){let r={},o=(n,i)=>{let s=n.props._offset,a=n.id,c=n.parent&&n.parent.id,l;if(c&&!(c in e)&&o(n.parent,!1),c in r){let f=r[c]=r[c]||JI(e[c],e);l=f(n,i),r[a]=f}else Number.isFinite(s)?(l=s+(e[c]||0),r[a]=null):l=t;return i&&l>=t&&(t=l+1),e[a]=l,l};return o}function JY(t,{shaderModuleProps:e,target:r,viewport:o}){let n=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,i]=t.canvasContext.getDrawingBufferSize(),s=r?r.height:i,a=o;return[a.x*n,s-(a.y+a.height)*n,a.width*n,a.height*n]}function ZI(t,...e){for(let r of e)if(r)for(let o in r)t[o]?Object.assign(t[o],r[o]):t[o]=r[o];return t}var Xf=class extends At{constructor(e,r){super(e,r);let o=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),n=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[o],depthStencilAttachment:n})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,o=this.device.canvasContext.cssToDeviceRatio(),n=e.viewports[0],i=n.width*o,s=n.height*o,a=[1,1,1,1];(i!==r.width||s!==r.height)&&r.resize({width:i,height:s}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,o){return{shadow:{project:o.project,drawToShadowMap:!0}}}};var QY={color:[255,255,255],intensity:1},QI=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],eK=[0,0,0,200/255],ai=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=eK,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:o}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),o._addDefaultShaderModule(rc),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let o=e[r];switch(o.type){case"ambient":this.ambientLight=o;break;case"directional":this.directionalLights.push(o);break;case"point":this.pointLights.push(o);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:o,onViewportActive:n,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:r,viewports:o,onViewportActive:n,views:i,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let o=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(s=>s.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},n={enabled:!0,lights:this._getLights(e)},i=e.props.material;return{shadow:o,lighting:n,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(rc))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let o=new V().lookAt({eye:new E(r.direction).negate()});e.push(o)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let o=new Xf(e);this.shadowPasses[r]=o}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:o}=this;!e&&r.length===0&&o.length===0&&(this.ambientLight=new oc(QY),this.directionalLights.push(new fn(QI[0]),new fn(QI[1])))}_getLights(e){let r=[];this.ambientLight&&r.push(this.ambientLight);for(let o of this.pointLights)r.push(o.getProjectedLight({layer:e}));for(let o of this.directionalLights)r.push(o.getProjectedLight({layer:e}));return r}};var Iv=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,r,{size:o=1,type:n,padding:i=0,copy:s=!1,initialize:a=!1,maxCount:c}){let l=n||e&&e.constructor||Float32Array,f=r*o+i;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let u=1/0;c&&(u=c*o+i);let d=this._allocate(l,f,a,u);return e&&s?d.set(e):a||d.fill(0,0,4),this._release(e),d}release(e){this._release(e)}_allocate(e,r,o,n){let i=Math.max(Math.ceil(r*this.opts.overAlloc),1);i>n&&(i=n);let s=this._pool,a=e.BYTES_PER_ELEMENT*i,c=s.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(s.splice(c,1)[0],0,i);return o&&l.fill(0),l}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:o}=e,{byteLength:n}=o,i=r.findIndex(s=>s.byteLength>=n);i<0?r.push(o):(i>0||r.length<this.opts.poolSize)&&r.splice(i,0,o),r.length>this.opts.poolSize&&r.shift()}},Zr=new Iv;function ic(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ro(t,e){let r=t%e;return r<0?e+r:r}function t3(t){return[t[12],t[13],t[14]]}function r3(t){let e=t[10],r=t[14];return{near:r/(e-1),far:r/(e+1)}}function o3(t){return{left:nc(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:nc(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:nc(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:nc(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:nc(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:nc(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var e3=new E;function nc(t,e,r,o){e3.set(t,e,r);let n=e3.len();return{distance:o/n,normal:new E(-t/n,-e/n,-r/n)}}function sc(t){return t-Math.fround(t)}var Yf;function pg(t,e){let{size:r=1,startIndex:o=0}=e,n=e.endIndex!==void 0?e.endIndex:t.length,i=(n-o)/r;Yf=Zr.allocate(Yf,i,{type:Float32Array,size:r*2});let s=o,a=0;for(;s<n;){for(let c=0;c<r;c++){let l=t[s++];Yf[a+c]=l,Yf[a+c+r]=sc(l)}a+=r*2}return Yf.subarray(0,i*r*2)}function n3(t){let e=null,r=!1;for(let o of t)o&&(e?(r||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],r=!0),e[0][0]=Math.min(e[0][0],o[0][0]),e[0][1]=Math.min(e[0][1],o[0][1]),e[1][0]=Math.max(e[1][0],o[1][0]),e[1][1]=Math.max(e[1][1],o[1][1])):e=o);return e}var tK=Math.PI/180,rK=ic(),i3=[0,0,0],oK={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function nK({width:t,height:e,orthographic:r,fovyRadians:o,focalDistance:n,padding:i,near:s,far:a}){let c=t/e,l=r?new V().orthographic({fovy:o,aspect:c,focalDistance:n,near:s,far:a}):new V().perspective({fovy:o,aspect:c,near:s,far:a});if(i){let{left:f=0,right:u=0,top:d=0,bottom:h=0}=i,p=ee((f+t-u)/2,0,t)-t/2,m=ee((d+e-h)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=m*2/e}return l}var ac=class{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||oK,this.focalDistance=e.focalDistance||1,this.position=e.position||i3,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:o}=e;this.isGeospatial=Number.isFinite(o)&&Number.isFinite(r),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?ft.WEB_MERCATOR:ft.WEB_MERCATOR_AUTO_OFFSET:ft.IDENTITY}equals(e){return e instanceof ac?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Ce(e.projectionMatrix,this.projectionMatrix)&&Ce(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let o=this.projectPosition(e),n=tc(o,this.pixelProjectionMatrix),[i,s]=n,a=r?s:this.height-s;return e.length===2?[i,a]:[i,a,n[2]]}unproject(e,{topLeft:r=!0,targetZ:o}={}){let[n,i,s]=e,a=r?i:this.height-i,c=o&&o*this.distanceScales.unitsPerMeter[2],l=Mr([n,a,s],this.pixelUnprojectionMatrix,c),[f,u,d]=this.unprojectPosition(l);return Number.isFinite(s)?[f,u,d]:Number.isFinite(o)?[f,u,o]:[f,u]}projectPosition(e){let[r,o]=this.projectFlat(e),n=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,o,n]}unprojectPosition(e){let[r,o]=this.unprojectFlat(e),n=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,o,n]}projectFlat(e){if(this.isGeospatial){let r=Oe(e);return r[1]=ee(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?pt(e):e}getBounds(e={}){let r={targetZ:e.z||0},o=this.unproject([0,0],r),n=this.unproject([this.width,0],r),i=this.unproject([0,this.height],r),s=this.unproject([this.width,this.height],r);return[Math.min(o[0],n[0],i[0],s[0]),Math.min(o[1],n[1],i[1],s[1]),Math.max(o[0],n[0],i[0],s[0]),Math.max(o[1],n[1],i[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?ec({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:o=1,height:n=1}){return e<this.x+this.width&&this.x<e+o&&r<this.y+this.height&&this.y<r+n}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,o3(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r,o){return null}_initProps(e){let r=e.longitude,o=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Gf({latitude:o})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||ec({latitude:o,longitude:r}));let n=Math.pow(2,this.zoom);this.scale=n;let{position:i,modelMatrix:s}=e,a=i3;if(i&&(a=s?new V(s).transformAsVector(i,[]):i),this.isGeospatial){let c=this.projectPosition([r,o,0]);this.center=new E(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:r=rK,projectionMatrix:o=null,orthographic:n=!1,fovyRadians:i,fovy:s=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new V().multiplyRight(r).translate(new E(this.center).negate()),this.projectionMatrix=o||nK({width:this.width,height:this.height,orthographic:n,fovyRadians:i||s*tK,focalDistance:f,padding:l,near:a,far:c});let u=ic();je.multiply(u,u,this.projectionMatrix),je.multiply(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=je.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=t3(this.viewMatrixInverse);let d=ic(),h=ic();je.scale(d,d,[this.width/2,-this.height/2,1]),je.translate(d,d,[1,-1,0]),je.multiply(h,d,this.viewProjectionMatrix),this.pixelProjectionMatrix=h,this.pixelUnprojectionMatrix=je.invert(ic(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||N.warn("Pixel project matrix not invertible")()}};ac.displayName="Viewport";var ot=ac;var ds=class extends ot{constructor(e={}){let{latitude:r=0,longitude:o=0,zoom:n=0,pitch:i=0,bearing:s=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:u=!1,projectionMatrix:d,repeat:h=!1,worldOffset:p=0,position:m,padding:g,legacyMeterSizes:_=!1}=e,{width:x,height:y,altitude:b=1.5}=e,T=Math.pow(2,n);x=x||1,y=y||1;let v,w=null;if(d)b=d[5]/2,v=cn(b);else{e.fovy?(v=e.fovy,b=ln(v)):v=cn(b);let S;if(g){let{top:A=0,bottom:M=0}=g;S=[0,ee((A+y-M)/2,0,y)-y/2]}w=Pv({width:x,height:y,scale:T,center:m&&[0,0,m[2]*fs(r)],offset:S,pitch:i,fovy:v,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(w.near=l),Number.isFinite(f)&&(w.far=f)}let C=fg({height:y,pitch:i,bearing:s,scale:T,altitude:b});p&&(C=new V().translate([512*p,0,0]).multiplyLeft(C)),super({...e,width:x,height:y,viewMatrix:C,longitude:o,latitude:r,zoom:n,...w,fovy:v,focalDistance:b}),this.latitude=r,this.longitude=o,this.zoom=n,this.pitch=i,this.bearing=s,this.altitude=b,this.fovy=v,this.orthographic=u,this._subViewports=h?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),o=Math.ceil((e[2]-180)/360);for(let n=r;n<=o;n++){let i=n?new ds({...this,worldOffset:n}):this;this._subViewports.push(i)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,o]=this.projectFlat(e),n=(e[2]||0)*fs(e[1]);return[r,o,n]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,o]=this.unprojectFlat(e),n=(e[2]||0)/fs(o);return[r,o,n]}addMetersToLngLat(e,r){return $f(e,r)}panByPosition(e,r,o){let n=Mr(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),s=Ye.add([],i,Ye.negate([],n)),a=Ye.add([],this.center,s),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,r){let o=e[2]||0,n=Ye.sub([],e,this.unproject(r,{targetZ:o}));return{longitude:this.longitude+n[0],latitude:this.latitude+n[1]}}getBounds(e={}){let r=dg(this,e.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(e,r={}){let{width:o,height:n}=this,{longitude:i,latitude:s,zoom:a}=ug({width:o,height:n,bounds:e,...r});return new ds({width:o,height:n,longitude:i,latitude:s,zoom:a})}};ds.displayName="WebMercatorViewport";var Mt=ds;var s3=[0,0,0];function Lv(t,e,r=!1){let o=e.projectPosition(t);if(r&&e instanceof Mt){let[n,i,s=0]=t,a=e.getDistanceScales([n,i]);o[2]=s*a.unitsPerMeter[2]}return o}function iK(t){let{viewport:e,modelMatrix:r,coordinateOrigin:o}=t,{coordinateSystem:n,fromCoordinateSystem:i,fromCoordinateOrigin:s}=t;return n==="default"&&(n=e.isGeospatial?"lnglat":"cartesian"),i===void 0?i=n:i==="default"&&(i=e.isGeospatial?"lnglat":"cartesian"),s===void 0&&(s=o),{viewport:e,coordinateSystem:n,coordinateOrigin:o,modelMatrix:r,fromCoordinateSystem:i,fromCoordinateOrigin:s}}function mg(t,{viewport:e,modelMatrix:r,coordinateSystem:o,coordinateOrigin:n,offsetMode:i}){let[s,a,c=0]=t;switch(r&&([s,a,c]=Nt.transformMat4([],[s,a,c,1],r)),o){case"default":return mg(t,{viewport:e,modelMatrix:r,coordinateSystem:e.isGeospatial?"lnglat":"cartesian",coordinateOrigin:n,offsetMode:i});case"lnglat":return Lv([s,a,c],e,i);case"lnglat-offsets":return Lv([s+n[0],a+n[1],c+(n[2]||0)],e,i);case"meter-offsets":return Lv($f(n,[s,a,c]),e,i);case"cartesian":return e.isGeospatial?[s+n[0],a+n[1],c+n[2]]:e.projectPosition([s,a,c]);default:throw new Error(`Invalid coordinateSystem: ${o}`)}}function gg(t,e){let{viewport:r,coordinateSystem:o,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:s,fromCoordinateOrigin:a}=iK(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=s3,shaderCoordinateOrigin:f=s3,offsetMode:u=!1}=c?Cv(r,o,n):{},d=mg(t,{viewport:r,modelMatrix:i,coordinateSystem:s,coordinateOrigin:a,offsetMode:u});if(u){let h=r.projectPosition(l||f);Ke.sub(d,d,h)}return d}var sK=[255,255,255],aK=1,cK=[1,0,0],lK=[0,0,1],fK=0,cc=class{constructor(e={}){this.type="point";let{color:r=sK}=e,{intensity:o=aK}=e,{position:n=lK}=e;this.id=e.id||`point-${fK++}`,this.color=r,this.intensity=o,this.type="point",this.position=n,this.attenuation=uK(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,o=e.context.viewport,{coordinateSystem:n,coordinateOrigin:i}=e.props,s=gg(this.position,{viewport:o,coordinateSystem:n,coordinateOrigin:i,fromCoordinateSystem:o.isGeospatial?Be.LNGLAT:Be.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=s,r}};function uK(t){return t.attenuation?t.attenuation:cK}var Kf=class extends cc{getProjectedLight({layer:e}){let{projectedLight:r}=this,o=e.context.viewport,{coordinateSystem:n,coordinateOrigin:i,modelMatrix:s}=e.props,{cameraPosition:a}=ag({viewport:o,modelMatrix:s,coordinateSystem:n,coordinateOrigin:i});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var hs=Math.PI/180,dK=1e3*60*60*24,hK=2440588,pK=2451545,_g=hs*23.4397,mK=357.5291,gK=.98560028,_K=280.147,yK=360.9856235;function a3(t,e,r){let o=hs*-r,n=hs*e,i=bK(t),s=PK(i),a=CK(i,o)-s.rightAscension;return{azimuth:vK(a,n,s.declination),altitude:SK(a,n,s.declination)}}function yg(t,e,r){let{azimuth:o,altitude:n}=a3(t,e,r);return[Math.sin(o)*Math.cos(n),Math.cos(o)*Math.cos(n),-Math.sin(n)]}function xK(t){return(typeof t=="number"?t:t.getTime())/dK-.5+hK}function bK(t){return xK(t)-pK}function AK(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(_g)-Math.tan(e)*Math.sin(_g),Math.cos(r))}function TK(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(_g)+Math.cos(e)*Math.sin(_g)*Math.sin(r))}function vK(t,e,r){let o=t,n=e,i=r;return Math.atan2(Math.sin(o),Math.cos(o)*Math.sin(n)-Math.tan(i)*Math.cos(n))}function SK(t,e,r){let o=t,n=e,i=r;return Math.asin(Math.sin(n)*Math.sin(i)+Math.cos(n)*Math.cos(i)*Math.cos(o))}function CK(t,e){return hs*(_K+yK*t)-e}function EK(t){return hs*(mK+gK*t)}function wK(t){let e=t,r=hs*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),o=hs*102.9372;return e+r+o+Math.PI}function PK(t){let e=EK(t),r=wK(e);return{declination:TK(r,0),rightAscension:AK(r,0)}}var qf=class extends fn{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[n,i,s]=yg(this.timestamp,0,0);this.direction=[n,-s,i]}else{let{latitude:n,longitude:i}=r;this.direction=yg(this.timestamp,n,i)}return this}};var MK=1,RK=1,ps=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:o=Number.POSITIVE_INFINITY,rate:n=1,repeat:i=1}=e,s=MK++,a={time:0,delay:r,duration:o,rate:n,repeat:i};return this._setChannelTime(a,this.time),this.channels.set(s,a),s}removeChannel(e){this.channels.delete(e);for(let[r,o]of this.animations)o.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let n of r)this._setChannelTime(n,this.time);let o=this.animations.values();for(let n of o){let{animation:i,channel:s}=n;i.setTime(this.getTime(s))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let o=RK++;return this.animations.set(o,{animation:e,channel:r}),e.setTime(this.getTime(r)),o}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let o=r-e.delay,n=e.duration*e.repeat;o>=n?e.time=e.duration*e.rate:(e.time=Math.max(0,o)%e.duration,e.time*=e.rate)}};q();function c3(t){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function l3(t){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}Xi();var IK=0,LK="Animation Loop",Bv=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...Bv.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Et({id:`animation-loop-${IK++}`}),this.sharedStats=Co.stats.get(LK),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=c3(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(l3(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let r=e?.canvas,o=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:r,useDevicePixels:o,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:o}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),o!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=o,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let o=this.props.onAddHTML(r);o&&(r.innerHTML=o)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),o=e>0&&r>0?e/r:1;return{width:e,height:r,aspect:o}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let r=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let o=r-this._lastFrameTime;o>0&&this.frameRate.addTime(o)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let r=this.sharedStats.get(e.name,e.type);r.sampleSize=e.sampleSize,r.time=e.time,r.count=e.count,r.samples=e.samples,r.lastTiming=e.lastTiming,r.lastSampleTime=e.lastSampleTime,r.lastSampleCount=e.lastSampleCount,r._count=e._count,r._time=e._time,r._samples=e._samples,r._startTime=e._startTime,r._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},lc=Bv;k(lc,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});q();q();var Ov={};function nt(t="id"){Ov[t]=Ov[t]||1;let e=Ov[t]++;return`${t}-${e}`}var xg=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||nt("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&K.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function f3(t,e){if(e instanceof xg)return e;let r=BK(t,e),{attributes:o,bufferLayout:n}=OK(t,e);return new xg({topology:e.topology||"triangle-list",bufferLayout:n,vertexCount:e.vertexCount,indices:r,attributes:o})}function BK(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:K.INDEX,data:r})}function OK(t,e){let r=[],o={};for(let[i,s]of Object.entries(e.attributes)){let a=i;switch(i){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"TEXCOORD_1":a="texCoords1";break;case"COLOR_0":a="colors";break}if(s){o[a]=t.createBuffer({data:s.value,id:`${i}-buffer`});let{value:c,size:l,normalized:f}=s;if(l===void 0)throw new Error(`Attribute ${i} is missing a size`);r.push({name:a,format:tn.getVertexFormatFromAttribute(c,l,f)})}}let n=e._calculateVertexCount(e.attributes,e.indices);return{attributes:o,bufferLayout:r,vertexCount:n}}function u3(t,e){let r={},o="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[o]:"N/A"}};for(let n of t.attributes)if(n){let i=`${n.location} ${n.name}: ${n.type}`;r[`in ${i}`]={[o]:n.stepMode||"vertex"}}for(let n of t.varyings||[]){let i=`${n.location} ${n.name}`;r[`out ${i}`]={[o]:JSON.stringify(n)}}return r}var d3="__debugFramebufferState";function p3(t,e,r){if(t.device.type!=="webgl")return;let o=DK(t.device);if(!o.flushing){if(kK(t)){FK(t,r,o);return}e&&UK(e)&&e.handle!==null&&(o.queuedFramebuffers.includes(e)||o.queuedFramebuffers.push(e))}}function FK(t,e,r){if(r.queuedFramebuffers.length===0)return;let o=t.device,{gl:n}=o,i=n.getParameter(36010),s=n.getParameter(36006),[a,c]=t.device.getDefaultCanvasContext().getDrawingBufferSize(),l=h3(e.top,8),f=h3(e.left,8);r.flushing=!0;try{for(let u of r.queuedFramebuffers){let[d,h,p,m,g]=NK({framebuffer:u,targetWidth:a,targetHeight:c,topPx:l,leftPx:f,minimap:e.minimap});n.bindFramebuffer(36008,u.handle),n.bindFramebuffer(36009,null),n.blitFramebuffer(0,0,u.width,u.height,d,h,p,m,16384,9728),l+=g+8}}finally{n.bindFramebuffer(36008,i),n.bindFramebuffer(36009,s),r.flushing=!1}}function NK(t){let{framebuffer:e,targetWidth:r,targetHeight:o,topPx:n,leftPx:i,minimap:s}=t,a=s?Math.max(Math.floor(r/4),1):r,c=s?Math.max(Math.floor(o/4),1):o,l=Math.min(a/e.width,c/e.height),f=Math.max(Math.floor(e.width*l),1),u=Math.max(Math.floor(e.height*l),1),d=i,h=Math.max(o-n-u,0),p=d+f,m=h+u;return[d,h,p,m,u]}function DK(t){return t.userData[d3]||={flushing:!1,queuedFramebuffers:[]},t.userData[d3]}function UK(t){return"colorAttachments"in t}function kK(t){let e=t.props.framebuffer;return!e||e.handle===null}function h3(t,e){if(!t)return e;let r=Number.parseInt(t,10);return Number.isFinite(r)?r:e}function bg(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!bg(t[o],e[o],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let i of o)if(!e.hasOwnProperty(i)||!bg(t[i],e[i],r-1))return!1;return!0}return!1}q();var fc=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(r=>r.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(r=>r.attribute):[e.name]}mergeBufferLayouts(e,r){let o=[...e];for(let n of r){let i=o.findIndex(s=>s.name===n.name);i<0?o.push(n):o[i]=n}return o}getBufferIndex(e){let r=this.bufferLayouts.findIndex(o=>o.name===e);return r===-1&&P.warn(`BufferLayout: Missing buffer for "${e}".`)(),r}};function m3(t,e){let r=1/0;for(let o of t){let n=e[o];n!==void 0&&(r=Math.min(r,n))}return r}function g3(t,e){let r=Object.fromEntries(t.attributes.map(n=>[n.name,n.location])),o=e.slice();return o.sort((n,i)=>{let s=n.attributes?n.attributes.map(f=>f.attribute):[n.name],a=i.attributes?i.attributes.map(f=>f.attribute):[i.name],c=m3(s,r),l=m3(a,r);return c-l}),o}function Fv(t,e){if(!t||!e.some(o=>o.bindingLayout?.length))return t;let r={...t,bindings:t.bindings.map(o=>({...o}))};"attributes"in(t||{})&&(r.attributes=t?.attributes||[]);for(let o of e)for(let n of o.bindingLayout||[])for(let i of VK(n.name)){let s=r.bindings.find(a=>a.name===i);s?.group===0&&(s.group=n.group)}return r}function Ag(t){return Boolean(t.uniformTypes&&!zK(t.uniformTypes))}function VK(t){let e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function zK(t){for(let e in t)return!1;return!0}q();function HK(t){return nA(t)||typeof t=="number"||typeof t=="boolean"}function _3(t,e={}){let r={bindings:{},uniforms:{}};return Object.keys(t).forEach(o=>{let n=t[o];Object.prototype.hasOwnProperty.call(e,o)||HK(n)?r.uniforms[o]=n:r.bindings[o]=n}),r}var ci=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let o=wa(Object.values(e).filter(jK));for(let n of o)e[n.name]=n;P.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[n,i]of Object.entries(e))i&&(this._addModule(i),i.name&&n!==i.name&&!this.options.disableWarnings&&P.warn(`Module name: ${n} vs ${i.name}`)())}destroy(){}setProps(e){for(let r of Object.keys(e)){let o=r,n=e[o]||{},i=this.modules[o];if(!i)this.options.disableWarnings||P.warn(`Module ${r} not found`)();else{let s=this.moduleUniforms[o],a=this.moduleBindings[o],c=i.getUniforms?.(n,s)||n,{uniforms:l,bindings:f}=_3(c,i.uniformTypes);this.moduleUniforms[o]=y3(s,l,i.uniformTypes),this.moduleBindings[o]={...a,...f}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,o]of Object.entries(this.moduleUniforms))for(let[n,i]of Object.entries(o))e[`${r}.${n}`]={type:this.modules[r].uniformTypes?.[n],value:String(i)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=y3({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[r]={}}};function y3(t={},e={},r={}){let o={...t};for(let[n,i]of Object.entries(e))i!==void 0&&(o[n]=Nv(t[n],i,r[n]));return o}function Nv(t,e,r){if(!r||typeof r=="string")return Zf(e);if(Array.isArray(r)){if(Dv(e)||!Array.isArray(e))return Zf(e);let s=Array.isArray(t)&&!Dv(t)?[...t]:[],a=s.slice();for(let c=0;c<e.length;c++){let l=e[c];l!==void 0&&(a[c]=Nv(s[c],l,r[0]))}return a}if(!Uv(e))return Zf(e);let o=r,n=Uv(t)?t:{},i={...n};for(let[s,a]of Object.entries(e))a!==void 0&&(i[s]=Nv(n[s],a,o[s]));return i}function Zf(t){return ArrayBuffer.isView(t)?Array.prototype.slice.call(t):Array.isArray(t)?Dv(t)?t.slice():t.map(r=>r===void 0?void 0:Zf(r)):Uv(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,r===void 0?void 0:Zf(r)])):t}function Dv(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(t.length===0||typeof t[0]=="number")}function Uv(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function jK(t){return Boolean(t?.dependencies)}q();q();var kv={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function Jf(t){return t?Array.isArray(t)?t[0]??null:t:null}function x3(t){let{dimension:e,data:r}=t;if(!r)return null;switch(e){case"1d":{let o=Jf(r);if(!o)return null;let{width:n}=Qf(o);return{width:n,height:1}}case"2d":{let o=Jf(r);return o?Qf(o):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;let o=Jf(r[0]);return o?Qf(o):null}case"cube":{let o=Object.keys(r)[0]??null;if(!o)return null;let n=r[o],i=Jf(n);return i?Qf(i):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;let o=r[0],n=Object.keys(o)[0]??null;if(!n)return null;let i=Jf(o[n]);return i?Qf(i):null}default:return null}}function Qf(t){if(Na(t))return Sf(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function WK(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function GK(t){return ArrayBuffer.isView(t)}function Vv(t){let{textureFormat:e,format:r}=t;if(e&&r&&e!==r)throw new Error(`Conflicting texture formats "${e}" and "${r}" provided for the same mip level`);return e??r}function b3(t){let e=kv[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function $K(t,e){return 6*t+b3(e)}function zv(t){throw new Error("setTexture1DData not supported in WebGL.")}function XK(t){return Array.isArray(t)?t:[t]}function ms(t,e,r,o){let n=XK(e),i=t,s=[];for(let a=0;a<n.length;a++){let c=n[a];if(Na(c))s.push({type:"external-image",image:c,z:i,mipLevel:a});else if(WK(c))s.push({type:"texture-data",data:c,textureFormat:Vv(c),z:i,mipLevel:a});else if(GK(c)&&r)s.push({type:"texture-data",data:{data:c,width:Math.max(1,r.width>>a),height:Math.max(1,r.height>>a),...o?{format:o}:{}},textureFormat:o,z:i,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return s}function Hv(t){let e=[];for(let r=0;r<t.length;r++)e.push(...ms(r,t[r]));return e}function jv(t){let e=[];for(let r=0;r<t.length;r++)e.push(...ms(r,t[r]));return e}function Wv(t){let e=[];for(let[r,o]of Object.entries(t)){let n=b3(r);e.push(...ms(n,o))}return e}function Gv(t){let e=[];return t.forEach((r,o)=>{for(let[n,i]of Object.entries(r)){let s=$K(o,n);e.push(...ms(s,i))}}),e}var Xv=class{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){let e=this._texture?.width??this.props.width??"?",r=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${r}px:(${this.isReady?"ready":"loading..."})`}constructor(e,r){this.device=e;let o=nt("dynamic-texture"),n=r;this.props={...Xv.defaultProps,id:o,...r,data:null},this.id=this.props.id,this.ready=new Promise((i,s)=>{this.resolveReady=i,this.rejectReady=s}),this.initAsync(n)}async initAsync(e){try{let r=await this._loadAllData(e);this._checkNotDestroyed();let o=r.data?YK({...r,width:e.width,height:e.height,format:e.format}):[],n="format"in e&&e.format!==void 0,i="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let m=x3(r);return m||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=KK(this.device,o,a,{format:n?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!i&&(f.usage=Y.SAMPLE|Y.COPY_DST);let u=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&u){let m=this.props.dimension==="3d"?Y.SAMPLE|Y.STORAGE|Y.COPY_DST|Y.COPY_SRC:Y.SAMPLE|Y.RENDER|Y.COPY_DST|Y.COPY_SRC;f.usage|=m}let d=this.device.getMipLevelCount(f.width,f.height),h=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?d:Math.max(1,Math.min(d,this.props.mipLevels??1)),p={...f,mipLevels:h};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!u&&P.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),u&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),P.info(0,`${this} created`)()}catch(r){let o=r instanceof Error?r:new Error(String(r));this.rejectReady(o)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):P.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let r=e instanceof Pt?e:this.device.createSampler(e);this.texture.setSampler(r),this._sampler=r}async readBuffer(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,o=e.height??this.texture.height,n=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:r,height:o,depthOrArrayLayers:n}),s=this.device.createBuffer({byteLength:i.byteLength,usage:K.COPY_DST|K.MAP_READ});this.texture.readBuffer({...e,width:r,height:o,depthOrArrayLayers:n},s);let a=this.device.createFence();return await a.signaled,a.destroy(),s}async readAsync(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,o=e.height??this.texture.height,n=e.depthOrArrayLayers??this.texture.depth,i=this.texture.computeMemoryLayout({width:r,height:o,depthOrArrayLayers:n}),s=await this.readBuffer(e),a=await s.readAsync(0,i.byteLength);return s.destroy(),a.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let r=this.texture;return this._texture=r.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),P.info(`${this} resized`),!0}getCubeFaceIndex(e){let r=kv[e];if(r===void 0)throw new Error(`Invalid cube face: ${e}`);return r}getCubeArrayFaceIndex(e,r){return 6*e+this.getCubeFaceIndex(r)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let r=zv(e);this._setTextureSubresources(r)}setTexture2DData(e,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let o=ms(r,e);this._setTextureSubresources(o)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let r=Hv(e);this._setTextureSubresources(r)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let r=jv(e);this._setTextureSubresources(r)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let r=Wv(e);this._setTextureSubresources(r)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let r=Gv(e);this._setTextureSubresources(r)}_setTextureSubresources(e){for(let r of e){let{z:o,mipLevel:n}=r;switch(r.type){case"external-image":let{image:i,flipY:s}=r;this.texture.copyExternalImage({image:i,z:o,mipLevel:n,flipY:s});break;case"texture-data":let{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:o,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){let r=await $v(e.data);return{dimension:e.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&P.warn(`${this} already destroyed`)}_checkReady(){this.isReady||P.warn(`${this} Cannot perform this operation before ready`)}},Kt=Xv;k(Kt,"defaultProps",{...Y.defaultProps,dimension:"2d",data:null,mipmaps:!1});function YK(t){if(!t.data)return[];let e=t.width&&t.height?{width:t.width,height:t.height}:void 0,r="format"in t?t.format:void 0;switch(t.dimension){case"1d":return zv(t.data);case"2d":return ms(0,t.data,e,r);case"3d":return Hv(t.data);case"2d-array":return jv(t.data);case"cube":return Wv(t.data);case"cube-array":return Gv(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function KK(t,e,r,o){if(e.length===0)return{subresources:e,mipLevels:1,format:o.format,hasExplicitMipChain:!1};let n=new Map;for(let f of e){let u=n.get(f.z)??[];u.push(f),n.set(f.z,u)}let i=e.some(f=>f.mipLevel>0),s=o.format,a=Number.POSITIVE_INFINITY,c=[];for(let[f,u]of n){let d=[...u].sort((x,y)=>x.mipLevel-y.mipLevel),h=d[0];if(!h||h.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);let p=T3(t,h);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);let m=A3(h);if(m){if(s&&s!==m)throw new Error(`DynamicTexture: slice ${f} base level format "${m}" does not match texture format "${s}"`);s=m}let g=s&&t.isTextureFormatCompressed(s)?qK(t,p.width,p.height,s):t.getMipLevelCount(p.width,p.height),_=0;for(let x=0;x<d.length;x++){let y=d[x];if(!y||y.mipLevel!==x||x>=g)break;let b=T3(t,y),T=Math.max(1,p.width>>x),v=Math.max(1,p.height>>x);if(b.width!==T||b.height!==v)break;let w=A3(y);if(w&&(s||(s=w),w!==s))break;_++,c.push(y)}a=Math.min(a,_)}let l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:s,hasExplicitMipChain:i}}function A3(t){if(t.type==="texture-data")return t.textureFormat??Vv(t.data)}function T3(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function qK(t,e,r,o){let{blockWidth:n=1,blockHeight:i=1}=t.getTextureFormatInfo(o),s=1;for(let a=1;;a++){let c=Math.max(1,e>>a),l=Math.max(1,r>>a);if(c<n||l<i)break;s++}return s}async function $v(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map($v));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e).map($v)),o=Object.keys(e),n={};for(let i=0;i<o.length;i++)n[o[i]]=r[i];return n}return t}var li=2,ZK=1e4,v3="render pipeline initialization failed",Yv=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...Yv.defaultProps,...r},r=this.props,this.id=r.id||nt("model"),this.device=e,Object.assign(this.userData,r.userData),this.material=r.material||null;let o=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),n=r.shaderInputs||new ci(o,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(n);let i=JK(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=Fv(this.props.shaderLayout,s)||null,this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l,bindingTable:f}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:s});this.source=c,this._getModuleUniforms=l,this._bindingTable=f;let u=e.getShaderLayout?.(this.source);this.props.shaderLayout=Fv(this.props.shaderLayout||u||null,s)||null}else{let{vs:c,fs:l,getUniforms:f}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:i,...this.props,modules:s});this.vs=c,this.fs=l,this._getModuleUniforms=f,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||ka.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||Va.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return P.info(li,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let o,n=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),n=this.pipeline.isErrored,n)P.info(li,`>>> DRAWING ABORTED ${this.id}: ${v3}`)(),o=!1;else{let i=this._getBindings(),s=this._getBindGroups(),{indexBuffer:a}=this.vertexArray,c=a?a.byteLength/(a.indexType==="uint32"?4:2):void 0;o=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:c,transformFeedback:this.transformFeedback||void 0,bindings:i,bindGroups:s,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),o?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):n?this._needsRedraw=v3:this._needsRedraw="waiting for resource initialization",o}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&f3(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let o=new fc(this.bufferLayout);this.bufferLayout=o.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let r=new fc(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){bg(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new is(this.device,this.shaderInputs.modules);for(let[r,o]of Object.entries(this.shaderInputs.modules))if(Ag(o)&&!this.material?.ownsModule(r)){let n=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=n}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,r){let o=r?.disableWarnings??this.props.disableWarnings;e.indices&&P.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=g3(this.pipeline.shaderLayout,this.bufferLayout);let n=new fc(this.bufferLayout);for(let[i,s]of Object.entries(e)){let a=n.getBufferLayout(i);if(!a){o||P.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let c=n.getAttributeNamesForBuffer(a),l=!1;for(let f of c){let u=this._attributeInfos[f];if(u){let d=this.device.type==="webgpu"?n.getBufferIndex(u.bufferName):u.location;this.vertexArray.setBuffer(d,s),l=!0}}!l&&!o&&P.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[o,n]of Object.entries(e)){let i=this._attributeInfos[o];i?this.vertexArray.setConstantWebGL(i.location,n):(r?.disableWarnings??this.props.disableWarnings)||P.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${o}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof Kt&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof Kt&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,o]of Object.entries(this.bindings))o instanceof Kt?o.isReady&&(e[r]=o.texture):e[r]=o;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},r=e.bindings.length?If(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return r;for(let[o,n]of Object.entries(this.material.getBindingsByGroup())){let i=Number(o);r[i]={...r[i]||{},...n}}return r}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof wr?e=Math.max(e,r.texture.updateTimestamp):r instanceof K||r instanceof Y?e=Math.max(e,r.updateTimestamp):r instanceof Kt?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Pt||(e=Math.max(e,r.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let r={...e.attributes};for(let[o]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(n=>n.name===o)&&o!=="positions"&&delete r[o];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(P.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let o=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),n=null;this.source?n=o:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:o,fs:n}),this._attributeInfos=Vm(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&r!==e&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=P.level>3?0:ZK;P.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,P.group(li,`>>> DRAWING MODEL ${this.id}`,{collapsed:P.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=u3(this.pipeline.shaderLayout,this.id);P.table(li,e)();let r=this.shaderInputs.getDebugTable();P.table(li,r)();let o=this._getAttributeDebugTable();P.table(li,this._attributeInfos)(),P.table(li,o)(),P.groupEnd(li)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let o=e.props.framebuffer;p3(e,o,{id:o?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,o]of Object.entries(this._attributeInfos)){let n=this.vertexArray.attributes[o.location];e[o.location]={name:r,type:o.shaderType,values:n?this._getBufferOrConstantValues(n,o.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,o=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:o.toString()}}return e}_getBufferOrConstantValues(e,r){let o=Dt.getTypedArrayConstructor(r);return(e instanceof K?new o(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let r={};for(let[o,n]of Object.entries(e))this.material.ownsBinding(o)||(r[o]=n);return r}},Q=Yv;k(Q,"defaultProps",{...fr.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Zn.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function JK(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}q();var eu=3,un=class{device;modules;_materialBindingNames;_materialModuleNames;constructor(e,r={}){this.device=e,this.modules=r.modules||[];let o=new ci(Object.fromEntries(this.modules.map(n=>[n.name,n])));this._materialBindingNames=QK(o),this._materialModuleNames=eq(o)}createMaterial(e={}){return new Tg(this.device,{...e,factory:this})}getBindingNames(){return Array.from(this._materialBindingNames)}ownsBinding(e){if(this._materialBindingNames.has(e))return!0;let r=Kv(e);return r?this._materialModuleNames.has(r):!1}ownsModule(e){return this._materialModuleNames.has(e)}getBindingsByGroup(e){return Object.keys(e).length>0?{[eu]:e}:{}}};function Kv(t){return t.endsWith("Uniforms")?t.slice(0,-8):null}function QK(t){let e=new Set;for(let r of Object.values(t.modules))for(let o of r.bindingLayout||[])o.group===eu&&e.add(o.name);return e}function eq(t){let e=new Set;for(let r of Object.values(t.modules))r.name&&r.bindingLayout?.some(o=>o.group===eu&&o.name===r.name)&&e.add(r.name);return e}var Tg=class{id;device;factory;shaderInputs;bindings={};_uniformStore;_bindGroupCacheToken={};constructor(e,r={}){this.id=r.id||nt("material"),this.device=e,this.factory=r.factory||new un(e,{modules:r.modules||r.shaderInputs?.getModules()||[]});let o=Object.fromEntries((r.shaderInputs?.getModules()||this.factory.modules).map(n=>[n.name,n]));this.shaderInputs=r.shaderInputs||new ci(o),this._uniformStore=new is(this.device,this.shaderInputs.modules);for(let[n,i]of Object.entries(this.shaderInputs.modules))if(this.ownsModule(n)&&Ag(i)){let s=this._uniformStore.getManagedUniformBuffer(n);this.bindings[`${n}Uniforms`]=s}this.updateShaderInputs(),r.bindings&&this._replaceOwnedBindings(r.bindings)}destroy(){this._uniformStore.destroy()}clone(e={}){let r=this.factory.createMaterial({id:e.id,shaderInputs:e.shaderInputs,bindings:{...this.getResourceBindings(),...e.bindings}});return e.shaderInputs||r.setProps(this.shaderInputs.getUniformValues()),e.moduleProps&&r.setProps(e.moduleProps),r}ownsBinding(e){return this.factory.ownsBinding(e)}ownsModule(e){return this.factory.ownsModule(e)}setProps(e){this.shaderInputs.setProps(e),this.updateShaderInputs()}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this._setOwnedBindings(this.shaderInputs.getBindingValues())&&(this._bindGroupCacheToken={})}getResourceBindings(){let e={};for(let[r,o]of Object.entries(this.bindings))Kv(r)||(e[r]=o);return e}getBindings(){let e={},r=e;for(let[o,n]of Object.entries(this.bindings))n instanceof Kt?n.isReady&&(r[o]=n.texture):r[o]=n;return e}getBindingsByGroup(){return this.factory.getBindingsByGroup(this.getBindings())}getBindGroupCacheKey(e){return e===eu?this._bindGroupCacheToken:null}getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof wr?e=Math.max(e,r.texture.updateTimestamp):r instanceof K||r instanceof Y?e=Math.max(e,r.updateTimestamp):r instanceof Kt?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Pt||(e=Math.max(e,r.buffer.updateTimestamp));return e}_replaceOwnedBindings(e){this._setOwnedBindings(e)&&(this._bindGroupCacheToken={})}_setOwnedBindings(e){let r=!1;for(let[o,n]of Object.entries(e))n!==void 0&&this.ownsBinding(o)&&this.bindings[o]!==n&&(this.bindings[o]=n,r=!0);return r}};q();var vg=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=vg.defaultProps){if(!vg.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Q(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||uf(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof K)return r.readAsync();let{buffer:o,byteOffset:n=0,byteLength:i=o.byteLength}=r;return o.readAsync(n,i)}},ur=vg;k(ur,"defaultProps",{...Q.defaultProps,outputs:void 0,feedbackBuffers:void 0});var tq="transform_output",fi=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Q(this.device,{id:r.id||nt("texture-transform-model"),fs:r.fs||uf({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:tq}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],o=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(o),o.end(),this.device.submit()}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:o,targetTexture:n}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,o),Object.assign(e.sourceBuffers,r),n){e.targetTexture=n;let{width:i,height:s}=n;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:i,height:s,colorAttachments:[n]}),e.framebuffer.resize({width:i,height:s})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let o in r)r[o].sampler=this.sampler}};var ce=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:o=null,vertexCount:n=null}=e;this.id=e.id||nt("geometry"),this.topology=e.topology,o&&(this.indices=ArrayBuffer.isView(o)?{value:o,size:1}:o),this.attributes={};for(let[i,s]of Object.entries(r)){let a=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(i)}: must be typed array or object with value as typed array`);if((i==="POSITION"||i==="positions")&&!a.size&&(a.size=3),i==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[i]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let o=1/0;for(let n of Object.values(e)){let{value:i,size:s,constant:a}=n;!a&&i&&s!==void 0&&s>=1&&(o=Math.min(o,i.length/s))}return o}};var rq=`struct VertexInputs {
@location(0) clipSpacePositions: vec2<f32>,
@location(1) texCoords: vec2<f32>,
@location(2) coordinates: vec2<f32>
}
struct FragmentInputs {
@builtin(position) Position : vec4<f32>,
@location(0) position : vec2<f32>,
@location(1) coordinate : vec2<f32>,
@location(2) uv : vec2<f32>
};
@vertex
fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
var outputs: FragmentInputs;
outputs.Position = vec4(inputs.clipSpacePositions, 0., 1.);
outputs.position = inputs.clipSpacePositions;
outputs.coordinate = inputs.coordinates;
outputs.uv = inputs.texCoords;
return outputs;
}
`,oq=`#version 300 es
in vec2 clipSpacePositions;
in vec2 texCoords;
in vec2 coordinates;
out vec2 position;
out vec2 coordinate;
out vec2 uv;
void main(void) {
gl_Position = vec4(clipSpacePositions, 0., 1.);
position = clipSpacePositions;
coordinate = coordinates;
uv = texCoords;
}
`,S3=[-1,-1,1,-1,-1,1,1,1],tu=class extends Q{constructor(e,r){let o=S3.map(n=>n===-1?0:n);r.source&&(r={...r,source:`${rq}
${r.source}`}),super(e,{id:r.id||nt("clip-space"),...r,vs:oq,vertexCount:4,geometry:new ce({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(S3)},texCoords:{size:2,value:new Float32Array(o)},coordinates:{size:2,value:new Float32Array(o)}}})})}};var ru=class extends ce{constructor(e={}){let{id:r=nt("sphere-geometry")}=e,{indices:o,attributes:n}=nq(e);super({...e,id:r,topology:"triangle-list",indices:o,attributes:{...n,...e.attributes}})}};function nq(t){let{nlat:e=10,nlong:r=10}=t,i=Math.PI-0,s=0,c=2*Math.PI-s,l=(e+1)*(r+1),f=(_,x,y,b,T)=>t.radius||1,u=new Float32Array(l*3),d=new Float32Array(l*3),h=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,m=new p(e*r*6);for(let _=0;_<=e;_++)for(let x=0;x<=r;x++){let y=x/r,b=_/e,T=x+_*(r+1),v=T*2,w=T*3,C=c*y,S=i*b,A=Math.sin(C),M=Math.cos(C),B=Math.sin(S),O=Math.cos(S),F=M*B,X=O,G=A*B,j=f(F,X,G,y,b);u[w+0]=j*F,u[w+1]=j*X,u[w+2]=j*G,d[w+0]=F,d[w+1]=X,d[w+2]=G,h[v+0]=y,h[v+1]=1-b}let g=r+1;for(let _=0;_<r;_++)for(let x=0;x<e;x++){let y=(_*e+x)*6;m[y+0]=x*g+_,m[y+1]=x*g+_+1,m[y+2]=(x+1)*g+_,m[y+3]=(x+1)*g+_,m[y+4]=x*g+_+1,m[y+5]=(x+1)*g+_+1}return{indices:{size:1,value:m},attributes:{POSITION:{size:3,value:u},NORMAL:{size:3,value:d},TEXCOORD_0:{size:2,value:h}}}}function qv(t,e){if(!t)throw new Error(e)}var Rr=class{id;matrix=new V;display=!0;position=new E;rotation=new E;scale=new E(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||nt(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return qv(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return qv(e.length===3||e.length===4,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return qv(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:o,scale:n,update:i=!0}=e;return r&&this.setPosition(r),o&&this.setRotation(o),n&&this.setScale(n),i&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),this.rotation.length===4){let e=new V().fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:r,scale:o}={}){return e&&this.setPosition(e),r&&this.setRotation(r),o&&this.setScale(o),this.updateMatrix(),this}getCoordinateUniforms(e,r){r=r||this.matrix;let o=new V(e).multiplyRight(r),n=o.invert(),i=n.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:o,worldInverseMatrix:n,worldInverseTransposeMatrix:i}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};q();var qt=class extends Rr{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;P.assert(r.every(o=>o instanceof Rr),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:o})=>{let n=r.getBounds();if(!n)return;let[i,s]=n,a=new E(i).add(s).divide([2,2,2]);o.transformAsPoint(a,a);let c=new E(s).subtract(i).divide([2,2,2]);o.transformAsVector(c,c);for(let l=0;l<8;l++){let f=new E(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let u=0;u<3;u++)e[0][u]=Math.min(e[0][u],f[u]),e[1][u]=Math.max(e[1][u],f[u])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,o=r.indexOf(e);return o>-1&&r.splice(o,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new V}={}){let o=new V(r).multiplyRight(this.matrix);for(let n of this.children)n instanceof qt?n.traverse(e,{worldMatrix:o}):e(n,{worldMatrix:o})}preorderTraversal(e,{worldMatrix:r=new V}={}){let o=new V(r).multiplyRight(this.matrix);e(this,{worldMatrix:o});for(let n of this.children)n instanceof qt?n.preorderTraversal(e,{worldMatrix:o}):e(n,{worldMatrix:o})}};var Io=class extends Rr{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var dn=class extends ce{constructor(e={}){let{id:r=nt("cube-geometry"),indices:o=!0}=e;super(o?{...e,id:r,topology:"triangle-list",indices:{size:1,value:iq},attributes:{...dq,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...hq,...e.attributes}})}},iq=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),sq=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),aq=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),cq=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),lq=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),fq=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),uq=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),dq={POSITION:{size:3,value:sq},NORMAL:{size:3,value:aq},TEXCOORD_0:{size:2,value:cq}},hq={POSITION:{size:3,value:lq},TEXCOORD_0:{size:2,value:fq},COLOR_0:{size:3,value:uq}};var pq=`layout(std140) uniform screenUniforms {
vec2 texSize;
} screen;
`,C3={name:"screen",fs:pq,uniformTypes:{texSize:"vec2<f32>"}};var ou=class extends us{constructor(e,r){super(e,r);let{module:o,fs:n,id:i}=r,s={depthWriteEnabled:!1,depthCompare:"always",depthBias:0,blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"};this.model=new tu(e,{id:i,fs:n,modules:[o,C3],parameters:s})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,r){let{clearCanvas:o,inputBuffer:n,outputBuffer:i}=r,s=[n.width,n.height],a={texSrc:n.colorAttachments[0],texSize:s};this.model.shaderInputs.setProps({screen:a,...r.moduleProps});let c=this.device.beginRenderPass({framebuffer:i,parameters:{viewport:[0,0,...s]},clearColor:o?[0,0,0,0]:!1,clearDepth:1,clearStencil:!1});this.model.draw(c),c.end()}};var nu=class{constructor(e,r){this.id=`${e.name}-pass`,this.props=r,tm(e),this.module=e}setup({device:e}){this.passes=mq(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){let r=this.passes,{target:o}=e,n=e.inputBuffer,i=e.swapBuffer;for(let s=0;s<r.length;s++){let a=s===r.length-1,c=o!==void 0&&a;c&&(i=o);let l=!c||Boolean(e.clearCanvas),f={},u=this.module.passes[s].uniforms;f[this.module.name]={...this.props,...u},r[s].render({clearCanvas:l,inputBuffer:n,outputBuffer:i,moduleProps:f});let d=i;i=n,n=d}return n}cleanup(){if(this.passes){for(let e of this.passes)e.delete();this.passes=void 0}}};function mq(t,e,r){return e.passes.map((o,n)=>{let i=yq(e,o),s=`${r}-${n}`;return new ou(t,{id:s,module:e,fs:i})})}var E3=`#version 300 es
uniform sampler2D texSrc;
in vec2 position;
in vec2 coordinate;
in vec2 uv;
out vec4 fragColor;
`,gq=t=>`${E3}
void main() {
fragColor = texture(texSrc, coordinate);
fragColor = ${t}(fragColor, screen.texSize, coordinate);
}
`,_q=t=>`${E3}
void main() {
fragColor = ${t}(texSrc, screen.texSize, coordinate);
}
`;function yq(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor_ext`;return gq(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return _q(r)}return""}var xq={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},Jr=class extends At{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:r,views:o,viewports:n,onViewportActive:i,pickingFBO:s,deviceRect:{x:a,y:c,width:l,height:f},cullRect:u,effects:d,pass:h="picking",pickZ:p,shaderModuleProps:m,clearColor:g}){this.pickZ=p;let _=this._resetColorEncoder(p),x=[a,c,l,f],y=super._render({target:s,layers:e,layerFilter:r,views:o,viewports:n,onViewportActive:i,cullRect:u,effects:d?.filter(T=>T.useInPicking),pass:h,isPicking:!0,shaderModuleProps:m,clearColor:g??[0,0,0,0],colorMask:15,scissorRect:x});return this._colorEncoderState=null,{decodePickingColor:_&&bq.bind(null,_),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:o}=e.props;return r&&o.includes("draw")||o.includes("terrain")||o.includes("mask")}getShaderModuleProps(e,r,o){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,r,o){let n={...e.props.parameters},{pickable:i,operation:s}=e.props;return this._colorEncoderState?i&&s.includes("draw")?(Object.assign(n,xq),n.blend=!0,this.device.type==="webgpu"?n.blendConstant=w3(this._colorEncoderState,e,o):n.blendColor=w3(this._colorEncoderState,e,o),s.includes("terrain")&&e.state?._hasPickingCover&&(n.blendAlphaSrcFactor="one")):s.includes("terrain")&&(n.blend=!1):n.blend=!1,n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function w3(t,e,r){let{byLayer:o,byAlpha:n}=t,i,s=o.get(e);return s?(s.viewports.push(r),i=s.a):(i=o.size+1,i<=255?(s={a:i,layer:e,viewports:[r]},o.set(e,s),n[i]=s):(N.warn("Too many pickable layers, only picking the first 255")(),i=0)),[0,0,0,i/255]}function bq(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var ui={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"},uc=Symbol.for("component"),Ir=Symbol.for("propTypes"),Sg=Symbol.for("deprecatedProps"),hn=Symbol.for("asyncPropDefaults"),Lo=Symbol.for("asyncPropOriginal"),Qr=Symbol.for("asyncPropResolved");function kt(t,e=()=>!0){return Array.isArray(t)?P3(t,e,[]):e(t)?[t]:[]}function P3(t,e,r){let o=-1;for(;++o<t.length;){let n=t[o];Array.isArray(n)?P3(n,e,r):e(n)&&r.push(n)}return r}function Cg({target:t,source:e,start:r=0,count:o=1}){let n=e.length,i=o*n,s=0;for(let a=r;s<n;s++)t[a++]=e[s];for(;s<i;)s<i-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+i-s),s=i);return t}Xi();var iu=class{constructor(e,r,o){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=o,this.setData(r)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let o=++this._loadCount,n=e;typeof e=="string"&&(n=Kn(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(i=>{this._loadCount===o&&(this.isLoaded=!0,this._error=void 0,this._content=i)}).catch(i=>{this._loadCount===o&&(this.isLoaded=!0,this._error=i||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let i of this._subscribers)i.onChange(this.getData())}};var su=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:o=!1,persistent:n=!0}){let i=this._resources[e];i?i.setData(r,o):(i=new iu(e,r,this._context),this._resources[e]=i),i.persistent=n}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let o in r){let n=r[o],i=this._resources[n.resourceId];i&&i.unsubscribe(n)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:o,requestId:n="default"}){let{_resources:i,protocol:s}=this;e.startsWith(s)&&(e=e.replace(s,""),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=i[e];if(this._track(o,n,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,o,n){let i=this._consumers,s=i[e]=i[e]||{},a=s[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),o&&(a?(a.onChange=n,a.resourceId=o.id):a={onChange:n,resourceId:o.id},s[r]=a,o.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var Aq="layerManager.setLayers",Tq="layerManager.activateViewport",gs=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{He(Tq,this,a),a&&(this.context.viewport=a)};let{deck:o,stats:n,viewport:i,timeline:s}=r||{};this.layers=[],this.resourceManager=new su({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:o,shaderAssembler:hg(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[mv],renderPass:void 0,stats:n||new Et({id:"deck.gl"}),viewport:i||new ot({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:s||new ps,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let o of this.layers){let n=o.getNeedsRedraw(e);r=r||n}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(o=>r.id.indexOf(o)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){He(Aq,this,r,e),this._lastRenderedLayers=e;let o=kt(e,Boolean);for(let n of o)n.context=this.context;this._updateLayers(this.layers,o)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(o=>o.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,o=r.findIndex(n=>n.name===e.name);o>=0&&(r.splice(o,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,o){o.raiseError(r,`${e} of ${o}`)}_updateLayers(e,r){let o={};for(let s of e)o[s.id]?N.warn(`Multiple old layers with same id ${s.id}`)():o[s.id]=s;if(this._defaultShaderModulesChanged){for(let s of e)s.setNeedsUpdate(),s.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let n=[];this._updateSublayersRecursively(r,o,n),this._finalizeOldLayers(o);let i=!1;for(let s of n)if(s.hasUniformTransition()){i=`Uniform transition in ${s}`;break}this._needsUpdate=i,this.layers=n}_updateSublayersRecursively(e,r,o){for(let n of e){n.context=this.context;let i=r[n.id];i===null&&N.warn(`Multiple new layers with same id ${n.id}`)(),r[n.id]=null;let s=null;try{this._debug&&i!==n&&n.validateProps(),i?(this._transferLayerState(i,n),this._updateLayer(n)):this._initializeLayer(n),o.push(n),s=n.isComposite?n.getSubLayers():null}catch(a){this._handleError("matching",a,n)}s&&this._updateSublayersRecursively(s,r,o)}}_finalizeOldLayers(e){for(let r in e){let o=e[r];o&&this._finalizeLayer(o)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=ui.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=ui.MATCHED,r!==e&&(e.lifecycle=ui.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=ui.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=ui.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function ie(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!ie(t[o],e[o],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let i of o)if(!e.hasOwnProperty(i)||!ie(t[i],e[i],r-1))return!1;return!0}return!1}var au=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let r=this.controllers[e];r&&r.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let r=this.controllers[e];r&&r.updateTransition()}}getViewports(e){return e?this._viewports.filter(r=>r.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,o=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(o):o}getViewport(e){return this._viewportMap[e]}unproject(e,r){let o=this.getViewports(),n={x:e[0],y:e[1]};for(let i=o.length-1;i>=0;--i){let s=o[i];if(s.containsPixel(n)){let a=e.slice();return a[0]-=s.x,a[1]-=s.y,s.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=kt(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!ie(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):N.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let o=r.type;return new o({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:i=>this.getView(e.id)?.makeViewport({viewState:i,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,r,o,n){let i=e.controller;if(i&&o){let s={...r,...i,id:e.id,x:o.x,y:o.y,width:o.width,height:o.height};return(!n||n.constructor!==i.type)&&(n=this._createController(e,s)),n&&n.setProps(s),n}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let o=!1;for(let n=e.length;n--;){let i=e[n],s=this.getViewState(i),a=i.makeViewport({viewState:s,width:this.width,height:this.height}),c=r[i.id],l=Boolean(i.controller);l&&!c&&(o=!0),(o||!l)&&c&&(c.finalize(),c=null),this.controllers[i.id]=this._updateController(i,s,a,c),a&&this._viewports.unshift(a)}for(let n in r){let i=r[n];i&&!this.controllers[n]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((o,n)=>!e[n].equals(r[n]))}};var vq=/^(?:\d+\.?\d*|\.\d+)$/;function pn(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{let e=Sq(t);return new Jv(e).parseExpression()}catch(e){let r=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${r}`)}default:throw new Error(`Could not parse position string ${t}`)}}function Zv(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":let r=Zv(t.left,e),o=Zv(t.right,e);return t.operator==="+"?r+o:r-o;default:throw new Error("Unknown layout expression type")}}function mn(t,e){return Zv(t,e)}function Sq(t){let e=[],r=0;for(;r<t.length;){let o=t[r];if(/\s/.test(o)){r++;continue}if(o==="+"||o==="-"||o==="("||o===")"||o==="%"){e.push({type:"symbol",value:o}),r++;continue}if(M3(o)||o==="."){let n=r,i=o===".";for(r++;r<t.length;){let a=t[r];if(M3(a)){r++;continue}if(a==="."&&!i){i=!0,r++;continue}break}let s=t.slice(n,r);if(!vq.test(s))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(s)});continue}if(R3(o)){let n=r;for(;r<t.length&&R3(t[r]);)r++;let i=t.slice(n,r).toLowerCase();e.push({type:"word",value:i});continue}throw new Error("Invalid token in position string")}return e}var Jv=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),r=this.peek();for(;Cq(r);){this.index++;let o=this.parseFactor();e={type:"binary",operator:r.value,left:e,right:o},r=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;let r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(e.type==="symbol"&&e.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="number"){this.index++;let r=e.value,o=this.peek();return o&&o.type==="symbol"&&o.value==="%"?(this.index++,{type:"percentage",value:r/100}):o&&o.type==="word"&&o.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let r=this.peek();return r&&r.type==="symbol"&&r.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function M3(t){return t>="0"&&t<="9"}function R3(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function Cq(t){return Boolean(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function I3(t,e){let r={...t};for(let o in e)o!=="id"&&(Array.isArray(r[o])&&Array.isArray(e[o])?r[o]=Eq(r[o],e[o]):r[o]=e[o]);return r}function Eq(t,e){t=t.slice();for(let r=0;r<e.length;r++){let o=e[r];Number.isFinite(o)&&(t[r]=o)}return t}var Vt=class{constructor(e){let{id:r,x:o=0,y:n=0,width:i="100%",height:s="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=pn(o),this._y=pn(n),this._width=pn(i),this._height=pn(s),this._padding=a&&{left:pn(a.left||0),right:pn(a.right||0),top:pn(a.top||0),bottom:pn(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&ie(this.props,e.props,2)}clone(e){let r=this.constructor;return new r({...this.props,...e})}makeViewport({width:e,height:r,viewState:o}){o=this.filterViewState(o);let n=this.getDimensions({width:e,height:r});if(!n.height||!n.width)return null;let i=this.getViewportType(o);return new i({...o,...this.props,...n})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?I3(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:r}){let o={x:mn(this._x,e),y:mn(this._y,r),width:mn(this._width,e),height:mn(this._height,r)};return this._padding&&(o.padding={left:mn(this._padding.left,e),top:mn(this._padding.top,r),right:mn(this._padding.right,e),bottom:mn(this._padding.bottom,r)}),o}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var eo=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(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var L3=()=>{},cu={BREAK:1,SNAP_TO_END:2,IGNORE:3},wq=t=>t,Pq=cu.BREAK,lu=class{constructor(e){this._onTransitionUpdate=r=>{let{time:o,settings:{interpolator:n,startProps:i,endProps:s,duration:a,easing:c}}=r,l=c(o/a),f=n.interpolateProps(i,s,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new eo(e.timeline),this.onViewStateChange=e.onViewStateChange||L3,this.onStateChange=e.onStateChange||L3}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,o=this.props;if(this.props=e,!o||this._shouldIgnoreViewportChange(o,e))return!1;if(this._isTransitionEnabled(e)){let n=o;if(this.transition.inProgress){let{interruption:i,endProps:s}=this.transition.settings;n={...o,...i===cu.SNAP_TO_END?s:this.propsInTransition||o}}this._triggerTransition(n,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:o}=e;return(r>0||r==="auto")&&Boolean(o)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===cu.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let o=this.getControllerState(e),n=this.getControllerState(r).shortestPathFrom(o),i=r.transitionInterpolator,s=i.getDuration?i.getDuration(e,r):r.transitionDuration;if(s===0)return;let a=i.initializeProps(e,n);this.propsInTransition={};let c={duration:s,easing:r.transitionEasing||wq,interpolator:i,interruption:r.transitionInterruption||Pq,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function ge(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var gn=class{constructor(e){let{compare:r,extract:o,required:n}=e;this._propsToCompare=r,this._propsToExtract=o||r,this._requiredProps=n}arePropsEqual(e,r){for(let o of this._propsToCompare)if(!(o in e)||!(o in r)||!Ce(e[o],r[o]))return!1;return!0}initializeProps(e,r){let o={},n={};for(let i of this._propsToExtract)(i in e||i in r)&&(o[i]=e[i],n[i]=r[i]);return this._checkRequiredProps(o),this._checkRequiredProps(n),{start:o,end:n}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let o=e[r];ge(Number.isFinite(o)||Array.isArray(o),`${r} is required for transition`)})}};var Eg=Math.PI/180,B3=180/Math.PI,wg=6370972,_n=256;function Mq(){let t=_n/wg,e=Math.PI/180*_n;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var Pg=class extends ot{constructor(e={}){let{longitude:r=0,zoom:o=0,nearZMultiplier:n=.5,farZMultiplier:i=1,resolution:s=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,Ut),-Ut),c=c||1,f?l=ln(f):f=cn(l);let u=Math.pow(2,o-Bo(a)),d=e.nearZ??n,h=e.farZ??(l+_n*2*u/c)*i,p=new V().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*Eg),p.rotateZ(-r*Eg),p.scale(u/c),super({...e,height:c,viewMatrix:p,longitude:r,latitude:a,zoom:o,distanceScales:Mq(),fovy:f,focalDistance:l,near:d,far:h}),this.scale=u,this.latitude=a,this.longitude=r,this.fovy=f,this.resolution=s}get projectionMode(){return ft.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},o=this.unproject([0,this.height/2],r),n=this.unproject([this.width/2,0],r),i=this.unproject([this.width,this.height/2],r),s=this.unproject([this.width/2,this.height],r);return i[0]<this.longitude&&(i[0]+=360),o[0]>this.longitude&&(o[0]-=360),[Math.min(o[0],i[0],n[0],s[0]),Math.min(o[1],i[1],n[1],s[1]),Math.max(o[0],i[0],n[0],s[0]),Math.max(o[1],i[1],n[1],s[1])]}unproject(e,{topLeft:r=!0,targetZ:o}={}){let[n,i,s]=e,a=r?i:this.height-i,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(s))l=Qv(c,[n,a,s,1]);else{let h=Qv(c,[n,a,-1,1]),p=Qv(c,[n,a,1,1]),m=((o||0)/wg+1)*_n,g=Ke.sqrLen(Ke.sub([],h,p)),_=Ke.sqrLen(h),x=Ke.sqrLen(p),b=4*((4*_*x-(g-_-x)**2)/16)/g,T=Math.sqrt(_-b),v=Math.sqrt(Math.max(0,m*m-b)),w=(T-v)/Math.sqrt(g);l=Ke.lerp([],h,p,w)}let[f,u,d]=this.unprojectPosition(l);return Number.isFinite(s)?[f,u,d]:Number.isFinite(o)?[f,u,o]:[f,u]}projectPosition(e){let[r,o,n=0]=e,i=r*Eg,s=o*Eg,a=Math.cos(s),c=(n/wg+1)*_n;return[Math.sin(i)*a*c,-Math.cos(i)*a*c,Math.sin(s)*c]}unprojectPosition(e){let[r,o,n]=e,i=Ke.len(e),s=Math.asin(n/i),c=Math.atan2(r,-o)*B3,l=s*B3,f=(i/_n-1)*wg;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,r,o],n,i){let a=.25/Math.pow(2,this.zoom-Bo(this.latitude)),c=e+a*(i[0]-n[0]),l=r-a*(i[1]-n[1]);l=Math.max(Math.min(l,Ut),-Ut);let f={longitude:c,latitude:l,zoom:o-Bo(r)};return f.zoom+=Bo(f.latitude),f}};Pg.displayName="GlobeViewport";var Oo=Pg;function Bo(t){let e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function Qv(t,e){let r=Nt.transformMat4([],e,t);return Nt.scale(r,r,1/r[3]),r}var Rq=["longitude","latitude","zoom","bearing","pitch"],Iq=["longitude","latitude","zoom"],Ue=class extends gn{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,o=Array.isArray(e)?{}:e;o.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:Rq,required:Iq},super(o.transitionProps),this.opts=o}initializeProps(e,r){let o=super.initializeProps(e,r),{makeViewport:n,around:i}=this.opts;if(n&&i)if(n(e)instanceof Oo)N.warn("around not supported in GlobeView")();else{let a=n(e),c=n(r),l=a.unproject(i);o.start.around=i,Object.assign(o.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return o}interpolateProps(e,r,o){let n={};for(let i of this._propsToExtract)n[i]=lt(e[i]||0,r[i]||0,o);if(r.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...r,...n});Object.assign(n,i.panByPosition(r.aroundPosition,lt(e.around,r.around,o)))}return n}};var yn={transitionDuration:0},Lq=300,Mg=t=>1-(1-t)*(1-t),dc={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},_s={},zt=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new lu({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return r?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:o}=this.props,{offsetCenter:n}=e;return[n.x-r,n.y-o]}isPointInBounds(e,r){let{width:o,height:n}=this.props;if(r&&r.handled)return!1;let i=e[0]>=0&&e[0]<=o&&e[1]>=0&&e[1]<=n;return i&&r&&r.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let r=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:o}=e;this.inertia=Number.isFinite(o)?o:o===!0?Lq:0;let{scrollZoom:n=!0,dragPan:i=!0,dragRotate:s=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,u=Boolean(this.onViewStateChange);if(this.toggleEvents(dc.WHEEL,u&&n),this.toggleEvents(dc.PAN,u),this.toggleEvents(dc.PINCH,u&&(c||l)),this.toggleEvents(dc.MULTI_PAN,u&&l),this.toggleEvents(dc.DOUBLE_CLICK,u&&a),this.toggleEvents(dc.KEYBOARD,u&&f),this.scrollZoom=n,this.dragPan=i,this.dragRotate=s,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!r||r.height!==e.height||r.width!==e.width||r.maxBounds!==e.maxBounds)&&e.maxBounds){let h=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=h.getViewportProps();Object.keys(p).some(g=>!ie(p[g],e[g],1))&&this.updateViewport(h)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(o=>{this._events[o]!==r&&(this._events[o]=r,r?this.eventManager.on(o,this.handleEvent):this.eventManager.off(o,this.handleEvent))})}updateViewport(e,r=null,o={}){let n={...e.getViewportProps(),...r},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(o),i){let s=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:s,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(o=!o);let n=this.controllerState[o?"panStart":"rotateStart"]({pos:r});return this._panMove=o,this.updateViewport(n,yn,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),o=this.controllerState.pan({pos:r});return this.updateViewport(o,yn,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let o=this.getCenter(e),n=[o[0]+e.velocityX*r/2,o[1]+e.velocityY*r/2],i=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isPanning:!0})}else{let o=this.controllerState.panEnd();this.updateViewport(o,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),o=this.controllerState.rotate({pos:r});return this.updateViewport(o,yn,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let o=this.getCenter(e),n=[o[0]+e.velocityX*r/2,o[1]+e.velocityY*r/2],i=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isRotating:!0})}else{let o=this.controllerState.rotateEnd();this.updateViewport(o,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:o=.01,smooth:n=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,s=2/(1+Math.exp(-Math.abs(i*o)));i<0&&s!==0&&(s=1/s);let a=n?{...this._getTransitionProps({around:r}),transitionDuration:250}:yn,c=this.controllerState.zoom({pos:r,scale:s});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),n||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.controllerState.rotateStart({pos:r});return this.updateViewport(o,yn,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let o=this.controllerState.rotate({pos:r});return this.updateViewport(o,yn,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let o=this.getCenter(e),n=[o[0],o[1]+=e.velocityY*r/2],i=this.controllerState.rotate({pos:n});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let o=this.controllerState.rotateEnd();this.updateViewport(o,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return _s._startPinchRotation=e.rotation,_s._lastPinchEvent=e,this.updateViewport(o,yn,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:o}=e,n=this.getCenter(e);r=r.zoom({pos:n,scale:o})}if(this.touchRotate){let{rotation:o}=e;r=r.rotate({deltaAngleX:_s._startPinchRotation-o})}return this.updateViewport(r,yn,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),_s._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:o}=_s;if(this.touchZoom&&r&&o&&e.scale!==o.scale){let n=this.getCenter(e),i=this.controllerState.rotateEnd(),s=Math.log2(e.scale),a=(s-Math.log2(o.scale))/(e.deltaTime-o.deltaTime),c=Math.pow(2,s+a*r/2);i=i.zoom({pos:n,scale:c}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:n}),transitionDuration:r,transitionEasing:Mg},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let n=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(n,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return _s._startPinchRotation=null,_s._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let o=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:r,scale:o?.5:2});return this.updateViewport(n,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:o,moveSpeed:n,rotateSpeedX:i,rotateSpeedY:s}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(o).zoomOut(o):a.zoomOut(o),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(o).zoomIn(o):a.zoomIn(o),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(i),l.isRotating=!0):(c=a.moveLeft(n),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(i),l.isRotating=!0):(c=a.moveRight(n),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(s),l.isRotating=!0):(c=a.moveUp(n),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(s),l.isRotating=!0):(c=a.moveDown(n),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?yn:e?{...r,transitionInterpolator:new Ue({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var to=class{constructor(e,r,o){this.makeViewport=o,this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var O3=5,Bq=1.2,F3=512,N3=[[-1/0,-90],[1/0,90]];function Rg([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){let[o,n]=Oe([t,e]);return[o,ee(n,0,F3)]}let[,r]=Oe([0,e]);return[t,ee(r,0,F3)]}var fu=class extends to{constructor(e){let{width:r,height:o,latitude:n,longitude:i,zoom:s,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:u=20,minZoom:d=0,maxPitch:h=60,minPitch:p=0,startPanLngLat:m,startZoomLngLat:g,startRotatePos:_,startRotateLngLat:x,startBearing:y,startPitch:b,startZoom:T,normalize:v=!0}=e;ge(Number.isFinite(i)),ge(Number.isFinite(n)),ge(Number.isFinite(s));let w=e.maxBounds||(v?N3:null);super({width:r,height:o,latitude:n,longitude:i,zoom:s,bearing:a,pitch:c,altitude:l,maxZoom:u,minZoom:d,maxPitch:h,minPitch:p,normalize:v,position:f,maxBounds:w},{startPanLngLat:m,startZoomLngLat:g,startRotatePos:_,startRotateLngLat:x,startBearing:y,startPitch:b,startZoom:T},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let o=this.getState().startPanLngLat||this._unproject(r);if(!o)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(o,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let r=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:r!==void 0?this._unproject3D(e,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:o=0}){let{startRotatePos:n,startRotateLngLat:i,startBearing:s,startPitch:a}=this.getState();if(!n||s===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,n,a,s):c={bearing:s+r,pitch:a+o},i){let l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](i,n)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:o}){let{startZoom:n,startZoomLngLat:i}=this.getState();if(i||(n=this.getViewportProps().zoom,i=this._unproject(r)||this._unproject(e)),!i)return this;let s=this._constrainZoom(n+Math.log2(o)),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),o={...this.getViewportProps()},{bearing:n,longitude:i}=o;return Math.abs(n-r.bearing)>180&&(o.bearing=n<0?n+360:n-360),Math.abs(i-r.longitude)>180&&(o.longitude=i<0?i+360:i-360),o}applyConstraints(e){let{maxPitch:r,minPitch:o,pitch:n,longitude:i,bearing:s,normalize:a,maxBounds:c}=e;if(a&&((i<-180||i>180)&&(e.longitude=Ro(i+180,360)-180),(s<-180||s>180)&&(e.bearing=Ro(s+180,360)-180)),e.pitch=ee(n,o,r),e.zoom=this._constrainZoom(e.zoom,e),c){let l=Rg(c[0]),f=Rg(c[1]),u=2**e.zoom,d=e.width/2/u,h=e.height/2/u,[p,m]=pt([l[0]+d,l[1]+h]),[g,_]=pt([f[0]-d,f[1]-h]);e.longitude=ee(e.longitude,p,g),e.latitude=ee(e.latitude,m,_)}return e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:o,maxBounds:n}=r,i=n!==null&&r.width>0&&r.height>0,{minZoom:s}=r;if(i){let a=Rg(n[0]),c=Rg(n[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(s=Math.max(s,Math.log2(r.width/l))),Number.isFinite(f)&&f>0&&(s=Math.max(s,Math.log2(r.height/f))),s>o&&(s=o)}return ee(e,s,o)}_zoomFromCenter(e){let{width:r,height:o}=this.getViewportProps();return this.zoom({pos:[r/2,o/2],scale:e})}_panFromCenter(e){let{width:r,height:o}=this.getViewportProps();return this.pan({startPos:[r/2,o/2],pos:[r/2+e[0],o/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_unproject3D(e,r){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:r})}_getNewRotation(e,r,o,n){let i=e[0]-r[0],s=e[1]-r[1],a=e[1],c=r[1],{width:l,height:f}=this.getViewportProps(),u=i/l,d=0;s>0?Math.abs(f-c)>O3&&(d=s/(c-f)*Bq):s<0&&c>O3&&(d=1-a/c),d=ee(d,-1,1);let{minPitch:h,maxPitch:p}=this.getViewportProps(),m=n+180*u,g=o;return d>0?g=o+d*(p-o):d<0&&(g=o-d*(h-o)),{pitch:g,bearing:m}}},xn=class extends zt{constructor(){super(...arguments),this.ControllerState=fu,this.transition={transitionDuration:300,transitionInterpolator:new Ue({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:o}=this.props,n=this.pickPosition(r+e[0],o+e[1]);if(n&&n.coordinate&&n.coordinate.length>=3)return n.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:N3),super.setProps(e)}updateViewport(e,r=null,o={}){let n=e.getState();o.isDragging&&n.startRotateLngLat?o={...o,rotationPivotPosition:n.startRotateLngLat}:o.isDragging===!1&&(o={...o,rotationPivotPosition:void 0}),super.updateViewport(e,r,o)}};var Ig=class extends Vt{constructor(e={}){super(e)}getViewportType(){return Mt}get ControllerType(){return xn}};Ig.displayName="MapView";var di=Ig;var Oq=new ai;function Fq(t,e){let r=t.order??1/0,o=e.order??1/0;return r-o}var uu=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(o=>o.id===e.id)){let o=r.findIndex(n=>Fq(n,e)>0);o<0?r.push(e):r.splice(o,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(ie(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let n of this.effects)r[n.id]=n;let o=[];for(let n of e){let i=r[n.id],s=n;i&&i!==n?i.setProps?(i.setProps(n.props),s=i):i.cleanup(this._context):i||n.setup(this._context),o.push(s),delete r[n.id]}for(let n in r)r[n].cleanup(this._context);this.effects=o,this._resolvedEffects=o.concat(this._defaultEffects),e.some(n=>n instanceof ai)||this._resolvedEffects.push(Oq),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var du=class extends At{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}render(e){return this._render(e)}};var Nq="deckRenderer.renderLayers",ys=class{constructor(e,r={}){this.device=e,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new du(e),this.pickLayersPass=new Jr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,o={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};o.effects&&this._preRender(o.effects,o);let n=this.lastPostProcessEffect?this.renderBuffers[0]:o.target;this.lastPostProcessEffect&&(o.clearColor=[0,0,0,0],o.clearCanvas=!0);let i=r.render({...o,target:n}),s="stats"in i?i.stats:i;o.effects&&(this.lastPostProcessEffect&&(o.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(o.effects,o)),this.renderCount++,He(Nq,this,s,e),this._updateStats(s)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:o}of e)r+=o;this.stats.get("Layers rendered").addCount(r)}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let o of e)r.preRenderStats[o.id]=o.preRender(r),o.postRender&&(this.lastPostProcessEffect=o.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize(),[o,n]=r;e.length===0&&[0,1].map(i=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:o,height:n});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[s]}))});for(let i of e)i.resize(r)}_postRender(e,r){let{renderBuffers:o}=this,n={...r,inputBuffer:o[0],swapBuffer:o[1]};for(let i of e)if(i.postRender){n.target=i.id===this.lastPostProcessEffect?r.target:void 0;let s=i.postRender(n);n.inputBuffer=s,n.swapBuffer=s===o[0]?o[1]:o[0]}}};q();var Dq={pickedColor:null,pickedObjectIndex:-1};function e1({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:o,deviceRadius:n,deviceRect:i}){let{x:s,y:a,width:c,height:l}=i,f=n*n,u=-1,d=0;for(let h=0;h<l;h++){let p=h+a-o,m=p*p;if(m>f)d+=4*c;else for(let g=0;g<c;g++){if(t[d+3]-1>=0){let x=g+s-r,y=x*x+m;y<=f&&(f=y,u=d)}d+=4}}if(u>=0){let h=t.slice(u,u+4),p=e(h);if(p){let m=Math.floor(u/4/c),g=u/4-m*c;return{...p,pickedColor:h,pickedX:s+g,pickedY:a+m}}N.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Dq}function t1({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let o=0;o<t.length;o+=4)if(t[o+3]-1>=0){let i=t.slice(o,o+4),s=i.join(",");if(!r.has(s)){let a=e(i);a?r.set(s,{...a,color:i}):N.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function Lg({pickInfo:t,viewports:e,pixelRatio:r,x:o,y:n,z:i}){let s=e[0];e.length>1&&(s=Uq(t?.pickedViewports||e,{x:o,y:n}));let a;if(s){let c=[o-s.x,n-s.y];i!==void 0&&(c[2]=i),a=s.unproject(c)}return{color:null,layer:null,viewport:s,index:-1,picked:!1,x:o,y:n,pixel:[o,n],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function r1(t){let{pickInfo:e,lastPickedInfo:r,mode:o,layers:n}=t,{pickedColor:i,pickedLayer:s,pickedObjectIndex:a}=e,c=s?[s]:[];if(o==="hover"){let u=r.index,d=r.layerId,h=s?s.props.id:null;if(h!==d||a!==u){if(h!==d){let p=n.find(m=>m.props.id===d);p&&c.unshift(p)}r.layerId=h,r.index=a,r.info=null}}let l=Lg(t),f=new Map;return f.set(null,l),c.forEach(u=>{let d={...l};u===s&&(d.color=i,d.index=a,d.picked=!0),d=Bg({layer:u,info:d,mode:o});let h=d.layer;u===s&&o==="hover"&&(r.info=d),f.set(h.id,d),o==="hover"&&h.updateAutoHighlight(d)}),f}function Bg({layer:t,info:e,mode:r}){for(;t&&e;){let o=e.layer||null;e.sourceLayer=o,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:o}),t=t.parent}return e}function Uq(t,e){for(let r=t.length-1;r>=0;r--){let o=t[r];if(o.containsPixel(e))return o}return t[0]}var hu=class{constructor(e,r={}){this._pickable=!0,this.device=e,this.stats=r.stats,this.pickLayersPass=new Jr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:o,viewports:n},i=this.lastPickedInfo.info){let s=i&&i.layer&&i.layer.id,a=i&&i.viewport&&i.viewport.id,c=s?o.find(d=>d.id===s):null,l=a&&n.find(d=>d.id===a)||n[0],f=l&&l.unproject([e-l.x,r-l.y]);return{...i,...{x:e,y:r,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(e=this.device.getDefaultCanvasContext()){if(!this.pickingFBO){let n=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Y.RENDER_ATTACHMENT|Y.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[n],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let i=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:Y.RENDER_ATTACHMENT|Y.COPY_SRC}),s=this.device.createFramebuffer({colorAttachments:[i],depthStencilAttachment:"depth16unorm"});this.depthFBO=s}}let[r,o]=e.getDrawingBufferSize();this.pickingFBO?.resize({width:r,height:o}),this.depthFBO?.resize({width:r,height:o})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(o=>this.pickLayersPass.shouldDrawLayer(o)&&!o.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:e,views:r,viewports:o,x:n,y:i,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=f.cssToDeviceRatio(),p=this._getPickable(e);if(!p||o.length===0)return{result:[],emptyInfo:Lg({viewports:o,x:n,y:i,pixelRatio:h})};this._resizeBuffer(f);let m=f.cssToDevicePixels([n,i],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(s*h),{width:x,height:y}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceWidth:x,deviceHeight:y}),T={x:n-s,y:i-s,width:s*2+1,height:s*2+1},v,w=[],C=new Set;for(let S=0;S<a;S++){let A;if(b){let O=await this._drawAndSampleAsync({layers:p,views:r,viewports:o,onViewportActive:u,deviceRect:b,cullRect:T,effects:d,pass:`picking:${c}`});A=e1({...O,deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceRect:b})}else A={pickedColor:null,pickedObjectIndex:-1};let M,B=this._getDepthLayers(A,p,l);if(B.length>0){let{pickedColors:O}=await this._drawAndSampleAsync({layers:B,views:r,viewports:o,onViewportActive:u,deviceRect:{x:A.pickedX??g[0],y:A.pickedY??g[1],width:1,height:1},cullRect:T,effects:d,pass:`picking:${c}:z`},!0);O[3]&&(M=O[0])}A.pickedLayer&&S+1<a&&(C.add(A.pickedLayer),A.pickedLayer.disablePickingIndex(A.pickedObjectIndex)),v=r1({pickInfo:A,lastPickedInfo:this.lastPickedInfo,mode:c,layers:p,viewports:o,x:n,y:i,z:M,pixelRatio:h});for(let O of v.values())O.layer&&w.push(O);if(!A.pickedColor)break}for(let S of C)S.restorePickingColors();return{result:w,emptyInfo:v.get(null)}}_pickClosestObject({layers:e,views:r,viewports:o,x:n,y:i,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=f.cssToDeviceRatio(),p=this._getPickable(e);if(!p||o.length===0)return{result:[],emptyInfo:Lg({viewports:o,x:n,y:i,pixelRatio:h})};this._resizeBuffer(f);let m=f.cssToDevicePixels([n,i],!0),g=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(s*h),{width:x,height:y}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceWidth:x,deviceHeight:y}),T={x:n-s,y:i-s,width:s*2+1,height:s*2+1},v,w=[],C=new Set;for(let S=0;S<a;S++){let A;if(b){let O=this._drawAndSample({layers:p,views:r,viewports:o,onViewportActive:u,deviceRect:b,cullRect:T,effects:d,pass:`picking:${c}`});A=e1({...O,deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceRect:b})}else A={pickedColor:null,pickedObjectIndex:-1};let M,B=this._getDepthLayers(A,p,l);if(B.length>0){let{pickedColors:O}=this._drawAndSample({layers:B,views:r,viewports:o,onViewportActive:u,deviceRect:{x:A.pickedX??g[0],y:A.pickedY??g[1],width:1,height:1},cullRect:T,effects:d,pass:`picking:${c}:z`},!0);O[3]&&(M=O[0])}A.pickedLayer&&S+1<a&&(C.add(A.pickedLayer),A.pickedLayer.disablePickingIndex(A.pickedObjectIndex)),v=r1({pickInfo:A,lastPickedInfo:this.lastPickedInfo,mode:c,layers:p,viewports:o,x:n,y:i,z:M,pixelRatio:h});for(let O of v.values())O.layer&&w.push(O);if(!A.pickedColor)break}for(let S of C)S.restorePickingColors();return{result:w,emptyInfo:v.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:r,viewports:o,x:n,y:i,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=this._getPickable(e);if(!h||o.length===0)return[];this._resizeBuffer(f);let p=f.cssToDeviceRatio(),m=f.cssToDevicePixels([n,i],!0),g=m.x,_=m.y+m.height,x=f.cssToDevicePixels([n+s,i+a],!0),y=x.x+x.width,b=x.y,T={x:g,y:b,width:y-g,height:_-b},v=await this._drawAndSampleAsync({layers:h,views:r,viewports:o,onViewportActive:u,deviceRect:T,cullRect:{x:n,y:i,width:s,height:a},effects:d,pass:`picking:${c}`}),w=t1(v),C=new Map,S=[],A=Number.isFinite(l);for(let M=0;M<w.length&&!(A&&S.length>=l);M++){let B=w[M],O={color:B.pickedColor,layer:null,index:B.pickedObjectIndex,picked:!0,x:n,y:i,pixelRatio:p};O=Bg({layer:B.pickedLayer,info:O,mode:c});let F=O.layer.id;C.has(F)||C.set(F,new Set);let X=C.get(F),G=O.object??O.index;X.has(G)||(X.add(G),S.push(O))}return S}_pickVisibleObjects({layers:e,views:r,viewports:o,x:n,y:i,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,canvasContext:f=this.device.getDefaultCanvasContext(),onViewportActive:u,effects:d}){let h=this._getPickable(e);if(!h||o.length===0)return[];this._resizeBuffer(f);let p=f.cssToDeviceRatio(),m=f.cssToDevicePixels([n,i],!0),g=m.x,_=m.y+m.height,x=f.cssToDevicePixels([n+s,i+a],!0),y=x.x+x.width,b=x.y,T={x:g,y:b,width:y-g,height:_-b},v=this._drawAndSample({layers:h,views:r,viewports:o,onViewportActive:u,deviceRect:T,cullRect:{x:n,y:i,width:s,height:a},effects:d,pass:`picking:${c}`}),w=t1(v),C=new Map,S=[],A=Number.isFinite(l);for(let M=0;M<w.length&&!(A&&S.length>=l);M++){let B=w[M],O={color:B.pickedColor,layer:null,index:B.pickedObjectIndex,picked:!0,x:n,y:i,pixelRatio:p};O=Bg({layer:B.pickedLayer,info:O,mode:c});let F=O.layer.id;C.has(F)||C.set(F,new Set);let X=C.get(F),G=O.object??O.index;X.has(G)||(X.add(G),S.push(O))}return S}async _drawAndSampleAsync({layers:e,views:r,viewports:o,onViewportActive:n,deviceRect:i,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:r,viewports:o,onViewportActive:n,pickingFBO:f,deviceRect:i,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let b of a)b.useInPicking&&(u.preRenderStats[b.id]=b.preRender(u));let{decodePickingColor:d,stats:h}=this.pickLayersPass.render(u);this._updateStats(h);let{x:p,y:m,width:g,height:_}=i,x=f.colorAttachments[0]?.texture;if(!x)throw new Error("Picking framebuffer color attachment is missing");let y=await this._readTextureDataAsync(x,{x:p,y:m,width:g,height:_},l?Float32Array:Uint8Array);if(!l){let b=!1;for(let T=3;T<y.length;T+=4)if(y[T]!==0){b=!0;break}!b&&y.length>0&&N.warn("Async pick readback returned only zero alpha values",{deviceRect:i,bytes:Array.from(y.subarray(0,Math.min(y.length,16)))})()}return{pickedColors:y,decodePickingColor:d}}async _readTextureDataAsync(e,r,o){let{width:n,height:i}=r,s=e.computeMemoryLayout(r),a=this.device.createBuffer({byteLength:s.byteLength,usage:K.COPY_DST|K.MAP_READ});try{e.readBuffer(r,a);let c=await a.readAsync(0,s.byteLength),l=o.BYTES_PER_ELEMENT;if(s.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${s.bytesPerRow} is not aligned to ${l}-byte elements.`);let f=new o(c.buffer,c.byteOffset,s.byteLength/l),u=n*4,d=s.bytesPerRow/l;if(d<u)throw new Error(`Texture readback row stride ${d} is smaller than packed row length ${u}.`);let h=new o(n*i*4);for(let p=0;p<i;p++){let m=p*d;h.set(f.subarray(m,m+u),p*u)}return h}finally{a.destroy()}}_drawAndSample({layers:e,views:r,viewports:o,onViewportActive:n,deviceRect:i,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:r,viewports:o,onViewportActive:n,pickingFBO:f,deviceRect:i,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(u.preRenderStats[y.id]=y.preRender(u));let{decodePickingColor:d,stats:h}=this.pickLayersPass.render(u);this._updateStats(h);let{x:p,y:m,width:g,height:_}=i,x=new(l?Float32Array:Uint8Array)(g*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:m,sourceWidth:g,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:d}}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:o}of e)r+=o;this.stats.get("Layers picked").addCount(r)}_getDepthLayers(e,r,o){if(!o||!this.depthFBO)return[];let{pickedLayer:n}=e,i=n?.state?.terrainDrawMode==="drape";return n&&!i?[n]:r.filter(s=>s.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:o,deviceWidth:n,deviceHeight:i}){let s=Math.max(0,e-o),a=Math.max(0,r-o),c=Math.min(n,e+o+1)-s,l=Math.min(i,r+o+1)-a;return c<=0||l<=0?null:{x:s,y:a,width:c,height:l}}};var kq={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Vq="top-left",D3="root",Og=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!ie(e.widgets,this.widgets,1)){let r=e.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:r}){let o=e.reduce((n,i)=>(n[i.id]=i,n),{});for(let n of this.getWidgets()){let{viewId:i}=n;if(i){let s=o[i];s&&(n.onViewportChange&&n.onViewportChange(s),n.onRedraw?.({viewports:[s],layers:r}))}else{if(n.onViewportChange)for(let s of e)n.onViewportChange(s);n.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=o,this._updateContainers()}onHover(e,r){for(let o of this.getWidgets()){let{viewId:n}=o;(!n||n===e.viewport?.id)&&o.onHover?.(e,r)}}onEvent(e,r){let o=Ja[r.type];if(o)for(let n of this.getWidgets()){let{viewId:i}=n;(!i||i===e.viewport?.id)&&n[o]?.(e,r)}}_setWidgets(e){let r={};for(let o of this.resolvedWidgets)r[o.id]=o;this.resolvedWidgets.length=0;for(let o of this.defaultWidgets)r[o.id]=null,this.resolvedWidgets.push(o);for(let o of e){let n=r[o.id];n?n.viewId!==o.viewId||n.placement!==o.placement?(this._removeWidget(n),this._addWidget(o)):o!==n&&(n.setProps(o.props),o=n):this._addWidget(o),r[o.id]=null,this.resolvedWidgets.push(o)}for(let o in r){let n=r[o];n&&this._removeWidget(n)}this.widgets=e}_addWidget(e){let{viewId:r=null,placement:o=Vq}=e,n=e.props._container??r;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:r}),e.rootElement&&this._getContainer(n,o).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,r){if(e&&typeof e!="string")return e;let o=e||D3,n=this.containers[o];n||(n=document.createElement("div"),n.style.pointerEvents="none",n.style.position="absolute",n.style.overflow="hidden",this.parentElement?.append(n),this.containers[o]=n);let i=n.querySelector(`.${r}`);return i||(i=globalThis.document.createElement("div"),i.className=r,i.style.position="absolute",i.style.zIndex="2",Object.assign(i.style,kq[r]),n.append(i)),i}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let o in this.containers){let n=this.lastViewports[o]||null,i=o===D3||n,s=this.containers[o];i?(s.style.display="block",s.style.left=`${n?n.x:0}px`,s.style.top=`${n?n.y:0}px`,s.style.width=`${n?n.width:e}px`,s.style.height=`${n?n.height:r}px`):s.style.display="none"}}};function xs(t,e){e&&Object.entries(e).map(([r,o])=>{r.startsWith("--")?t.style.setProperty(r,o):t.style[r]=o})}function Fg(t,e){e&&Object.keys(e).map(r=>{r.startsWith("--")?t.style.removeProperty(r):t.style[r]=""})}var $=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let r=this.props,o=this.rootElement;o&&r.className!==e.className&&(r.className&&o.classList.remove(r.className),e.className&&o.classList.add(e.className)),o&&!ie(r.style,e.style,1)&&(Fg(o,r.style),xs(o,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){return this.viewId?[this.viewId]:this.deck?.getViews().map(e=>e.id)??[]}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,r){this.deck?._onViewStateChange({viewId:e,viewState:r,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],r=document.createElement("div");return e.filter(o=>typeof o=="string"&&o.length>0).forEach(o=>r.classList.add(o)),xs(r,this.props.style),r}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,r){}onClick(e,r){}onDrag(e,r){}onDragStart(e,r){}onDragEnd(e,r){}};$.defaultProps={id:"widget",style:{},_container:null,className:""};var zq={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},pu=class extends ${constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,zq),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:r}=this,o=r&&r.props.getTooltip;if(!o)return;let n=o(e);this.setTooltip(n,e.x,e.y)}setTooltip(e,r,o){let n=this.rootElement;if(n){if(typeof e=="string")n.innerText=e;else if(e)e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className);else{this.isVisible=!1,n.style.display="none";return}this.isVisible=!0,n.style.display="block",n.style.transform=`translate(${r}px, ${o}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(n.style,e.style)}}};pu.defaultProps={...$.defaultProps};q();Au();Xi();function bn(){}var ZZ=({isDragging:t})=>t?"grabbing":"grab",cB={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:bn,onWebGLInitialized:bn,onResize:bn,onViewStateChange:bn,onInteractionStateChange:bn,onBeforeRender:bn,onAfterRender:bn,onLoad:bn,onError:t=>N.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:ZZ,getTooltip:null,debug:!1,drawPickingColors:!1},Su=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this._canvasContext=null,this._deviceResizeHandler=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Et({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=n=>{let{_pickRequest:i}=this;if(n.type==="pointerleave")i.x=-1,i.y=-1,i.radius=0;else{if(n.leftButton||n.rightButton)return;{let s=n.offsetCenter;if(!s)return;i.x=s.x,i.y=s.y,i.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:i.x,y:i.y}),i.event=n},this._onEvent=n=>{let i=Ja[n.type],s=n.offsetCenter;if(!i||!s||!this.layerManager)return;let a=this.layerManager.getLayers(),c=this._getInternalPickingMode();if(!c)return;if(c==="sync"){let f=n.type==="click"&&this._shouldUnproject3D(a)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(s.x,s.y,{unproject3D:!0},a))):this._getLastPointerDownPickingInfo(s.x,s.y,a);this._dispatchPickingEvent(f,n);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(s.x,s.y,a))).then(f=>{this._dispatchPickingEvent(f,n)}).catch(f=>this.props.onError?.(f))},this._onPointerDown=n=>{let i=n.offsetCenter;if(!i)return;let s=this._getInternalPickingMode();if(!s)return;let a=this.layerManager?.getLayers()||[],c=++this._pointerDownPickSequence;if(s==="sync"){let f=this._pickPointSync({x:i.x,y:i.y,radius:this.props.pickingRadius}),u=this._getFirstPickedInfo(f);this._lastPointerDownInfo=u,this._lastPointerDownInfoPromise=Promise.resolve(u);return}let l=this._pickPointAsync(this._getPointPickOptions(i.x,i.y,{},a)).then(f=>this._getFirstPickedInfo(f)).then(f=>(c===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f)).catch(f=>{this.props.onError?.(f);let u=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(i.x,i.y,a):{};return c===this._pointerDownPickSequence&&(this._lastPointerDownInfo=u),u});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=l};let r=e;this.props={...cB,...e},e=this.props,e.viewState&&e.initialViewState&&N.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device,this._setDeviceCanvasContext(e.device));let o=this.device;!o&&e.gl&&(e.gl instanceof WebGLRenderingContext&&N.error("WebGL1 context not supported.")(),o=vu.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps})),o||(o=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(o,e),this.setProps(r),e._typedArrayManagerProps&&Zr.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this._restoreDeviceResizeHandler(),this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null),this._canvasContext=null}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&N.removed("onLayerHover","onHover")(),"onLayerClick"in e&&N.removed("onLayerClick","onClick")(),e.initialViewState&&!ie(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let r=Object.create(this.props);if(Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id){let o=e.device.getDefaultCanvasContext();this.animationLoop?.stop(),this.canvas!==o.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),this._setDeviceCanvasContext(e.device),N.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()}this.animationLoop?.setProps(r),e.useDevicePixels!==void 0&&this._canvasContext?.setProps&&this._canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let o=this.viewManager.needsRedraw(e),n=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return r=r||o||n||i||s,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return ge(this.viewManager),this.viewManager.views}getView(e){return ge(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ge(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return r.length?r[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,r){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:r,radius:0,unproject3D:!0})}_addResources(e,r=!1){for(let o in e)this.layerManager.resourceManager.add({resourceId:o,data:e[o],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return r==="webgpu"?"async":"sync";if(e==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:r}){return e[0]||r}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(r=>r.props.pickable==="3d")}_getPointPickOptions(e,r,o={},n=this.layerManager?.getLayers()||[]){return{x:e,y:r,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(n),...o}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,r,o=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:r,layers:o,viewports:this.getViewports({x:e,y:r})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:r},o){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let n=r,i=!1;for(let s of e)n=s,i=s.layer?.onHover(s,o)||i;i||(this.props.onHover?.(n,o),this.widgetManager.onHover(n,o))}_dispatchPickingEvent(e,r){if(!this.layerManager||!this.widgetManager)return;let o=Ja[r.type];if(!o)return;let{layer:n}=e,i=n&&(n[o]||n.props[o]),s=this.props[o],a=!1;i&&(a=i.call(n,e,r)),a||(s?.(e,r),this.widgetManager.onEvent(e,r))}_pickAsync(e,r,o){ge(this.deckPicker);let{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(r).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(o),views:this.viewManager.getViews(),viewports:this.getViewports(o),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...o,canvasContext:this._canvasContext||void 0});return n.get(r).timeEnd(),i}_pick(e,r,o){ge(this.deckPicker);let{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(r).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(o),views:this.viewManager.getViews(),viewports:this.getViewports(o),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...o,canvasContext:this._canvasContext||void 0});return n.get(r).timeEnd(),i}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),ge(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(r.width=e.width),e.height&&typeof e.height=="number"&&(r.height=e.height),(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasContext(e){this._canvasContext=e,"style"in e.canvas&&(this.canvas=e.canvas)}_setDeviceCanvasContext(e,r={}){let o=e.getDefaultCanvasContext();this._setCanvasContext(o),this._setDeviceResizeHandler(e,r)}_setDeviceResizeHandler(e,r={}){let o=Boolean(r.syncDrawingBuffer);if(this._deviceResizeHandler?.device===e){this._deviceResizeHandler.syncDrawingBuffer=o;return}this._restoreDeviceResizeHandler();let n=i=>{i===this._canvasContext&&this._canvasContext&&this._onCanvasContextResize(this._canvasContext,{syncDrawingBuffer:this._deviceResizeHandler?.syncDrawingBuffer})};e.props.onResize=n,this._deviceResizeHandler={device:e,onResize:n,syncDrawingBuffer:o}}_restoreDeviceResizeHandler(){let e=this._deviceResizeHandler;e&&e.device.props?.onResize===e.onResize&&(e.device.props.onResize=bn),this._deviceResizeHandler=null}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:o}=e;if(r||r===0){let n=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=n}if(o||o===0){let n=Number.isFinite(o)?`${o}px`:o;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=n}}_updateCanvasSize(e=this._canvasContext){let{canvas:r}=this,[o,n]=e?e.getCSSSize():[r?.clientWidth??r?.width??0,r?.clientHeight??r?.height??0];(o!==this.width||n!==this.height)&&(this.width=o,this.height=n,this.viewManager?.setProps({width:o,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:o,height:n},e||void 0))}_onCanvasContextResize(e,r={}){if(r.syncDrawingBuffer){let{width:o,height:n}=e.canvas;e.setDrawingBufferSize(o,n)}this._needsRedraw="Canvas resized",this._updateCanvasSize(e)}_createAnimationLoop(e,r){let{gl:o,onError:n}=r;return new lc({device:e,autoResizeDrawingBuffer:!o,autoResizeViewport:!1,onInitialize:i=>this._setDevice(i.device),onRender:this._onRenderFrame.bind(this),onError:n})}_createDevice(e){let r=this.props.deviceProps?.createCanvasContext,o=typeof r=="object"?r:void 0,n={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};n.adapters.includes(vu)||n.adapters.push(vu);let i={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0};return Co.createDevice({_reuseDevices:!0,type:"webgl",...n,createCanvasContext:{...i,...o,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new di({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let r=e.event,o=this.layerManager?.getLayers()||[],n=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},o),i=this._getInternalPickingMode(),s=++this._hoverPickSequence;if(e.event=null,!i)return;if(i==="sync"){this._applyHoverCallbacks(this._pickPointSync(n),r);return}this._pickPointAsync(n).then(({result:a,emptyInfo:c})=>{s===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},r)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this._setDeviceCanvasContext(e,{syncDrawingBuffer:Boolean(this.props.gl&&this.props.device!==e)}),this.canvas&&!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new ps;r.play(),this.animationLoop.attachTimeline(r);let o=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new zf(o,{touchAction:this.props.touchAction,recognizers:Object.keys(Sv).map(s=>{let[a,c,l,f]=Sv[s],u=this.props.eventRecognizerOptions?.[s],d={...c,...u,event:s};return{recognizer:new a(d),recognizeWith:l,requireFailure:f}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in Ja)this.eventManager.on(s,this._onEvent);this.viewManager=new au({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let n=this.viewManager.getViewports()[0];this.layerManager=new gs(this.device,{deck:this,stats:this.stats,viewport:n,timeline:r}),this.effectManager=new uu({deck:this,device:this.device}),this.deckRenderer=new ys(this.device,{stats:this.stats}),this.deckPicker=new hu(this.device,{stats:this.stats});let i=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new Og({deck:this,parentElement:i}),this.widgetManager.addDefault(new pu),this.setProps({}),this._updateCanvasSize(this._canvasContext),this.props.onLoad()}_drawLayers(e,r){let{device:o,gl:n}=this.layerManager.context;this.props.onBeforeRender({device:o,gl:n});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(i),i.pass==="screen"&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:o,gl:n})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),N.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=r.get("Layers rendered").lastSampleCount,e.pickLayersCount=r.get("Layers picked").lastSampleCount,e.updateAttributesCount=r.get("Layers updated").count,e.updateAttributesCount=r.get("Attributes updated").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let o=Co.stats.get("GPU Time and Memory");e.bufferMemory=o.get("Buffer Memory").count,e.textureMemory=o.get("Texture Memory").count,e.renderbufferMemory=o.get("Renderbuffer Memory").count,e.gpuMemory=o.get("GPU Memory").count}};Su.defaultProps=cB;Su.VERSION=em;var An=Su;q();q();function lB(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Lf(t)}}var fB=Dt.getDataType.bind(Dt);function Cu(t,e,r){if(e.size>4)return null;let o=r==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${o}x${e.size}`:e.type,byteOffset:e.offset||0}}function pi(t){return t.stride||t.size*t.bytesPerElement}function uB(t,e){return t.type===e.type&&t.size===e.size&&pi(t)===pi(e)&&(t.offset||0)===(e.offset||0)}function M1(t,e){e.offset&&N.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=pi(t),o=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,n=e.elementOffset||0,i=o*r+n*t.bytesPerElement+(t.offset||0);return{...e,offset:i,stride:r}}function JZ(t,e){let r=M1(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Eu=class{constructor(e,r,o){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let n=r.logicalType||r.type,i=n==="float64",{defaultValue:s}=r;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0);let a;i?a="float32":!n&&r.isIndexed?a="uint32":a=n||"float32";let c=lB(n||a);this.doublePrecision=i,i&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:s,logicalType:n,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...o,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*pi(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Zr.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let o={};if(this.state.constant){let n=this.value;if(r){let i=M1(this.getAccessor(),r),s=i.offset/n.BYTES_PER_ELEMENT,a=i.size||this.size;o[e]=n.subarray(s,s+a)}else o[e]=n}else o[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?o[`${e}64Low`]=o[e]:o[`${e}64Low`]=new Float32Array(this.size)),o}_getBufferLayout(e=this.id,r=null){let o=this.getAccessor(),n=[],i={name:this.id,byteStride:pi(o)};if(this.doublePrecision){let s=JZ(o,r||{});n.push(Cu(e,{...o,...s.high},this.device.type),Cu(`${e}64Low`,{...o,...s.low},this.device.type))}else if(r){let s=M1(o,r);n.push(Cu(e,{...o,...s},this.device.type))}else n.push(Cu(e,o,this.device.type));return i.attributes=n.filter(Boolean),i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:o,size:n}=this,i=o*n;if(r&&i&&r.length>=i){let s=new Array(n).fill(1/0),a=new Array(n).fill(-1/0);for(let c=0;c<i;)for(let l=0;l<n;l++){let f=r[c++];f<s[l]&&(s[l]=f),f>a[l]&&(a[l]=f)}e=[s,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,o;ArrayBuffer.isView(e)?o={value:e}:e instanceof K?o={buffer:e}:o=e;let n={...this.settings,...o};if(ArrayBuffer.isView(o.value)){if(!o.type)if(this.doublePrecision&&o.value instanceof Float64Array)n.type="float32";else{let s=fB(o.value);n.type=n.normalized?s.replace("int","norm"):s}n.bytesPerElement=o.value.BYTES_PER_ELEMENT,n.stride=pi(n)}if(r.bounds=null,o.constant){let i=o.value;if(i=this._normalizeValue(i,[],0),this.settings.normalized&&(i=this.normalizeConstant(i)),!(!r.constant||!this._areValuesEqual(i,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(i)?i:new Float32Array(i)}else if(o.buffer){let i=o.buffer;r.externalBuffer=i,r.constant=!1,this.value=o.value||null}else if(o.value){this._checkExternalBuffer(o);let i=o.value;r.externalBuffer=null,r.constant=!1,this.value=i;let{buffer:s}=this,a=pi(n),c=(n.vertexOffset||0)*a;if(this.doublePrecision&&i instanceof Float64Array&&(i=pg(i,n)),this.settings.isIndexed){let f=this.settings.defaultType;i.constructor!==f&&(i=new f(i))}let l=i.byteLength+c+a*2;(!s||s.byteLength<l)&&(s=this._createBuffer(l)),s.write(i,c)}return this.setAccessor(n),!0}updateSubBuffer(e={}){this.state.bounds=null;let r=this.value,{startOffset:o=0,endOffset:n}=e;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?pg(r,{size:this.size,startIndex:o,endIndex:n}):r.subarray(o,n),o*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,r=!1){let{state:o}=this,n=o.allocatedValue,i=Zr.allocate(n,e+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=i;let{byteOffset:s}=this,{buffer:a}=this;return(!a||a.byteLength<i.byteLength+s)&&(a=this._createBuffer(i.byteLength+s),r&&n&&a.write(n instanceof Float64Array?pg(n,this):n,s)),o.allocatedValue=i,o.constant=!1,o.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:r}=e;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let o=this.settings.defaultType,n=!1;if(this.doublePrecision&&(n=r.BYTES_PER_ELEMENT<4),n)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof o)&&this.settings.normalized&&!("normalized"in e)&&N.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,o){let{defaultValue:n,size:i}=this.settings;if(Number.isFinite(e))return r[o]=e,r;if(!e){let s=i;for(;--s>=0;)r[o+s]=n[s];return r}switch(i){case 4:r[o+3]=Number.isFinite(e[3])?e[3]:n[3];case 3:r[o+2]=Number.isFinite(e[2])?e[2]:n[2];case 2:r[o+1]=Number.isFinite(e[1])?e[1]:n[1];case 1:r[o+0]=Number.isFinite(e[0])?e[0]:n[0];break;default:let s=i;for(;--s>=0;)r[o+s]=Number.isFinite(e[s])?e[s]:n[s]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:o}=this;for(let n=0;n<o;n++)if(e[n]!==r[n])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:o}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(r?K.INDEX:K.VERTEX)|K.COPY_DST,indexType:r?o:void 0,byteLength:e}),this._buffer}};var dB=[],hB=[];function Fe(t,e=0,r=1/0){let o=dB,n={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?o=t:t.length>0&&(hB.length=t.length,o=hB):o=dB,(e>0||Number.isFinite(r))&&(o=(Array.isArray(o)?o:Array.from(o)).slice(e,r),n.index=e-1),{iterable:o,objectInfo:n}}function y_(t){return t&&t[Symbol.asyncIterator]}function x_(t,e){let{size:r,stride:o,offset:n,startIndices:i,nested:s}=e,a=t.BYTES_PER_ELEMENT,c=o?o/a:r,l=n?n/a:0,f=Math.floor((t.length-l)/c);return(u,{index:d,target:h})=>{if(!i){let _=d*c+l;for(let x=0;x<r;x++)h[x]=t[_+x];return h}let p=i[d],m=i[d+1]||f,g;if(s){g=new Array(m-p);for(let _=p;_<m;_++){let x=_*c+l;h=new Array(r);for(let y=0;y<r;y++)h[y]=t[x+y];g[_-p]=h}}else if(c===r)g=t.subarray(p*r+l,m*r+l);else{g=new t.constructor((m-p)*r);let _=0;for(let x=p;x<m;x++){let y=x*c+l;for(let b=0;b<r;b++)g[_++]=t[y+b]}}return g}}var pB=[],wu=[[0,1/0]];function mB(t,e){if(t===wu||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;let r=[],o=t.length,n=0;for(let i=0;i<o;i++){let s=t[i];s[1]<e[0]?(r.push(s),n=i+1):s[0]>e[1]?r.push(s):e=[Math.min(s[0],e[0]),Math.max(s[1],e[1])]}return r.splice(n,0,e),r}var eJ={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function b_(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...eJ[r],...e,...t,type:r}}var Tn=class extends Eu{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:wu}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!uB(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,o=this.settings.transition,n=Array.isArray(r)?e[r.find(i=>e[i])]:e[r];return b_(n,o)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:o=0,endRow:n=1/0}=r;this.state.updateRanges=mB(this.state.updateRanges,[o,n])}else this.state.updateRanges=wu}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=pB}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:o}=this;return o.noAlloc?!1:o.update?(super.allocate(e,r.updateRanges!==wu),!0):!1}updateBuffer({numInstances:e,data:r,props:o,context:n}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:s,noAlloc:a}}=this,c=!0;if(s){for(let[l,f]of i)s.call(n,this,{data:r,startRow:l,endRow:f,props:o,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(n,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,f]of i){let u=Number.isFinite(l)?this.getVertexOffset(l):0,d=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:u,endOffset:d})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,r){if(r===void 0||typeof r=="function")return!1;let o=this.settings.transform&&e?this.settings.transform.call(e,r):r;return this.device.type==="webgpu"?this.setConstantBufferValue(o,this.numInstances):(this.setData({constant:!0,value:o})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,r){let o=this.settings.defaultType,n=this._normalizeValue(e,new o(this.size),0);if(this._hasConstantBufferValue(n,r))return this.constant=!1,this.clearNeedsUpdate(),!1;let i=new o(Math.max(r,1)*this.size);for(let a=0;a<i.length;a+=this.size)i.set(n,a);let s=this.setData({value:i});return this.constant=!1,this.clearNeedsUpdate(),s&&this.setNeedsRedraw(),s}_hasConstantBufferValue(e,r){let o=this.value,n=Math.max(r,1)*this.size;if(!ArrayBuffer.isView(o)||o.length!==n||o.length%this.size!==0)return!1;for(let i=0;i<o.length;i+=this.size)for(let s=0;s<this.size;s++)if(o[i+s]!==e[s])return!1;return!0}setExternalBuffer(e){let{state:r}=this;return e?(this.clearNeedsUpdate(),r.lastExternalBuffer===e||(r.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(e,r=null){let{state:o,settings:n}=this;if(!e)return o.binaryValue=null,o.binaryAccessor=null,!1;if(n.noAlloc)return!1;if(o.binaryValue===e)return this.clearNeedsUpdate(),!0;if(o.binaryValue=e,this.setNeedsRedraw(),n.transform||r!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let s=e;ge(ArrayBuffer.isView(s.value),`invalid ${n.accessor}`);let a=Boolean(s.size)&&s.size!==this.size;return o.binaryAccessor=x_(s.value,{size:s.size||this.size,stride:s.stride,offset:s.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:r}=this;return(r?e<r.length?r[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,r=super.getValue();if(!e)return r;for(let o in e)Object.assign(r,super.getValue(o,e[o]));return r}getBufferLayout(e){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,o=super._getBufferLayout(),{stepMode:n}=this.settings;if(n==="dynamic"?o.stepMode=e?e.isInstanced?"instance":"vertex":"instance":o.stepMode=n??"vertex",!r)return o;for(let i in r){let s=super._getBufferLayout(i,r[i]);o.attributes.push(...s.attributes)}return o}_autoUpdater(e,{data:r,startRow:o,endRow:n,props:i,numInstances:s}){let{settings:a,state:c,value:l,size:f,startIndices:u}=e,{accessor:d,transform:h}=a,p=c.binaryAccessor||(typeof d=="function"?d:i[d]);ge(typeof p=="function",`accessor "${d}" is not a function`);let m=e.getVertexOffset(o),{iterable:g,objectInfo:_}=Fe(r,o,n);for(let x of g){_.index++;let y=p(x,_);if(h&&(y=h.call(this,y)),u){let b=(_.index<u.length-1?u[_.index+1]:s)-u[_.index];if(y&&Array.isArray(y[0])){let T=m;for(let v of y)e._normalizeValue(v,l,T),T+=f}else y&&y.length>f?l.set(y,m):(e._normalizeValue(y,_.target,0),Cg({target:l,source:_.target,start:m,count:b}));m+=b*f}else e._normalizeValue(y,l,m),m+=f}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let o=!0;switch(r){case 4:o=o&&Number.isFinite(e[3]);case 3:o=o&&Number.isFinite(e[2]);case 2:o=o&&Number.isFinite(e[1]);case 1:o=o&&Number.isFinite(e[0]);break;default:o=!1}if(!o)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function R1(t){let{source:e,target:r,start:o=0,size:n,getData:i}=t,s=t.end||r.length,a=e.length,c=s-o;if(a>c){r.set(e.subarray(0,c),o);return}if(r.set(e,o),!i)return;let l=a;for(;l<c;){let f=i(l,e);for(let u=0;u<n;u++)r[o+l]=f[u]||0,l++}}function gB({source:t,target:e,size:r,getData:o,sourceStartIndices:n,targetStartIndices:i}){if(!n||!i)return R1({source:t,target:e,size:r,getData:o}),e;let s=0,a=0,c=o&&((f,u)=>o(f+a,u)),l=Math.min(n.length,i.length);for(let f=1;f<l;f++){let u=n[f]*r,d=i[f]*r;R1({source:t.subarray(s,u),target:e,start:a,end:d,size:r,getData:c}),s=u,a=d}return a<e.length&&R1({source:[],target:e,start:a,size:r,getData:c}),e}function _B(t){let{device:e,settings:r,value:o}=t,n=new Tn(e,r);return n.setData({value:o instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),n}function A_(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function T_(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function v_(t){t.push(t.shift())}function yB(t,e){let{doublePrecision:r,settings:o,value:n,size:i}=t,s=r&&n instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=t.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(o.noAlloc?n.length:(e+a)*i)*s}function S_({device:t,source:e,target:r}){return(!r||r.byteLength<e.byteLength)&&(r?.destroy(),r=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),r}function C_({device:t,buffer:e,attribute:r,fromLength:o,toLength:n,fromStartIndices:i,getData:s=a=>a}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,f=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,u=r.startIndices,d=i&&u,h=r.isConstant;if(!d&&e&&o>=n)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,m=h?r.value:new p(r.getBuffer().readSyncWebGL(l,n*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!h){let y=s;s=(b,T)=>r.normalizeConstant(y(b,T))}let g=h?(y,b)=>s(m,b):(y,b)=>s(m.subarray(y+l,y+l+c),b),_=e?new Float32Array(e.readSyncWebGL(f,o*4).buffer):new Float32Array(0),x=new Float32Array(n);return gB({source:_,target:x,sourceStartIndices:i,targetStartIndices:u,size:c,getData:g}),(!e||e.byteLength<x.byteLength+f)&&(e?.destroy(),e=t.createBuffer({byteLength:x.byteLength+f,usage:35050})),e.write(x,f),e}var yc=class{constructor({device:e,attribute:r,timeline:o}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new eo(o),this.attribute=r,this.attributeInTransition=_B(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(e,r,o=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=yB(this.attribute,r),this.transition.start({...e,duration:o})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}};var Pu=class extends yc{constructor({device:e,attribute:r,timeline:o}){super({device:e,attribute:r,timeline:o}),this.type="interpolation",this.transform=nJ(e,r)}start(e,r){let o=this.currentLength,n=this.currentStartIndices;if(super.start(e,r,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:s}=this;v_(i),i[0]=C_({device:this.device,buffer:i[0],attribute:s,fromLength:o,toLength:this.currentLength,fromStartIndices:n,getData:e.enter}),i[1]=S_({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/s.size);bB(s)&&(l/=2),c.setVertexCount(l),s.isConstant?(c.setAttributes({aFrom:i[0]}),c.setConstantAttributes({aTo:s.value})):c.setAttributes({aFrom:i[0],aTo:s.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:r}=this.settings,{time:o}=this.transition,n=o/e;r&&(n=r(n));let{model:i}=this.transform,s={time:n};i.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},tJ=`layout(std140) uniform interpolationUniforms {
float time;
} interpolation;
`,xB={name:"interpolation",vs:tJ,uniformTypes:{time:"f32"}},rJ=`#version 300 es
#define SHADER_NAME interpolation-transition-vertex-shader
in ATTRIBUTE_TYPE aFrom;
in ATTRIBUTE_TYPE aTo;
out ATTRIBUTE_TYPE vCurrent;
void main(void) {
vCurrent = mix(aFrom, aTo, interpolation.time);
gl_Position = vec4(0.0);
}
`,oJ=`#version 300 es
#define SHADER_NAME interpolation-transition-vertex-shader
in ATTRIBUTE_TYPE aFrom;
in ATTRIBUTE_TYPE aFrom64Low;
in ATTRIBUTE_TYPE aTo;
in ATTRIBUTE_TYPE aTo64Low;
out ATTRIBUTE_TYPE vCurrent;
out ATTRIBUTE_TYPE vCurrent64Low;
vec2 mix_fp64(vec2 a, vec2 b, float x) {
vec2 range = sub_fp64(b, a);
return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));
}
void main(void) {
for (int i=0; i<ATTRIBUTE_SIZE; i++) {
vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);
vCurrent[i] = value.x;
vCurrent64Low[i] = value.y;
}
gl_Position = vec4(0.0);
}
`;function bB(t){return t.doublePrecision&&t.value instanceof Float64Array}function nJ(t,e){let r=e.size,o=A_(r),n=T_(r),i=e.getBufferLayout();return bB(e)?new ur(t,{vs:oJ,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:n,byteOffset:0},{attribute:"aFrom64Low",format:n,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:n,byteOffset:0},{attribute:"aTo64Low",format:n,byteOffset:4*r}]}],modules:[bm,xB],defines:{ATTRIBUTE_TYPE:o,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new ur(t,{vs:rJ,bufferLayout:[{name:"aFrom",format:n},{name:"aTo",format:i.attributes[0].format}],modules:[xB],defines:{ATTRIBUTE_TYPE:o},varyings:["vCurrent"],disableWarnings:!0})}var Mu=class extends yc{constructor({device:e,attribute:r,timeline:o}){super({device:e,attribute:r,timeline:o}),this.type="spring",this.texture=fJ(e),this.framebuffer=uJ(e,this.texture),this.transform=lJ(e,r)}start(e,r){let o=this.currentLength,n=this.currentStartIndices;super.start(e,r);let{buffers:i,attribute:s}=this;for(let c=0;c<2;c++)i[c]=C_({device:this.device,buffer:i[c],attribute:s,fromLength:o,toLength:this.currentLength,fromStartIndices:n,getData:e.enter});i[2]=S_({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?a.setConstantAttributes({aTo:s.value}):a.setAttributes({aTo:s.getBuffer()})}onUpdate(){let{buffers:e,transform:r,framebuffer:o,transition:n}=this,i=this.settings;r.model.setAttributes({aPrev:e[0],aCur:e[1]}),r.transformFeedback.setBuffers({vNext:e[2]});let s={stiffness:i.stiffness,damping:i.damping};r.model.shaderInputs.setProps({spring:s}),r.run({framebuffer:o,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),v_(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(o)[0]>0||n.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},iJ=`layout(std140) uniform springUniforms {
float damping;
float stiffness;
} spring;
`,sJ={name:"spring",vs:iJ,uniformTypes:{damping:"f32",stiffness:"f32"}},aJ=`#version 300 es
#define SHADER_NAME spring-transition-vertex-shader
#define EPSILON 0.00001
in ATTRIBUTE_TYPE aPrev;
in ATTRIBUTE_TYPE aCur;
in ATTRIBUTE_TYPE aTo;
out ATTRIBUTE_TYPE vNext;
out float vIsTransitioningFlag;
ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {
ATTRIBUTE_TYPE velocity = cur - prev;
ATTRIBUTE_TYPE delta = dest - cur;
ATTRIBUTE_TYPE force = delta * spring.stiffness;
ATTRIBUTE_TYPE resistance = velocity * spring.damping;
return force - resistance + velocity + cur;
}
void main(void) {
bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;
vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;
vNext = getNextValue(aCur, aPrev, aTo);
gl_Position = vec4(0, 0, 0, 1);
gl_PointSize = 100.0;
}
`,cJ=`#version 300 es
#define SHADER_NAME spring-transition-is-transitioning-fragment-shader
in float vIsTransitioningFlag;
out vec4 fragColor;
void main(void) {
if (vIsTransitioningFlag == 0.0) {
discard;
}
fragColor = vec4(1.0);
}`;function lJ(t,e){let r=A_(e.size),o=T_(e.size);return new ur(t,{vs:aJ,fs:cJ,bufferLayout:[{name:"aPrev",format:o},{name:"aCur",format:o},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[sJ],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function fJ(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function uJ(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var dJ={interpolation:Pu,spring:Mu},Ru=class{constructor(e,{id:r,timeline:o}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=o,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:o}){this.numInstances=o||1;for(let n in e){let i=e[n],s=i.getTransitionSetting(r);s&&this._updateAttribute(n,i,s)}for(let n in this.transitions){let i=e[n];(!i||!i.getTransitionSetting(r))&&this._removeTransition(n)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let o=this.transitions[r];o.inProgress&&(e[r]=o.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,o){let n=this.transitions[e],i=!n||n.type!==o.type;if(i){n&&this._removeTransition(e);let s=dJ[o.type];s?this.transitions[e]=new s({attribute:r,timeline:this.timeline,device:this.device}):(N.error(`unsupported transition type '${o.type}'`)(),i=!1)}(i||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(o,this.numInstances))}};var AB="attributeManager.invalidate",hJ="attributeManager.updateStart",pJ="attributeManager.updateEnd",mJ="attribute.updateStart",gJ="attribute.allocate",_J="attribute.updateEnd",pr=class{constructor(e,{id:r="attribute-manager",stats:o,timeline:n}={}){this.mergeBoundsMemoized=Yt(n3),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=o,this.attributeTransitionManager=new Ru(e,{id:`${r}-transitions`,timeline:n}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let o=this._invalidateTrigger(e,r);He(AB,this,e,o)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);He(AB,this,"all")}update({data:e,numInstances:r,startIndices:o=null,transitions:n,props:i={},buffers:s={},context:a={}}){let c=!1;He(hJ,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let f=this.attributes[l],u=f.settings.accessor;f.startIndices=o,f.numInstances=r,i[l]&&N.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(s[l])||f.setBinaryValue(typeof u=="string"?s[u]:void 0,e.startIndices)||typeof u=="string"&&!s[u]&&f.setConstantValue(a,i[u])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:r,data:e,props:i,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&He(pJ,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:n})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(o=>this.attributes[o]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:o}=this,n={...o.getAttributes()};for(let i in r){let s=r[i];s.needsRedraw(e)&&!o.hasAttribute(i)&&(n[i]=s)}return n}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let o in e){let n=e[o],i={...n,id:o,size:n.isIndexed&&1||n.size||1,...r};this.attributes[o]=new Tn(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:o,updateTriggers:n}=this,i=n[e];return i&&i.forEach(s=>{let a=o[s];a&&a.setNeedsUpdate(a.id,r)}),i}_updateAttribute(e){let{attribute:r,numInstances:o}=e;if(He(mJ,r),r.constant){r.setConstantValue(e.context,r.value);return}r.allocate(o)&&He(gJ,r,o),r.updateBuffer(e)&&(this.needsRedraw=!0,He(_J,r,o))}};q();Au();var Iu=class extends eo{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:o,duration:n,easing:i}}=this,s=i(e/n);this._value=lt(r,o,s)}};var TB=1e-5;function vB(t,e,r,o,n){let i=e-t,a=(r-e)*n,c=-i*o;return a+c+i+e}function yJ(t,e,r,o,n){if(Array.isArray(r)){let i=[];for(let s=0;s<r.length;s++)i[s]=vB(t[s],e[s],r[s],o,n);return i}return vB(t,e,r,o,n)}function SB(t,e){if(Array.isArray(t)){let r=0;for(let o=0;o<t.length;o++){let n=t[o]-e[o];r+=n*n}return Math.sqrt(r)}return Math.abs(t-e)}var Lu=class extends eo{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:r,damping:o,stiffness:n}=this.settings,{_prevValue:i=e,_currValue:s=e}=this,a=yJ(i,s,r,o,n),c=SB(a,r),l=SB(a,s);c<TB&&l<TB&&(a=r,this.end()),this._prevValue=s,this._currValue=a}};var xJ={interpolation:Iu,spring:Lu},Bu=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,r,o,n){let{transitions:i}=this;if(i.has(e)){let c=i.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(n=b_(n),!n)return;let s=xJ[n.type];if(!s){N.error(`unsupported transition type '${n.type}'`)();return}let a=new s(this.timeline);a.start({...n,fromValue:r,toValue:o}),i.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,o]of this.transitions)o.update(),e[r]=o.value,o.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function EB(t){let e=t[Ir];for(let r in e){let o=e[r],{validate:n}=o;if(n&&!n(t[r],o))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function wB(t,e){let r=xc({newProps:t,oldProps:e,propTypes:t[Ir],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),o=AJ(t,e),n=!1;return o||(n=TJ(t,e)),{dataChanged:o,propsChanged:r,updateTriggersChanged:n,extensionsChanged:vJ(t,e),transitionsChanged:bJ(t,e)}}function bJ(t,e){if(!t.transitions)return!1;let r={},o=t[Ir],n=!1;for(let i in t.transitions){let s=o[i],a=s&&s.type;(a==="number"||a==="color"||a==="array")&&I1(t[i],e[i],s)&&(r[i]=!0,n=!0)}return n?r:!1}function xc({newProps:t,oldProps:e,ignoreProps:r={},propTypes:o={},triggerName:n="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${n} changed shallowly`;if(typeof e!="object"||e===null)return`${n} changed shallowly`;for(let i of Object.keys(t))if(!(i in r)){if(!(i in e))return`${n}.${i} added`;let s=I1(t[i],e[i],o[i]);if(s)return`${n}.${i} ${s}`}for(let i of Object.keys(e))if(!(i in r)){if(!(i in t))return`${n}.${i} dropped`;if(!Object.hasOwnProperty.call(t,i)){let s=I1(t[i],e[i],o[i]);if(s)return`${n}.${i} ${s}`}}return!1}function I1(t,e,r){let o=r&&r.equal;return o&&!o(t,e,r)||!o&&(o=t&&e&&t.equals,o&&!o.call(t,e))?"changed deeply":!o&&e!==t?"changed shallowly":null}function AJ(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:o,_dataDiff:n}=t;return o?o(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&n&&(r=n(t.data,e.data)||r),r}function TJ(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&CB(t,e,"all"))return{all:!0};let r={},o=!1;for(let n in t.updateTriggers)n!=="all"&&CB(t,e,n)&&(r[n]=!0,o=!0);return o?r:!1}function vJ(t,e){if(e===null)return!0;let r=e.extensions,{extensions:o}=t;if(o===r)return!1;if(!r||!o||o.length!==r.length)return!0;for(let n=0;n<o.length;n++)if(!o[n].equals(r[n]))return!0;return!1}function CB(t,e,r){let o=t.updateTriggers[r];o=o??{};let n=e.updateTriggers[r];return n=n??{},xc({oldProps:n,newProps:o,triggerName:r})}var SJ="count(): argument not an object",CJ="count(): argument not a container";function E_(t){if(!wJ(t))throw new Error(SJ);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(EJ(t))return Object.keys(t).length;throw new Error(CJ)}function EJ(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function wJ(t){return t!==null&&typeof t=="object"}function mi(t,e){if(!e)return t;let r={...t,...e};if("defines"in e&&(r.defines={...t.defines,...e.defines}),"modules"in e&&(r.modules=(t.modules||[]).concat(e.modules),e.modules.some(o=>o.name==="project64"))){let o=r.modules.findIndex(n=>n.name==="project32");o>=0&&r.modules.splice(o,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let o={...t.inject};for(let n in e.inject)o[n]=(o[n]||"")+e.inject[n];r.inject=o}return r}q();var PJ={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},L1={};function PB(t,e,r,o){if(r instanceof Y)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let n=null;r.compressed&&(n={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:i,height:s}=r.data,a=e.createTexture({...r,sampler:{...PJ,...n,...o},mipLevels:e.getMipLevelCount(i,s)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),L1[a.id]=t,a}function MB(t,e){!e||!(e instanceof Y)||L1[e.id]===t&&(e.delete(),delete L1[e.id])}var MJ={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||B1(t)&&(t.length===3||t.length===4)},equal(t,e,r){return ie(t,e,1)}},accessor:{validate(t,e){let r=w_(t);return r==="function"||r===w_(e.value)},equal(t,e,r){return typeof e=="function"?!0:ie(t,e,1)}},array:{validate(t,e){return e.optional&&!t||B1(t)},equal(t,e,r){let{compare:o}=r,n=Number.isInteger(o)?o:o?1:0;return o?ie(t,e,n):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:o}=r,n=Number.isInteger(o)?o:o?1:0;return o?ie(t,e,n):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:o}=r.props;return o?o(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let o=r.context;return!o||!o.device?null:PB(r.id,o.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{MB(r.id,t)}}};function RB(t){let e={},r={},o={};for(let[n,i]of Object.entries(t)){let s=i?.deprecatedFor;if(s)o[n]=Array.isArray(s)?s:[s];else{let a=RJ(n,i);e[n]=a,r[n]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:o}}function RJ(t,e){switch(w_(e)){case"object":return Ou(t,e);case"array":return Ou(t,{type:"array",value:e,compare:!1});case"boolean":return Ou(t,{type:"boolean",value:e});case"number":return Ou(t,{type:"number",value:e});case"function":return Ou(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Ou(t,e){return"type"in e?{name:t,...MJ[e.type],...e}:"value"in e?{name:t,type:w_(e.value),...e}:{name:t,type:"object",value:e}}function B1(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function w_(t){return B1(t)?"array":t===null?"null":typeof t}function IB(t,e){let r;for(let i=e.length-1;i>=0;i--){let s=e[i];"extensions"in s&&(r=s.extensions)}let o=O1(t.constructor,r),n=Object.create(o);n[uc]=t,n[Lo]={},n[Qr]={};for(let i=0;i<e.length;++i){let s=e[i];for(let a in s)n[a]=s[a]}return Object.freeze(n),n}var IJ="_mergedDefaultProps";function O1(t,e){if(!(t instanceof bc.constructor))return{};let r=IJ;if(e)for(let n of e){let i=n.constructor;i&&(r+=`:${i.extensionName||i.name}`)}let o=LB(t,r);return o||(t[r]=LJ(t,e||[]))}function LJ(t,e){if(!t.prototype)return null;let o=Object.getPrototypeOf(t),n=O1(o),i=LB(t,"defaultProps")||{},s=RB(i),a=Object.assign(Object.create(null),n,s.defaultProps),c=Object.assign(Object.create(null),n?.[Ir],s.propTypes),l=Object.assign(Object.create(null),n?.[Sg],s.deprecatedProps);for(let f of e){let u=O1(f.constructor);u&&(Object.assign(a,u),Object.assign(c,u[Ir]),Object.assign(l,u[Sg]))}return BJ(a,t),FJ(a,c),OJ(a,l),a[Ir]=c,a[Sg]=l,e.length===0&&!F1(t,"_propTypes")&&(t._propTypes=c),a}function BJ(t,e){let r=DJ(e);Object.defineProperties(t,{id:{writable:!0,value:r}})}function OJ(t,e){for(let r in e)Object.defineProperty(t,r,{enumerable:!1,set(o){let n=`${this.id}: ${r}`;for(let i of e[r])F1(this,i)||(this[i]=o);N.deprecated(n,e[r].join("/"))()}})}function FJ(t,e){let r={},o={};for(let n in e){let i=e[n],{name:s,value:a}=i;i.async&&(r[s]=a,o[s]=NJ(s))}t[hn]=r,t[Lo]={},Object.defineProperties(t,o)}function NJ(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||y_(e)?this[Lo][t]=e:this[Qr][t]=e},get(){if(this[Qr]){if(t in this[Qr])return this[Qr][t]||this[hn][t];if(t in this[Lo]){let e=this[uc]&&this[uc].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[hn][t]}}return this[hn][t]}}}function F1(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function LB(t,e){return F1(t,e)&&t[e]}function DJ(t){let e=t.componentName;return e||N.warn(`${t.name}.componentName not specified`)(),e||t.name}var UJ=0,Fu=class{constructor(...e){this.props=IB(this,e),this.id=this.props.id,this.count=UJ++}clone(e){let{props:r}=this,o={};for(let n in r[hn])n in r[Qr]?o[n]=r[Qr][n]:n in r[Lo]&&(o[n]=r[Lo][n]);return new this.constructor({...r,...o,...e})}};Fu.componentName="Component";Fu.defaultProps={};var bc=Fu;var kJ=Object.freeze({}),Ts=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||kJ}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[uc]||this.component;let r=e[Qr]||{},o=e[Lo]||e,n=e[hn]||{};for(let i in r){let s=r[i];this._createAsyncPropData(i,n[i]),this._updateAsyncProp(i,s),r[i]=this.getAsyncProp(i)}for(let i in o){let s=o[i];this._createAsyncPropData(i,n[i]),this._updateAsyncProp(i,s)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(y_(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let o=this.asyncProps[e];return r===o.resolvedValue||r===o.lastValue?!1:(o.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let o=this.asyncProps[e];o&&(r=this._postProcessValue(o,r),o.resolvedValue=r,o.pendingLoadCount++,o.resolvedLoadCount=o.pendingLoadCount)}_setAsyncPropValue(e,r,o){let n=this.asyncProps[e];n&&o>=n.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),n.resolvedValue=r,n.resolvedLoadCount=o,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let o=this.asyncProps[e];if(o){o.pendingLoadCount++;let n=o.pendingLoadCount;r.then(i=>{this.component&&(i=this._postProcessValue(o,i),this._setAsyncPropValue(e,i,n),this._onResolve(e,i))}).catch(i=>{this._onError(e,i)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let o=this.asyncProps[e];if(!o)return;o.pendingLoadCount++;let n=o.pendingLoadCount,i=[],s=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?i=c(a,i):i=i.concat(a),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:s,endRow:i.length}]}),s=i.length,this._setAsyncPropValue(e,i,n)}this._onResolve(e,i)}_postProcessValue(e,r){let o=e.type;return o&&this.component&&(o.release&&o.release(e.resolvedValue,o,this.component),o.transform)?o.transform(r,o,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let n=this.component&&this.component.props[Ir];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var Nu=class extends Ts{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let o=this.layer,n=o?.props.fetch;return n?n(r,{propName:e,layer:o}):super._fetch(e,r)}_onResolve(e,r){let o=this.layer;if(o){let n=o.props.onDataLoad;e==="data"&&n&&n(r,{propName:e,layer:o})}}_onError(e,r){let o=this.layer;o&&o.raiseError(r,`loading ${e} of ${this.layer}`)}};var VJ="layer.changeFlag",zJ="layer.initialize",HJ="layer.update",jJ="layer.finalize",WJ="layer.matched",BB=2**24-1,GJ=Object.freeze([]),$J=Yt(({oldViewport:t,viewport:e})=>t.equals(e)),Lr=new Uint8ClampedArray(0),XJ={data:{type:"data",value:GJ,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:o,loadOptions:n,signal:i})=>{let{resourceManager:s}=r.context;n=n||r.getLoadOptions(),o=o||r.props.loaders,i&&(n={...n,core:{...n?.core,fetch:{...n?.core?.fetch,signal:i}}});let a=s.contains(t);return!a&&!n&&(s.add({resourceId:t,data:Kn(t,o),persistent:!1}),a=!0),a?s.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):Kn(t,o,n)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},Du=class extends bc{constructor(){super(...arguments),this.internalState=null,this.lifecycle=ui.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ge(this.internalState);let r=this.internalState.viewport||this.context.viewport,o=mg(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[n,i,s]=tc(o,r.pixelProjectionMatrix);return e.length===2?[n,i]:[n,i,s]}unproject(e){return ge(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){ge(this.internalState);let o=this.internalState.viewport||this.context.viewport;return gg(e,{viewport:o,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){ge(e instanceof Uint8Array);let[r,o,n]=e;return r+o*256+n*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:E_(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=mi(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=mi(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:o}=e.changeFlags;if(o&&r)if(Array.isArray(o))for(let n of o)r.invalidateAll(n);else r.invalidateAll();if(r){let{props:n}=e,i=this.internalState.hasPickingBuffer,s=Number.isInteger(n.highlightedObjectIndex)||Boolean(n.pickable)||n.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(i!==s){this.internalState.hasPickingBuffer=s;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(s&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!s&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let o of this.getModels())o.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e.renderPass)}getPickingInfo({info:e,mode:r,sourceLayer:o}){let{index:n}=e;return n>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[n]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!$J({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let o in e)e[o].layoutChanged()&&(r=!0);for(let o of this.getModels())this._setModelAttributes(o,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,o=this.getNumInstances(),n=this.getStartIndices();e.update({data:r.data,numInstances:o,startIndices:n,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),o=Object.create(this.props);for(let n in r)Object.defineProperty(o,n,{value:r[n]});return o}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let o=Math.floor(Lr.length/4);this.internalState.usesPickingColorCache=!0;let n=r>0&&Lr[0]===0;if(o<r||n){r>BB&&N.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Lr=Zr.allocate(Lr,r,{size:4,copy:!0,maxCount:Math.max(r,BB)});let i=Math.floor(Lr.length/4),s=[0,0,0],a=n?0:o;for(let c=a;c<i;c++)this.encodePickingColor(c,s),Lr[c*4+0]=s[0],Lr[c*4+1]=s[1],Lr[c*4+2]=s[2],Lr[c*4+3]=0}e.value=Lr.subarray(0,r*4)}_setModelAttributes(e,r,o=!1){if(!Object.keys(r).length)return;if(o){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),r=a.getAttributes()}let n=e.userData?.excludeAttributes||{},i={},s={};for(let a in r){if(n[a])continue;let c=r[a].getValue();for(let l in c){let f=c[l];f instanceof K?r[a].settings.isIndexed?e.setIndexBuffer(f):i[l]=f:f&&(s[l]=f)}}e.setAttributes(i),e.setConstantAttributes(s)}disablePickingIndex(e){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(e);return}let{pickingColors:o,instancePickingColors:n}=this.getAttributeManager().attributes,i=o||n,s=i&&r.attributes&&r.attributes[i.id];if(s&&s.value){let a=s.value,c=this.encodePickingColor(e);for(let l=0;l<r.length;l++){let f=i.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:r,instancePickingColors:o}=this.getAttributeManager().attributes,n=r||o;if(!n)return;let i=n.getVertexOffset(e),s=n.getVertexOffset(e+1);n.buffer.write(new Uint8Array(s-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:r}=this.getAttributeManager().attributes,o=e||r;o&&(this.internalState.usesPickingColorCache&&o.value.buffer!==Lr.buffer&&(o.value=Lr.subarray(0,o.value.length)),o.updateSubBuffer({startOffset:0}))}_initialize(){ge(!this.internalState),He(zJ,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Nu({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(N.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Bu(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){He(WJ,this,this===e);let{state:r,internalState:o}=e;this!==e&&(this.internalState=o,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(He(HJ,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,o=this.context,n=this.internalState,i=o.viewport,s=this._updateUniformTransition();n.propsInTransition=s,o.viewport=n.viewport||i,this.props=s;try{let a=this._getUpdateParams(),c=this.getModels();if(o.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{o.viewport=i,this.props=r,this._clearChangeFlags(),n.needsUpdate=!1,n.resetOldProps()}}_finalize(){He(jJ,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:r=null,uniforms:o={},parameters:n={}}){this._updateAttributeTransition();let i=this.props,s=this.context;this.props=this.internalState.propsInTransition||i;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:a}=this.props,c=a&&a(o)||[0,0];s.device instanceof Zt&&s.device.setParametersWebGL({polygonOffset:c});let l=s.device instanceof Zt?null:YJ(n);if(KJ(this.getModels(),e,n,l),s.device instanceof Zt)s.device.withParametersWebGL(n,()=>{let f={renderPass:e,shaderModuleProps:r,uniforms:o,parameters:n,context:s};for(let u of this.props.extensions)u.draw.call(this,f,u);this.draw(f)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let f={renderPass:e,shaderModuleProps:r,uniforms:o,parameters:n,context:s};for(let u of this.props.extensions)u.draw.call(this,f,u);this.draw(f)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let n in e)if(e[n]){let i=!1;switch(n){case"dataChanged":let s=e[n],a=r[n];s&&Array.isArray(a)&&(r.dataChanged=Array.isArray(s)?a.concat(s):s,i=!0);default:r[n]||(r[n]=e[n],i=!0)}i&&He(VJ,this,n,e)}let o=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=o,r.somethingChanged=o||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let o=wB(e,r);if(o.updateTriggersChanged)for(let n in o.updateTriggersChanged)o.updateTriggersChanged[n]&&this.invalidateAttribute(n);if(o.transitionsChanged)for(let n in o.transitionsChanged)this.internalState.uniformTransitions.add(n,r[n],e[n],e.transitions?.[n]);return this.setChangeFlags(o)}validateProps(){EB(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:o}=this.props;e.picked&&typeof o=="function"&&(r.highlightColor=o(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new pr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:o,oldProps:n}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:s,highlightedObjectIndex:a,highlightColor:c}=o;if(r||n.autoHighlight!==s||n.highlightedObjectIndex!==a||n.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||n.autoHighlight!==s||a!==n.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let o=this.getAttributeManager(),n=o?o.getNeedsRedraw(e):!1;if(r=r||n,r)for(let i of this.props.extensions)i.onNeedsRedraw.call(this,i);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};Du.defaultProps=XJ;Du.layerName="Layer";var _e=Du;function YJ(t){let{blendConstant:e,...r}=t;return e?{pipelineParameters:r,renderPassParameters:{blendConstant:e}}:{pipelineParameters:r}}function KJ(t,e,r,o){for(let n of t)n.device.type==="webgpu"?(qJ(n,e),n.setParameters({...n.parameters,...o?.pipelineParameters})):n.setParameters(r)}function qJ(t,e){let r=e.props.framebuffer||(e.framebuffer??null);if(!r)return;let o=r.colorAttachments.map(s=>s?.texture?.format??null),n=r.depthStencilAttachment?.texture?.format,i=t;(!ZJ(i.props.colorAttachmentFormats,o)||i.props.depthStencilAttachmentFormat!==n)&&(i.props.colorAttachmentFormats=o,i.props.depthStencilAttachmentFormat=n,i._setPipelineNeedsUpdate("attachment formats"))}function ZJ(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}var JJ="compositeLayer.renderLayers",P_=class extends _e{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:o}=this.props;return o&&o[e]&&o[e].type||r}getSubLayerRow(e,r,o){return e.__source={parent:this,object:r,index:o},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(o,n)=>o&&o.__source?(r.index=o.__source.index,e(o.__source.object,r)):e(o,n)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:o,visible:n,parameters:i,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:u,wrapLongitude:d,positionFormat:h,modelMatrix:p,extensions:m,fetch:g,operation:_,_subLayerProps:x}=this.props,y={id:"",updateTriggers:{},opacity:r,pickable:o,visible:n,parameters:i,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:u,wrapLongitude:d,positionFormat:h,modelMatrix:p,extensions:m,fetch:g,operation:_},b=x&&e.id&&x[e.id],T=b&&b.updateTriggers,v=e.id||"sublayer";if(b){let w=this.props[Ir],C=e.type?e.type._propTypes:{};for(let S in b){let A=C[S]||w[S];A&&A.type==="accessor"&&(b[S]=this.getSubLayerAccessor(b[S]))}}Object.assign(y,e,b),y.id=`${this.props.id}-${v}`,y.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...T};for(let w of m){let C=w.getSubLayerProps.call(this,w);C&&Object.assign(y,C,{updateTriggers:Object.assign(y.updateTriggers,C.updateTriggers)})}return y}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let o=this.internalState.subLayers,n=!o||this.needsUpdate();if(n){let i=this.renderLayers();o=kt(i,Boolean),this.internalState.subLayers=o}He(JJ,this,n,o);for(let i of o)i.parent=this}};P_.layerName="CompositeLayer";var Ne=P_;var N1=Math.PI/180;function QJ({height:t,focalDistance:e,orbitAxis:r,rotationX:o,rotationOrbit:n,zoom:i}){let s=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new V().lookAt({eye:a,up:s});c.rotateX(o*N1),r==="Z"?c.rotateZ(n*N1):c.rotateY(n*N1);let l=Math.pow(2,i)/t;return c.scale(l),c}var M_=class extends ot{constructor(e){let{height:r,projectionMatrix:o,fovy:n=50,orbitAxis:i="Z",target:s=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,f=o?o[5]/2:ln(n);super({...e,longitude:void 0,viewMatrix:QJ({height:r||1,focalDistance:f,orbitAxis:i,rotationX:a,rotationOrbit:c,zoom:l}),fovy:n,focalDistance:f,position:s,zoom:l}),this.target=s,this.orbitAxis=i,this.rotationX=a,this.rotationOrbit=c,this.fovy=n,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[o,n,i=this.projectedCenter[2]]=e,s=r?n:this.height-n,[a,c,l]=Mr([o,s,i],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r,o){let n=this.project(e),{near:i,far:s}=r3(this.projectionMatrix),a=i*s/(s-n[2]*(s-i)),c=i*s/(s-this.projectedCenter[2]*(s-i)),l=a/c,f=[this.width/2+(n[0]-r[0])*l,this.height/2+(n[1]-r[1])*l,this.projectedCenter[2]];return{target:this.unproject(f)}}};M_.displayName="OrbitViewport";var R_=M_;var eQ=new V().lookAt({eye:[0,0,1]});function tQ({width:t,height:e,near:r,far:o,padding:n}){let i=-t/2,s=t/2,a=-e/2,c=e/2;if(n){let{left:l=0,right:f=0,top:u=0,bottom:d=0}=n,h=ee((l+t-f)/2,0,t)-t/2,p=ee((u+e-d)/2,0,e)-e/2;i-=h,s-=h,a+=p,c+=p}return new V().ortho({left:i,right:s,bottom:a,top:c,near:r,far:o})}var I_=class extends ot{constructor(e){let{width:r,height:o,near:n=.1,far:i=1e3,zoom:s=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,f=e.zoomX??(Array.isArray(s)?s[0]:s),u=e.zoomY??(Array.isArray(s)?s[1]:s),d=Math.min(f,u),h=Math.pow(2,d),p;if(f!==u){let m=Math.pow(2,f),g=Math.pow(2,u);p={unitsPerMeter:[m/h,g/h,1],metersPerUnit:[h/m,h/g,1]}}super({...e,longitude:void 0,position:a,viewMatrix:eQ.clone().scale([h,h*(l?-1:1),h]),projectionMatrix:tQ({width:r||1,height:o||1,padding:c,near:n,far:i}),zoom:d,distanceScales:p}),this.target=a,this.zoomX=f,this.zoomY=u,this.flipY=l}projectFlat([e,r]){let{unitsPerMeter:o}=this.distanceScales;return[e*o[0],r*o[1]]}unprojectFlat([e,r]){let{metersPerUnit:o}=this.distanceScales;return[e*o[0],r*o[1]]}panByPosition(e,r,o){let n=Mr(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),s=Ye.add([],i,Ye.negate([],n)),a=Ye.add([],this.center,s);return{target:this.unprojectFlat(a)}}};I_.displayName="OrthographicViewport";var Ac=I_;var L_=class extends ot{constructor(e){let{longitude:r,latitude:o,modelMatrix:n,bearing:i=0,pitch:s=0,up:a=[0,0,1]}=e,l=new $r({bearing:i,pitch:s===-90?1e-4:90+s}).toVector3().normalize(),f=n?new V(n).transformAsVector(l):l,u=Number.isFinite(o)?Gf({latitude:o}):0,d=Math.pow(2,u),h=new V().lookAt({eye:[0,0,0],center:f,up:a}).scale(d);super({...e,zoom:u,viewMatrix:h}),this.latitude=o,this.longitude=r,this.pitch=s,this.bearing=i,this.up=a}};L_.displayName="FirstPersonViewport";var B_=L_;var vs=20,OB=500,Uu=class extends to{constructor(e){let{width:r,height:o,position:n=[0,0,0],bearing:i=0,pitch:s=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:f=-90,maxBounds:u=null,startRotatePos:d,startBearing:h,startPitch:p,startZoomPosition:m,startPanPos:g,startPanPosition:_}=e;super({width:r,height:o,position:n,bearing:i,pitch:s,longitude:a,latitude:c,maxPitch:l,minPitch:f,maxBounds:u},{startRotatePos:d,startBearing:h,startPitch:p,startZoomPosition:m,startPanPos:g,startPanPosition:_},e.makeViewport)}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:o=[0,0]}=this.getState(),{width:n,height:i,bearing:s,pitch:a}=this.getViewportProps(),c=OB*(e[0]-r[0])/n,l=OB*(e[1]-r[1])/i,f=new $r({bearing:s,pitch:a}),u=new $r({bearing:s,pitch:-90}),d=f.toVector3().normalize(),h=u.toVector3().cross(d).normalize();return this._getUpdatedState({position:new E(o).add(h.scale(c)).add(d.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:o=0}){let{startRotatePos:n,startBearing:i,startPitch:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!n||i===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-n[0])/a,u=(e[1]-n[1])/c;l={bearing:i-f*180,pitch:s-u*90}}else l={bearing:i-r,pitch:s-o};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:r}){let o=this.getViewportProps(),n=this.getState().startZoomPosition||o.position,i=this.makeViewport(o),{projectionMatrix:s,width:a}=i,l=2*Math.atan(1/s[0])*(e[0]/a-.5),f=this.getDirection(!0);return this._move(f.rotateZ({radians:-l}),Math.log2(r)*vs,n)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=vs){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=vs){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=vs){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=vs){let r=this.getDirection(!0);return this._move(r.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=vs){return this._move(new E(0,0,1),e)}zoomOut(e=vs){return this._move(new E(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),o={...this.getViewportProps()},{bearing:n,longitude:i}=o;return Math.abs(n-r.bearing)>180&&(o.bearing=n<0?n+360:n-360),i!==null&&r.longitude!==null&&Math.abs(i-r.longitude)>180&&(o.longitude=i<0?i+360:i-360),o}_move(e,r,o=this.getViewportProps().position){let n=e.scale(r);return this._getUpdatedState({position:new E(o).add(n)})}getDirection(e=!1){return new $r({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new Uu({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:o,minPitch:n,longitude:i,position:s,bearing:a,maxBounds:c}=e;if(e.pitch=ee(r,n,o),i!==null&&(i<-180||i>180)&&(e.longitude=Ro(i+180,360)-180),(a<-180||a>180)&&(e.bearing=Ro(a+180,360)-180),c){let l=ee(s[0],c[0][0],c[1][0]),f=ee(s[1],c[0][1],c[1][1]),u=ee(s[2]??0,c[0][2]??0,c[1][2]??0);(l!==s[0]||f!==s[1]||u!==s[2])&&(e.position=[l,f,u])}return e}},Ss=class extends zt{constructor(){super(...arguments),this.ControllerState=Uu,this.transition={transitionDuration:300,transitionInterpolator:new Ue(["position","pitch","bearing"])}}};var O_=class extends Vt{constructor(e={}){super(e)}getViewportType(){return B_}get ControllerType(){return Ss}};O_.displayName="FirstPersonView";var FB=O_;var D1=class extends to{constructor(e){let{width:r,height:o,rotationX:n=0,rotationOrbit:i=0,target:s=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:f=-1/0,maxZoom:u=1/0,maxBounds:d=null,startPanPosition:h,startRotatePos:p,startRotationX:m,startRotationOrbit:g,startZoomPosition:_,startZoom:x}=e;super({width:r,height:o,rotationX:n,rotationOrbit:i,target:s,zoom:a,minRotationX:c,maxRotationX:l,minZoom:f,maxZoom:u,maxBounds:d},{startPanPosition:h,startRotatePos:p,startRotationX:m,startRotationOrbit:g,startZoomPosition:_,startZoom:x},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let o=this.getState().startPanPosition||r;if(!o)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(o,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:o=0}){let{startRotatePos:n,startRotationX:i,startRotationOrbit:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!n||i===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-n[0])/a,u=(e[1]-n[1])/c;(i<-90||i>90)&&(f*=-1),l={rotationX:i+u*180,rotationOrbit:s+f*180}}else l={rotationX:i+o,rotationOrbit:s+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),o={...this.getViewportProps()},{rotationOrbit:n}=o;return Math.abs(n-r.rotationOrbit)>180&&(o.rotationOrbit=n<0?n+360:n-360),o}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:o}){let{startZoom:n,startZoomPosition:i}=this.getState();if(i||(n=this.getViewportProps().zoom,i=this._unproject(r||e)),!i)return this;let s=this._calculateNewZoom({scale:o,startZoom:n}),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){let r=this.unproject3D?.(e);return r||this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){r===void 0&&(r=this.getViewportProps().zoom);let o=r+Math.log2(e);return this._constrainZoom(o)}_panFromCenter(e){let{target:r}=this.getViewportProps(),o=this._project(r);return this.pan({startPosition:r,pos:[o[0]+e[0],o[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxRotationX:r,minRotationX:o,rotationOrbit:n}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=ee(e.rotationX,o,r),(n<-180||n>180)&&(e.rotationOrbit=Ro(n+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:o,maxBounds:n}=r,{minZoom:i}=r;if(n&&r.width>0&&r.height>0){let s=n[1][0]-n[0][0],a=n[1][1]-n[0][1],c=(n[1][2]??0)-(n[0][2]??0),l=Math.sqrt(s*s+a*a+c*c);l>0&&(i=Math.max(i,Math.log2(Math.min(r.width,r.height)/l)),i>o&&(i=o))}return ee(e,i,o)}_constrainTarget(e){let{target:r,maxBounds:o}=e;if(!o)return r;let[[n,i,s=0],[a,c,l=0]]=o;if(r[0]>=n&&r[0]<=a&&r[1]>=i&&r[1]<=c&&r[2]>=s&&r[2]<=l)return r;let f=this.makeViewport?.(e);if(f){let{cameraPosition:u}=f,d=u[0]-r[0],h=u[1]-r[1],p=u[2]-r[2],m=d*r[0]+h*r[1]+p*r[2],g=d*(d>=0?n:a)+h*(h>=0?i:c)+p*(p>=0?s:l),_=d*(d>=0?a:n)+h*(h>=0?c:i)+p*(p>=0?l:s);if((d||h||p)&&m>=g&&m<=_){let x=M=>ee(M,n,a),y=M=>ee(M,i,c),b=M=>ee(M,s,l),T=M=>d*x(r[0]-M*d)+h*y(r[1]-M*h)+p*b(r[2]-M*p)-m,v=-1,w=1,C=T(v),S=T(w);for(;C<0;)w=v,S=C,v*=2,C=T(v);for(;S>0;)v=w,C=S,w*=2,S=T(w);for(let M=0;M<30;M++){let B=(v+w)/2;T(B)>0?v=B:w=B}let A=(v+w)/2;return[x(r[0]-A*d),y(r[1]-A*h),b(r[2]-A*p)]}}return[ee(r[0],n,a),ee(r[1],i,c),ee(r[2],s,l)]}},Cs=class extends zt{constructor(){super(...arguments),this.ControllerState=D1,this.transition={transitionDuration:300,transitionInterpolator:new Ue({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){let{x:r,y:o}=this.props,n=this.pickPosition(r+e[0],o+e[1]);if(n&&n.coordinate)return n.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}};var F_=class extends Vt{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return R_}get ControllerType(){return Cs}};F_.displayName="OrbitView";var NB=F_;function DB({zoom:t=0,zoomX:e,zoomY:r}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r}}var U1=class extends to{constructor(e){let{width:r,height:o,target:n=[0,0,0],zoom:i=0,zoomAxis:s="all",minZoom:a=-1/0,maxZoom:c=1/0,minZoomX:l=a,maxZoomX:f=c,minZoomY:u=a,maxZoomY:d=c,maxBounds:h=null,startPanPosition:p,startZoomPosition:m,startZoom:g}=e,{zoomX:_,zoomY:x}=DB(e);super({width:r,height:o,target:n,zoom:i,zoomX:_,zoomY:x,zoomAxis:s,minZoomX:l,maxZoomX:f,minZoomY:u,maxZoomY:d,maxBounds:h},{startPanPosition:p,startZoomPosition:m,startZoom:g},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let o=this.getState().startPanPosition||r;if(!o)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(o,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){let r=e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){let{zoomX:r,zoomY:o}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[r,o]})}zoom({pos:e,startPos:r,scale:o}){let{startZoom:n,startZoomPosition:i}=this.getState();if(!i){let{zoomX:c,zoomY:l}=this.getViewportProps();n=[c,l],i=this._unproject(r||e)}if(!i)return this;let s=this._constrainZoom(this._calculateNewZoom({scale:o,startZoom:n})),a=this.makeViewport({...this.getViewportProps(),...s});return this._getUpdatedState({...s,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:1/e}))}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{zoomX:o,zoomY:n,zoomAxis:i}=this.getViewportProps();r===void 0&&(r=[o,n]);let s=Math.log2(e),[a,c]=r;switch(i){case"X":a+=s;break;case"Y":c+=s;break;default:a+=s,c+=s}return{zoomX:a,zoomY:c}}_panFromCenter(e){let{target:r}=this.getViewportProps(),o=this._project(r);return this.pan({startPosition:r,pos:[o[0]+e[0],o[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{zoomX:r,zoomY:o}=this._constrainZoom(e,e);e.zoomX=r,e.zoomY=o,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;let{maxBounds:n,target:i}=e;if(n){let s=e.width/2/2**r,a=e.height/2/2**o,c=n[0][0]+s,l=n[1][0]-s,f=n[0][1]+a,u=n[1][1]-a,d=ee(i[0],c,l),h=ee(i[1],f,u);(d!==i[0]||h!==i[1])&&(e.target=i.slice(),e.target[0]=d,e.target[1]=h)}return e}_constrainZoom({zoomX:e,zoomY:r},o){o||(o=this.getViewportProps());let{zoomAxis:n,maxZoomX:i,maxZoomY:s,maxBounds:a}=o,{minZoomX:c,minZoomY:l}=o;if(a!==null&&o.width>0&&o.height>0){let u=a[0],d=a[1],h=d[0]-u[0],p=d[1]-u[1];Number.isFinite(h)&&h>0&&(c=Math.max(c,Math.log2(o.width/h)),c>i&&(c=i)),Number.isFinite(p)&&p>0&&(l=Math.max(l,Math.log2(o.height/p)),l>s&&(l=s))}switch(n){case"X":e=ee(e,c,i);break;case"Y":r=ee(r,l,s);break;default:let u=Math.min(i-e,s-r,0);u===0&&(u=Math.max(c-e,l-r,0)),u!==0&&(e+=u,r+=u)}return{zoomX:e,zoomY:r}}},Es=class extends zt{constructor(){super(...arguments),this.ControllerState=U1,this.transition={transitionDuration:300,transitionInterpolator:new Ue(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,DB(e)),super.setProps(e)}_onPanRotate(){return!1}};var N_=class extends Vt{constructor(e={}){super(e)}getViewportType(){return Ac}get ControllerType(){return Es}};N_.displayName="OrthographicView";var D_=N_;var k1=Math.PI/180,rQ=180/Math.PI;function UB(t,e=0){let r=Math.min(180,t)*k1;return _n*2*Math.sin(r/2)*Math.pow(2,e)}function kB(t,e=0){let r=t/Math.pow(2,e);return Math.asin(Math.min(1,r/_n/2))*2*rQ}var V1=class extends fu{constructor(e){let{startPanPos:r,...o}=e;o.normalize=!1,super(o),r!==void 0&&(this._state.startPanPos=r)}panStart({pos:e}){let{latitude:r,longitude:o,zoom:n}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[o,r],startPanPos:e,startZoom:n})}pan({pos:e,startPos:r}){let o=this.getState(),n=o.startPanLngLat||this._unproject(r);if(!n)return this;let i=o.startZoom??this.getViewportProps().zoom,s=o.startPanPos||r,a=[n[0],n[1],i],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,s);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let o=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:o})}applyConstraints(e){let{longitude:r,latitude:o,maxBounds:n}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(r<-180||r>180)&&(e.longitude=Ro(r+180,360)-180),e.latitude=ee(o,-Ut,Ut),n&&(e.longitude=ee(e.longitude,n[0][0],n[1][0]),e.latitude=ee(e.latitude,n[0][1],n[1][1])),n){let i=e.zoom-Bo(o),s=n[1][0]-n[0][0],a=n[1][1]-n[0][1];if(a>0&&a<Ut*2){let c=Math.min(kB(e.height,i),a)/2;e.latitude=ee(e.latitude,n[0][1]+c,n[1][1]-c)}if(s>0&&s<360){let c=Math.min(kB(e.width/Math.cos(e.latitude*k1),i),s)/2;e.longitude=ee(e.longitude,n[0][0]+c,n[1][0]-c)}}return e.latitude!==o&&(e.zoom+=Bo(e.latitude)-Bo(o)),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{latitude:o,maxZoom:n,maxBounds:i}=r,{minZoom:s}=r,a=Bo(0),c=Bo(o)-a;if(i!==null&&r.width>0&&r.height>0){let f=i[0][1],u=i[1][1],d=Math.sign(f)===Math.sign(u)?Math.min(Math.abs(f),Math.abs(u)):0,h=UB(i[1][0]-i[0][0])*Math.cos(d*k1),p=UB(i[1][1]-i[0][1]);h>0&&(s=Math.max(s,Math.log2(r.width/h)+a)),p>0&&(s=Math.max(s,Math.log2(r.height/p)+a)),s>n&&(s=n)}return ee(e,s+c,n+c)}},ws=class extends zt{constructor(){super(...arguments),this.ControllerState=V1,this.transition={transitionDuration:300,transitionInterpolator:new Ue(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var oQ={cullMode:"back"},U_=class extends Vt{constructor(e={}){super({...e,parameters:{...oQ,...e.parameters}})}getViewportType(e){return e.zoom>12?Mt:Oo}get ControllerType(){return ws}};U_.displayName="GlobeView";var k_=U_;var ku=class extends xn{constructor(){super(...arguments),this._terrainAltitude=void 0,this._terrainAltitudeTarget=void 0,this._pickFrameId=null,this._lastPickTime=0}setProps(e){if(super.setProps({rotationPivot:"3d",...e}),this._pickFrameId===null){let r=()=>{let o=Date.now();if(o-this._lastPickTime>500&&!this.isDragging()&&(this._lastPickTime=o,this._pickTerrainCenterAltitude(),this._terrainAltitude===void 0&&this._terrainAltitudeTarget!==void 0)){this._terrainAltitude=this._terrainAltitudeTarget;let n=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),i=this._rebaseViewport(this._terrainAltitudeTarget,n);if(i){let s=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state,...i});super.updateViewport(s)}}this._pickFrameId=requestAnimationFrame(r)};this._pickFrameId=requestAnimationFrame(r)}}finalize(){this._pickFrameId!==null&&(cancelAnimationFrame(this._pickFrameId),this._pickFrameId=null),super.finalize()}updateViewport(e,r=null,o={}){if(this._terrainAltitude===void 0){super.updateViewport(e,r,o);return}let n=.05;this._terrainAltitude+=(this._terrainAltitudeTarget-this._terrainAltitude)*n;let s=e.getViewportProps().position||[0,0,0];r={...r,position:[s[0],s[1],this._terrainAltitude]},super.updateViewport(e,r,o)}_pickTerrainCenterAltitude(){if(!this.pickPosition)return;let{x:e,y:r,width:o,height:n}=this.props,i=this.pickPosition(e+o/2,r+n/2);i?.coordinate&&i.coordinate.length>=3&&(this._terrainAltitudeTarget=i.coordinate[2])}_rebaseViewport(e,r){let o=r.getViewportProps(),n=this.makeViewport({...o,position:[0,0,0]}),i=n.cameraPosition,s=e*n.distanceScales.unitsPerMeter[2],a=i[2],c=a-s;if(c<=0)return null;let l=Math.log2(a/c),f=o.zoom+l,u=this.makeViewport({...o,zoom:f,position:[0,0,e]}),{width:d,height:h}=o,p=[d/2,h/2],m=n.unproject(p,{targetZ:e});if(m&&"panByPosition3D"in u&&typeof u.panByPosition3D=="function"){let g=u.panByPosition3D(m,p);return{position:[0,0,e],zoom:f,...g}}return null}};var Vu=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&ie(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,o={updateTriggers:{}};for(let n in r)if(n in this.props){let i=r[n],s=this.props[n];o[n]=s,i&&i.type==="accessor"&&(o.updateTriggers[n]=this.props.updateTriggers[n],typeof s=="function"&&(o[n]=this.getSubLayerAccessor(s)))}return o}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};Vu.defaultProps={};Vu.extensionName="LayerExtension";var st=Vu;var z1={bearing:0,pitch:0,position:[0,0,0]},nQ={speed:1.2,curve:1.414},so=class extends gn{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...nQ,...e}}interpolateProps(e,r,o){let n=Mv(e,r,o,this.opts);for(let i in z1)n[i]=lt(e[i]||z1[i],r[i]||z1[i],o);return n}getDuration(e,r){let{transitionDuration:o}=r;return o==="auto"&&(o=Rv(e,r,this.opts)),o}};q();var vn=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Zr,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:o={},getGeometry:n,geometryBuffer:i,positionFormat:s,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=n,this.positionSize=i&&i.size||(s==="XY"?2:3),this.buffers=o,this.normalize=c,i&&(ge(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),c||(o.vertexPositions=i)),this.geometryBuffer=o.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?x_(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:o,buffers:n,_attributeDefs:i,typedArrayManager:s}=this;for(let a in i)if(a in n)s.release(o[a]),o[a]=null;else{let c=i[a];c.copy=r,o[a]=s.allocate(o[a],e,c)}}_forEachGeometry(e,r,o){let{data:n,getGeometry:i}=this,{iterable:s,objectInfo:a}=Fe(n,r,o);for(let c of s){a.index++;let l=i?i(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:o,instanceCount:n}=this,{data:i,geometryBuffer:s}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],o=[0]),this.normalize||!s)this._forEachGeometry((u,d)=>{let h=u&&this.normalizeGeometry(u);l[d]=h,o[d+1]=o[d]+(h?this.getGeometrySize(h):0)},a,c),n=o[o.length-1];else if(o=i.startIndices,n=o[i.length]||0,ArrayBuffer.isView(s))n=n||s.length/this.positionSize;else if(s instanceof K){let u=this.positionSize*4;n=n||s.byteLength/u}else if(s.buffer){let u=s.stride||this.positionSize*4;n=n||s.buffer.byteLength/u}else if(s.value){let u=s.value,d=s.stride/u.BYTES_PER_ELEMENT||this.positionSize;n=n||u.length/d}this._allocate(n,Boolean(e)),this.indexStarts=r,this.vertexStarts=o,this.instanceCount=n;let f={};this._forEachGeometry((u,d)=>{let h=l[d]||u;f.vertexStart=o[d],f.indexStart=r[d];let p=d<o.length-1?o[d+1]:n;f.geometrySize=p-o[d],f.geometryIndex=d,this.updateGeometryAttributes(h,f)},a,c),this.vertexCount=r[r.length-1]}};var VB=`layout(std140) uniform arcUniforms {
bool greatCircle;
bool useShortestPath;
float numSegments;
float widthScale;
float widthMinPixels;
float widthMaxPixels;
highp int widthUnits;
} arc;
`,zB={name:"arc",vs:VB,fs:VB,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}};var HB=`#version 300 es
#define SHADER_NAME arc-layer-vertex-shader
in vec4 instanceSourceColors;
in vec4 instanceTargetColors;
in vec3 instanceSourcePositions;
in vec3 instanceSourcePositions64Low;
in vec3 instanceTargetPositions;
in vec3 instanceTargetPositions64Low;
in vec3 instancePickingColors;
in float instanceWidths;
in float instanceHeights;
in float instanceTilts;
out vec4 vColor;
out vec2 uv;
out float isValid;
float paraboloid(float distance, float sourceZ, float targetZ, float ratio) {
float deltaZ = targetZ - sourceZ;
float dh = distance * instanceHeights;
if (dh == 0.0) {
return sourceZ + deltaZ * ratio;
}
float unitZ = deltaZ / dh;
float p2 = unitZ * unitZ + 1.0;
float dir = step(deltaZ, 0.0);
float z0 = mix(sourceZ, targetZ, dir);
float r = mix(ratio, 1.0 - ratio, dir);
return sqrt(r * (p2 - r)) * dh + z0;
}
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
return dir_screenspace * offset_direction * width / 2.0;
}
float getSegmentRatio(float index) {
return smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0));
}
vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {
float distance = length(source.xy - target.xy);
float z = paraboloid(distance, source.z, target.z, segmentRatio);
float tiltAngle = radians(instanceTilts);
vec2 tiltDirection = normalize(target.xy - source.xy);
vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);
return vec3(
mix(source.xy, target.xy, segmentRatio) + tilt,
z * cos(tiltAngle)
);
}
float getAngularDist (vec2 source, vec2 target) {
vec2 sourceRadians = radians(source);
vec2 targetRadians = radians(target);
vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);
vec2 shd_sq = sin_half_delta * sin_half_delta;
float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;
return 2.0 * asin(sqrt(a));
}
vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {
vec2 lngLat;
if(abs(angularDist - PI) < 0.001) {
lngLat = (1.0 - t) * source.xy + t * target.xy;
} else {
float a = sin((1.0 - t) * angularDist);
float b = sin(t * angularDist);
vec3 p = source3D.yxz * a + target3D.yxz * b;
lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));
}
float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);
return vec3(lngLat, z);
}
void main(void) {
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
float segmentIndex = float(gl_VertexID / 2);
float segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.;
float segmentRatio = getSegmentRatio(segmentIndex);
float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));
float nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0));
float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
isValid = 1.0;
uv = vec2(segmentRatio, segmentSide);
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
vec4 curr;
vec4 next;
vec3 source;
vec3 target;
if ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
source = project_globe_(vec3(instanceSourcePositions.xy, 0.0));
target = project_globe_(vec3(instanceTargetPositions.xy, 0.0));
float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);
vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);
vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);
vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);
if (abs(currPos.x - prevPos.x) > 180.0) {
indexDir = -1.0;
isValid = 0.0;
} else if (abs(currPos.x - nextPos.x) > 180.0) {
indexDir = 1.0;
isValid = 0.0;
}
nextPos = indexDir < 0.0 ? prevPos : nextPos;
nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
if (isValid == 0.0) {
nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;
float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);
currPos = mix(currPos, nextPos, t);
segmentRatio = mix(segmentRatio, nextSegmentRatio, t);
}
vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);
vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);
curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);
next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));
} else {
vec3 source_world = instanceSourcePositions;
vec3 target_world = instanceTargetPositions;
if (arc.useShortestPath) {
source_world.x = mod(source_world.x + 180., 360.0) - 180.;
target_world.x = mod(target_world.x + 180., 360.0) - 180.;
float deltaLng = target_world.x - source_world.x;
if (deltaLng > 180.) target_world.x -= 360.;
if (deltaLng < -180.) source_world.x -= 360.;
}
source = project_position(source_world, instanceSourcePositions64Low);
target = project_position(target_world, instanceTargetPositions64Low);
float antiMeridianX = 0.0;
if (arc.useShortestPath) {
if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
antiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE;
}
float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);
if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {
isValid = 0.0;
indexDir = sign(segmentRatio - thresholdRatio);
segmentRatio = thresholdRatio;
}
}
nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
vec3 currPos = interpolateFlat(source, target, segmentRatio);
vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);
if (arc.useShortestPath) {
if (nextPos.x < antiMeridianX) {
currPos.x += TILE_SIZE;
nextPos.x += TILE_SIZE;
}
}
curr = project_common_position_to_clipspace(vec4(currPos, 1.0));
next = project_common_position_to_clipspace(vec4(nextPos, 1.0));
geometry.position = vec4(currPos, 1.0);
}
float widthPixels = clamp(
project_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits),
arc.widthMinPixels, arc.widthMaxPixels
);
vec3 offset = vec3(
getExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels),
0.0);
DECKGL_FILTER_SIZE(offset, geometry);
DECKGL_FILTER_GL_POSITION(curr, geometry);
gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);
vColor = vec4(color.rgb, color.a * layer.opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var jB=`#version 300 es
#define SHADER_NAME arc-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 uv;
in float isValid;
out vec4 fragColor;
void main(void) {
if (isValid == 0.0) {
discard;
}
fragColor = vColor;
geometry.uv = uv;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var V_=[0,0,0,255],iQ={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:V_},getTargetColor:{type:"accessor",value:V_},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},zu=class extends _e{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:HB,fs:jB,modules:[fe,Se,zB]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:V_},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:V_},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:o,widthMinPixels:n,widthMaxPixels:i,greatCircle:s,wrapLongitude:a,numSegments:c}=this.props,l={numSegments:c,widthUnits:Pe[r],widthScale:o,widthMinPixels:n,widthMaxPixels:i,greatCircle:s,useShortestPath:a},f=this.state.model;f.shaderInputs.setProps({arc:l}),f.setVertexCount(c*2),f.draw(this.context.renderPass)}_getModel(){return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}};zu.layerName="ArcLayer";zu.defaultProps=iQ;var z_=zu;var sQ=new Uint32Array([0,2,1,0,3,2]),aQ=new Float32Array([0,1,0,0,1,0,1,1]);function H1(t,e){if(!e)return cQ(t);let r=Math.max(Math.abs(t[0][0]-t[3][0]),Math.abs(t[1][0]-t[2][0])),o=Math.max(Math.abs(t[1][1]-t[0][1]),Math.abs(t[2][1]-t[3][1])),n=Math.ceil(r/e)+1,i=Math.ceil(o/e)+1,s=(n-1)*(i-1)*6,a=new Uint32Array(s),c=new Float32Array(n*i*2),l=new Float64Array(n*i*3),f=0,u=0;for(let d=0;d<n;d++){let h=d/(n-1);for(let p=0;p<i;p++){let m=p/(i-1),g=lQ(t,h,m);l[f*3+0]=g[0],l[f*3+1]=g[1],l[f*3+2]=g[2]||0,c[f*2+0]=h,c[f*2+1]=1-m,d>0&&p>0&&(a[u++]=f-i,a[u++]=f-i-1,a[u++]=f-1,a[u++]=f-i,a[u++]=f-1,a[u++]=f),f++}}return{vertexCount:s,positions:l,indices:a,texCoords:c}}function cQ(t){let e=new Float64Array(12);for(let r=0;r<t.length;r++)e[r*3+0]=t[r][0],e[r*3+1]=t[r][1],e[r*3+2]=t[r][2]||0;return{vertexCount:6,positions:e,indices:sQ,texCoords:aQ}}function lQ(t,e,r){return lt(lt(t[0],t[1],r),lt(t[3],t[2],r),e)}var WB=`layout(std140) uniform bitmapUniforms {
vec4 bounds;
float coordinateConversion;
float desaturate;
vec3 tintColor;
vec4 transparentColor;
} bitmap;
`,GB={name:"bitmap",vs:WB,fs:WB,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};var $B=`#version 300 es
#define SHADER_NAME bitmap-layer-vertex-shader
in vec2 texCoords;
in vec3 positions;
in vec3 positions64Low;
out vec2 vTexCoord;
out vec2 vTexPos;
const vec3 pickingColor = vec3(1.0, 0.0, 0.0);
void main(void) {
geometry.worldPosition = positions;
geometry.uv = texCoords;
geometry.pickingColor = pickingColor;
gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vTexCoord = texCoords;
if (bitmap.coordinateConversion < -0.5) {
vTexPos = geometry.position.xy + project.commonOrigin.xy;
} else if (bitmap.coordinateConversion > 0.5) {
vTexPos = geometry.worldPosition.xy;
}
vec4 color = vec4(0.0);
DECKGL_FILTER_COLOR(color, geometry);
}
`;var fQ=`
vec3 packUVsIntoRGB(vec2 uv) {
// Extract the top 8 bits. We want values to be truncated down so we can add a fraction
vec2 uv8bit = floor(uv * 256.);
// Calculate the normalized remainders of u and v parts that do not fit into 8 bits
// Scale and clamp to 0-1 range
vec2 uvFraction = fract(uv * 256.);
vec2 uvFraction4bit = floor(uvFraction * 16.);
// Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates
float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;
return vec3(uv8bit, fractions) / 255.;
}
`,XB=`#version 300 es
#define SHADER_NAME bitmap-layer-fragment-shader
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D bitmapTexture;
in vec2 vTexCoord;
in vec2 vTexPos;
out vec4 fragColor;
/* projection utils */
const float TILE_SIZE = 512.0;
const float PI = 3.1415926536;
const float WORLD_SCALE = TILE_SIZE / PI / 2.0;
// from degrees to Web Mercator
vec2 lnglat_to_mercator(vec2 lnglat) {
float x = lnglat.x;
float y = clamp(lnglat.y, -89.9, 89.9);
return vec2(
radians(x) + PI,
PI + log(tan(PI * 0.25 + radians(y) * 0.5))
) * WORLD_SCALE;
}
// from Web Mercator to degrees
vec2 mercator_to_lnglat(vec2 xy) {
xy /= WORLD_SCALE;
return degrees(vec2(
xy.x - PI,
atan(exp(xy.y - PI)) * 2.0 - PI * 0.5
));
}
/* End projection utils */
// apply desaturation
vec3 color_desaturate(vec3 color) {
float luminance = (color.r + color.g + color.b) * 0.333333333;
return mix(color, vec3(luminance), bitmap.desaturate);
}
// apply tint
vec3 color_tint(vec3 color) {
return color * bitmap.tintColor;
}
// blend with background color
vec4 apply_opacity(vec3 color, float alpha) {
if (bitmap.transparentColor.a == 0.0) {
return vec4(color, alpha);
}
float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);
float highLightRatio = alpha / blendedAlpha;
vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio);
return vec4(blendedRGB, blendedAlpha);
}
vec2 getUV(vec2 pos) {
return vec2(
(pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),
(pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])
);
}
${fQ}
void main(void) {
vec2 uv = vTexCoord;
if (bitmap.coordinateConversion < -0.5) {
vec2 lnglat = mercator_to_lnglat(vTexPos);
uv = getUV(lnglat);
} else if (bitmap.coordinateConversion > 0.5) {
vec2 commonPos = lnglat_to_mercator(vTexPos);
uv = getUV(commonPos);
}
vec4 bitmapColor = texture(bitmapTexture, uv);
fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);
geometry.uv = uv;
DECKGL_FILTER_COLOR(fragColor, geometry);
if (bool(picking.isActive) && !bool(picking.isAttribute)) {
// Since instance information is not used, we can use picking color for pixel index
fragColor.rgb = packUVsIntoRGB(uv);
}
}
`;var uQ={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},Hu=class extends _e{getShaders(){return super.getShaders({vs:$B,fs:XB,modules:[fe,Se,GB]})}initializeState(){let e=this.getAttributeManager();e.remove(["instancePickingColors"]);let r=!0;e.add({indices:{size:1,isIndexed:!0,update:o=>o.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:o=>o.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:o=>o.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:e,oldProps:r,changeFlags:o}){let n=this.getAttributeManager();if(o.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll()),e.bounds!==r.bounds){let i=this.state.mesh,s=this._createMesh();this.state.model.setVertexCount(s.vertexCount);for(let a in s)i&&i[a]!==s[a]&&n.invalidate(a);this.setState({mesh:s,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:r}=this.props,o=e.info;if(!o.color||!r)return o.bitmap=null,o;let{width:n,height:i}=r;o.index=0;let s=dQ(o.color);return o.bitmap={size:{width:n,height:i},uv:s,pixel:[Math.floor(s[0]*n),Math.floor(s[1]*i)]},o}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,r=e;return YB(e)&&(r=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),H1(r,this.context.viewport.resolution)}_getModel(){return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){let{shaderModuleProps:r}=e,{model:o,coordinateConversion:n,bounds:i,disablePicking:s}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:f}=this.props;if(!(r.picking.isActive&&s)&&a&&o){let u={bitmapTexture:a,bounds:i,coordinateConversion:n,desaturate:c,tintColor:f.slice(0,3).map(d=>d/255),transparentColor:l.map(d=>d/255)};o.shaderInputs.setProps({bitmap:u}),o.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){let{bounds:r}=this.props;if(!YB(r))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&o==="cartesian")return{coordinateConversion:-1,bounds:r};if(e==="cartesian"&&o==="lnglat"){let n=Oe([r[0],r[1]]),i=Oe([r[2],r[3]]);return{coordinateConversion:1,bounds:[n[0],n[1],i[0],i[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};Hu.layerName="BitmapLayer";Hu.defaultProps=uQ;var H_=Hu;function dQ(t){let[e,r,o]=t,n=(o&240)/256,i=(o&15)/16;return[(e+i)/256,(r+n)/256]}function YB(t){return Number.isFinite(t[0])}var KB=`layout(std140) uniform iconUniforms {
float sizeScale;
vec2 iconsTextureDim;
float sizeBasis;
float sizeMinPixels;
float sizeMaxPixels;
bool billboard;
highp int sizeUnits;
float alphaCutoff;
} icon;
`,qB={name:"icon",vs:KB,fs:KB,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}};var ZB=`#version 300 es
#define SHADER_NAME icon-layer-vertex-shader
in vec2 positions;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in float instanceSizes;
in float instanceAngles;
in vec4 instanceColors;
in vec3 instancePickingColors;
in vec4 instanceIconFrames;
in float instanceColorModes;
in vec2 instanceOffsets;
in vec2 instancePixelOffset;
out float vColorMode;
out vec4 vColor;
out vec2 vTextureCoords;
out vec2 uv;
vec2 rotate_by_angle(vec2 vertex, float angle) {
float angle_radian = angle * PI / 180.0;
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
}
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vec2 iconSize = instanceIconFrames.zw;
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
icon.sizeMinPixels, icon.sizeMaxPixels
);
float iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;
float instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;
vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
pixelOffset += instancePixelOffset;
pixelOffset.y *= -1.0;
if (icon.billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
DECKGL_FILTER_SIZE(offset_common, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vTextureCoords = mix(
instanceIconFrames.xy,
instanceIconFrames.xy + iconSize,
(positions.xy + 1.0) / 2.0
) / icon.iconsTextureDim;
vColor = instanceColors;
DECKGL_FILTER_COLOR(vColor, geometry);
vColorMode = instanceColorModes;
}
`;var JB=`#version 300 es
#define SHADER_NAME icon-layer-fragment-shader
precision highp float;
uniform sampler2D iconsTexture;
in float vColorMode;
in vec4 vColor;
in vec2 vTextureCoords;
in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
vec4 texColor = texture(iconsTexture, vTextureCoords);
vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);
float a = texColor.a * layer.opacity * vColor.a;
if (a < icon.alphaCutoff) {
discard;
}
fragColor = vec4(color, a);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var QB=`struct IconUniforms {
sizeScale: f32,
iconsTextureDim: vec2<f32>,
sizeBasis: f32,
sizeMinPixels: f32,
sizeMaxPixels: f32,
billboard: i32,
sizeUnits: i32,
alphaCutoff: f32
};
@group(0) @binding(auto) var<uniform> icon: IconUniforms;
@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;
@group(0) @binding(auto) var iconsTextureSampler : sampler;
fn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {
let angle_radian = angle_deg * PI / 180.0;
let c = cos(angle_radian);
let s = sin(angle_radian);
let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c));
return rotation * vertex;
}
struct Attributes {
@location(0) positions: vec2<f32>,
@location(1) instancePositions: vec3<f32>,
@location(2) instancePositions64Low: vec3<f32>,
@location(3) instanceSizes: f32,
@location(4) instanceAngles: f32,
@location(5) instanceColors: vec4<f32>,
@location(6) instancePickingColors: vec3<f32>,
@location(7) instanceIconFrames: vec4<f32>,
@location(8) instanceColorModes: f32,
@location(9) instanceOffsets: vec2<f32>,
@location(10) instancePixelOffset: vec2<f32>,
};
struct Varyings {
@builtin(position) position: vec4<f32>,
@location(0) vColorMode: f32,
@location(1) vColor: vec4<f32>,
@location(2) vTextureCoords: vec2<f32>,
@location(3) uv: vec2<f32>,
@location(4) pickingColor: vec3<f32>,
};
@vertex
fn vertexMain(inp: Attributes) -> Varyings {
// write geometry fields used by filters + FS
geometry.worldPosition = inp.instancePositions;
geometry.uv = inp.positions;
geometry.pickingColor = inp.instancePickingColors;
var outp: Varyings;
outp.uv = inp.positions;
let iconSize = inp.instanceIconFrames.zw;
// convert size in meters to pixels, then clamp
let sizePixels = clamp(
project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),
icon.sizeMinPixels, icon.sizeMaxPixels
);
// scale icon height to match instanceSize
let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0);
let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0);
// scale and rotate vertex in "pixel" units; then add per-instance pixel offset
var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;
pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;
pixelOffset = pixelOffset + inp.instancePixelOffset;
pixelOffset.y = pixelOffset.y * -1.0;
if (icon.billboard != 0) {
var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position);
// DECKGL_FILTER_GL_POSITION(pos, geometry);
var offset = vec3<f32>(pixelOffset, 0.0);
// DECKGL_FILTER_SIZE(offset, geometry);
let clipOffset = project_pixel_size_to_clipspace(offset.xy);
pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);
outp.position = pos;
} else {
var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);
// DECKGL_FILTER_SIZE(offset_common, geometry);
var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position);
// DECKGL_FILTER_GL_POSITION(pos, geometry);
outp.position = pos;
}
let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;
outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;
outp.vColor = inp.instanceColors;
// DECKGL_FILTER_COLOR(outp.vColor, geometry);
outp.vColorMode = inp.instanceColorModes;
outp.pickingColor = inp.instancePickingColors;
return outp;
}
@fragment
fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {
// expose to deck.gl filter hooks
geometry.uv = inp.uv;
let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);
// if colorMode == 0, use pixel color from the texture
// if colorMode == 1 (or picking), use texture as transparency mask
let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode);
let a = texColor.a * layer.opacity * inp.vColor.a;
if (a < icon.alphaCutoff) {
discard;
}
if (picking.isActive > 0.5) {
if (!picking_isColorValid(inp.pickingColor)) {
discard;
}
return vec4<f32>(inp.pickingColor, 1.0);
}
var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a));
if (picking.isHighlightActive > 0.5) {
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {
let highLightAlpha = picking.highlightColor.a;
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
if (blendedAlpha > 0.0) {
let highLightRatio = highLightAlpha / blendedAlpha;
fragColor = vec4<f32>(
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
blendedAlpha
);
} else {
fragColor = vec4<f32>(fragColor.rgb, 0.0);
}
}
}
return fragColor;
}
`;function j_(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var Vo={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},hQ=Vo.self||Vo.window||Vo.global||{},pQ=Vo.window||Vo.self||Vo.global||{},mQ=Vo.global||Vo.self||Vo.window||{},gQ=Vo.document||{};var ju=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var eO=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),_Q=eO&&parseFloat(eO[1])||0;zn();var j1="4.4.1",yQ=j1[0]>="0"&&j1[0]<="9"?`v${j1}`:"";function xQ(){let t=new ct({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=yQ,globalThis.probe||={},globalThis.probe.loaders=t,t}var W1=xQ();var bQ=t=>typeof t=="boolean",zo=t=>typeof t=="function",Ho=t=>t!==null&&typeof t=="object",W_=t=>Ho(t)&&t.constructor==={}.constructor;var G1=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,Tc=t=>Ho(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var $1=t=>Boolean(t)&&zo(t[Symbol.iterator]),X1=t=>Boolean(t)&&zo(t[Symbol.asyncIterator]);var mr=t=>typeof Response<"u"&&t instanceof Response||Ho(t)&&zo(t.arrayBuffer)&&zo(t.text)&&zo(t.json);var gr=t=>typeof Blob<"u"&&t instanceof Blob;var tO=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||Ho(t)&&zo(t.tee)&&zo(t.cancel)&&zo(t.getReader);var rO=t=>Ho(t)&&zo(t.read)&&zo(t.pipe)&&bQ(t.readable),Wu=t=>tO(t)||rO(t);function Y1(t,e){return oO(t||{},e)}function oO(t,e,r=0){if(r>3)return e;let o={...t};for(let[n,i]of Object.entries(e))i&&typeof i=="object"&&!Array.isArray(i)?o[n]=oO(o[n]||{},e[n],r+1):o[n]=e[n];return o}var nO="latest";function AQ(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}var iO=AQ();function Ht(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var jo={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},YVe=jo.self||jo.window||jo.global||{},KVe=jo.window||jo.self||jo.global||{},qVe=jo.global||jo.self||jo.window||{},ZVe=jo.document||{};var Br=typeof process!="object"||String(process)!=="[object process]"||process.browser;var aO=typeof window<"u"&&typeof window.orientation<"u",sO=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),JVe=sO&&parseFloat(sO[1])||0;var Gu=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((o,n)=>{this._resolve=o,this._reject=n})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){Ht(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Ht(this.isRunning),this.isRunning=!1,this._reject(e)}};var vc=class{terminate(){}};var K1=new Map;function cO(t){Ht(t.source&&!t.url||!t.source&&t.url);let e=K1.get(t.source||t.url);return e||(t.url&&(e=TQ(t.url),K1.set(t.url,e)),t.source&&(e=lO(t.source),K1.set(t.source,e))),Ht(e),e}function TQ(t){if(!t.startsWith("http"))return t;let e=vQ(t);return lO(e)}function lO(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function vQ(t){return`try {
importScripts('${t}');
} catch (error) {
console.error(error);
throw error;
}`}function q1(t,e=!0,r){let o=r||new Set;if(t){if(fO(t))o.add(t);else if(fO(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let n in t)q1(t[n],e,o)}}return r===void 0?Array.from(o):[]}function fO(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Z1=()=>{},gi=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Br||typeof vc<"u"&&!Br}constructor(e){let{name:r,source:o,url:n}=e;Ht(o||n),this.name=r,this.source=o,this.url=n,this.onMessage=Z1,this.onError=i=>console.log(i),this.worker=Br?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Z1,this.onError=Z1,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||q1(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=cO({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let o=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,n=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new vc(o,{eval:!1,type:n})}else if(this.source)e=new vc(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var $u=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return gi.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},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(n,i,s)=>n.done(s),o=(n,i)=>n.error(i)){let n=new Promise(i=>(this.jobQueue.push({name:e,onMessage:r,onError:o,onStart:i}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let o=new Gu(r.name,e);e.onMessage=n=>r.onMessage(o,n.type,n.payload),e.onError=n=>r.onError(o,n),r.onStart(o);try{await o.result}catch(n){console.error(`Worker exception: ${n}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Br||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++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new gi({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return aO?this.maxMobileConcurrency:this.maxConcurrency}};var SQ={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Ps=class{props;workerPools=new Map;static isSupported(){return gi.isSupported()}static getWorkerFarm(e={}){return Ps._workerFarm=Ps._workerFarm||new Ps({}),Ps._workerFarm.setProps(e),Ps._workerFarm}constructor(e){this.props={...SQ},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:o,url:n}=e,i=this.workerPools.get(r);return i||(i=new $u({name:r,source:o,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},_i=Ps;k(_i,"_workerFarm");function J1(t,e={}){let r=e[t.id]||{},o=Br?`${t.id}-worker.js`:`${t.id}-worker-node.js`,n=r.workerUrl;if(!n&&t.id==="compression"&&(n=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Br?n=`modules/${t.module}/dist/${o}`:n=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!n){let s=t.version;s==="latest"&&(s=nO);let a=s?`@${s}`:"";n=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${o}`}return Ht(n),n}function Q1(t,e=iO){Ht(t,"no worker provided");let r=t.version;return!(!e||!r)}function eS(t,e){if(!_i.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Br&&!r)return!1;let o=e?.worker??e?.core?.worker;return Boolean(t.worker&&o)}async function tS(t,e,r,o,n){let i=t.id,s=J1(t,r),c=_i.getWorkerFarm(r?.core).getWorkerPool({name:i,url:s});r=JSON.parse(JSON.stringify(r)),o=JSON.parse(JSON.stringify(o||{}));let l=await c.startJob("process-on-worker",CQ.bind(null,n));return l.postMessage("process",{input:e,options:r,context:o}),await(await l.result).result}async function CQ(t,e,r,o){switch(r){case"done":e.done(o);break;case"error":e.error(new Error(o.error));break;case"process":let{id:n,input:i,options:s}=o;try{let a=await t(i,s);e.postMessage("done",{id:n,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:n,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function rS(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let o=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<o.length;++i)if(o[i]!==n[i])return!1;return!0}function oS(...t){return uO(t)}function uO(t){let e=t.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),r=e.reduce((i,s)=>i+s.byteLength,0),o=new Uint8Array(r),n=0;for(let i of e)o.set(i,n),n+=i.byteLength;return o.buffer}async function nS(t){let e=[];for await(let r of t)e.push(EQ(r));return oS(...e)}function EQ(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:o}=t;return dO(e,r,o)}return dO(t)}function dO(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}var wQ="",hO={};function iS(t){for(let e in hO)if(t.startsWith(e)){let r=hO[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${wQ}${t}`),t}function $_(t){return t&&typeof t=="object"&&t.isBuffer}function Sc(t){if($_(t))return t;if(t instanceof ArrayBuffer)return t;if(G1(t))return G_(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Xu(t){if(t instanceof ArrayBuffer)return t;if(G1(t))return G_(t);let{buffer:e,byteOffset:r,byteLength:o}=t;return e instanceof ArrayBuffer&&r===0&&o===e.byteLength?e:G_(e,r,o)}function G_(t,e=0,r=t.byteLength-e){let o=new Uint8Array(t,e,r),n=new Uint8Array(o.length);return n.set(o),n.buffer}function sS(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Sn={};ze(Sn,{dirname:()=>MQ,filename:()=>PQ,join:()=>RQ,resolve:()=>IQ});function pO(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function PQ(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function MQ(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function RQ(...t){let e="/";return t=t.map((r,o)=>(o&&(r=r.replace(new RegExp(`^${e}`),"")),o!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function IQ(...t){let e=[];for(let i=0;i<t.length;i++)e[i]=t[i];let r="",o=!1,n;for(let i=e.length-1;i>=-1&&!o;i--){let s;i>=0?s=e[i]:(n===void 0&&(n=pO()),s=n),s.length!==0&&(r=`${s}/${r}`,o=s.charCodeAt(0)===Yu)}return r=LQ(r,!o),o?`/${r}`:r.length>0?r:"."}var Yu=47,aS=46;function LQ(t,e){let r="",o=-1,n=0,i,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)i=t.charCodeAt(a);else{if(i===Yu)break;i=Yu}if(i===Yu){if(!(o===a-1||n===1))if(o!==a-1&&n===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==aS||r.charCodeAt(r.length-2)!==aS){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Yu;--l);if(l!==c){r=l===-1?"":r.slice(0,l),o=a,n=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",o=a,n=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(o+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}o=a,n=0}else i===aS&&n!==-1?++n:n=-1}return r}var X_=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var FQ=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,NQ=/^([-\w.]+\/[-\w.+]+)/;function cS(t,e){return t.toLowerCase()===e.toLowerCase()}function mO(t){let e=NQ.exec(t);return e?e[1]:t}function lS(t){let e=FQ.exec(t);return e?e[1]:""}var gO=/\?.*/;function _O(t){let e=t.match(gO);return e&&e[0]}function yi(t){return t.replace(gO,"")}function yO(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Ms(t){return mr(t)?t.url:gr(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Cc(t){if(mr(t)){let e=t.headers.get("content-type")||"",r=yi(t.url);return mO(e)||lS(r)}return gr(t)?t.type||"":typeof t=="string"?lS(t):""}function xO(t){return mr(t)?t.headers["content-length"]||-1:gr(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Y_(t){if(mr(t))return t;let e={},r=xO(t);r>=0&&(e["content-length"]=String(r));let o=Ms(t),n=Cc(t);n&&(e["content-type"]=n);let i=await UQ(t);i&&(e["x-first-bytes"]=i),typeof t=="string"&&(t=new TextEncoder().encode(t));let s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:o}),s}async function bO(t){if(!t.ok)throw await DQ(t)}async function DQ(t){let e=yO(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let o={reason:t.statusText,url:t.url,response:t};try{let n=t.headers.get("Content-Type");o.reason=!t.bodyUsed&&n?.includes("application/json")?await t.json():await t.text()}catch{}return new X_(r,o)}async function UQ(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(o=>{let n=new FileReader;n.onload=i=>o(i?.target?.result),n.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${kQ(r)}`}return null}function kQ(t){let e="",r=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)e+=String.fromCharCode(r[o]);return btoa(e)}function VQ(t){return!zQ(t)&&!HQ(t)}function zQ(t){return t.startsWith("http:")||t.startsWith("https:")}function HQ(t){return t.startsWith("data:")}async function fS(t,e){if(typeof t=="string"){let r=iS(t);return VQ(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await Y_(t)}zn();var Ku=new ct({id:"loaders.gl"}),K_=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},q_=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)}};var Z_={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new q_,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:ju,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},AO={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"};var uS=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function dS(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function hS(){let t=dS();return t.globalOptions=t.globalOptions||{...Z_,core:{...Z_.core}},Cn(t.globalOptions)}function SO(t,e,r,o){return r=r||[],r=Array.isArray(r)?r:[r],jQ(t,r),Cn(GQ(e,t,o))}function Cn(t){let e=XQ(t);CO(e);for(let r of uS)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function jQ(t,e){TO(t,null,Z_,AO,e);for(let r of e){let o=t&&t[r.id]||{},n=r.options&&r.options[r.id]||{},i=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};TO(o,r.id,n,i,e)}}function TO(t,e,r,o,n){let i=e||"Top level",s=e?`${e}.`:"";for(let a in t){let c=!e&&Ho(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in o)Ku.level>0&&Ku.warn(`${i} loader option '${s}${a}' no longer supported, use '${o[a]}'`)();else if(!c&&Ku.level>0){let u=WQ(a,n);Ku.warn(`${i} loader option '${s}${a}' not recognized. ${u}`)()}}}}function WQ(t,e){let r=t.toLowerCase(),o="";for(let n of e)for(let i in n.options){if(t===i)return`Did you mean '${n.id}.${i}'?`;let s=i.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(o=o||`Did you mean '${n.id}.${i}'?`)}return o}function GQ(t,e,r){let o=t.options||{},n={...o};o.core&&(n.core={...o.core}),CO(n),n.core?.log===null&&(n.core={...n.core,log:new K_}),vO(n,Cn(hS()));let i=Cn(e);return vO(n,i),$Q(n,r),YQ(n),n}function vO(t,e){for(let r in e)if(r in e){let o=e[r];W_(o)&&W_(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function $Q(t,e){if(!e)return;t.core?.baseUrl!==void 0||(t.core||={},t.core.baseUrl=Sn.dirname(yi(e)))}function XQ(t){let e={...t};return t.core&&(e.core={...t.core}),e}function CO(t){t.baseUri!==void 0&&(t.core||={},t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(let r of uS)if(t[r]!==void 0){let n=t.core=t.core||{};n[r]===void 0&&(n[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function YQ(t){let e=t.core;if(e)for(let r of uS)e[r]!==void 0&&(t[r]=e[r])}function qu(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function pS(t){j_(t,"null loader"),j_(qu(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var KQ=()=>{let t=dS();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function EO(){return KQ()}var qQ=/\.([^.]+)$/;async function MO(t,e=[],r,o){if(!RO(t))return null;let n=Cn(r||{});if(n.core||={},t instanceof Response&&wO(t)){let s=await t.clone().text(),a=J_(s,e,{...n,core:{...n.core,nothrow:!0}},o);if(a)return a}let i=J_(t,e,{...n,core:{...n.core,nothrow:!0}},o);if(i)return i;if(gr(t)&&(t=await t.slice(0,10).arrayBuffer(),i=J_(t,e,n,o)),!i&&t instanceof Response&&wO(t)){let s=await t.clone().text();i=J_(s,e,n,o)}if(!i&&!n.core.nothrow)throw new Error(IO(t));return i}function wO(t){let e=Cc(t);return Boolean(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function J_(t,e=[],r,o){if(!RO(t))return null;let n=Cn(r||{});if(n.core||={},e&&!Array.isArray(e))return pS(e);let i=[];e&&(i=i.concat(e)),n.core.ignoreRegisteredLoaders||i.push(...EO()),JQ(i);let s=ZQ(t,i,n,o);if(!s&&!n.core.nothrow)throw new Error(IO(t));return s}function ZQ(t,e,r,o){let n=Ms(t),i=Cc(t),s=yi(n)||o?.url,a=null,c="";return r?.core?.mimeType&&(a=mS(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||QQ(e,s),c=c||(a?`matched url ${s}`:""),a=a||mS(e,i),c=c||(a?`matched MIME type ${i}`:""),a=a||tee(e,t),c=c||(a?`matched initial data ${LO(t)}`:""),r?.core?.fallbackMimeType&&(a=a||mS(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${i}`:"")),c&&W1.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function RO(t){return!(t instanceof Response&&t.status===204)}function IO(t){let e=Ms(t),r=Cc(t),o="No valid loader found (";o+=e?`${Sn.filename(e)}, `:"no url provided, ",o+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let n=t?LO(t):"";return o+=n?` first bytes: "${n}"`:"first bytes: not available",o+=")",o}function JQ(t){for(let e of t)pS(e)}function QQ(t,e){let r=e&&qQ.exec(e),o=r&&r[1];return o?eee(t,o):null}function eee(t,e){e=e.toLowerCase();for(let r of t)for(let o of r.extensions)if(o.toLowerCase()===e)return r;return null}function mS(t,e){for(let r of t)if(r.mimeTypes?.some(o=>cS(e,o))||cS(e,`application/x.${r.id}`))return r;return null}function tee(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(ree(e,r))return r}else if(ArrayBuffer.isView(e)){if(PO(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&PO(e,0,r))return r;return null}function ree(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(o=>t.startsWith(o))}function PO(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>oee(t,e,r,n))}function oee(t,e,r,o){if(Tc(o))return rS(o,t,o.byteLength);switch(typeof o){case"function":return o(Xu(t));case"string":let n=gS(t,e,o.length);return o===n;default:return!1}}function LO(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?gS(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?gS(t,0,e):""}function gS(t,e,r){if(t.byteLength<e+r)return"";let o=new DataView(t),n="";for(let i=0;i<r;i++)n+=String.fromCharCode(o.getUint8(e+i));return n}var nee=256*1024;function*BO(t,e){let r=e?.chunkSize||nee,o=0,n=new TextEncoder;for(;o<t.length;){let i=Math.min(t.length-o,r),s=t.slice(o,o+i);o+=i,yield Xu(n.encode(s))}}function*OO(t,e={}){let{chunkSize:r=262144}=e,o=0;for(;o<t.byteLength;){let n=Math.min(t.byteLength-o,r),i=new ArrayBuffer(n),s=new Uint8Array(t,o,n);new Uint8Array(i).set(s),o+=n,yield i}}async function*FO(t,e){let r=e?.chunkSize||1048576,o=0;for(;o<t.size;){let n=o+r,i=await t.slice(o,n).arrayBuffer();o=n,yield i}}function _S(t,e){return ju?iee(t,e):see(t,e)}async function*iee(t,e){let r=t.getReader(),o;try{for(;;){let n=o||r.read();e?._streamReadAhead&&(o=r.read());let{done:i,value:s}=await n;if(i)return;yield Sc(s)}}catch{r.releaseLock()}}async function*see(t,e){for await(let r of t)yield Sc(r)}function NO(t,e){if(typeof t=="string")return BO(t,e);if(t instanceof ArrayBuffer)return OO(t,e);if(gr(t))return FO(t,e);if(Wu(t))return _S(t,e);if(mr(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return _S(r,e)}throw new Error("makeIterator")}var DO="Cannot convert supplied data type";function aee(t,e,r){if(e.text&&typeof t=="string")return t;if($_(t)&&(t=t.buffer),Tc(t)){let o=sS(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(o):Sc(o)}throw new Error(DO)}async function UO(t,e,r){if(typeof t=="string"||Tc(t))return aee(t,e,r);if(gr(t)&&(t=await Y_(t)),mr(t))return await bO(t),e.binary?await t.arrayBuffer():await t.text();if(Wu(t)&&(t=NO(t,r)),$1(t)||X1(t))return nS(t);throw new Error(DO)}function Q_(t,e){let r=hS(),o=t||r,n=o.fetch??o.core?.fetch;return typeof n=="function"?n:Ho(n)?i=>fS(i,n):e?.fetch?e?.fetch:fS}function kO(t,e,r){if(r)return r;let o={fetch:Q_(e,t),...t};if(o.url){let n=yi(o.url);o.baseUrl=n,o.queryString=_O(o.url),o.filename=Sn.filename(n),o.baseUrl=Sn.dirname(n)}return Array.isArray(o.loaders)||(o.loaders=null),o}function VO(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let o=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...o]:o}return r&&r.length?r:void 0}async function Zu(t,e,r,o){e&&!Array.isArray(e)&&!qu(e)&&(o=void 0,r=e,e=void 0),t=await t,r=r||{};let n=Ms(t),s=VO(e,o),a=await MO(t,s,r);if(!a)return null;let c=SO(r,a,s,n);return o=kO({url:n,_parse:Zu,loaders:s},c,o||null),await cee(a,t,c,o)}async function cee(t,e,r,o){if(Q1(t),r=Y1(t.options,r),mr(e)){let{ok:i,redirected:s,status:a,statusText:c,type:l,url:f}=e,u=Object.fromEntries(e.headers.entries());o.response={headers:u,ok:i,redirected:s,status:a,statusText:c,type:l,url:f}}e=await UO(e,t,r);let n=t;if(n.parseTextSync&&typeof e=="string")return n.parseTextSync(e,r,o);if(eS(t,r))return await tS(t,e,r,o,Zu);if(n.parseText&&typeof e=="string")return await n.parseText(e,r,o);if(n.parse)return await n.parse(e,r,o);throw Ht(!n.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function _r(t,e,r,o){let n,i;!Array.isArray(e)&&!qu(e)?(n=[],i=e,o=void 0):(n=e,i=r);let s=Q_(i),a=t;return typeof t=="string"&&(a=await s(t)),gr(t)&&(a=await s(t)),typeof t=="string"&&(Cn(i||{}).core?.baseUrl||(i={...i,core:{...i?.core,baseUrl:t}})),Array.isArray(n)?await Zu(a,n,i):await Zu(a,n,i)}function yS(t,e,r){let o=r?.core?.type||r.type||"auto",n=o==="auto"?lee(t,e):fee(o,e);if(!n)throw new Error("Not a valid source type");return n.createDataSource(t,r)}function lee(t,e){for(let r of e)if(r.testURL&&r.testURL(t))return r;return null}function fee(t,e){for(let r of e)if(r.type===t)return r;return null}var uee=1024,dee=4,zO=()=>{},HO={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},hee={x:0,y:0,width:0,height:0};function pee(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function mee(t,e,r,o){let n=Math.min(r/e.width,o/e.height),i=Math.floor(e.width*n),s=Math.floor(e.height*n);return n===1?{image:e,width:i,height:s}:(t.canvas.height=s,t.canvas.width=i,t.clearRect(0,0,i,s),t.drawImage(e,0,0,e.width,e.height,0,0,i,s),{image:t.canvas,width:i,height:s})}function Ju(t){return t&&(t.id||t.url)}function WO(t){let{device:e}=t;e.type==="webgl"?t.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(t)}function gee(t,e,r,o){let{width:n,height:i,device:s}=t,a=s.createTexture({format:"rgba8unorm",width:e,height:r,sampler:o,mipLevels:s.getMipLevelCount(e,r)}),c=s.createCommandEncoder();c.copyTextureToTexture({sourceTexture:t,destinationTexture:a,width:n,height:i});let l=c.finish();return s.submit(l),WO(a),t.destroy(),a}function jO(t,e,r){for(let o=0;o<e.length;o++){let{icon:n,xOffset:i}=e[o],s=Ju(n);t[s]={...n,x:i,y:r}}}function _ee({icons:t,buffer:e,mapping:r={},xOffset:o=0,yOffset:n=0,rowHeight:i=0,canvasWidth:s}){let a=[];for(let c=0;c<t.length;c++){let l=t[c],f=Ju(l);if(!r[f]){let{height:u,width:d}=l;o+d+e>s&&(jO(r,a,n),o=0,n=i+n+e,i=0,a=[]),a.push({icon:l,xOffset:o}),o=o+d+e,i=Math.max(i,u)}}return a.length>0&&jO(r,a,n),{mapping:r,rowHeight:i,xOffset:o,yOffset:n,canvasWidth:s,canvasHeight:pee(i+n+e)}}function yee(t,e,r){if(!t||!e)return null;r=r||{};let o={},{iterable:n,objectInfo:i}=Fe(t);for(let s of n){i.index++;let a=e(s,i),c=Ju(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!o[c]&&(!r[c]||a.url!==r[c].url)&&(o[c]={...a,source:s,sourceIndex:i.index})}return o}var Qu=class{constructor(e,{onUpdate:r=zO,onError:o=zO}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=dee,this._canvasWidth=uee,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=r,this.onError=o}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let r=this._autoPacking?Ju(e):e;return this._mapping[r]||hee}setProps({loadOptions:e,autoPacking:r,iconAtlas:o,iconMapping:n,textureParameters:i}){e&&(this._loadOptions=e),r!==void 0&&(this._autoPacking=r),n&&(this._mapping=n),o&&(this._texture?.delete(),this._texture=null,this._externalTexture=o),i&&(this._samplerParameters=i)}get isLoaded(){return this._pendingCount===0}packIcons(e,r){if(!this._autoPacking||typeof document>"u")return;let o=Object.values(yee(e,r,this._mapping)||{});if(o.length>0){let{mapping:n,xOffset:i,yOffset:s,rowHeight:a,canvasHeight:c}=_ee({icons:o,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=n,this._xOffset=i,this._yOffset=s,this._canvasHeight=c,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||HO,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=gee(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||HO)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(o)}}_loadIcons(e){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let o of e)this._pendingCount++,_r(o.url,this._loadOptions).then(n=>{let i=Ju(o),s=this._mapping[i],{x:a,y:c,width:l,height:f}=s,{image:u,width:d,height:h}=mee(r,n,l,f),p=a+(l-d)/2,m=c+(f-h)/2;this._texture?.copyExternalImage({image:u,x:p,y:m,width:d,height:h}),s.x=p,s.y=m,s.width=d,s.height=h,this._texture&&WO(this._texture),this.onUpdate(d!==l||h!==f)}).catch(n=>{this.onError({url:o.url,source:o.source,sourceIndex:o.sourceIndex,loadOptions:this._loadOptions,error:n})}).finally(()=>{this._pendingCount--})}};var GO=[0,0,0,255],xee={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:GO},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},ed=class extends _e{getShaders(){return super.getShaders({vs:ZB,fs:JB,source:QB,modules:[fe,Yr,Se,qB]})}initializeState(){this.state={iconManager:new Qu(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,accessor:"getIcon",transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:GO},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,i=this.getAttributeManager(),{iconAtlas:s,iconMapping:a,data:c,getIcon:l,textureParameters:f}=r,{iconManager:u}=this.state;if(typeof s=="string")return;let d=s||this.internalState.isAsyncPropLoading("iconAtlas");u.setProps({loadOptions:r.loadOptions,autoPacking:!d,iconAtlas:s,iconMapping:d?a:null,textureParameters:f}),d?o.iconMapping!==r.iconMapping&&i.invalidate("getIcon"):(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getIcon))&&u.packIcons(c,l),n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:r,sizeBasis:o,sizeMinPixels:n,sizeMaxPixels:i,sizeUnits:s,billboard:a,alphaCutoff:c}=this.props,{iconManager:l}=this.state,f=l.getTexture();if(f){let u=this.state.model,d={iconsTexture:f,iconsTextureDim:[f.width,f.height],sizeUnits:Pe[s],sizeScale:r,sizeBasis:o==="height"?1:0,sizeMinPixels:n,sizeMaxPixels:i,billboard:a,alphaCutoff:c};u.shaderInputs.setProps({icon:d}),u.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(e){e?(this.getAttributeManager()?.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){let r=this.getCurrentLayer()?.props.onIconError;r?r(e):N.error(e.error.message)()}getInstanceIconDef(e){let{x:r,y:o,width:n,height:i,mask:s,anchorX:a=n/2,anchorY:c=i/2}=this.state.iconManager.getIconMapping(e);return[n/2-a,i/2-c,r,o,n,i,s?1:0]}};ed.defaultProps=xee;ed.layerName="IconLayer";var Ec=ed;var $O=`layout(std140) uniform lineUniforms {
float widthScale;
float widthMinPixels;
float widthMaxPixels;
float useShortestPath;
highp int widthUnits;
} line;
`,XO={name:"line",source:"",vs:$O,fs:$O,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}};var YO=`// ---------- Helper Structures & Functions ----------
// Placeholder filter functions.
fn deckgl_filter_size(offset: vec3<f32>, geometry: Geometry) -> vec3<f32> {
return offset;
}
fn deckgl_filter_gl_position(p: vec4<f32>, geometry: Geometry) -> vec4<f32> {
if (picking.isAttribute > 0.5) {
// For depth picking, write normalized depth into the picking payload.
// This mirrors the legacy DECKGL_FILTER_GL_POSITION hook on WebGL.
}
return p;
}
// Compute an extrusion offset given a line direction (in clipspace),
// an offset direction (-1 or 1), and a width in pixels.
// Assumes a uniform "project" with a viewportSize field is available.
fn getExtrusionOffset(line_clipspace: vec2<f32>, offset_direction: f32, width: f32) -> vec2<f32> {
// project.viewportSize should be provided as a uniform (not shown here)
let dir_screenspace = normalize(line_clipspace * project.viewportSize);
// Rotate by 90\xB0: (x,y) becomes (-y,x)
let rotated = vec2<f32>(-dir_screenspace.y, dir_screenspace.x);
return rotated * offset_direction * width / 2.0;
}
// Splits the line between two points at a given x coordinate.
// Interpolates the y and z components.
fn splitLine(a: vec3<f32>, b: vec3<f32>, x: f32) -> vec3<f32> {
let t: f32 = (x - a.x) / (b.x - a.x);
return vec3<f32>(x, a.yz + t * (b.yz - a.yz));
}
// ---------- Uniforms & Global Structures ----------
struct LineUniforms {
widthScale: f32,
widthMinPixels: f32,
widthMaxPixels: f32,
useShortestPath: f32,
widthUnits: i32,
};
@group(0) @binding(0)
var<uniform> line: LineUniforms;
// ---------- Vertex Output Structure ----------
struct Varyings {
@builtin(position) gl_Position: vec4<f32>,
@location(0) vColor: vec4<f32>,
@location(1) uv: vec2<f32>,
@location(2) pickingColor: vec3<f32>,
};
// ---------- Vertex Shader Entry Point ----------
@vertex
fn vertexMain(
@location(0) positions: vec3<f32>,
@location(1) instanceSourcePositions: vec3<f32>,
@location(2) instanceTargetPositions: vec3<f32>,
@location(3) instanceSourcePositions64Low: vec3<f32>,
@location(4) instanceTargetPositions64Low: vec3<f32>,
@location(5) instanceColors: vec4<f32>,
@location(6) instancePickingColors: vec3<f32>,
@location(7) instanceWidths: f32
) -> Varyings {
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
var source_world: vec3<f32> = instanceSourcePositions;
var target_world: vec3<f32> = instanceTargetPositions;
var source_world_64low: vec3<f32> = instanceSourcePositions64Low;
var target_world_64low: vec3<f32> = instanceTargetPositions64Low;
// Apply shortest-path adjustments if needed.
if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {
source_world.x = (source_world.x + 180.0 % 360.0) - 180.0;
target_world.x = (target_world.x + 180.0 % 360.0) - 180.0;
let deltaLng: f32 = target_world.x - source_world.x;
if (deltaLng * line.useShortestPath > 180.0) {
source_world.x = source_world.x + 360.0 * line.useShortestPath;
source_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);
source_world_64low = vec3<f32>(0.0, 0.0, 0.0);
} else if (deltaLng * line.useShortestPath < -180.0) {
target_world.x = target_world.x + 360.0 * line.useShortestPath;
target_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath);
target_world_64low = vec3<f32>(0.0, 0.0, 0.0);
} else if (line.useShortestPath < 0.0) {
var abortOut: Varyings;
abortOut.gl_Position = vec4<f32>(0.0);
abortOut.vColor = vec4<f32>(0.0);
abortOut.uv = vec2<f32>(0.0);
return abortOut;
}
}
// Project Pos and target positions to clip space.
let sourceResult = project_position_to_clipspace_and_commonspace(source_world, source_world_64low, vec3<f32>(0.0));
let targetResult = project_position_to_clipspace_and_commonspace(target_world, target_world_64low, vec3<f32>(0.0));
let sourcePos: vec4<f32> = sourceResult.clipPosition;
let targetPos: vec4<f32> = targetResult.clipPosition;
let source_commonspace: vec4<f32> = sourceResult.commonPosition;
let target_commonspace: vec4<f32> = targetResult.commonPosition;
// Interpolate along the line segment.
let segmentIndex: f32 = positions.x;
let p: vec4<f32> = sourcePos + segmentIndex * (targetPos - sourcePos);
geometry.position = source_commonspace + segmentIndex * (target_commonspace - source_commonspace);
let uv: vec2<f32> = positions.xy;
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
// Determine width in pixels.
let widthPixels: f32 = clamp(
project_unit_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),
line.widthMinPixels, line.widthMaxPixels
);
// Compute extrusion offset.
let extrusion: vec2<f32> = getExtrusionOffset(targetPos.xy - sourcePos.xy, positions.y, widthPixels);
let offset: vec3<f32> = vec3<f32>(extrusion, 0.0);
// Apply deck.gl filter functions.
let filteredOffset = deckgl_filter_size(offset, geometry);
let filteredP = deckgl_filter_gl_position(p, geometry);
let clipOffset: vec2<f32> = project_pixel_size_to_clipspace(filteredOffset.xy);
let finalPosition: vec4<f32> = filteredP + vec4<f32>(clipOffset, 0.0, 0.0);
// Compute color.
var vColor: vec4<f32> = vec4<f32>(instanceColors.rgb, instanceColors.a * layer.opacity);
// vColor = deckgl_filter_color(vColor, geometry);
var output: Varyings;
output.gl_Position = finalPosition;
output.vColor = vColor;
output.uv = uv;
output.pickingColor = instancePickingColors;
return output;
}
@fragment
fn fragmentMain(
@location(0) vColor: vec4<f32>,
@location(1) uv: vec2<f32>,
@location(2) pickingColor: vec3<f32>
) -> @location(0) vec4<f32> {
// Create and initialize geometry with the provided uv.
var geometry: Geometry;
geometry.uv = uv;
// Start with the input color.
var fragColor: vec4<f32> = vColor;
if (picking.isActive > 0.5) {
if (!picking_isColorValid(pickingColor)) {
discard;
}
return vec4<f32>(pickingColor, 1.0);
}
if (picking.isHighlightActive > 0.5) {
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
if (picking_isColorZero(abs(pickingColor - highlightedObjectColor))) {
let highLightAlpha = picking.highlightColor.a;
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
if (blendedAlpha > 0.0) {
let highLightRatio = highLightAlpha / blendedAlpha;
fragColor = vec4<f32>(
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
blendedAlpha
);
} else {
fragColor = vec4<f32>(fragColor.rgb, 0.0);
}
}
}
// Apply premultiplied alpha as required by transparent canvas
fragColor = deckgl_premultiplied_alpha(fragColor);
return fragColor;
}
`;var KO=`#version 300 es
#define SHADER_NAME line-layer-vertex-shader
in vec3 positions;
in vec3 instanceSourcePositions;
in vec3 instanceTargetPositions;
in vec3 instanceSourcePositions64Low;
in vec3 instanceTargetPositions64Low;
in vec4 instanceColors;
in vec3 instancePickingColors;
in float instanceWidths;
out vec4 vColor;
out vec2 uv;
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
return dir_screenspace * offset_direction * width / 2.0;
}
vec3 splitLine(vec3 a, vec3 b, float x) {
float t = (x - a.x) / (b.x - a.x);
return vec3(x, mix(a.yz, b.yz, t));
}
void main(void) {
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
vec3 source_world = instanceSourcePositions;
vec3 target_world = instanceTargetPositions;
vec3 source_world_64low = instanceSourcePositions64Low;
vec3 target_world_64low = instanceTargetPositions64Low;
if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {
source_world.x = mod(source_world.x + 180., 360.0) - 180.;
target_world.x = mod(target_world.x + 180., 360.0) - 180.;
float deltaLng = target_world.x - source_world.x;
if (deltaLng * line.useShortestPath > 180.) {
source_world.x += 360. * line.useShortestPath;
source_world = splitLine(source_world, target_world, 180. * line.useShortestPath);
source_world_64low = vec3(0.0);
} else if (deltaLng * line.useShortestPath < -180.) {
target_world.x += 360. * line.useShortestPath;
target_world = splitLine(source_world, target_world, 180. * line.useShortestPath);
target_world_64low = vec3(0.0);
} else if (line.useShortestPath < 0.) {
gl_Position = vec4(0.);
return;
}
}
vec4 source_commonspace;
vec4 target_commonspace;
vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace);
vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace);
float segmentIndex = positions.x;
vec4 p = mix(source, target, segmentIndex);
geometry.position = mix(source_commonspace, target_commonspace, segmentIndex);
uv = positions.xy;
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
float widthPixels = clamp(
project_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits),
line.widthMinPixels, line.widthMaxPixels
);
vec3 offset = vec3(
getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels),
0.0);
DECKGL_FILTER_SIZE(offset, geometry);
DECKGL_FILTER_GL_POSITION(p, geometry);
gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var qO=`#version 300 es
#define SHADER_NAME line-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var bee=[0,0,0,255],Aee={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:bee},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},td=class extends _e{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:KO,fs:qO,source:YO,modules:[fe,Yr,Se,XO]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:o,widthMinPixels:n,widthMaxPixels:i,wrapLongitude:s}=this.props,a=this.state.model,c={widthUnits:Pe[r],widthScale:o,widthMinPixels:n,widthMaxPixels:i,useShortestPath:s?1:0};a.shaderInputs.setProps({line:c}),a.draw(this.context.renderPass),s&&(a.shaderInputs.setProps({line:{...c,useShortestPath:-1}}),a.draw(this.context.renderPass))}_getModel(){let e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};td.layerName="LineLayer";td.defaultProps=Aee;var ZO=td;var JO=`layout(std140) uniform pointCloudUniforms {
float radiusPixels;
highp int sizeUnits;
} pointCloud;
`,QO={name:"pointCloud",source:"",vs:JO,fs:JO,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}};var eF=`#version 300 es
#define SHADER_NAME point-cloud-layer-vertex-shader
in vec3 positions;
in vec3 instanceNormals;
in vec4 instanceColors;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in vec3 instancePickingColors;
out vec4 vColor;
out vec2 unitPosition;
void main(void) {
geometry.worldPosition = instancePositions;
geometry.normal = project_normal(instanceNormals);
unitPosition = positions.xy;
geometry.uv = unitPosition;
geometry.pickingColor = instancePickingColors;
vec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, instanceColors.a * layer.opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var tF=`#version 300 es
#define SHADER_NAME point-cloud-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 unitPosition;
out vec4 fragColor;
void main(void) {
geometry.uv = unitPosition.xy;
float distToCenter = length(unitPosition);
if (distToCenter > 1.0) {
discard;
}
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var rF=`struct PointCloudUniforms {
radiusPixels: f32,
sizeUnits: i32,
};
@group(0) @binding(0)
var<uniform> pointCloudUniforms: PointCloudUniforms;
struct ConstantAttributes {
instanceNormals: vec3<f32>,
instanceColors: vec4<f32>,
instancePositions: vec3<f32>,
instancePositions64Low: vec3<f32>,
instancePickingColors: vec3<f32>
};
const constants = ConstantAttributes(
vec3<f32>(1.0, 0.0, 0.0),
vec4<f32>(0.0, 0.0, 0.0, 1.0),
vec3<f32>(0.0),
vec3<f32>(0.0),
vec3<f32>(0.0)
);
struct Attributes {
@builtin(instance_index) instanceIndex : u32,
@builtin(vertex_index) vertexIndex : u32,
@location(0) positions: vec3<f32>,
@location(1) instancePositions: vec3<f32>,
@location(2) instancePositions64Low: vec3<f32>,
@location(3) instanceNormals: vec3<f32>,
@location(4) instanceColors: vec4<f32>,
@location(5) instancePickingColors: vec3<f32>
};
struct Varyings {
@builtin(position) position: vec4<f32>,
@location(0) vColor: vec4<f32>,
@location(1) unitPosition: vec2<f32>,
@location(2) pickingColor: vec3<f32>,
};
@vertex
fn vertexMain(attributes: Attributes) -> Varyings {
var varyings: Varyings;
geometry.worldPosition = attributes.instancePositions;
let centerResult = project_position_to_clipspace_and_commonspace(
attributes.instancePositions,
attributes.instancePositions64Low,
vec3<f32>(0.0)
);
geometry.position = centerResult.commonPosition;
geometry.normal = project_normal(attributes.instanceNormals);
// position on the containing square in [-1, 1] space
varyings.unitPosition = attributes.positions.xy;
geometry.uv = varyings.unitPosition;
geometry.pickingColor = attributes.instancePickingColors;
// Find the center of the point and add the current vertex
let offset = vec3<f32>(
attributes.positions.xy *
project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits),
0.0
);
// DECKGL_FILTER_SIZE(offset, geometry);
varyings.position = centerResult.clipPosition;
// DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
let clipPixels = project_pixel_size_to_clipspace(offset.xy);
varyings.position.x += clipPixels.x;
varyings.position.y += clipPixels.y;
// Apply lighting
let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
// Apply opacity to instance color, or return instance picking color
varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity);
// DECKGL_FILTER_COLOR(vColor, geometry);
varyings.pickingColor = attributes.instancePickingColors;
return varyings;
}
@fragment
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
// var geometry: Geometry;
// geometry.uv = unitPosition.xy;
let distToCenter = length(varyings.unitPosition);
if (distToCenter > 1.0) {
discard;
}
var fragColor: vec4<f32>;
fragColor = varyings.vColor;
if (picking.isActive > 0.5) {
if (!picking_isColorValid(varyings.pickingColor)) {
discard;
}
return vec4<f32>(varyings.pickingColor, 1.0);
}
if (picking.isHighlightActive > 0.5) {
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
let highLightAlpha = picking.highlightColor.a;
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
if (blendedAlpha > 0.0) {
let highLightRatio = highLightAlpha / blendedAlpha;
fragColor = vec4<f32>(
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
blendedAlpha
);
} else {
fragColor = vec4<f32>(fragColor.rgb, 0.0);
}
}
}
// Apply premultiplied alpha as required by transparent canvas
fragColor = deckgl_premultiplied_alpha(fragColor);
return fragColor;
}
`;var oF=[0,0,0,255],nF=[0,0,1],Tee={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:nF},getColor:{type:"accessor",value:oF},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function vee(t){let{header:e,attributes:r}=t;if(!(!e||!r)&&(t.length=e.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:o,value:n}=r.COLOR_0;r.instanceColors={size:o,type:"unorm8",value:n}}}var rd=class extends _e{getShaders(){return super.getShaders({vs:eF,fs:tF,source:rF,modules:[fe,Yr,Xr,Se,QO]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:nF},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:oF}})}updateState(e){let{changeFlags:r,props:o}=e;super.updateState(e),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&vee(o.data)}draw({uniforms:e}){let{pointSize:r,sizeUnits:o}=this.props,n=this.state.model,i={sizeUnits:Pe[o],radiusPixels:r};n.shaderInputs.setProps({pointCloud:i}),n.draw(this.context.renderPass)}_getModel(){let e=[];for(let r=0;r<3;r++){let o=r/3*Math.PI*2;e.push(Math.cos(o)*2,Math.sin(o)*2,0)}return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}};rd.layerName="PointCloudLayer";rd.defaultProps=Tee;var e0=rd;var iF=`layout(std140) uniform scatterplotUniforms {
float radiusScale;
float radiusMinPixels;
float radiusMaxPixels;
float lineWidthScale;
float lineWidthMinPixels;
float lineWidthMaxPixels;
float stroked;
float filled;
bool antialiasing;
bool billboard;
highp int radiusUnits;
highp int lineWidthUnits;
} scatterplot;
`,sF={name:"scatterplot",vs:iF,fs:iF,source:"",uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var aF=`#version 300 es
#define SHADER_NAME scatterplot-layer-vertex-shader
in vec3 positions;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in float instanceRadius;
in float instanceLineWidths;
in vec4 instanceFillColors;
in vec4 instanceLineColors;
in vec3 instancePickingColors;
in vec2 instancePixelOffset;
out vec4 vFillColor;
out vec4 vLineColor;
out vec2 unitPosition;
out float innerUnitRadius;
out float outerRadiusPixels;
void main(void) {
geometry.worldPosition = instancePositions;
outerRadiusPixels = clamp(
project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),
scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
);
float lineWidthPixels = clamp(
project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),
scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
);
outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
unitPosition = edgePadding * positions.xy;
geometry.uv = unitPosition;
geometry.pickingColor = instancePickingColors;
innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;
if (scatterplot.billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = edgePadding * positions * outerRadiusPixels;
offset.xy += instancePixelOffset;
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
offset.xy += project_pixel_size(instancePixelOffset);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
DECKGL_FILTER_COLOR(vFillColor, geometry);
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
DECKGL_FILTER_COLOR(vLineColor, geometry);
}
`;var cF=`#version 300 es
#define SHADER_NAME scatterplot-layer-fragment-shader
precision highp float;
in vec4 vFillColor;
in vec4 vLineColor;
in vec2 unitPosition;
in float innerUnitRadius;
in float outerRadiusPixels;
out vec4 fragColor;
void main(void) {
geometry.uv = unitPosition;
float distToCenter = length(unitPosition) * outerRadiusPixels;
float inCircle = scatterplot.antialiasing ?
smoothedge(distToCenter, outerRadiusPixels) :
step(distToCenter, outerRadiusPixels);
if (inCircle == 0.0) {
discard;
}
if (scatterplot.stroked > 0.5) {
float isLine = scatterplot.antialiasing ?
smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
step(innerUnitRadius * outerRadiusPixels, distToCenter);
if (scatterplot.filled > 0.5) {
fragColor = mix(vFillColor, vLineColor, isLine);
} else {
if (isLine == 0.0) {
discard;
}
fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
}
} else if (scatterplot.filled < 0.5) {
discard;
} else {
fragColor = vFillColor;
}
fragColor.a *= inCircle;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var lF=`// Main shaders
struct ScatterplotUniforms {
radiusScale: f32,
radiusMinPixels: f32,
radiusMaxPixels: f32,
lineWidthScale: f32,
lineWidthMinPixels: f32,
lineWidthMaxPixels: f32,
stroked: f32,
filled: i32,
antialiasing: i32,
billboard: i32,
radiusUnits: i32,
lineWidthUnits: i32,
};
struct ConstantAttributeUniforms {
instancePositions: vec3<f32>,
instancePositions64Low: vec3<f32>,
instanceRadius: f32,
instanceLineWidths: f32,
instanceFillColors: vec4<f32>,
instanceLineColors: vec4<f32>,
instancePickingColors: vec3<f32>,
instancePixelOffset: vec2<f32>,
instancePositionsConstant: i32,
instancePositions64LowConstant: i32,
instanceRadiusConstant: i32,
instanceLineWidthsConstant: i32,
instanceFillColorsConstant: i32,
instanceLineColorsConstant: i32,
instancePickingColorsConstant: i32,
instancePixelOffsetConstant: i32
};
@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;
struct ConstantAttributes {
instancePositions: vec3<f32>,
instancePositions64Low: vec3<f32>,
instanceRadius: f32,
instanceLineWidths: f32,
instanceFillColors: vec4<f32>,
instanceLineColors: vec4<f32>,
instancePickingColors: vec3<f32>,
instancePixelOffset: vec2<f32>
};
const constants = ConstantAttributes(
vec3<f32>(0.0),
vec3<f32>(0.0),
0.0,
0.0,
vec4<f32>(0.0, 0.0, 0.0, 1.0),
vec4<f32>(0.0, 0.0, 0.0, 1.0),
vec3<f32>(0.0),
vec2<f32>(0.0)
);
struct Attributes {
@builtin(instance_index) instanceIndex : u32,
@builtin(vertex_index) vertexIndex : u32,
@location(0) positions: vec3<f32>,
@location(1) instancePositions: vec3<f32>,
@location(2) instancePositions64Low: vec3<f32>,
@location(3) instanceRadius: f32,
@location(4) instanceLineWidths: f32,
@location(5) instanceFillColors: vec4<f32>,
@location(6) instanceLineColors: vec4<f32>,
@location(7) instancePickingColors: vec3<f32>,
@location(8) instancePixelOffset: vec2<f32>
};
struct Varyings {
@builtin(position) position: vec4<f32>,
@location(0) vFillColor: vec4<f32>,
@location(1) vLineColor: vec4<f32>,
@location(2) unitPosition: vec2<f32>,
@location(3) innerUnitRadius: f32,
@location(4) outerRadiusPixels: f32,
@location(5) pickingColor: vec3<f32>,
};
@vertex
fn vertexMain(attributes: Attributes) -> Varyings {
var varyings: Varyings;
// Draw an inline geometry constant array clip space triangle to verify that rendering works.
// var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));
// if (attributes.instanceIndex == 0) {
// varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);
// return varyings;
// }
geometry.worldPosition = attributes.instancePositions;
// Multiply out radius and clamp to limits
varyings.outerRadiusPixels = clamp(
project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),
scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
);
// Multiply out line width and clamp to limits
let lineWidthPixels = clamp(
project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),
scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
);
// outer radius needs to offset by half stroke width
varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
// Expand geometry to accommodate edge smoothing
let edgePadding = select(
(varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,
1.0,
scatterplot.antialiasing != 0
);
// position on the containing square in [-1, 1] space
varyings.unitPosition = edgePadding * attributes.positions.xy;
geometry.uv = varyings.unitPosition;
geometry.pickingColor = attributes.instancePickingColors;
varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;
if (scatterplot.billboard != 0) {
varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);
// DECKGL_FILTER_GL_POSITION(varyings.position, geometry);
var offset = edgePadding * attributes.positions * varyings.outerRadiusPixels;
offset = vec3<f32>(offset.xy + attributes.instancePixelOffset, offset.z);
// DECKGL_FILTER_SIZE(offset, geometry);
let clipPixels = project_pixel_size_to_clipspace(offset.xy);
varyings.position = vec4<f32>(varyings.position.x + clipPixels.x, varyings.position.y + clipPixels.y, varyings.position.z, varyings.position.w);
} else {
var offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);
offset = vec3<f32>(offset.xy + project_pixel_size_vec2(attributes.instancePixelOffset), offset.z);
// DECKGL_FILTER_SIZE(offset, geometry);
varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);
// DECKGL_FILTER_GL_POSITION(varyings.position, geometry);
}
// Apply opacity to instance color, or return instance picking color
varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity);
// DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);
varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity);
// DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);
varyings.pickingColor = attributes.instancePickingColors;
return varyings;
}
@fragment
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
// var geometry: Geometry;
// geometry.uv = unitPosition;
let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;
let inCircle = select(
smoothedge(distToCenter, varyings.outerRadiusPixels),
step(distToCenter, varyings.outerRadiusPixels),
scatterplot.antialiasing != 0
);
if (inCircle == 0.0) {
discard;
}
var fragColor: vec4<f32>;
if (scatterplot.stroked != 0) {
let isLine = select(
smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),
step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),
scatterplot.antialiasing != 0
);
if (scatterplot.filled != 0) {
fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);
} else {
if (isLine == 0.0) {
discard;
}
fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);
}
} else if (scatterplot.filled == 0) {
discard;
} else {
fragColor = varyings.vFillColor;
}
fragColor.a *= inCircle;
if (picking.isActive > 0.5) {
if (!picking_isColorValid(varyings.pickingColor)) {
discard;
}
return vec4<f32>(varyings.pickingColor, 1.0);
}
if (picking.isHighlightActive > 0.5) {
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
let highLightAlpha = picking.highlightColor.a;
let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);
if (blendedAlpha > 0.0) {
let highLightRatio = highLightAlpha / blendedAlpha;
fragColor = vec4<f32>(
mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),
blendedAlpha
);
} else {
fragColor = vec4<f32>(fragColor.rgb, 0.0);
}
}
}
// Apply premultiplied alpha as required by transparent canvas
fragColor = deckgl_premultiplied_alpha(fragColor);
return fragColor;
// return vec4<f32>(0, 0, 1, 1);
}
`;var fF=[0,0,0,255],See={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:fF},getLineColor:{type:"accessor",value:fF},getLineWidth:{type:"accessor",value:1},getPixelOffset:{type:"accessor",value:[0,0]},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},od=class extends _e{getShaders(){return super.getShaders({vs:aF,fs:cF,source:lF,modules:[fe,Yr,Se,sF]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:r,radiusScale:o,radiusMinPixels:n,radiusMaxPixels:i,stroked:s,filled:a,billboard:c,antialiasing:l,lineWidthUnits:f,lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:h}=this.props,p={stroked:s,filled:a,billboard:c,antialiasing:l,radiusUnits:Pe[r],radiusScale:o,radiusMinPixels:n,radiusMaxPixels:i,lineWidthUnits:Pe[f],lineWidthScale:u,lineWidthMinPixels:d,lineWidthMaxPixels:h},m=this.state.model;m.shaderInputs.setProps({scatterplot:p}),m.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};od.defaultProps=See;od.layerName="ScatterplotLayer";var t0=od;var wc={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function Rs(t,e,r={}){return uF(t,r)!==e?(Cee(t,r),!0):!1}function uF(t,e={}){return Math.sign(xi(t,e))}var nd={x:0,y:1,z:2};function xi(t,e={}){let{start:r=0,end:o=t.length,plane:n="xy"}=e,i=e.size||2,s=0,a=nd[n[0]],c=nd[n[1]];for(let l=r,f=o-i;l<o;l+=i)s+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return s/2}function Cee(t,e){let{start:r=0,end:o=t.length,size:n=2}=e,i=(o-r)/n,s=Math.floor(i/2);for(let a=0;a<s;++a){let c=r+a*n,l=r+(i-1-a)*n;for(let f=0;f<n;++f){let u=t[c+f];t[c+f]=t[l+f],t[l+f]=u}}}function bS(t,e,r=2,o,n="xy"){let i=e&&e.length,s=i?e[0]*r:t.length,a=hF(t,0,s,r,!0,o&&o[0],n),c=[];if(!a||a.next===a.prev)return c;let l,f,u,d,h,p,m;if(i&&(a=Iee(t,e,a,r,o,n)),t.length>80*r){d=f=t[0],h=u=t[1];for(let g=r;g<s;g+=r)p=t[g],m=t[g+1],p<d&&(d=p),m<h&&(h=m),p>f&&(f=p),m>u&&(u=m);l=Math.max(f-d,u-h),l=l!==0?32767/l:0}return id(a,c,r,d,h,l,0),c}function hF(t,e,r,o,n,i,s){let a,c;i===void 0&&(i=xi(t,{start:e,end:r,size:o,plane:s}));let l=nd[s[0]],f=nd[s[1]];if(n===i<0)for(a=e;a<r;a+=o)c=dF(a,t[a+l],t[a+f],c);else for(a=r-o;a>=e;a-=o)c=dF(a,t[a+l],t[a+f],c);return c&&n0(c,c.next)&&(ad(c),c=c.next),c}function Is(t,e){if(!t)return t;e||(e=t);let r=t,o;do if(o=!1,!r.steiner&&(n0(r,r.next)||ke(r.prev,r,r.next)===0)){if(ad(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function id(t,e,r,o,n,i,s){if(!t)return;!s&&i&&Nee(t,o,n,i);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,i?Pee(t,o,n,i):wee(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),ad(t),t=l.next,a=l.next;continue}if(t=l,t===a){s?s===1?(t=Mee(Is(t),e,r),id(t,e,r,o,n,i,2)):s===2&&Ree(t,e,r,o,n,i):id(Is(t),e,r,o,n,i,1);break}}}function wee(t){let e=t.prev,r=t,o=t.next;if(ke(e,r,o)>=0)return!1;let n=e.x,i=r.x,s=o.x,a=e.y,c=r.y,l=o.y,f=n<i?n<s?n:s:i<s?i:s,u=a<c?a<l?a:l:c<l?c:l,d=n>i?n>s?n:s:i>s?i:s,h=a>c?a>l?a:l:c>l?c:l,p=o.next;for(;p!==e;){if(p.x>=f&&p.x<=d&&p.y>=u&&p.y<=h&&Pc(n,a,i,c,s,l,p.x,p.y)&&ke(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Pee(t,e,r,o){let n=t.prev,i=t,s=t.next;if(ke(n,i,s)>=0)return!1;let a=n.x,c=i.x,l=s.x,f=n.y,u=i.y,d=s.y,h=a<c?a<l?a:l:c<l?c:l,p=f<u?f<d?f:d:u<d?u:d,m=a>c?a>l?a:l:c>l?c:l,g=f>u?f>d?f:d:u>d?u:d,_=xS(h,p,e,r,o),x=xS(m,g,e,r,o),y=t.prevZ,b=t.nextZ;for(;y&&y.z>=_&&b&&b.z<=x;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Pc(a,f,c,u,l,d,y.x,y.y)&&ke(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Pc(a,f,c,u,l,d,b.x,b.y)&&ke(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=h&&y.x<=m&&y.y>=p&&y.y<=g&&y!==n&&y!==s&&Pc(a,f,c,u,l,d,y.x,y.y)&&ke(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=x;){if(b.x>=h&&b.x<=m&&b.y>=p&&b.y<=g&&b!==n&&b!==s&&Pc(a,f,c,u,l,d,b.x,b.y)&&ke(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Mee(t,e,r){let o=t;do{let n=o.prev,i=o.next.next;!n0(n,i)&&pF(n,o,o.next,i)&&sd(n,i)&&sd(i,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(i.i/r|0),ad(o),ad(o.next),o=t=i),o=o.next}while(o!==t);return Is(o)}function Ree(t,e,r,o,n,i){let s=t;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&kee(s,a)){let c=mF(s,a);s=Is(s,s.next),c=Is(c,c.next),id(s,e,r,o,n,i,0),id(c,e,r,o,n,i,0);return}a=a.next}s=s.next}while(s!==t)}function Iee(t,e,r,o,n,i){let s=[],a,c,l,f,u;for(a=0,c=e.length;a<c;a++)l=e[a]*o,f=a<c-1?e[a+1]*o:t.length,u=hF(t,l,f,o,!1,n&&n[a+1],i),u===u.next&&(u.steiner=!0),s.push(Uee(u));for(s.sort(Lee),a=0;a<s.length;a++)r=Bee(s[a],r);return r}function Lee(t,e){return t.x-e.x}function Bee(t,e){let r=Oee(t,e);if(!r)return e;let o=mF(r,t);return Is(o,o.next),Is(r,r.next)}function Oee(t,e){let r=e,o=t.x,n=t.y,i=-1/0,s;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let d=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(d<=o&&d>i&&(i=d,s=r.x<r.next.x?r:r.next,d===o))return s}r=r.next}while(r!==e);if(!s)return null;let a=s,c=s.x,l=s.y,f=1/0,u;r=s;do o>=r.x&&r.x>=c&&o!==r.x&&Pc(n<l?o:i,n,c,l,n<l?i:o,n,r.x,r.y)&&(u=Math.abs(n-r.y)/(o-r.x),sd(r,t)&&(u<f||u===f&&(r.x>s.x||r.x===s.x&&Fee(s,r)))&&(s=r,f=u)),r=r.next;while(r!==a);return s}function Fee(t,e){return ke(t.prev,t,e.prev)<0&&ke(e.next,t,t.next)<0}function Nee(t,e,r,o){let n=t;do n.z===0&&(n.z=xS(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,Dee(n)}function Dee(t){let e,r,o=1,n,i,s,a,c,l;do{for(i=t,t=null,l=null,n=0;i;){for(n++,a=i,s=0,r=0;r<o&&(s++,a=a.nextZ,!!a);r++);for(c=o;s>0||c>0&&a;)s!==0&&(c===0||!a||i.z<=a.z)?(e=i,i=i.nextZ,s--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;i=a}l.nextZ=null,o*=2}while(n>1);return t}function xS(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function Uee(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Pc(t,e,r,o,n,i,s,a){return(n-s)*(e-a)>=(t-s)*(i-a)&&(t-s)*(o-a)>=(r-s)*(e-a)&&(r-s)*(i-a)>=(n-s)*(o-a)}function kee(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Vee(t,e)&&(sd(t,e)&&sd(e,t)&&zee(t,e)&&(ke(t.prev,t,e.prev)||ke(t,e.prev,e))||n0(t,e)&&ke(t.prev,t,t.next)>0&&ke(e.prev,e,e.next)>0)}function ke(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function n0(t,e){return t.x===e.x&&t.y===e.y}function pF(t,e,r,o){let n=o0(ke(t,e,r)),i=o0(ke(t,e,o)),s=o0(ke(r,o,t)),a=o0(ke(r,o,e));return!!(n!==i&&s!==a||n===0&&r0(t,r,e)||i===0&&r0(t,o,e)||s===0&&r0(r,t,o)||a===0&&r0(r,e,o))}function r0(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function o0(t){return t>0?1:t<0?-1:0}function Vee(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&pF(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function sd(t,e){return ke(t.prev,t,t.next)<0?ke(t,e,t.next)>=0&&ke(t,t.prev,e)>=0:ke(t,e,t.prev)<0||ke(t,t.next,e)<0}function zee(t,e){let r=t,o=!1,n=(t.x+e.x)/2,i=(t.y+e.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&n<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function mF(t,e){let r=new cd(t.i,t.x,t.y),o=new cd(e.i,e.x,e.y),n=t.next,i=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,i.next=o,o.prev=i,o}function dF(t,e,r,o){let n=new cd(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function ad(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var cd=class{constructor(e,r,o){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=o}};function Jt(t,e){let r=e.length,o=t.length;if(o>0){let n=!0;for(let i=0;i<r;i++)if(t[o-r+i]!==e[i]){n=!1;break}if(n)return!1}for(let n=0;n<r;n++)t[o+n]=e[n];return!0}function ld(t,e){let r=e.length;for(let o=0;o<r;o++)t[o]=e[o]}function bi(t,e,r,o,n=[]){let i=o+e*r;for(let s=0;s<r;s++)n[s]=t[i+s];return n}function i0(t,e,r,o,n=[]){let i,s;if(r&8)i=(o[3]-t[1])/(e[1]-t[1]),s=3;else if(r&4)i=(o[1]-t[1])/(e[1]-t[1]),s=1;else if(r&2)i=(o[2]-t[0])/(e[0]-t[0]),s=2;else if(r&1)i=(o[0]-t[0])/(e[0]-t[0]),s=0;else return null;for(let a=0;a<t.length;a++)n[a]=(s&1)===a?o[s]:i*(e[a]-t[a])+t[a];return n}function fd(t,e){let r=0;return t[0]<e[0]?r|=1:t[0]>e[2]&&(r|=2),t[1]<e[1]?r|=4:t[1]>e[3]&&(r|=8),r}function ud(t,e){let{size:r=2,broken:o=!1,gridResolution:n=10,gridOffset:i=[0,0],startIndex:s=0,endIndex:a=t.length}=e||{},c=(a-s)/r,l=[],f=[l],u=bi(t,0,r,s),d,h,p=yF(u,n,i,[]),m=[];Jt(l,u);for(let g=1;g<c;g++){for(d=bi(t,g,r,s,d),h=fd(d,p);h;){i0(u,d,h,p,m);let _=fd(m,p);_&&(i0(u,m,_,p,m),h=_),Jt(l,m),ld(u,m),jee(p,n,h),o&&l.length>r&&(l=[],f.push(l),Jt(l,u)),h=fd(d,p)}Jt(l,d),ld(u,d)}return o?f:f[0]}var gF=0,Hee=1;function dd(t,e=null,r){if(!t.length)return[];let{size:o=2,gridResolution:n=10,gridOffset:i=[0,0],edgeTypes:s=!1}=r||{},a=[],c=[{pos:t,types:s?new Array(t.length/o).fill(Hee):null,holes:e||[]}],l=[[],[]],f=[];for(;c.length;){let{pos:u,types:d,holes:h}=c.shift();Wee(u,o,h[0]||u.length,l),f=yF(l[0],n,i,f);let p=fd(l[1],f);if(p){let m=_F(u,d,o,0,h[0]||u.length,f,p),g={pos:m[0].pos,types:m[0].types,holes:[]},_={pos:m[1].pos,types:m[1].types,holes:[]};c.push(g,_);for(let x=0;x<h.length;x++)m=_F(u,d,o,h[x],h[x+1]||u.length,f,p),m[0]&&(g.holes.push(g.pos.length),g.pos=s0(g.pos,m[0].pos),s&&(g.types=s0(g.types,m[0].types))),m[1]&&(_.holes.push(_.pos.length),_.pos=s0(_.pos,m[1].pos),s&&(_.types=s0(_.types,m[1].types)))}else{let m={positions:u};s&&(m.edgeTypes=d),h.length&&(m.holeIndices=h),a.push(m)}}return a}function _F(t,e,r,o,n,i,s){let a=(n-o)/r,c=[],l=[],f=[],u=[],d=[],h,p,m,g=bi(t,a-1,r,o),_=Math.sign(s&8?g[1]-i[3]:g[0]-i[2]),x=e&&e[a-1],y=0,b=0;for(let T=0;T<a;T++)h=bi(t,T,r,o,h),p=Math.sign(s&8?h[1]-i[3]:h[0]-i[2]),m=e&&e[o/r+T],p&&_&&_!==p&&(i0(g,h,s,i,d),Jt(c,d)&&f.push(x),Jt(l,d)&&u.push(x)),p<=0?(Jt(c,h)&&f.push(m),y-=p):f.length&&(f[f.length-1]=gF),p>=0?(Jt(l,h)&&u.push(m),b+=p):u.length&&(u[u.length-1]=gF),ld(g,h),_=p,x=m;return[y?{pos:c,types:e&&f}:null,b?{pos:l,types:e&&u}:null]}function yF(t,e,r,o){let n=Math.floor((t[0]-r[0])/e)*e+r[0],i=Math.floor((t[1]-r[1])/e)*e+r[1];return o[0]=n,o[1]=i,o[2]=n+e,o[3]=i+e,o}function jee(t,e,r){r&8?(t[1]+=e,t[3]+=e):r&4?(t[1]-=e,t[3]-=e):r&2?(t[0]+=e,t[2]+=e):r&1&&(t[0]-=e,t[2]-=e)}function Wee(t,e,r,o){let n=1/0,i=-1/0,s=1/0,a=-1/0;for(let c=0;c<r;c+=e){let l=t[c],f=t[c+1];n=l<n?l:n,i=l>i?l:i,s=f<s?f:s,a=f>a?f:a}return o[0][0]=n,o[0][1]=s,o[1][0]=i,o[1][1]=a,o}function s0(t,e){for(let r=0;r<e.length;r++)t.push(e[r]);return t}var Gee=85.051129;function AS(t,e){let{size:r=2,startIndex:o=0,endIndex:n=t.length,normalize:i=!0}=e||{},s=t.slice(o,n);xF(s,r,0,n-o);let a=ud(s,{size:r,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(i)for(let c of a)bF(c,r);return a}function TS(t,e=null,r){let{size:o=2,normalize:n=!0,edgeTypes:i=!1}=r||{};e=e||[];let s=[],a=[],c=0,l=0;for(let u=0;u<=e.length;u++){let d=e[u]||t.length,h=l,p=$ee(t,o,c,d);for(let m=p;m<d;m++)s[l++]=t[m];for(let m=c;m<p;m++)s[l++]=t[m];xF(s,o,h,l),Xee(s,o,h,l,r?.maxLatitude),c=d,a[u]=l}a.pop();let f=dd(s,a,{size:o,gridResolution:360,gridOffset:[-180,-180],edgeTypes:i});if(n)for(let u of f)bF(u.positions,o);return f}function $ee(t,e,r,o){let n=-1,i=-1;for(let s=r+1;s<o;s+=e){let a=Math.abs(t[s]);a>n&&(n=a,i=s-1)}return i}function Xee(t,e,r,o,n=Gee){let i=t[r],s=t[o-e];if(Math.abs(i-s)>180){let a=bi(t,0,e,r);a[0]+=Math.round((s-i)/360)*360,Jt(t,a),a[1]=Math.sign(a[1])*n,Jt(t,a),a[0]=i,Jt(t,a)}}function xF(t,e,r,o){let n=t[0],i;for(let s=r;s<o;s+=e){i=t[s];let a=i-n;(a>180||a<-180)&&(i-=Math.round(a/360)*360),t[s]=n=i}}function bF(t,e){let r,o=t.length/e;for(let i=0;i<o&&(r=t[i*e],(r+180)%360===0);i++);let n=-Math.round(r/360)*360;if(n!==0)for(let i=0;i<o;i++)t[i*e]+=n}var hd=class extends ce{constructor(e){let{indices:r,attributes:o}=Kee(e);super({...e,indices:r,attributes:o})}};function Kee(t){let{radius:e,height:r=1,nradial:o=10}=t,{vertices:n}=t;n&&(N.assert(n.length>=o),n=n.flatMap(h=>[h[0],h[1]]),Rs(n,wc.COUNTER_CLOCKWISE));let i=r>0,s=o+1,a=i?s*3+1:o,c=Math.PI*2/o,l=new Uint16Array(i?o*3*2:0),f=new Float32Array(a*3),u=new Float32Array(a*3),d=0;if(i){for(let h=0;h<s;h++){let p=h*c,m=h%o,g=Math.sin(p),_=Math.cos(p);for(let x=0;x<2;x++)f[d+0]=n?n[m*2]:_*e,f[d+1]=n?n[m*2+1]:g*e,f[d+2]=(1/2-x)*r,u[d+0]=n?n[m*2]:_,u[d+1]=n?n[m*2+1]:g,d+=3}f[d+0]=f[d-3],f[d+1]=f[d-2],f[d+2]=f[d-1],d+=3}for(let h=i?0:1;h<s;h++){let p=Math.floor(h/2)*Math.sign(.5-h%2),m=p*c,g=(p+o)%o,_=Math.sin(m),x=Math.cos(m);f[d+0]=n?n[g*2]:x*e,f[d+1]=n?n[g*2+1]:_*e,f[d+2]=r/2,u[d+2]=1,d+=3}if(i){let h=0;for(let p=0;p<o;p++)l[h++]=p*2+0,l[h++]=p*2+2,l[h++]=p*2+0,l[h++]=p*2+1,l[h++]=p*2+1,l[h++]=p*2+3}return{indices:l,attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:u}}}}var AF=`layout(std140) uniform columnUniforms {
float radius;
float angle;
vec2 offset;
bool extruded;
bool stroked;
bool isStroke;
float coverage;
float elevationScale;
float edgeDistance;
float widthScale;
float widthMinPixels;
float widthMaxPixels;
highp int radiusUnits;
highp int widthUnits;
} column;
`,TF={name:"column",vs:AF,fs:AF,uniformTypes:{radius:"f32",angle:"f32",offset:"vec2<f32>",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}};var vF=`#version 300 es
#define SHADER_NAME column-layer-vertex-shader
in vec3 positions;
in vec3 normals;
in vec3 instancePositions;
in float instanceElevations;
in vec3 instancePositions64Low;
in vec4 instanceFillColors;
in vec4 instanceLineColors;
in float instanceStrokeWidths;
in vec3 instancePickingColors;
out vec4 vColor;
#ifdef FLAT_SHADING
out vec3 cameraPosition;
out vec4 position_commonspace;
#endif
void main(void) {
geometry.worldPosition = instancePositions;
vec4 color = column.isStroke ? instanceLineColors : instanceFillColors;
mat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle));
float elevation = 0.0;
float strokeOffsetRatio = 1.0;
if (column.extruded) {
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;
} else if (column.stroked) {
float widthPixels = clamp(
project_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits),
column.widthMinPixels, column.widthMaxPixels) / 2.0;
float halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius);
if (column.isStroke) {
strokeOffsetRatio -= sign(positions.z) * halfOffset;
} else {
strokeOffsetRatio -= halfOffset;
}
}
float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);
float dotRadius = column.radius * column.coverage * shouldRender;
geometry.pickingColor = instancePickingColors;
vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);
vec3 centroidPosition64Low = instancePositions64Low;
vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius;
if (column.radiusUnits == UNIT_METERS) {
offset = project_size(offset);
} else if (column.radiusUnits == UNIT_PIXELS) {
offset = project_pixel_size(offset);
}
vec3 pos = vec3(offset, 0.);
DECKGL_FILTER_SIZE(pos, geometry);
gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
if (column.extruded && !column.isStroke) {
#ifdef FLAT_SHADING
cameraPosition = project.cameraPosition;
position_commonspace = geometry.position;
vColor = vec4(color.rgb, color.a * layer.opacity);
#else
vec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, color.a * layer.opacity);
#endif
} else {
vColor = vec4(color.rgb, color.a * layer.opacity);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var SF=`#version 300 es
#define SHADER_NAME column-layer-fragment-shader
precision highp float;
out vec4 fragColor;
in vec4 vColor;
#ifdef FLAT_SHADING
in vec3 cameraPosition;
in vec4 position_commonspace;
#endif
void main(void) {
fragColor = vColor;
geometry.uv = vec2(0.);
#ifdef FLAT_SHADING
if (column.extruded && !column.isStroke && !bool(picking.isActive)) {
vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
fragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);
}
#endif
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var a0=[0,0,0,255],qee={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:a0},getLineColor:{type:"accessor",value:a0},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},pd=class extends _e{getShaders(){let e={},{flatShading:r}=this.props;return r&&(e.FLAT_SHADING=1),super.getShaders({vs:vF,fs:SF,defines:e,modules:[fe,r?nn:Xr,Se,TF]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:a0},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:a0},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,i=n.extensionsChanged||r.flatShading!==o.flatShading;i&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let s=this.getNumInstances();this.state.fillModel.setInstanceCount(s),this.state.wireframeModel.setInstanceCount(s),(i||r.diskResolution!==o.diskResolution||r.vertices!==o.vertices||(r.extruded||r.stroked)!==(o.extruded||o.stroked))&&this._updateGeometry(r)}getGeometry(e,r,o){let n=new hd({radius:1,height:o?2:0,vertices:r,nradial:e}),i=0;if(r)for(let s=0;s<e;s++){let a=r[s],c=Math.sqrt(a[0]*a[0]+a[1]*a[1]);i+=c/e}else i=1;return this.setState({edgeDistance:Math.cos(Math.PI/e)*i}),n}_getModels(){let e=this.getShaders(),r=this.getAttributeManager().getBufferLayouts(),o=new Q(this.context.device,{...e,id:`${this.props.id}-fill`,bufferLayout:r,isInstanced:!0}),n=new Q(this.context.device,{...e,id:`${this.props.id}-wireframe`,bufferLayout:r,isInstanced:!0});return{fillModel:o,wireframeModel:n,models:[n,o]}}_updateGeometry({diskResolution:e,vertices:r,extruded:o,stroked:n}){let i=this.getGeometry(e,r,o||n);this.setState({fillVertexCount:i.attributes.POSITION.value.length/3});let s=this.state.fillModel,a=this.state.wireframeModel,{POSITION:c,NORMAL:l}=i.attributes,f=new ce({topology:"triangle-strip",attributes:{POSITION:c,NORMAL:l}});s.setGeometry(f),a.setGeometry(i),a.setTopology("line-list")}draw({uniforms:e}){let{lineWidthUnits:r,lineWidthScale:o,lineWidthMinPixels:n,lineWidthMaxPixels:i,radiusUnits:s,elevationScale:a,extruded:c,filled:l,stroked:f,wireframe:u,offset:d,coverage:h,radius:p,angle:m}=this.props,g=this.state.fillModel,_=this.state.wireframeModel,{fillVertexCount:x,edgeDistance:y}=this.state,b={radius:p,angle:m/180*Math.PI,offset:d,extruded:c,stroked:f,coverage:h,elevationScale:a,edgeDistance:y,radiusUnits:Pe[s],widthUnits:Pe[r],widthScale:o,widthMinPixels:n,widthMaxPixels:i};c&&u&&(_.shaderInputs.setProps({column:{...b,isStroke:!0}}),_.draw(this.context.renderPass)),l&&(g.setVertexCount(x),g.shaderInputs.setProps({column:{...b,isStroke:!1}}),g.draw(this.context.renderPass)),!c&&f&&(g.setVertexCount(x*2/3),g.shaderInputs.setProps({column:{...b,isStroke:!0}}),g.draw(this.context.renderPass))}};pd.layerName="ColumnLayer";pd.defaultProps=qee;var Wo=pd;var Zee={cellSize:{type:"number",min:0,value:1e3},offset:{type:"array",value:[1,1]}},md=class extends Wo{_updateGeometry(){let e=new dn;this.state.fillModel.setGeometry(e)}draw({uniforms:e}){let{elevationScale:r,extruded:o,offset:n,coverage:i,cellSize:s,angle:a,radiusUnits:c}=this.props,l=this.state.fillModel,f={radius:s/2,radiusUnits:Pe[c],angle:a,offset:n,extruded:o,stroked:!1,coverage:i,elevationScale:r,edgeDistance:1,isStroke:!1,widthUnits:0,widthScale:0,widthMinPixels:0,widthMaxPixels:0};l.shaderInputs.setProps({column:f}),l.draw(this.context.renderPass)}};md.layerName="GridCellLayer";md.defaultProps=Zee;var CF=md;function EF(t,e,r,o){let n;if(Array.isArray(t[0])){let i=t.length*e;n=new Array(i);for(let s=0;s<t.length;s++)for(let a=0;a<e;a++)n[s*e+a]=t[s][a]||0}else n=t;return r?ud(n,{size:e,gridResolution:r}):o?AS(n,{size:e}):n}var Jee=1,Qee=2,vS=4,gd=class extends vn{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?EF(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(wF(e)){let o=0;for(let n of e)o+=this.getGeometrySize(n);return o}let r=this.getPathLength(e);return r<2?0:this.isClosed(e)?r<3?0:r+2:r}updateGeometryAttributes(e,r){if(r.geometrySize!==0)if(e&&wF(e))for(let o of e){let n=this.getGeometrySize(o);r.geometrySize=n,this.updateGeometryAttributes(o,r),r.vertexStart+=n}else this._updateSegmentTypes(e,r),this._updatePositions(e,r)}_updateSegmentTypes(e,r){let o=this.attributes.segmentTypes,n=e?this.isClosed(e):!1,{vertexStart:i,geometrySize:s}=r;o.fill(0,i,i+s),n?(o[i]=vS,o[i+s-2]=vS):(o[i]+=Jee,o[i+s-2]+=Qee),o[i+s-1]=vS}_updatePositions(e,r){let{positions:o}=this.attributes;if(!o||!e)return;let{vertexStart:n,geometrySize:i}=r,s=new Array(3);for(let a=n,c=0;c<i;a++,c++)this.getPointOnPath(e,c,s),o[a*3]=s[0],o[a*3+1]=s[1],o[a*3+2]=s[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,r,o=[]){let{positionSize:n}=this;r*n>=e.length&&(r+=1-e.length/n);let i=r*n;return o[0]=e[i],o[1]=e[i+1],o[2]=n===3&&e[i+2]||0,o}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);let{positionSize:r}=this,o=e.length-r;return e[0]===e[o]&&e[1]===e[o+1]&&(r===2||e[2]===e[o+2])}};function wF(t){return Array.isArray(t[0])}var PF=`layout(std140) uniform pathUniforms {
float widthScale;
float widthMinPixels;
float widthMaxPixels;
float jointType;
float capType;
float miterLimit;
bool billboard;
highp int widthUnits;
} path;
`,MF={name:"path",vs:PF,fs:PF,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var RF=`#version 300 es
#define SHADER_NAME path-layer-vertex-shader
in vec2 positions;
in float instanceTypes;
in vec3 instanceStartPositions;
in vec3 instanceEndPositions;
in vec3 instanceLeftPositions;
in vec3 instanceRightPositions;
in vec3 instanceLeftPositions64Low;
in vec3 instanceStartPositions64Low;
in vec3 instanceEndPositions64Low;
in vec3 instanceRightPositions64Low;
in float instanceStrokeWidths;
in vec4 instanceColors;
in vec3 instancePickingColors;
uniform float opacity;
out vec4 vColor;
out vec2 vCornerOffset;
out float vMiterLength;
out vec2 vPathPosition;
out float vPathLength;
out float vJointType;
const float EPSILON = 0.001;
const vec3 ZERO_OFFSET = vec3(0.0);
float flipIfTrue(bool flag) {
return -(float(flag) * 2. - 1.);
}
vec3 getLineJoinOffset(
vec3 prevPoint, vec3 currPoint, vec3 nextPoint,
vec2 width
) {
bool isEnd = positions.x > 0.0;
float sideOfPath = positions.y;
float isJoint = float(sideOfPath == 0.0);
vec3 deltaA3 = (currPoint - prevPoint);
vec3 deltaB3 = (nextPoint - currPoint);
mat3 rotationMatrix;
bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);
if (needsRotation) {
deltaA3 = deltaA3 * rotationMatrix;
deltaB3 = deltaB3 * rotationMatrix;
}
vec2 deltaA = deltaA3.xy / width;
vec2 deltaB = deltaB3.xy / width;
float lenA = length(deltaA);
float lenB = length(deltaB);
vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);
vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);
vec2 perpA = vec2(-dirA.y, dirA.x);
vec2 perpB = vec2(-dirB.y, dirB.x);
vec2 tangent = dirA + dirB;
tangent = length(tangent) > 0. ? normalize(tangent) : perpA;
vec2 miterVec = vec2(-tangent.y, tangent.x);
vec2 dir = isEnd ? dirA : dirB;
vec2 perp = isEnd ? perpA : perpB;
float L = isEnd ? lenA : lenB;
float sinHalfA = abs(dot(miterVec, perp));
float cosHalfA = abs(dot(dirA, miterVec));
float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);
float cornerPosition = sideOfPath * turnDirection;
float miterSize = 1.0 / max(sinHalfA, EPSILON);
miterSize = mix(
min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),
miterSize,
step(0.0, cornerPosition)
);
vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))
* (sideOfPath + isJoint * turnDirection);
bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));
bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));
bool isCap = isStartCap || isEndCap;
if (isCap) {
offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);
vJointType = path.capType;
} else {
vJointType = path.jointType;
}
vPathLength = L;
vCornerOffset = offsetVec;
vMiterLength = dot(vCornerOffset, miterVec * turnDirection);
vMiterLength = isCap ? isJoint : vMiterLength;
vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);
vPathPosition = vec2(
dot(offsetFromStartOfPath, perp),
dot(offsetFromStartOfPath, dir)
);
geometry.uv = vPathPosition;
float isValid = step(instanceTypes, 3.5);
vec3 offset = vec3(offsetVec * width * isValid, 0.0);
if (needsRotation) {
offset = rotationMatrix * offset;
}
return offset;
}
void clipLine(inout vec4 position, vec4 refPosition) {
if (position.w < EPSILON) {
float r = (EPSILON - refPosition.w) / (position.w - refPosition.w);
position = refPosition + (position - refPosition) * r;
}
}
void main() {
geometry.pickingColor = instancePickingColors;
vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);
float isEnd = positions.x;
vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);
vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);
vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);
vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);
vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);
vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);
geometry.worldPosition = currPosition;
vec2 widthPixels = vec2(clamp(
project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),
path.widthMinPixels, path.widthMaxPixels) / 2.0);
vec3 width;
if (path.billboard) {
vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);
vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);
vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);
clipLine(prevPositionScreen, currPositionScreen);
clipLine(nextPositionScreen, currPositionScreen);
clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));
width = vec3(widthPixels, 0.0);
DECKGL_FILTER_SIZE(width, geometry);
vec3 offset = getLineJoinOffset(
prevPositionScreen.xyz / prevPositionScreen.w,
currPositionScreen.xyz / currPositionScreen.w,
nextPositionScreen.xyz / nextPositionScreen.w,
project_pixel_size_to_clipspace(width.xy)
);
DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);
gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);
} else {
prevPosition = project_position(prevPosition, prevPosition64Low);
currPosition = project_position(currPosition, currPosition64Low);
nextPosition = project_position(nextPosition, nextPosition64Low);
width = vec3(project_pixel_size(widthPixels), 0.0);
DECKGL_FILTER_SIZE(width, geometry);
vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);
geometry.position = vec4(currPosition + offset, 1.0);
gl_Position = project_common_position_to_clipspace(geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var IF=`#version 300 es
#define SHADER_NAME path-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 vCornerOffset;
in float vMiterLength;
in vec2 vPathPosition;
in float vPathLength;
in float vJointType;
out vec4 fragColor;
void main(void) {
geometry.uv = vPathPosition;
if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {
if (vJointType > 0.5 && length(vCornerOffset) > 1.0) {
discard;
}
if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {
discard;
}
}
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var LF=[0,0,0,255],ete={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:LF},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},SS={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},_d=class extends _e{getShaders(){return super.getShaders({vs:RF,fs:IF,modules:[fe,Se,MF]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:SS,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:SS,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:SS,defaultValue:LF},instancePickingColors:{size:4,type:"uint8",accessor:(o,{index:n,target:i})=>this.encodePickingColor(o&&o.__source?o.__source.index:n,i)}}),this.setState({pathTesselator:new gd({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:r,changeFlags:o}=e,n=this.getAttributeManager();if(o.dataChanged||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPath)){let{pathTesselator:s}=this.state,a=r.data.attributes||{};s.updateGeometry({data:r.data,geometryBuffer:a.getPath,buffers:a,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:o.dataChanged}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),o.dataChanged||n.invalidateAll()}o.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}getPickingInfo(e){let r=super.getPickingInfo(e),{index:o}=r,n=this.props.data;return n[0]&&n[0].__source&&(r.object=n.find(i=>i.__source.index===o)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let o=0;o<r.length;o++)r[o].__source.index===e&&this._disablePickingIndex(o);else super.disablePickingIndex(e)}draw({uniforms:e}){let{jointRounded:r,capRounded:o,billboard:n,miterLimit:i,widthUnits:s,widthScale:a,widthMinPixels:c,widthMaxPixels:l}=this.props,f=this.state.model,u={jointType:Number(r),capType:Number(o),billboard:n,widthUnits:Pe[s],widthScale:a,miterLimit:i,widthMinPixels:c,widthMaxPixels:l};f.shaderInputs.setProps({path:u}),f.draw(this.context.renderPass)}_getModel(){let e=[0,1,2,1,4,2,1,3,4,3,5,4],r=[0,0,0,-1,0,1,1,-1,1,1,1,0];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-list",attributes:{indices:new Uint16Array(e),positions:{value:new Float32Array(r),size:2}}}),isInstanced:!0})}calculatePositions(e){let{pathTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateSegmentTypes(e){let{pathTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("segmentTypes")}};_d.defaultProps=ete;_d.layerName="PathLayer";var Go=_d;var HF=kn(DF(),1);var d0=wc.CLOCKWISE,UF=wc.COUNTER_CLOCKWISE,Ai={isClosed:!0};function gte(t){if(t=t&&t.positions||t,!Array.isArray(t)&&!ArrayBuffer.isView(t))throw new Error("invalid polygon")}function Rc(t){return"positions"in t?t.positions:t}function Ad(t){return"holeIndices"in t?t.holeIndices:null}function _te(t){return Array.isArray(t[0])}function yte(t){return t.length>=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function xte(t){let e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]}function bte(t,e,r,o){for(let n=0;n<e;n++)if(t[r+n]!==t[o-e+n])return!1;return!0}function kF(t,e,r,o,n){let i=e,s=r.length;for(let a=0;a<s;a++)for(let c=0;c<o;c++)t[i++]=r[a][c]||0;if(!xte(r))for(let a=0;a<o;a++)t[i++]=r[0][a]||0;return Ai.start=e,Ai.end=i,Ai.size=o,Rs(t,n,Ai),i}function VF(t,e,r,o,n=0,i,s){i=i||r.length;let a=i-n;if(a<=0)return e;let c=e;for(let l=0;l<a;l++)t[c++]=r[n+l];if(!bte(r,o,n,i))for(let l=0;l<o;l++)t[c++]=r[n+l];return Ai.start=e,Ai.end=c,Ai.size=o,Rs(t,s,Ai),c}function h0(t,e){gte(t);let r=[],o=[];if("positions"in t){let{positions:n,holeIndices:i}=t;if(i){let s=0;for(let a=0;a<=i.length;a++)s=VF(r,s,n,e,i[a-1],i[a],a===0?d0:UF),o.push(s);return o.pop(),{positions:r,holeIndices:o}}t=n}if(!_te(t))return VF(r,0,t,e,0,r.length,d0),r;if(!yte(t)){let n=0;for(let[i,s]of t.entries())n=kF(r,n,s,e,i===0?d0:UF),o.push(n);return o.pop(),{positions:r,holeIndices:o}}return kF(r,0,t,e,d0),r}function MS(t,e,r){let o=t.length/3,n=0;for(let i=0;i<o;i++){let s=(i+1)%o;n+=t[i*3+e]*t[s*3+r],n-=t[s*3+e]*t[i*3+r]}return Math.abs(n/2)}function zF(t,e,r,o){let n=t.length/3;for(let i=0;i<n;i++){let s=i*3,a=t[s+0],c=t[s+1],l=t[s+2];t[s+e]=a,t[s+r]=c,t[s+o]=l}}function jF(t,e,r,o){let n=Ad(t);n&&(n=n.map(a=>a/e));let i=Rc(t),s=o&&e===3;if(r){let a=i.length;i=i.slice();let c=[];for(let l=0;l<a;l+=e){c[0]=i[l],c[1]=i[l+1],s&&(c[2]=i[l+2]);let f=r(c);i[l]=f[0],i[l+1]=f[1],s&&(i[l+2]=f[2])}}if(s){let a=MS(i,0,1),c=MS(i,0,2),l=MS(i,1,2);if(!a&&!c&&!l)return[];a>c&&a>l||(c>l?(r||(i=i.slice()),zF(i,0,2,1)):(r||(i=i.slice()),zF(i,2,0,1)))}return(0,HF.default)(i,n,e)}var Td=class extends vn{constructor(e){let{fp64:r,IndexType:o=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:o,size:1}}})}get(e){let{attributes:r}=this;return e==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[e]}updateGeometry(e){super.updateGeometry(e);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let r=h0(e,this.positionSize);return this.opts.resolution?dd(Rc(r),Ad(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?TS(Rc(r),Ad(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return e}getGeometrySize(e){if(GF(e)){let r=0;for(let o of e)r+=this.getGeometrySize(o);return r}return Rc(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,r){if(e&&GF(e))for(let o of e){let n=this.getGeometrySize(o);r.geometrySize=n,this.updateGeometryAttributes(o,r),r.vertexStart+=n,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let o=e;this._updateIndices(o,r),this._updatePositions(o,r),this._updateVertexValid(o,r)}}_updateIndices(e,{geometryIndex:r,vertexStart:o,indexStart:n}){let{attributes:i,indexStarts:s,typedArrayManager:a}=this,c=i.indices;if(!c||!e)return;let l=n,f=jF(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,n+f.length,{copy:!0});for(let u=0;u<f.length;u++)c[l++]=f[u]+o;s[r+1]=n+f.length,i.indices=c}_updatePositions(e,{vertexStart:r,geometrySize:o}){let{attributes:{positions:n},positionSize:i}=this;if(!n||!e)return;let s=Rc(e);for(let a=r,c=0;c<o;a++,c++){let l=s[c*i],f=s[c*i+1],u=i>2?s[c*i+2]:0;n[a*3]=l,n[a*3+1]=f,n[a*3+2]=u}}_updateVertexValid(e,{vertexStart:r,geometrySize:o}){let{positionSize:n}=this,i=this.attributes.vertexValid,s=e&&Ad(e);if(e&&e.edgeTypes?i.set(e.edgeTypes,r):i.fill(1,r,r+o),s)for(let a=0;a<s.length;a++)i[r+s[a]/n-1]=0;i[r+o-1]=0}};function GF(t){return Array.isArray(t)&&t.length>0&&!Number.isFinite(t[0])}var $F=`layout(std140) uniform solidPolygonUniforms {
bool extruded;
bool isWireframe;
float elevationScale;
} solidPolygon;
`,XF={name:"solidPolygon",vs:$F,fs:$F,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var p0=`in vec4 fillColors;
in vec4 lineColors;
in vec3 pickingColors;
out vec4 vColor;
struct PolygonProps {
vec3 positions;
vec3 positions64Low;
vec3 normal;
float elevations;
};
vec3 project_offset_normal(vec3 vector) {
if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {
return normalize(vector * project.commonUnitsPerWorldUnit);
}
return project_normal(vector);
}
void calculatePosition(PolygonProps props) {
vec3 pos = props.positions;
vec3 pos64Low = props.positions64Low;
vec3 normal = props.normal;
vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;
geometry.worldPosition = props.positions;
geometry.pickingColor = pickingColors;
if (solidPolygon.extruded) {
pos.z += props.elevations * solidPolygon.elevationScale;
}
gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
if (solidPolygon.extruded) {
#ifdef IS_SIDE_VERTEX
normal = project_offset_normal(normal);
#else
normal = project_normal(normal);
#endif
geometry.normal = normal;
vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, colors.a * layer.opacity);
} else {
vColor = vec4(colors.rgb, colors.a * layer.opacity);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var YF=`#version 300 es
#define SHADER_NAME solid-polygon-layer-vertex-shader
in vec3 vertexPositions;
in vec3 vertexPositions64Low;
in float elevations;
${p0}
void main(void) {
PolygonProps props;
props.positions = vertexPositions;
props.positions64Low = vertexPositions64Low;
props.elevations = elevations;
props.normal = vec3(0.0, 0.0, 1.0);
calculatePosition(props);
}
`;var KF=`#version 300 es
#define SHADER_NAME solid-polygon-layer-vertex-shader-side
#define IS_SIDE_VERTEX
in vec2 positions;
in vec3 vertexPositions;
in vec3 nextVertexPositions;
in vec3 vertexPositions64Low;
in vec3 nextVertexPositions64Low;
in float elevations;
in float instanceVertexValid;
${p0}
void main(void) {
if(instanceVertexValid < 0.5){
gl_Position = vec4(0.);
return;
}
PolygonProps props;
vec3 pos;
vec3 pos64Low;
vec3 nextPos;
vec3 nextPos64Low;
#if RING_WINDING_ORDER_CW == 1
pos = vertexPositions;
pos64Low = vertexPositions64Low;
nextPos = nextVertexPositions;
nextPos64Low = nextVertexPositions64Low;
#else
pos = nextVertexPositions;
pos64Low = nextVertexPositions64Low;
nextPos = vertexPositions;
nextPos64Low = vertexPositions64Low;
#endif
props.positions = mix(pos, nextPos, positions.x);
props.positions64Low = mix(pos64Low, nextPos64Low, positions.x);
props.normal = vec3(
pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),
nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),
0.0);
props.elevations = elevations * positions.y;
calculatePosition(props);
}
`;var qF=`#version 300 es
#define SHADER_NAME solid-polygon-layer-fragment-shader
precision highp float;
in vec4 vColor;
out vec4 fragColor;
void main(void) {
fragColor = vColor;
geometry.uv = vec2(0.);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var g0=[0,0,0,255],Ate={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:g0},getLineColor:{type:"accessor",value:g0},material:!0},m0={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},vd=class extends _e{getShaders(e){return super.getShaders({vs:e==="top"?YF:KF,fs:qF,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[fe,Xr,Se,XF]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:r}=this.props,{_full3d:o}=this.props;e.isGeospatial&&r==="default"&&(r="lnglat");let n;r==="lnglat"&&(o?n=e.projectPosition.bind(e):n=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Td({preproject:n,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let i=this.getAttributeManager(),s=!0;i.remove(["instancePickingColors"]),i.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:m0,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:m0,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:m0,accessor:"getFillColor",defaultValue:g0},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:m0,accessor:"getLineColor",defaultValue:g0},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:o}=r,n=this.props.data;return n[0]&&n[0].__source&&(r.object=n.find(i=>i.__source.index===o)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let o=0;o<r.length;o++)r[o].__source.index===e&&this._disablePickingIndex(o);else super.disablePickingIndex(e)}draw({uniforms:e}){let{extruded:r,filled:o,wireframe:n,elevationScale:i}=this.props,{topModel:s,sideModel:a,wireframeModel:c,polygonTesselator:l}=this.state,f={extruded:Boolean(r),elevationScale:i,isWireframe:!1};c&&n&&(c.setInstanceCount(l.instanceCount-1),c.shaderInputs.setProps({solidPolygon:{...f,isWireframe:!0}}),c.draw(this.context.renderPass)),a&&o&&(a.setInstanceCount(l.instanceCount-1),a.shaderInputs.setProps({solidPolygon:f}),a.draw(this.context.renderPass)),s&&o&&(s.setVertexCount(l.vertexCount),s.shaderInputs.setProps({solidPolygon:f}),s.draw(this.context.renderPass))}updateState(e){super.updateState(e),this.updateGeometry(e);let{props:r,oldProps:o,changeFlags:n}=e,i=this.getAttributeManager();(n.extensionsChanged||r.filled!==o.filled||r.extruded!==o.extruded)&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),i.invalidateAll())}updateGeometry({props:e,oldProps:r,changeFlags:o}){if(o.dataChanged||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPolygon)){let{polygonTesselator:i}=this.state,s=e.data.attributes||{};i.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:s.getPolygon,buffers:s,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:o.dataChanged,full3d:e._full3d}),this.setState({numInstances:i.instanceCount,startIndices:i.vertexStarts}),o.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:r,extruded:o}=this.props,n,i,s;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});n=new Q(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(o){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});i=new Q(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new ce({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new Q(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new ce({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[i,s,n].filter(Boolean),topModel:n,sideModel:i,wireframeModel:s}}calculateIndices(e){let{polygonTesselator:r}=this.state;e.startIndices=r.indexStarts,e.value=r.get("indices")}calculatePositions(e){let{polygonTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}};vd.defaultProps=Ate;vd.layerName="SolidPolygonLayer";var Ti=vd;function _0({data:t,getIndex:e,dataRange:r,replace:o}){let{startRow:n=0,endRow:i=1/0}=r,s=t.length,a=s,c=s;for(let d=0;d<s;d++){let h=e(t[d]);if(a>d&&h>=n&&(a=d),h>=i){c=d;break}}let l=a,u=c-a!==o.length?t.slice(c):void 0;for(let d=0;d<o.length;d++)t[l++]=o[d];if(u){for(let d=0;d<u.length;d++)t[l++]=u[d];t.length=l}return{startRow:a,endRow:a+o.length}}var ZF=[0,0,0,255],Tte=[0,0,0,255],vte={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:t=>t.polygon},getFillColor:{type:"accessor",value:Tte},getLineColor:{type:"accessor",value:ZF},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},Sd=class extends Ne{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&N.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){let r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(r&&Array.isArray(e.dataChanged)){let o=this.state.paths.slice(),n=e.dataChanged.map(i=>_0({data:o,getIndex:s=>s.__source.index,dataRange:i,replace:this._getPaths(i)}));this.setState({paths:o,pathsDiff:n})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){let{data:r,getPolygon:o,positionFormat:n,_normalize:i}=this.props,s=[],a=n==="XY"?2:3,{startRow:c,endRow:l}=e,{iterable:f,objectInfo:u}=Fe(r,c,l);for(let d of f){u.index++;let h=o(d,u);i&&(h=h0(h,a));let{holeIndices:p}=h,m=h.positions||h;if(p)for(let g=0;g<=p.length;g++){let _=m.slice(p[g-1]||0,p[g]||m.length);s.push(this.getSubLayerRow({path:_},d,u.index))}else s.push(this.getSubLayerRow({path:m},d,u.index))}return s}renderLayers(){let{data:e,_dataDiff:r,stroked:o,filled:n,extruded:i,wireframe:s,_normalize:a,_windingOrder:c,elevationScale:l,transitions:f,positionFormat:u}=this.props,{lineWidthUnits:d,lineWidthScale:h,lineWidthMinPixels:p,lineWidthMaxPixels:m,lineJointRounded:g,lineMiterLimit:_,lineDashJustified:x}=this.props,{getFillColor:y,getLineColor:b,getLineWidth:T,getLineDashArray:v,getElevation:w,getPolygon:C,updateTriggers:S,material:A}=this.props,{paths:M,pathsDiff:B}=this.state,O=this.getSubLayerClass("fill",Ti),F=this.getSubLayerClass("stroke",Go),X=this.shouldRenderSubLayer("fill",M)&&new O({_dataDiff:r,extruded:i,elevationScale:l,filled:n,wireframe:s,_normalize:a,_windingOrder:c,getElevation:w,getFillColor:y,getLineColor:i&&s?b:ZF,material:A,transitions:f},this.getSubLayerProps({id:"fill",updateTriggers:S&&{getPolygon:S.getPolygon,getElevation:S.getElevation,getFillColor:S.getFillColor,lineColors:i&&s,getLineColor:S.getLineColor}}),{data:e,positionFormat:u,getPolygon:C}),G=!i&&o&&this.shouldRenderSubLayer("stroke",M)&&new F({_dataDiff:B&&(()=>B),widthUnits:d,widthScale:h,widthMinPixels:p,widthMaxPixels:m,jointRounded:g,miterLimit:_,dashJustified:x,_pathType:"loop",transitions:f&&{getWidth:f.getLineWidth,getColor:f.getLineColor,getPath:f.getPolygon},getColor:this.getSubLayerAccessor(b),getWidth:this.getSubLayerAccessor(T),getDashArray:this.getSubLayerAccessor(v)},this.getSubLayerProps({id:"stroke",updateTriggers:S&&{getWidth:S.getLineWidth,getColor:S.getLineColor,getDashArray:S.getLineDashArray}}),{data:M,positionFormat:u,getPath:j=>j.path});return[!i&&X,G,i&&X]}};Sd.layerName="PolygonLayer";Sd.defaultProps=vte;var vi=Sd;function JF(t,e){if(!t)return null;let r="startIndices"in t?t.startIndices[e]:e,o=t.featureIds.value[r];return r!==-1?Ste(t,o,r):null}function Ste(t,e,r){let o={properties:{...t.properties[e]}};for(let n in t.numericProps)o.properties[n]=t.numericProps[n].value[r];return o}function QF(t,e){let r={points:null,lines:null,polygons:null};for(let o in r){let n=t[o].globalFeatureIds.value;r[o]=new Uint8ClampedArray(n.length*4);let i=[];for(let s=0;s<n.length;s++)e(n[s],i),r[o][s*4+0]=i[0],r[o][s*4+1]=i[1],r[o][s*4+2]=i[2],r[o][s*4+3]=255}return r}var eN=`layout(std140) uniform sdfUniforms {
float gamma;
bool enabled;
float buffer;
float outlineBuffer;
vec4 outlineColor;
} sdf;
`,tN={name:"sdf",vs:eN,fs:eN,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}};var Cd={none:0,start:1,center:2,end:3},Cte=`layout(std140) uniform textUniforms {
highp vec2 cutoffPixels;
highp ivec2 align;
highp float fontSize;
bool flipY;
} text;
#define ALIGN_MODE_START ${Cd.start}
#define ALIGN_MODE_CENTER ${Cd.center}
#define ALIGN_MODE_END ${Cd.end}
`,y0={name:"text",vs:Cte,getUniforms:({contentCutoffPixels:t=[0,0],contentAlignHorizontal:e="none",contentAlignVertical:r="none",fontSize:o,viewport:n})=>({cutoffPixels:t,align:[Cd[e],Cd[r]],fontSize:o,flipY:n?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}};var rN=`#version 300 es
#define SHADER_NAME multi-icon-layer-vertex-shader
in vec2 positions;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in float instanceSizes;
in float instanceAngles;
in vec4 instanceColors;
in vec3 instancePickingColors;
in vec4 instanceIconFrames;
in float instanceColorModes;
in vec2 instanceOffsets;
in vec2 instancePixelOffset;
in vec4 instanceClipRect;
out float vColorMode;
out vec4 vColor;
out vec2 vTextureCoords;
out vec2 uv;
vec2 rotate_by_angle(vec2 vertex, float angle) {
float angle_radian = angle * PI / 180.0;
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
}
float getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) {
if (clipEnd < clipStart) return 0.0;
if (mode == ALIGN_MODE_START) {
return max(- (anchor + clipStart), 0.0);
}
if (mode == ALIGN_MODE_CENTER) {
float _min = max(0., anchor + clipStart);
float _max = min(extent, anchor + clipEnd);
return _min < _max ? (_min + _max) / 2.0 - anchor : 0.0;
}
if (mode == ALIGN_MODE_END) {
return min(extent - (anchor + clipEnd), 0.);
}
return 0.0;
}
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vec2 iconSize = instanceIconFrames.zw;
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
icon.sizeMinPixels, icon.sizeMaxPixels
);
float instanceScale = sizePixels / text.fontSize;
vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
pixelOffset += instancePixelOffset;
pixelOffset.y *= -1.0;
vec2 anchorPosScreen;
if (icon.billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
anchorPosScreen = gl_Position.xy / gl_Position.w;
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
if (text.flipY) {
offset_common.y *= -1.;
}
DECKGL_FILTER_SIZE(offset_common, geometry);
vec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0));
anchorPosScreen = anchorPos.xy / anchorPos.w;
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
anchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio;
vec2 xy = project_size_to_pixel(instanceClipRect.xy);
vec2 wh = project_size_to_pixel(instanceClipRect.zw);
if (text.flipY) {
xy.y = -xy.y - wh.y;
}
if (text.align.x > 0 || text.align.y > 0) {
vec2 viewportPixels = project.viewportSize / project.devicePixelRatio;
vec2 scrollPixels = vec2(
getPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),
-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)
);
pixelOffset += scrollPixels;
gl_Position.xy += project_pixel_size_to_clipspace(scrollPixels);
}
if (instanceClipRect.z >= 0.) {
if (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {
gl_Position = vec4(0.0);
}
else if (text.cutoffPixels.x > 0.) {
float vpWidth = project.viewportSize.x / project.devicePixelRatio;
float l = max(anchorPosScreen.x + xy.x, 0.0);
float r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth);
if (r - l < text.cutoffPixels.x) {
gl_Position = vec4(0.0);
}
}
}
if (instanceClipRect.w >= 0.) {
if (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {
gl_Position = vec4(0.0);
}
else if (text.cutoffPixels.y > 0.) {
float vpHeight = project.viewportSize.y / project.devicePixelRatio;
float t = max(anchorPosScreen.y - xy.y - wh.y, 0.0);
float b = min(anchorPosScreen.y - xy.y, vpHeight);
if (b - t < text.cutoffPixels.y) {
gl_Position = vec4(0.0);
}
}
}
vTextureCoords = mix(
instanceIconFrames.xy,
instanceIconFrames.xy + iconSize,
(positions.xy + 1.0) / 2.0
) / icon.iconsTextureDim;
vColor = instanceColors;
DECKGL_FILTER_COLOR(vColor, geometry);
vColorMode = instanceColorModes;
}
`;var oN=`#version 300 es
#define SHADER_NAME multi-icon-layer-fragment-shader
precision highp float;
uniform sampler2D iconsTexture;
in vec4 vColor;
in vec2 vTextureCoords;
in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
if (!bool(picking.isActive)) {
float alpha = texture(iconsTexture, vTextureCoords).a;
vec4 color = vColor;
if (sdf.enabled) {
float distance = alpha;
alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);
if (sdf.outlineBuffer > 0.0) {
float inFill = alpha;
float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);
color = mix(sdf.outlineColor, vColor, inFill);
alpha = inBorder;
}
}
float a = alpha * color.a;
if (a < icon.alphaCutoff) {
discard;
}
fragColor = vec4(color.rgb, a * layer.opacity);
}
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var RS=192/256;var Ete={getIconOffsets:{type:"accessor",value:t=>t.offsets},getContentBox:{type:"accessor",value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none"},Ed=class extends Ec{getShaders(){let e=super.getShaders();return{...e,modules:[...e.modules,y0,tN],vs:rN,fs:oN}}initializeState(){super.initializeState();let e=this.getAttributeManager(),r=e.attributes.instanceIconDefs;r.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(o,{index:n,target:i})=>this.encodePickingColor(n,i)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,{outlineColor:i}=r;if(n.updateTriggersChanged&&(n.updateTriggersChanged.getIcon||n.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),i!==o.outlineColor){let s=[i[0]/255,i[1]/255,i[2]/255,(i[3]??255)/255];this.setState({outlineColor:s})}!r.sdf&&r.outlineWidth&&N.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:r,smoothing:o,fontSize:n,outlineWidth:i,contentCutoffPixels:s,contentAlignHorizontal:a,contentAlignVertical:c}=this.props,{outlineColor:l}=this.state,f=i?Math.max(o,RS*(1-i)):-1,u=this.state.model,d={buffer:RS,outlineBuffer:f,gamma:o,enabled:Boolean(r),outlineColor:l},h={contentCutoffPixels:s,contentAlignHorizontal:a,contentAlignVertical:c,fontSize:n,viewport:this.context.viewport};if(u.shaderInputs.setProps({sdf:d,text:h}),super.draw(e),r&&i){let{iconManager:p}=this.state;p.getTexture()&&(u.shaderInputs.setProps({sdf:{...d,outlineBuffer:RS}}),u.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:r,endRow:o}){let{data:n,getIcon:i,getIconOffsets:s}=this.props,a=e.getVertexOffset(r),c=e.value,{iterable:l,objectInfo:f}=Fe(n,r,o);for(let u of l){f.index++;let d=i(u,f),h=s(u,f);if(d){let p=0;for(let m of Array.from(d)){let g=super.getInstanceIconDef(m);g[0]=h[p*2],g[1]+=h[p*2+1],g[6]=1,c.set(g,a),a+=e.size,p++}}}}};Ed.defaultProps=Ete;Ed.layerName="MultiIconLayer";var x0=Ed;var wd=class{constructor({fontSize:e=24,buffer:r=3,radius:o=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=n,this.radius=o;let c=this.size=e+r*4,l=this._createCanvas(c),f=this.ctx=l.getContext("2d",{willReadFrequently:!0});f.font=`${a} ${s} ${e}px ${i}`,f.textBaseline="alphabetic",f.textAlign="left",f.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){let r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:o,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(o),c=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-i))),f=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=l+2*this.buffer,d=f+2*this.buffer,h=Math.max(u*d,0),p=new Uint8ClampedArray(h),m={data:p,width:u,height:d,glyphWidth:l,glyphHeight:f,glyphTop:a,glyphLeft:c,glyphAdvance:r};if(l===0||f===0)return m;let{ctx:g,buffer:_,gridInner:x,gridOuter:y}=this;g.clearRect(_,_,l,f),g.fillText(e,_,_+a);let b=g.getImageData(_,_,l,f);y.fill(1e20,0,h),x.fill(0,0,h);for(let T=0;T<f;T++)for(let v=0;v<l;v++){let w=b.data[4*(T*l+v)+3]/255;if(w===0)continue;let C=(T+_)*u+v+_;if(w===1)y[C]=0,x[C]=1e20;else{let S=.5-w;y[C]=S>0?S*S:0,x[C]=S<0?S*S:0}}nN(y,0,0,u,d,u,this.f,this.v,this.z),nN(x,_,_,l,f,u,this.f,this.v,this.z);for(let T=0;T<h;T++){let v=Math.sqrt(y[T])-Math.sqrt(x[T]);p[T]=Math.round(255-255*(v/this.radius+this.cutoff))}return m}};function nN(t,e,r,o,n,i,s,a,c){for(let l=e;l<e+o;l++)iN(t,r*i+l,i,n,s,a,c);for(let l=r;l<r+n;l++)iN(t,l*i+e,1,o,s,a,c)}function iN(t,e,r,o,n,i,s){i[0]=0,s[0]=-1e20,s[1]=1e20,n[0]=t[e];for(let a=1,c=0,l=0;a<o;a++){n[a]=t[e+a*r];let f=a*a;do{let u=i[c];l=(n[a]-n[u]+f-u*u)/(a-u)/2}while(l<=s[c]&&--c>-1);c++,i[c]=a,s[c]=l,s[c+1]=1e20}for(let a=0,c=0;a<o;a++){for(;s[c+1]<a;)c++;let l=i[c],f=a-l;t[e+a*r]=n[l]+f*f}}var wte=32,Pte=[];function Mte(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function sN({characterSet:t,measureText:e,buffer:r,maxCanvasWidth:o,mapping:n={},xOffset:i=0,yOffsetMin:s=0,yOffsetMax:a=0}){let l=i,f=s,u=a;for(let d of t)if(!n[d]){let{advance:h,width:p,ascent:m,descent:g}=e(d),_=m+g;l+p+r*2>o&&(l=0,f=u),n[d]={x:l+r,y:f+r,width:p,height:_,advance:h,anchorX:p/2,anchorY:m},l+=p+r*2,u=Math.max(u,f+_+r*2)}return{mapping:n,xOffset:l,yOffsetMin:f,yOffsetMax:u,canvasHeight:Mte(u)}}function aN(t,e,r,o){let n=0;for(let i=e;i<r;i++){let s=t[i];n+=o[s]?.advance||0}return n}function cN(t,e,r,o,n,i){let s=e,a=0;for(let c=e;c<r;c++){let l=aN(t,c,c+1,n);a+l>o&&(s<c&&i.push(c),s=c,a=0),a+=l}return a}function Rte(t,e,r,o,n,i){let s=e,a=e,c=e,l=0;for(let f=e;f<r;f++)if((t[f]===" "||t[f+1]===" "||f+1===r)&&(c=f+1),c>a){let u=aN(t,a,c,n);l+u>o&&(s<a&&(i.push(a),s=a,l=0),u>o&&(u=cN(t,a,c,o,n,i),s=i[i.length-1])),a=c,l+=u}return l}function Ite(t,e,r,o,n=0,i){i===void 0&&(i=t.length);let s=[];return e==="break-all"?cN(t,n,i,r,o,s):Rte(t,n,i,r,o,s),s}function Lte(t,e,r,o,n,i){let s=0,a=0;for(let c=e;c<r;c++){let l=t[c],f=o[l];f&&(a=Math.max(a,f.height))}for(let c=e;c<r;c++){let l=t[c],f=o[l];f?(n[c]=s+f.anchorX,s+=f.advance):(N.warn(`Missing character: ${l} (${l.codePointAt(0)})`)(),n[c]=s,s+=wte)}i[0]=s,i[1]=a}function lN(t,e,r,o,n,i){let s=Array.from(t),a=s.length,c=new Array(a),l=new Array(a),f=new Array(a),u=(o==="break-word"||o==="break-all")&&isFinite(n)&&n>0,d=[0,0],h=[0,0],p=0,m=e+r/2,g=0,_=0;for(let x=0;x<=a;x++){let y=s[x];if((y===`
`||x===a)&&(_=x),_>g){let b=u?Ite(s,o,n,i,g,_):Pte;for(let T=0;T<=b.length;T++){let v=T===0?g:b[T-1],w=T<b.length?b[T]:_;Lte(s,v,w,i,c,h);for(let C=v;C<w;C++)l[C]=m,f[C]=h[0];p++,m+=r,d[0]=Math.max(d[0],h[0])}g=_}y===`
`&&(c[g]=0,l[g]=0,f[g]=0,g++)}return d[1]=p*r,{x:c,y:l,rowWidth:f,size:d}}function fN({value:t,length:e,stride:r,offset:o,startIndices:n,characterSet:i}){let s=t.BYTES_PER_ELEMENT,a=r?r/s:1,c=o?o/s:0,l=n[e]||Math.ceil((t.length-c)/a),f=i&&new Set,u=new Array(e),d=t;if(a>1||c>0){let h=t.constructor;d=new h(l);for(let p=0;p<l;p++)d[p]=t[p*a+c]}for(let h=0;h<e;h++){let p=n[h],m=n[h+1]||l,g=d.subarray(p,m);u[h]=String.fromCodePoint.apply(null,g),f&&g.forEach(f.add,f)}if(f)for(let h of f)i.add(String.fromCodePoint(h));return{texts:u,characterCount:l}}var Ic=class{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){let r=this._cache[e];return r&&(this._deleteOrder(e),this._appendOrder(e)),r}set(e,r){this._cache[e]?(this.delete(e),this._cache[e]=r,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=r,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){let r=this._order.indexOf(e);r>=0&&this._order.splice(r,1)}_appendOrder(e){this._order.push(e)}};function Bte(){let t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}var Bs={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:Bte(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},uN=1024,dN=.9,hN=.3,mN=3,b0=new Ic(mN);function Ote(t,e){let r;typeof e=="string"?r=new Set(Array.from(e)):r=new Set(e);let o=b0.get(t);if(!o)return r;for(let n in o.mapping)r.has(n)&&r.delete(n);return r}function Fte(t,e){for(let r=0;r<t.length;r++)e.data[4*r+3]=t[r]}function pN(t,e,r,o){t.font=`${o} ${r}px ${e}`,t.fillStyle="#000",t.textBaseline="alphabetic",t.textAlign="left"}function Nte(t,e,r){if(r===void 0){let n=t.measureText("A");return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:e*dN,descent:e*hN}}let o=t.measureText(r);return o.actualBoundingBoxAscent?{advance:o.width,width:Math.ceil(o.actualBoundingBoxRight-o.actualBoundingBoxLeft),ascent:Math.ceil(o.actualBoundingBoxAscent),descent:Math.ceil(o.actualBoundingBoxDescent)}:{advance:o.width,width:o.width,ascent:e*dN,descent:e*hN}}function gN(t){N.assert(Number.isFinite(t)&&t>=mN,"Invalid cache limit"),b0=new Ic(t)}var Pd=class{constructor(){this.props={...Bs}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(e={}){Object.assign(this.props,e),e._getFontRenderer&&(this._getFontRenderer=e._getFontRenderer),this._key=this._getKey();let r=Ote(this._key,this.props.characterSet),o=b0.get(this._key);if(o&&r.size===0){this._atlas!==o&&(this._atlas=o);return}let n=this._generateFontAtlas(r,o);this._atlas=n,b0.set(this._key,n)}_generateFontAtlas(e,r){let{fontFamily:o,fontWeight:n,fontSize:i,buffer:s,sdf:a,radius:c,cutoff:l}=this.props,f=r&&r.data;f||(f=document.createElement("canvas"),f.width=uN);let u=f.getContext("2d",{willReadFrequently:!0});pN(u,o,i,n);let d=b=>Nte(u,i,b),h;this._getFontRenderer?h=this._getFontRenderer(this.props):a&&(h={measure:d,draw:Dte(this.props)});let{mapping:p,canvasHeight:m,xOffset:g,yOffsetMin:_,yOffsetMax:x}=sN({measureText:b=>h?h.measure(b):d(b),buffer:s,characterSet:e,maxCanvasWidth:uN,...r&&{mapping:r.mapping,xOffset:r.xOffset,yOffsetMin:r.yOffsetMin,yOffsetMax:r.yOffsetMax}});if(f.height!==m){let b=f.height>0?u.getImageData(0,0,f.width,f.height):null;f.height=m,b&&u.putImageData(b,0,0)}if(pN(u,o,i,n),h)for(let b of e){let T=p[b],{data:v,left:w=0,top:C=0}=h.draw(b),S=T.x-w,A=T.y-C,M=Math.max(0,Math.round(S)),B=Math.max(0,Math.round(A)),O=Math.min(v.width,f.width-M),F=Math.min(v.height,f.height-B);u.putImageData(v,M,B,0,0,O,F),T.x+=M-S,T.y+=B-A}else for(let b of e){let T=p[b];u.fillText(b,T.x,T.y+T.anchorY)}let y=h?h.measure():d();return{baselineOffset:(y.ascent-y.descent)/2,xOffset:g,yOffsetMin:_,yOffsetMax:x,mapping:p,data:f,width:f.width,height:f.height}}_getKey(){let{fontFamily:e,fontWeight:r,fontSize:o,buffer:n,sdf:i,radius:s,cutoff:a}=this.props;return i?`${e} ${r} ${o} ${n} ${s} ${a}`:`${e} ${r} ${o} ${n}`}};function Dte({fontSize:t,buffer:e,radius:r,cutoff:o,fontFamily:n,fontWeight:i}){let s=new wd({fontSize:t,buffer:e,radius:r,cutoff:o,fontFamily:n,fontWeight:`${i}`});return a=>{let{data:c,width:l,height:f}=s.draw(a),u=new ImageData(l,f);return Fte(c,u),{data:u,left:e,top:e}}}var _N=`layout(std140) uniform textBackgroundUniforms {
bool billboard;
float sizeScale;
float sizeMinPixels;
float sizeMaxPixels;
vec4 borderRadius;
vec4 padding;
highp int sizeUnits;
bool stroked;
} textBackground;
`,yN={name:"textBackground",vs:_N,fs:_N,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}};var xN=`#version 300 es
#define SHADER_NAME text-background-layer-vertex-shader
in vec2 positions;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in vec4 instanceRects;
in vec4 instanceClipRect;
in float instanceSizes;
in float instanceAngles;
in vec2 instancePixelOffsets;
in float instanceLineWidths;
in vec4 instanceFillColors;
in vec4 instanceLineColors;
in vec3 instancePickingColors;
out vec4 vFillColor;
out vec4 vLineColor;
out float vLineWidth;
out vec2 uv;
out vec2 dimensions;
vec2 rotate_by_angle(vec2 vertex, float angle) {
float angle_radian = radians(angle);
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
}
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vLineWidth = instanceLineWidths;
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),
textBackground.sizeMinPixels, textBackground.sizeMaxPixels
);
float instanceScale = sizePixels / text.fontSize;
dimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw;
vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);
pixelOffset += instancePixelOffsets;
pixelOffset.y *= -1.0;
vec2 xy = project_size_to_pixel(instanceClipRect.xy);
vec2 wh = project_size_to_pixel(instanceClipRect.zw);
if (text.flipY) {
xy.y = -xy.y - wh.y;
}
if (instanceClipRect.z >= 0.0) {
dimensions.x = wh.x;
pixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x);
}
if (instanceClipRect.w >= 0.0) {
dimensions.y = wh.y;
pixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y);
}
if (textBackground.billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
if (text.flipY) {
offset_common.y *= -1.;
}
DECKGL_FILTER_SIZE(offset_common, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
DECKGL_FILTER_COLOR(vFillColor, geometry);
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
DECKGL_FILTER_COLOR(vLineColor, geometry);
}
`;var bN=`#version 300 es
#define SHADER_NAME text-background-layer-fragment-shader
precision highp float;
in vec4 vFillColor;
in vec4 vLineColor;
in float vLineWidth;
in vec2 uv;
in vec2 dimensions;
out vec4 fragColor;
float round_rect(vec2 p, vec2 size, vec4 radii) {
vec2 pixelPositionCB = (p - 0.5) * size;
vec2 sizeCB = size * 0.5;
float maxBorderRadius = min(size.x, size.y) * 0.5;
vec4 borderRadius = vec4(min(radii, maxBorderRadius));
borderRadius.xy =
(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;
borderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;
vec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;
return -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);
}
float rect(vec2 p, vec2 size) {
vec2 pixelPosition = p * size;
return min(min(pixelPosition.x, size.x - pixelPosition.x),
min(pixelPosition.y, size.y - pixelPosition.y));
}
vec4 get_stroked_fragColor(float dist) {
float isBorder = smoothedge(dist, vLineWidth);
return mix(vFillColor, vLineColor, isBorder);
}
void main(void) {
geometry.uv = uv;
if (textBackground.borderRadius != vec4(0.0)) {
float distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);
float shapeAlpha = smoothedge(-distToEdge, 0.0);
if (shapeAlpha == 0.0) {
discard;
}
if (textBackground.stroked) {
fragColor = get_stroked_fragColor(distToEdge);
} else {
fragColor = vFillColor;
}
fragColor.a *= shapeAlpha;
} else {
if (textBackground.stroked) {
float distToEdge = rect(uv, dimensions);
fragColor = get_stroked_fragColor(distToEdge);
} else {
fragColor = vFillColor;
}
}
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var Ute={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,fontSize:1,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getClipRect:{type:"accessor",value:[0,0,-1,-1]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},Md=class extends _e{getShaders(){return super.getShaders({vs:xN,fs:bN,modules:[fe,Se,yN,y0]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instanceClipRect:{size:4,accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:r}=e;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:r,sizeScale:o,sizeUnits:n,sizeMinPixels:i,sizeMaxPixels:s,getLineWidth:a,fontSize:c}=this.props,{padding:l,borderRadius:f}=this.props;l.length<4&&(l=[l[0],l[1],l[0],l[1]]),Array.isArray(f)||(f=[f,f,f,f]);let u=this.state.model,d={billboard:r,stroked:Boolean(a),borderRadius:f,padding:l,sizeUnits:Pe[n],sizeScale:o,sizeMinPixels:i,sizeMaxPixels:s},h={fontSize:c,viewport:this.context.viewport};u.shaderInputs.setProps({textBackground:d,text:h}),u.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,0,1,1,1];return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};Md.defaultProps=Ute;Md.layerName="TextBackgroundLayer";var A0=Md;var AN={start:1,middle:0,end:-1},TN={top:1,center:0,bottom:-1},IS=[0,0,0,255],kte=1,Vte={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:IS},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Bs.characterSet},fontFamily:Bs.fontFamily,fontWeight:Bs.fontWeight,lineHeight:kte,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:IS},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none",getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:IS},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},getContentBox:{type:"accessor",value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},Rd=class extends Ne{constructor(){super(...arguments),this.getBoundingRect=(e,r)=>{let{size:[o,n]}=this.transformParagraph(e,r),{getTextAnchor:i,getAlignmentBaseline:s}=this.props,a=AN[typeof i=="function"?i(e,r):i],c=TN[typeof s=="function"?s(e,r):s];return[(a-1)*o/2,(c-1)*n/2,o,n]},this.getIconOffsets=(e,r)=>{let{getTextAnchor:o,getAlignmentBaseline:n}=this.props,{x:i,y:s,rowWidth:a,size:[,c]}=this.transformParagraph(e,r),l=AN[typeof o=="function"?o(e,r):o],f=TN[typeof n=="function"?n(e,r):n],u=i.length,d=new Array(u*2),h=0;for(let p=0;p<u;p++)d[h++]=(l-1)*a[p]/2+i[p],d[h++]=(f-1)*c/2+s[p];return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new Pd},this.props.maxWidth>0&&N.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){let{props:r,oldProps:o,changeFlags:n}=e;(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==o.lineHeight||r.wordBreak!==o.wordBreak||r.maxWidth!==o.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:r,fontWeight:o,_getFontRenderer:n}=this.props,{fontAtlasManager:i,characterSet:s}=this.state,a={...e,characterSet:s,fontFamily:r,fontWeight:o,_getFontRenderer:n};if(!i.mapping)return i.setProps(a),!0;for(let c in a)if(a[c]!==i.props[c])return i.setProps(a),!0;return!1}_updateText(){let{data:e,characterSet:r}=this.props,o=e.attributes?.getText,{getText:n}=this.props,i=e.startIndices,s,a=r==="auto"&&new Set;if(o&&i){let{texts:c,characterCount:l}=fN({...ArrayBuffer.isView(o)?{value:o}:o,length:e.length,startIndices:i,characterSet:a});s=l,n=(f,{index:u})=>c[u]}else{let{iterable:c,objectInfo:l}=Fe(e);i=[0],s=0;for(let f of c){l.index++;let u=Array.from(n(f,l)||"");a&&u.forEach(a.add,a),s+=u.length,i.push(s)}}this.setState({getText:n,startIndices:i,numInstances:s,characterSet:a||r})}transformParagraph(e,r){let{fontAtlasManager:o}=this.state,n=o.mapping,{baselineOffset:i}=o.atlas,{fontSize:s}=o.props,a=this.state.getText,{wordBreak:c,lineHeight:l,maxWidth:f}=this.props,u=a(e,r)||"";return lN(u,i,l*s,c,f*s,n)}renderLayers(){let{startIndices:e,numInstances:r,getText:o,fontAtlasManager:{atlas:n,mapping:i},styleVersion:s}=this.state,{data:a,_dataDiff:c,getPosition:l,getColor:f,getSize:u,getAngle:d,getPixelOffset:h,getBackgroundColor:p,getBorderColor:m,getBorderWidth:g,getContentBox:_,backgroundBorderRadius:x,backgroundPadding:y,background:b,billboard:T,fontSettings:v,outlineWidth:w,outlineColor:C,sizeScale:S,sizeUnits:A,sizeMinPixels:M,sizeMaxPixels:B,contentCutoffPixels:O,contentAlignHorizontal:F,contentAlignVertical:X,transitions:G,updateTriggers:j}=this.props,se=this.getSubLayerClass("characters",x0),ne=this.getSubLayerClass("background",A0),{fontSize:pe}=this.state.fontAtlasManager.props;return[b&&new ne({getFillColor:p,getLineColor:m,getLineWidth:g,borderRadius:x,padding:y,getPosition:l,getSize:u,getAngle:d,getPixelOffset:h,getClipRect:_,billboard:T,sizeScale:S,sizeUnits:A,sizeMinPixels:M,sizeMaxPixels:B,fontSize:pe,transitions:G&&{getPosition:G.getPosition,getAngle:G.getAngle,getSize:G.getSize,getFillColor:G.getBackgroundColor,getLineColor:G.getBorderColor,getLineWidth:G.getBorderWidth,getPixelOffset:G.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:j.getPosition,getAngle:j.getAngle,getSize:j.getSize,getFillColor:j.getBackgroundColor,getLineColor:j.getBorderColor,getLineWidth:j.getBorderWidth,getPixelOffset:j.getPixelOffset,getBoundingRect:{getText:j.getText,getTextAnchor:j.getTextAnchor,getAlignmentBaseline:j.getAlignmentBaseline,styleVersion:s}}}),{data:a.attributes&&a.attributes.background?{length:a.length,attributes:a.attributes.background}:a,_dataDiff:c,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new se({sdf:v.sdf,smoothing:Number.isFinite(v.smoothing)?v.smoothing:Bs.smoothing,outlineWidth:w/(v.radius||Bs.radius),outlineColor:C,iconAtlas:n,iconMapping:i,getPosition:l,getColor:f,getSize:u,getAngle:d,getPixelOffset:h,getContentBox:_,billboard:T,sizeScale:S,sizeUnits:A,sizeMinPixels:M,sizeMaxPixels:B,fontSize:pe,contentCutoffPixels:O,contentAlignHorizontal:F,contentAlignVertical:X,transitions:G&&{getPosition:G.getPosition,getAngle:G.getAngle,getColor:G.getColor,getSize:G.getSize,getPixelOffset:G.getPixelOffset,getContentBox:G.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:j.getText,getPosition:j.getPosition,getAngle:j.getAngle,getColor:j.getColor,getSize:j.getSize,getPixelOffset:j.getPixelOffset,getContentBox:j.getContentBox,getIconOffsets:{getTextAnchor:j.getTextAnchor,getAlignmentBaseline:j.getAlignmentBaseline,styleVersion:s}}}),{data:a,_dataDiff:c,startIndices:e,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:o})]}static set fontAtlasCacheLimit(e){gN(e)}};Rd.defaultProps=Vte;Rd.layerName="TextLayer";var T0=Rd;var Id={circle:{type:t0,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:Ec,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:T0,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Ld={type:Go,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},v0={type:Ti,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Lc({type:t,props:e}){let r={};for(let o in e)r[o]=t.defaultProps[e[o]];return r}function S0(t,e){let{transitions:r,updateTriggers:o}=t.props,n={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let i in e){let s=e[i],a=t.props[i];i.startsWith("get")&&(a=t.getSubLayerAccessor(a),n.updateTriggers[s]=o[i],r&&(n.transitions[s]=r[i])),n[s]=a}return n}function SN(t){if(Array.isArray(t))return t;switch(N.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return N.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function LS(t,e,r={}){let o={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:n=0,endRow:i=t.length}=r;for(let s=n;s<i;s++){let a=t[s],{geometry:c}=a;if(c)if(c.type==="GeometryCollection"){N.assert(Array.isArray(c.geometries),"GeoJSON does not have geometries array");let{geometries:l}=c;for(let f=0;f<l.length;f++){let u=l[f];vN(u,o,e,a,s)}}else vN(c,o,e,a,s)}return o}function vN(t,e,r,o,n){let{type:i,coordinates:s}=t,{pointFeatures:a,lineFeatures:c,polygonFeatures:l,polygonOutlineFeatures:f}=e;if(!Hte(i,s)){N.warn(`${i} coordinates are malformed`)();return}switch(i){case"Point":a.push(r({geometry:t},o,n));break;case"MultiPoint":s.forEach(u=>{a.push(r({geometry:{type:"Point",coordinates:u}},o,n))});break;case"LineString":c.push(r({geometry:t},o,n));break;case"MultiLineString":s.forEach(u=>{c.push(r({geometry:{type:"LineString",coordinates:u}},o,n))});break;case"Polygon":l.push(r({geometry:t},o,n)),s.forEach(u=>{f.push(r({geometry:{type:"LineString",coordinates:u}},o,n))});break;case"MultiPolygon":s.forEach(u=>{l.push(r({geometry:{type:"Polygon",coordinates:u}},o,n)),u.forEach(d=>{f.push(r({geometry:{type:"LineString",coordinates:d}},o,n))})});break;default:}}var zte={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Hte(t,e){let r=zte[t];for(N.assert(r,`Unknown GeoJSON type ${t}`);e&&--r>0;)e=e[0];return e&&Number.isFinite(e[0])}function CN(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function C0(t){return t.geometry.coordinates}function EN(t,e){let r=CN(),{pointFeatures:o,lineFeatures:n,polygonFeatures:i,polygonOutlineFeatures:s}=t;return r.points.data=o,r.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),r.points.getPosition=C0,r.lines.data=n,r.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),r.lines.getPath=C0,r.polygons.data=i,r.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),r.polygons.getPolygon=C0,r.polygonsOutline.data=s,r.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),r.polygonsOutline.getPath=C0,r}function wN(t,e){let r=CN(),{points:o,lines:n,polygons:i}=t,s=QF(t,e);r.points.data={length:o.positions.value.length/o.positions.size,attributes:{...o.attributes,getPosition:o.positions,instancePickingColors:{size:4,value:s.points}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},r.lines.data={length:n.pathIndices.value.length-1,startIndices:n.pathIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:4,value:s.lines}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.lines._pathType="open";let a=i.positions.value.length/i.positions.size,c=Array(a).fill(1);for(let l of i.primitivePolygonIndices.value)c[l-1]=0;return r.polygons.data={length:i.polygonIndices.value.length-1,startIndices:i.polygonIndices.value,attributes:{...i.attributes,getPolygon:i.positions,instanceVertexValid:{size:1,value:new Uint16Array(c)},pickingColors:{size:4,value:s.polygons}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.polygons._normalize=!1,i.triangles&&(r.polygons.data.attributes.indices=i.triangles.value),r.polygonsOutline.data={length:i.primitivePolygonIndices.value.length-1,startIndices:i.primitivePolygonIndices.value,attributes:{...i.attributes,getPath:i.positions,instancePickingColors:{size:4,value:s.polygons}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.polygonsOutline._pathType="open",r}var jte=["points","linestrings","polygons"],Wte={...Lc(Id.circle),...Lc(Id.icon),...Lc(Id.text),...Lc(Ld),...Lc(v0),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},Bd=class extends Ne{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:r}){if(!r.dataChanged)return;let{data:o}=this.props,n=o&&"points"in o&&"polygons"in o&&"lines"in o;this.setState({binary:n}),n?this._updateStateBinary({props:e,changeFlags:r}):this._updateStateJSON({props:e,changeFlags:r})}_updateStateBinary({props:e,changeFlags:r}){let o=wN(e.data,this.encodePickingColor);this.setState({layerProps:o})}_updateStateJSON({props:e,changeFlags:r}){let o=SN(e.data),n=this.getSubLayerRow.bind(this),i={},s={};if(Array.isArray(r.dataChanged)){let c=this.state.features;for(let l in c)i[l]=c[l].slice(),s[l]=[];for(let l of r.dataChanged){let f=LS(o,n,l);for(let u in c)s[u].push(_0({data:i[u],getIndex:d=>d.__source.index,dataRange:l,replace:f[u]}))}}else i=LS(o,n);let a=EN(i,s);this.setState({features:i,featuresDiff:s,layerProps:a})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:o,sourceLayer:n}=r;return r.featureType=jte.find(i=>n.id.startsWith(`${this.id}-${i}-`)),o>=0&&n.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[o]),r}_updateAutoHighlight(e){let r=`${this.id}-points-`,o=e.featureType==="points";for(let n of this.getSubLayers())n.id.startsWith(r)===o&&n.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:r}=this.props,{layerProps:o}=this.state,n="polygons-fill",i=this.shouldRenderSubLayer(n,o.polygons?.data)&&this.getSubLayerClass(n,v0.type);if(i){let s=S0(this,v0.props),a=e&&r;return a||delete s.getLineColor,s.updateTriggers.lineColors=a,new i(s,this.getSubLayerProps({id:n,updateTriggers:s.updateTriggers}),o.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:r}=this.props,{layerProps:o}=this.state,n="polygons-stroke",i="linestrings",s=!e&&r&&this.shouldRenderSubLayer(n,o.polygonsOutline?.data)&&this.getSubLayerClass(n,Ld.type),a=this.shouldRenderSubLayer(i,o.lines?.data)&&this.getSubLayerClass(i,Ld.type);if(s||a){let c=S0(this,Ld.props);return[s&&new s(c,this.getSubLayerProps({id:n,updateTriggers:c.updateTriggers}),o.polygonsOutline),a&&new a(c,this.getSubLayerProps({id:i,updateTriggers:c.updateTriggers}),o.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:r,binary:o}=this.state,{highlightedObjectIndex:n}=this.props;!o&&Number.isFinite(n)&&(n=r.points.data.findIndex(a=>a.__source.index===n));let i=new Set(e.split("+")),s=[];for(let a of i){let c=`points-${a}`,l=Id[a],f=l&&this.shouldRenderSubLayer(c,r.points?.data)&&this.getSubLayerClass(c,l.type);if(f){let u=S0(this,l.props),d=r.points;if(a==="text"&&o){let{instancePickingColors:h,...p}=d.data.attributes;d={...d,data:{...d.data,attributes:p}}}s.push(new f(u,this.getSubLayerProps({id:c,updateTriggers:u.updateTriggers,highlightedObjectIndex:n}),d))}}return s}renderLayers(){let{extruded:e}=this.props,r=this._renderPolygonLayer(),o=this._renderLineLayers(),n=this._renderPointLayers();return[!e&&r,o,n,e&&r]}getSubLayerAccessor(e){let{binary:r}=this.state;return!r||typeof e!="function"?super.getSubLayerAccessor(e):(o,n)=>{let{data:i,index:s}=n,a=JF(i,s);return e(a,n)}}};Bd.layerName="GeoJsonLayer";Bd.defaultProps=Wte;var Os=Bd;var Gte={...vi.defaultProps},Od=class extends Ne{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:o,filled:n,stroked:i,lineWidthUnits:s,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:d,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g}=this.props,{updateTriggers:_,material:x,transitions:y}=this.props,b=this.getSubLayerClass("cell",vi),{updateTriggers:T,...v}=this.indexToBounds()||{};return new b({filled:n,wireframe:o,extruded:r,elevationScale:e,stroked:i,lineWidthUnits:s,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:f,lineMiterLimit:u,lineDashJustified:d,material:x,transitions:y,getElevation:h,getFillColor:p,getLineColor:m,getLineWidth:g},this.getSubLayerProps({id:"cell",updateTriggers:_&&{...T,getElevation:_.getElevation,getFillColor:_.getFillColor,getLineColor:_.getLineColor,getLineWidth:_.getLineWidth}}),v)}};Od.layerName="GeoCellLayer";Od.defaultProps=Gte;var Or=Od;var $te=Object.defineProperty,Ud=(t,e)=>{for(var r in e)$te(t,r,{get:e[r],enumerable:!0})},vt={};Ud(vt,{ARRAY_TYPE:()=>$e,EPSILON:()=>Tt,RANDOM:()=>Fs,equals:()=>qte,setMatrixArrayType:()=>Xte,toRadian:()=>Kte});var Tt=1e-6,$e=typeof Float32Array<"u"?Float32Array:Array,Fs=Math.random;function Xte(t){$e=t}var Yte=Math.PI/180;function Kte(t){return t*Yte}function qte(t,e){return Math.abs(t-e)<=Tt*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Ns={};Ud(Ns,{LDU:()=>hre,add:()=>pre,adjoint:()=>ire,clone:()=>Jte,copy:()=>Qte,create:()=>Zte,determinant:()=>sre,equals:()=>gre,exactEquals:()=>mre,frob:()=>dre,fromRotation:()=>lre,fromScaling:()=>fre,fromValues:()=>tre,identity:()=>ere,invert:()=>nre,mul:()=>xre,multiply:()=>KN,multiplyScalar:()=>_re,multiplyScalarAndAdd:()=>yre,rotate:()=>are,scale:()=>cre,set:()=>rre,str:()=>ure,sub:()=>bre,subtract:()=>qN,transpose:()=>ore});function Zte(){var t=new $e(4);return $e!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function Jte(t){var e=new $e(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Qte(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function ere(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t}function tre(t,e,r,o){var n=new $e(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n}function rre(t,e,r,o,n){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t}function ore(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t}function nre(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=r*i-n*o;return s?(s=1/s,t[0]=i*s,t[1]=-o*s,t[2]=-n*s,t[3]=r*s,t):null}function ire(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t}function sre(t){return t[0]*t[3]-t[2]*t[1]}function KN(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=o*a+i*c,t[1]=n*a+s*c,t[2]=o*l+i*f,t[3]=n*l+s*f,t}function are(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+i*a,t[1]=n*c+s*a,t[2]=o*-a+i*c,t[3]=n*-a+s*c,t}function cre(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1];return t[0]=o*a,t[1]=n*a,t[2]=i*c,t[3]=s*c,t}function lre(t,e){var r=Math.sin(e),o=Math.cos(e);return t[0]=o,t[1]=r,t[2]=-r,t[3]=o,t}function fre(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t}function ure(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function dre(t){return Math.hypot(t[0],t[1],t[2],t[3])}function hre(t,e,r,o){return t[2]=o[2]/o[0],r[0]=o[0],r[1]=o[1],r[3]=o[3]-t[2]*r[1],[t,e,r]}function pre(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function qN(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function mre(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function gre(t,e){var r=t[0],o=t[1],n=t[2],i=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=Tt*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=Tt*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(n-c)<=Tt*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-l)<=Tt*Math.max(1,Math.abs(i),Math.abs(l))}function _re(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function yre(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t[3]=e[3]+r[3]*o,t}var xre=KN,bre=qN;function Are(){var t=new $e(9);return $e!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}var NS={};Ud(NS,{add:()=>Ooe,calculateW:()=>voe,clone:()=>Roe,conjugate:()=>woe,copy:()=>Loe,create:()=>US,dot:()=>dD,equals:()=>Voe,exactEquals:()=>koe,exp:()=>cD,fromEuler:()=>Poe,fromMat3:()=>fD,fromValues:()=>Ioe,getAngle:()=>xoe,getAxisAngle:()=>yoe,identity:()=>_oe,invert:()=>Eoe,len:()=>Doe,length:()=>hD,lerp:()=>Noe,ln:()=>lD,mul:()=>Foe,multiply:()=>aD,normalize:()=>YS,pow:()=>Soe,random:()=>Coe,rotateX:()=>boe,rotateY:()=>Aoe,rotateZ:()=>Toe,rotationTo:()=>zoe,scale:()=>uD,set:()=>Boe,setAxes:()=>joe,setAxisAngle:()=>sD,slerp:()=>F0,sqlerp:()=>Hoe,sqrLen:()=>Uoe,squaredLength:()=>pD,str:()=>Moe});var z={};Ud(z,{add:()=>Cre,angle:()=>Gre,bezier:()=>Dre,ceil:()=>Ere,clone:()=>Tre,copy:()=>vre,create:()=>$S,cross:()=>O0,dist:()=>Qre,distance:()=>tD,div:()=>Jre,divide:()=>eD,dot:()=>XS,equals:()=>Kre,exactEquals:()=>Yre,floor:()=>wre,forEach:()=>roe,fromValues:()=>DS,hermite:()=>Nre,inverse:()=>Ore,len:()=>iD,length:()=>ZN,lerp:()=>Fre,max:()=>Mre,min:()=>Pre,mul:()=>Zre,multiply:()=>QN,negate:()=>Bre,normalize:()=>nD,random:()=>Ure,rotateX:()=>Hre,rotateY:()=>jre,rotateZ:()=>Wre,round:()=>Rre,scale:()=>Ire,scaleAndAdd:()=>Lre,set:()=>Sre,sqrDist:()=>eoe,sqrLen:()=>toe,squaredDistance:()=>rD,squaredLength:()=>oD,str:()=>Xre,sub:()=>qre,subtract:()=>JN,transformMat3:()=>Vre,transformMat4:()=>kre,transformQuat:()=>zre,zero:()=>$re});function $S(){var t=new $e(3);return $e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Tre(t){var e=new $e(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ZN(t){var e=t[0],r=t[1],o=t[2];return Math.hypot(e,r,o)}function DS(t,e,r){var o=new $e(3);return o[0]=t,o[1]=e,o[2]=r,o}function vre(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Sre(t,e,r,o){return t[0]=e,t[1]=r,t[2]=o,t}function Cre(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function JN(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function QN(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function eD(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function Ere(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function wre(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function Pre(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function Mre(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function Rre(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function Ire(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Lre(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t[2]=e[2]+r[2]*o,t}function tD(t,e){var r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return Math.hypot(r,o,n)}function rD(t,e){var r=e[0]-t[0],o=e[1]-t[1],n=e[2]-t[2];return r*r+o*o+n*n}function oD(t){var e=t[0],r=t[1],o=t[2];return e*e+r*r+o*o}function Bre(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Ore(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function nD(t,e){var r=e[0],o=e[1],n=e[2],i=r*r+o*o+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function XS(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function O0(t,e,r){var o=e[0],n=e[1],i=e[2],s=r[0],a=r[1],c=r[2];return t[0]=n*c-i*a,t[1]=i*s-o*c,t[2]=o*a-n*s,t}function Fre(t,e,r,o){var n=e[0],i=e[1],s=e[2];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t}function Nre(t,e,r,o,n,i){var s=i*i,a=s*(2*i-3)+1,c=s*(i-2)+i,l=s*(i-1),f=s*(3-2*i);return t[0]=e[0]*a+r[0]*c+o[0]*l+n[0]*f,t[1]=e[1]*a+r[1]*c+o[1]*l+n[1]*f,t[2]=e[2]*a+r[2]*c+o[2]*l+n[2]*f,t}function Dre(t,e,r,o,n,i){var s=1-i,a=s*s,c=i*i,l=a*s,f=3*i*a,u=3*c*s,d=c*i;return t[0]=e[0]*l+r[0]*f+o[0]*u+n[0]*d,t[1]=e[1]*l+r[1]*f+o[1]*u+n[1]*d,t[2]=e[2]*l+r[2]*f+o[2]*u+n[2]*d,t}function Ure(t,e){e=e||1;var r=Fs()*2*Math.PI,o=Fs()*2-1,n=Math.sqrt(1-o*o)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=o*e,t}function kre(t,e,r){var o=e[0],n=e[1],i=e[2],s=r[3]*o+r[7]*n+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*o+r[4]*n+r[8]*i+r[12])/s,t[1]=(r[1]*o+r[5]*n+r[9]*i+r[13])/s,t[2]=(r[2]*o+r[6]*n+r[10]*i+r[14])/s,t}function Vre(t,e,r){var o=e[0],n=e[1],i=e[2];return t[0]=o*r[0]+n*r[3]+i*r[6],t[1]=o*r[1]+n*r[4]+i*r[7],t[2]=o*r[2]+n*r[5]+i*r[8],t}function zre(t,e,r){var o=r[0],n=r[1],i=r[2],s=r[3],a=e[0],c=e[1],l=e[2],f=n*l-i*c,u=i*a-o*l,d=o*c-n*a,h=n*d-i*u,p=i*f-o*d,m=o*u-n*f,g=s*2;return f*=g,u*=g,d*=g,h*=2,p*=2,m*=2,t[0]=a+f+h,t[1]=c+u+p,t[2]=l+d+m,t}function Hre(t,e,r,o){var n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0],i[1]=n[1]*Math.cos(o)-n[2]*Math.sin(o),i[2]=n[1]*Math.sin(o)+n[2]*Math.cos(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function jre(t,e,r,o){var n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[2]*Math.sin(o)+n[0]*Math.cos(o),i[1]=n[1],i[2]=n[2]*Math.cos(o)-n[0]*Math.sin(o),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function Wre(t,e,r,o){var n=[],i=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],i[0]=n[0]*Math.cos(o)-n[1]*Math.sin(o),i[1]=n[0]*Math.sin(o)+n[1]*Math.cos(o),i[2]=n[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function Gre(t,e){var r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2],c=Math.sqrt(r*r+o*o+n*n),l=Math.sqrt(i*i+s*s+a*a),f=c*l,u=f&&XS(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function $re(t){return t[0]=0,t[1]=0,t[2]=0,t}function Xre(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function Yre(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Kre(t,e){var r=t[0],o=t[1],n=t[2],i=e[0],s=e[1],a=e[2];return Math.abs(r-i)<=Tt*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(o-s)<=Tt*Math.max(1,Math.abs(o),Math.abs(s))&&Math.abs(n-a)<=Tt*Math.max(1,Math.abs(n),Math.abs(a))}var qre=JN,Zre=QN,Jre=eD,Qre=tD,eoe=rD,iD=ZN,toe=oD,roe=function(){var t=$S();return function(e,r,o,n,i,s){var a,c;for(r||(r=3),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();function ooe(){var t=new $e(4);return $e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function noe(t){var e=new $e(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ioe(t,e,r,o){var n=new $e(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=o,n}function soe(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function aoe(t,e,r,o,n){return t[0]=e,t[1]=r,t[2]=o,t[3]=n,t}function coe(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function loe(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function foe(t){var e=t[0],r=t[1],o=t[2],n=t[3];return Math.hypot(e,r,o,n)}function uoe(t){var e=t[0],r=t[1],o=t[2],n=t[3];return e*e+r*r+o*o+n*n}function doe(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=o*s,t[2]=n*s,t[3]=i*s,t}function hoe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function poe(t,e,r,o){var n=e[0],i=e[1],s=e[2],a=e[3];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t[2]=s+o*(r[2]-s),t[3]=a+o*(r[3]-a),t}function moe(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function goe(t,e){var r=t[0],o=t[1],n=t[2],i=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=Tt*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=Tt*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(n-c)<=Tt*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(i-l)<=Tt*Math.max(1,Math.abs(i),Math.abs(l))}var LGe=function(){var t=ooe();return function(e,r,o,n,i,s){var a,c;for(r||(r=4),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],i(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();function US(){var t=new $e(4);return $e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function _oe(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function sD(t,e,r){r=r*.5;var o=Math.sin(r);return t[0]=o*e[0],t[1]=o*e[1],t[2]=o*e[2],t[3]=Math.cos(r),t}function yoe(t,e){var r=Math.acos(e[3])*2,o=Math.sin(r/2);return o>Tt?(t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o):(t[0]=1,t[1]=0,t[2]=0),r}function xoe(t,e){var r=dD(t,e);return Math.acos(2*r*r-1)}function aD(t,e,r){var o=e[0],n=e[1],i=e[2],s=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=o*f+s*a+n*l-i*c,t[1]=n*f+s*c+i*a-o*l,t[2]=i*f+s*l+o*c-n*a,t[3]=s*f-o*a-n*c-i*l,t}function boe(t,e,r){r*=.5;var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+s*a,t[1]=n*c+i*a,t[2]=i*c-n*a,t[3]=s*c-o*a,t}function Aoe(t,e,r){r*=.5;var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c-i*a,t[1]=n*c+s*a,t[2]=i*c+o*a,t[3]=s*c-n*a,t}function Toe(t,e,r){r*=.5;var o=e[0],n=e[1],i=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=o*c+n*a,t[1]=n*c-o*a,t[2]=i*c+s*a,t[3]=s*c-i*a,t}function voe(t,e){var r=e[0],o=e[1],n=e[2];return t[0]=r,t[1]=o,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-o*o-n*n)),t}function cD(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=Math.sqrt(r*r+o*o+n*n),a=Math.exp(i),c=s>0?a*Math.sin(s)/s:0;return t[0]=r*c,t[1]=o*c,t[2]=n*c,t[3]=a*Math.cos(s),t}function lD(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=Math.sqrt(r*r+o*o+n*n),a=s>0?Math.atan2(s,i)/s:0;return t[0]=r*a,t[1]=o*a,t[2]=n*a,t[3]=.5*Math.log(r*r+o*o+n*n+i*i),t}function Soe(t,e,r){return lD(t,e),uD(t,t,r),cD(t,t),t}function F0(t,e,r,o){var n=e[0],i=e[1],s=e[2],a=e[3],c=r[0],l=r[1],f=r[2],u=r[3],d,h,p,m,g;return h=n*c+i*l+s*f+a*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>Tt?(d=Math.acos(h),p=Math.sin(d),m=Math.sin((1-o)*d)/p,g=Math.sin(o*d)/p):(m=1-o,g=o),t[0]=m*n+g*c,t[1]=m*i+g*l,t[2]=m*s+g*f,t[3]=m*a+g*u,t}function Coe(t){var e=Fs(),r=Fs(),o=Fs(),n=Math.sqrt(1-e),i=Math.sqrt(e);return t[0]=n*Math.sin(2*Math.PI*r),t[1]=n*Math.cos(2*Math.PI*r),t[2]=i*Math.sin(2*Math.PI*o),t[3]=i*Math.cos(2*Math.PI*o),t}function Eoe(t,e){var r=e[0],o=e[1],n=e[2],i=e[3],s=r*r+o*o+n*n+i*i,a=s?1/s:0;return t[0]=-r*a,t[1]=-o*a,t[2]=-n*a,t[3]=i*a,t}function woe(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function fD(t,e){var r=e[0]+e[4]+e[8],o;if(r>0)o=Math.sqrt(r+1),t[3]=.5*o,o=.5/o,t[0]=(e[5]-e[7])*o,t[1]=(e[6]-e[2])*o,t[2]=(e[1]-e[3])*o;else{var n=0;e[4]>e[0]&&(n=1),e[8]>e[n*3+n]&&(n=2);var i=(n+1)%3,s=(n+2)%3;o=Math.sqrt(e[n*3+n]-e[i*3+i]-e[s*3+s]+1),t[n]=.5*o,o=.5/o,t[3]=(e[i*3+s]-e[s*3+i])*o,t[i]=(e[i*3+n]+e[n*3+i])*o,t[s]=(e[s*3+n]+e[n*3+s])*o}return t}function Poe(t,e,r,o){var n=.5*Math.PI/180;e*=n,r*=n,o*=n;var i=Math.sin(e),s=Math.cos(e),a=Math.sin(r),c=Math.cos(r),l=Math.sin(o),f=Math.cos(o);return t[0]=i*c*f-s*a*l,t[1]=s*a*f+i*c*l,t[2]=s*c*l-i*a*f,t[3]=s*c*f+i*a*l,t}function Moe(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var Roe=noe,Ioe=ioe,Loe=soe,Boe=aoe,Ooe=coe,Foe=aD,uD=loe,dD=hoe,Noe=poe,hD=foe,Doe=hD,pD=uoe,Uoe=pD,YS=doe,koe=moe,Voe=goe,zoe=function(){var t=$S(),e=DS(1,0,0),r=DS(0,1,0);return function(o,n,i){var s=XS(n,i);return s<-.999999?(O0(t,e,n),iD(t)<1e-6&&O0(t,r,n),nD(t,t),sD(o,t,Math.PI),o):s>.999999?(o[0]=0,o[1]=0,o[2]=0,o[3]=1,o):(O0(t,n,i),o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=1+s,YS(o,o))}}(),Hoe=function(){var t=US(),e=US();return function(r,o,n,i,s,a){return F0(t,o,s,a),F0(e,n,i,a),F0(r,t,e,2*a*(1-a)),r}}(),joe=function(){var t=Are();return function(e,r,o,n){return t[0]=o[0],t[3]=o[1],t[6]=o[2],t[1]=n[0],t[4]=n[1],t[7]=n[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],YS(e,fD(e,t))}}(),oe={};Ud(oe,{add:()=>Yoe,angle:()=>pne,ceil:()=>Koe,clone:()=>Woe,copy:()=>$oe,create:()=>mD,cross:()=>sne,dist:()=>vne,distance:()=>xD,div:()=>Tne,divide:()=>yD,dot:()=>ine,equals:()=>yne,exactEquals:()=>_ne,floor:()=>qoe,forEach:()=>Ene,fromValues:()=>Goe,inverse:()=>one,len:()=>xne,length:()=>AD,lerp:()=>ane,max:()=>Joe,min:()=>Zoe,mul:()=>Ane,multiply:()=>_D,negate:()=>rne,normalize:()=>nne,random:()=>cne,rotate:()=>hne,round:()=>Qoe,scale:()=>ene,scaleAndAdd:()=>tne,set:()=>Xoe,sqrDist:()=>Sne,sqrLen:()=>Cne,squaredDistance:()=>bD,squaredLength:()=>TD,str:()=>gne,sub:()=>bne,subtract:()=>gD,transformMat2:()=>lne,transformMat2d:()=>fne,transformMat3:()=>une,transformMat4:()=>dne,zero:()=>mne});function mD(){var t=new $e(2);return $e!=Float32Array&&(t[0]=0,t[1]=0),t}function Woe(t){var e=new $e(2);return e[0]=t[0],e[1]=t[1],e}function Goe(t,e){var r=new $e(2);return r[0]=t,r[1]=e,r}function $oe(t,e){return t[0]=e[0],t[1]=e[1],t}function Xoe(t,e,r){return t[0]=e,t[1]=r,t}function Yoe(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function gD(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function _D(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function yD(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Koe(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function qoe(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function Zoe(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Joe(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function Qoe(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function ene(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function tne(t,e,r,o){return t[0]=e[0]+r[0]*o,t[1]=e[1]+r[1]*o,t}function xD(t,e){var r=e[0]-t[0],o=e[1]-t[1];return Math.hypot(r,o)}function bD(t,e){var r=e[0]-t[0],o=e[1]-t[1];return r*r+o*o}function AD(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function TD(t){var e=t[0],r=t[1];return e*e+r*r}function rne(t,e){return t[0]=-e[0],t[1]=-e[1],t}function one(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function nne(t,e){var r=e[0],o=e[1],n=r*r+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t}function ine(t,e){return t[0]*e[0]+t[1]*e[1]}function sne(t,e,r){var o=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=o,t}function ane(t,e,r,o){var n=e[0],i=e[1];return t[0]=n+o*(r[0]-n),t[1]=i+o*(r[1]-i),t}function cne(t,e){e=e||1;var r=Fs()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function lne(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n,t[1]=r[1]*o+r[3]*n,t}function fne(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[2]*n+r[4],t[1]=r[1]*o+r[3]*n+r[5],t}function une(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[3]*n+r[6],t[1]=r[1]*o+r[4]*n+r[7],t}function dne(t,e,r){var o=e[0],n=e[1];return t[0]=r[0]*o+r[4]*n+r[12],t[1]=r[1]*o+r[5]*n+r[13],t}function hne(t,e,r,o){var n=e[0]-r[0],i=e[1]-r[1],s=Math.sin(o),a=Math.cos(o);return t[0]=n*a-i*s+r[0],t[1]=n*s+i*a+r[1],t}function pne(t,e){var r=t[0],o=t[1],n=e[0],i=e[1],s=Math.sqrt(r*r+o*o)*Math.sqrt(n*n+i*i),a=s&&(r*n+o*i)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function mne(t){return t[0]=0,t[1]=0,t}function gne(t){return"vec2("+t[0]+", "+t[1]+")"}function _ne(t,e){return t[0]===e[0]&&t[1]===e[1]}function yne(t,e){var r=t[0],o=t[1],n=e[0],i=e[1];return Math.abs(r-n)<=Tt*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(o-i)<=Tt*Math.max(1,Math.abs(o),Math.abs(i))}var xne=AD,bne=gD,Ane=_D,Tne=yD,vne=xD,Sne=bD,Cne=TD,Ene=function(){var t=mD();return function(e,r,o,n,i,s){var a,c;for(r||(r=2),o||(o=0),n?c=Math.min(n*r+o,e.length):c=e.length,a=o;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],i(t,t,s),e[a]=t[0],e[a+1]=t[1];return e}}(),V0=(1+Math.sqrt(5))/2,BGe=2*Math.PI,N0=2*Math.PI/5,$o=Math.PI/5,PN=Math.PI/10,wne=2*Math.atan(V0),kS=Math.PI-wne,OGe=-.5*Math.PI+Math.acos(-1/Math.sqrt(3-V0)),z0=(Math.sqrt(5)-1)/2,Pne=3-Math.sqrt(5),Mne=Math.sqrt(3-V0),FGe=Math.sqrt(3)*Mne/V0,D0=63710072e-1,NGe=4*Math.PI*D0*D0;vt.setMatrixArrayType(Float64Array);var KS=class VS{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0,r=this.vertices.length;for(let o=0;o<r;o++){let n=(o+1)%r;e+=(this.vertices[n][0]-this.vertices[o][0])*(this.vertices[n][1]+this.vertices[o][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(let r of this.vertices)oe.scale(r,r,e);return this}rotate180(){for(let e of this.vertices)oe.negate(e,e);return this}reflectY(){for(let e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(let r of this.vertices)oe.add(r,r,e);return this}transform(e){for(let r of this.vertices)oe.transformMat2(r,r,e);return this}transform2d(e){for(let r of this.vertices)oe.transformMat2d(r,r,e);return this}clone(){return new VS(this.vertices.map(r=>oe.clone(r)))}getCenter(){let e=this.vertices.length;return this.vertices.reduce((o,n)=>[o[0]+n[0]/e,o[1]+n[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");let r=this.vertices.length,o=1;for(let n=0;n<r;n++){let i=this.vertices[n],s=this.vertices[(n+1)%r],a=i[0]-s[0],c=i[1]-s[1],l=e[0]-i[0],f=e[1]-i[1],u=a*f-c*l;if(u<0){let d=Math.sqrt(l*l+f*f);o=Math.min(o,u/d)}}return o}splitEdges(e){if(e<=1)return this;let r=[],o=this.vertices.length;for(let n=0;n<o;n++){let i=this.vertices[n],s=this.vertices[(n+1)%o];r.push(oe.clone(i));for(let a=1;a<e;a++){let c=a/e,l=oe.create();oe.lerp(l,i,s,c),r.push(l)}}return new VS(r)}};vt.setMatrixArrayType(Float64Array);var vD=[0,0],SD=[0,1],Ds=[.7885966681787006,1.6149108024237764],CD=[1.6171013659387945,1.054928690397459],ED=[Math.cos(PN),Math.sin(PN)],Rne=2*oe.length(Ds)*Math.cos($o),Ine=$o-Math.atan2(Ds[1],Ds[0]),Lne=2*z0/Rne;[vD,SD,Ds,CD,ED].forEach(t=>{oe.scale(t,t,Lne),oe.rotate(t,t,[0,0],Ine)});var Bne=new KS([vD,SD,Ds,CD,ED]),wD=Math.atan2(Ds[1],Ds[0])-$o,One=[0,0],U0=z0/Math.cos($o),MN=wD+$o,k0=[U0*Math.cos(MN),U0*Math.sin(MN)],RN=wD-$o,Dd=[U0*Math.cos(RN),U0*Math.sin(RN)],PD=new KS([One,k0,Dd]),MD=Ns.fromValues(k0[0],k0[1],Dd[0],Dd[1]),DGe=Ns.invert(Ns.create(),MD),Fne=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2559257686421274e-24,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),Nne=new Float64Array([.0022392089963541657,28831978048607556e-22,508622073997266e-23,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]),Dne=class{applyCoefficients(t,e){let r=Math.sin(t),o=Math.cos(t),n=2*(o-r)*(o+r),i,s;return i=n*e[5]+e[4],s=n*i+e[3],i=n*s-i+e[2],s=n*i-s+e[1],i=n*s-i+e[0],t+2*r*o*i}forward(t){return this.applyCoefficients(t,Fne)}inverse(t){return this.applyCoefficients(t,Nne)}};vt.setMatrixArrayType(Float64Array);var RD=new Dne;function IN(t){return t*(Math.PI/180)}function LN(t){return t*(180/Math.PI)}function BN(t){let e=oe.length(t),r=Math.atan2(t[1],t[0]);return[e,r]}function Une([t,e]){let r=t*Math.cos(e),o=t*Math.sin(e);return[r,o]}function kne(t,[e,r,o]){let n=[e[0]-o[0],e[1]-o[1]],i=[o[0]-r[0],o[1]-r[1]],s=[t[0]-o[0],t[1]-o[1]],a=i[0]*n[1]-i[1]*n[0],c=(i[0]*s[1]-i[1]*s[0])/a,l=(n[0]*s[1]-n[1]*s[0])/a,f=1-(c+l);return[c,l,f]}function Vne(t,[e,r,o]){return[t[0]*e[0]+t[1]*r[0]+t[2]*o[0],t[0]*e[1]+t[1]*r[1]+t[2]*o[1]]}function zS(t){let e=Math.atan2(t[1],t[0]),r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),o=Math.acos(t[2]/r);return[e,o]}function Nc([t,e]){let r=Math.sin(e),o=r*Math.cos(t),n=r*Math.sin(t),i=Math.cos(e);return[o,n,i]}var ID=93;function zne([t,e]){let r=IN(t+ID),o=IN(e),n=RD.forward(o),i=Math.PI/2-n;return[r,i]}function LD([t,e]){let r=LN(t)-ID,o=Math.PI/2-e,n=RD.inverse(o),i=LN(n);return[r,i]}function Hne(t){let e=t.map(i=>Nc(zne(i))),r=z.create();for(let i of e)z.add(r,r,i);z.normalize(r,r);let[o,n]=LD(zS(r));return(n>89.99||n<-89.99)&&(o=t[0][0]),o=((o+180)%360+360)%360-180,t.map(i=>{let[s,a]=i;for(;s-o>180;)s=s-360;for(;s-o<-180;)s=s+360;return[s,a]})}vt.setMatrixArrayType(Float64Array);var H0=Math.sqrt(5),j0=Math.sqrt(.2),BD=Math.sqrt((1-j0)/2),OD=Math.sqrt((1+j0)/2),E0=.5,ON=Math.sqrt((2.5-H0)/10),FN=Math.sqrt((2.5+H0)/10),NN=Math.sqrt((1+j0)/8),DN=Math.sqrt((1-j0)/8),UN=Math.sqrt((3-H0)/8),kN=Math.sqrt((3+H0)/8),jne=[[0,0],[BD,0],[ON,E0],[-NN,UN],[-NN,-UN],[ON,-E0],[-OD,0],[-DN,-kN],[FN,-E0],[FN,E0],[-DN,kN],[0,0]],Wne=jne.map(([t,e])=>[-e,t]),w0=Wne.map((t,e)=>e===0?[0,0,0,1]:e===11?[0,-1,0,0]:[...t,0,e<6?OD:BD]);vt.setMatrixArrayType(Float64Array);var FD=["vu","uw","vw","vw","vw"],Fd=["wu","uw","vw","vu","uw"],BS=["wu","uv","wv","wu","uw"],P0=["vu","uv","wv","wu","uw"],Gne=[FD,P0,BS,Fd,BS,P0,BS,Fd,Fd,Fd,P0,P0],$ne=[4,2,3,2,0,4,3,2,2,0,3,0],VN=[0,1,2,4,3,5,7,8,6,11,10,9],ao=[];function Xne(){M0([0,0],0,w0[0]);for(let t=0;t<5;t++){let e=t*N0,r=e+$o;M0([e,kS],$o,w0[t+1]),M0([r,Math.PI-kS],$o,w0[(t+3)%5+6])}M0([0,Math.PI],0,w0[11])}var Bc=0;function M0(t,e,r){if(Bc>11)throw new Error(`Too many origins: ${Bc}`);let o=NS.create();NS.conjugate(o,r);let n={id:Bc,axis:t,quat:r,inverseQuat:o,angle:e,orientation:Gne[Bc],firstQuintant:$ne[Bc]};ao.push(n),Bc++}Xne();ao.sort((t,e)=>VN.indexOf(t.id)-VN.indexOf(e.id));ao.forEach((t,e)=>t.id=e);function Yne(t,e){let r=e.orientation,o=r===FD||r===Fd?-1:1,n=(t-e.firstQuintant+5)%5,i=r[n];return{quintant:(e.firstQuintant+o*n+5)%5,orientation:i}}var Kne=class{forward([t,e]){return[Math.tan(e),t]}inverse([t,e]){return[e,Math.atan(t)]}},Oc=z.create(),Nd=z.create(),zN=z.create(),HN=z.create();function OS(t,e){z.lerp(Oc,t,e,.5),z.normalize(Oc,Oc),z.cross(Oc,t,Oc);let r=z.length(Oc);if(r<1e-8){let o=z.subtract(z.create(),t,e);return .5*z.length(o)}return r}function qne(t,e,r){return z.cross(Nd,e,r),z.dot(t,Nd)}function Zne(t,e,r,o,n){z.cross(Nd,o,n);let i=z.dot(e,Nd),s=z.dot(r,Nd);return z.scale(zN,e,s),z.scale(HN,r,i),z.sub(t,HN,zN)}function HS(t,e,r,o){let n=z.angle(e,r);if(n<1e-12)return z.lerp(t,e,r,o);let i=Math.sin((1-o)*n)/Math.sin(n),s=Math.sin(o*n)/Math.sin(n),a=z.scale(z.create(),e,i),c=z.scale(z.create(),r,s);return z.add(t,a,c)}vt.setMatrixArrayType(Float64Array);var R0=z.create(),I0=z.create(),L0=z.create(),Fc=z.create(),Jne=class{constructor(t){this._area=null,this.vertices=t,Object.freeze(this.vertices)}getBoundary(t=1,e=!0){let r=[],o=this.vertices.length;for(let n=0;n<o*t;n++){let i=n/t;r.push(this.slerp(i))}return e&&r.push(r[0]),r}slerp(t){let e=this.vertices.length,r=t%1,o=Math.floor(t%e),n=(o+1)%e;return HS(z.create(),this.vertices[o],this.vertices[n],r)}getTransformedVertices(t){let e=this.vertices.length,r=Math.floor(t%e),o=(r+1)%e,n=(r+e-1)%e,i=z.clone(this.vertices[r]),s=z.clone(this.vertices[o]),a=z.clone(this.vertices[n]);return z.sub(s,s,i),z.sub(a,a,i),[i,s,a]}containsPoint(t){let e=this.vertices.length,r=1/0;for(let o=0;o<e;o++){let[n,i,s]=this.getTransformedVertices(o),a=z.sub(z.create(),t,n);z.normalize(a,a),z.normalize(i,i),z.normalize(s,s);let c=z.cross(z.create(),i,a),l=z.cross(z.create(),a,s),f=z.dot(n,c),u=z.dot(n,l);r=Math.min(r,f,u)}return r}getTriangleArea(t,e,r){z.lerp(R0,e,r,.5),z.lerp(I0,r,t,.5),z.lerp(L0,t,e,.5),z.normalize(R0,R0),z.normalize(I0,I0),z.normalize(L0,L0);let o=qne(R0,I0,L0),n=Math.max(-1,Math.min(1,o));return Math.abs(n)<1e-8?2*n:Math.asin(n)*2}getArea(){return this._area===null&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(this.vertices.length===3)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;z.set(Fc,0,0,0);for(let e of this.vertices)z.add(Fc,Fc,e);z.normalize(Fc,Fc);let t=0;for(let e=0;e<this.vertices.length;e++){let r=this.vertices[e],o=this.vertices[(e+1)%this.vertices.length],n=this.getTriangleArea(Fc,r,o);isNaN(n)||(t+=n)}return this._area=t,this._area}isWindingCorrect(){if(!(this.getArea()>0))debugger}};vt.setMatrixArrayType(Float64Array);var B0=class extends Jne{constructor(t){if(t.length!==3)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(t)}};vt.setMatrixArrayType(Float64Array);var Qne=class{forward(t,e,r){let[o,n,i]=e,s=new B0([o,n,i]),a=z.subtract(z.create(),t,o);z.normalize(a,a);let c=Zne(z.create(),o,a,n,i);z.normalize(c,c);let l=OS(o,t)/OS(o,c),f=s.getArea(),u=l/f,d=[1-l,u*new B0([o,c,i]).getArea(),u*new B0([o,n,c]).getArea()];return Vne(d,r)}inverse(t,e,r){let[o,n,i]=r,s=new B0([o,n,i]),a=kne(t,e),c=1-1e-14;if(a[0]>c)return o;if(a[1]>c)return n;if(a[2]>c)return i;let l=z.create();z.cross(l,n,i);let f=s.getArea(),u=1-a[0],h=a[2]/u*f,p=Math.sin(h),m=Math.sin(h/2),g=2*m*m,_=z.dot(o,n),x=z.dot(n,i),y=z.dot(i,o),b=z.length(l),T=z.dot(o,l),v=p*T+g*(_*x-y),w=g*b*(1+_),C=2/Math.acos(x)*Math.atan2(w,v),S=HS(z.create(),n,i,C),A=OS(o,S),M=this.safeAcos(u*A)/this.safeAcos(A);return HS([0,0,0],o,S,M)}safeAcos(t){return t<.001?2*t+t*t*t/3:Math.acos(1-2*t*t)}},yr=-1,jt=1;vt.setMatrixArrayType(Float64Array);var eie=([t,e])=>oe.fromValues(t-e,e);vt.setMatrixArrayType(Float64Array);var jS=oe.fromValues(1,0),WS=oe.fromValues(0,1),jN=oe.negate(oe.create(),jS),WN=oe.negate(oe.create(),WS),FS=oe.fromValues(0,0),tie=(t,[e,r])=>{let o=FS,n=FS;switch(e===jt&&r===jt?(o=jS,n=WS):e===yr&&r===jt?(o=WN,n=jN):e===jt&&r===yr?(o=WS,n=jS):e===yr&&r===yr&&(o=jN,n=WN),t){case 0:return FS;case 1:return o;case 2:return oe.add(oe.create(),n,o);case 3:return oe.scaleAndAdd(oe.create(),n,o,2);default:throw new Error(`Invalid Quaternary value: ${t}`)}},GN=t=>[[jt,jt],[jt,yr],[jt,jt],[yr,jt]][t];function ND(t){return Array.from({length:t.length},(e,r)=>t.indexOf(r))}var DD=[0,1,3,4,5,6,7,2],UD=[0,1,2,7,3,4,5,6],UGe=ND(DD),kGe=ND(UD),rie=(t,e,r,o,n)=>{if(e<=0)return;let i=t[e]||0,s=t[e-1],a=r[0]+r[1],c=!0,l=!0;if(o!==(a===0)?(c=i===1||i===2,l=i===1):(c=i<2,l=i===0),!c)return;let f=l?s:s+4,u=n[f];t[e-1]=u%4,t[e]=(i+4+Math.floor(u/4)-Math.floor(f/4))%4};vt.setMatrixArrayType(Float64Array);var $N=oe.fromValues(-1,1),kD=!0,oie=(t,e,r,o=kD)=>{let n=BigInt(t),i=r==="vu"||r==="wu"||r==="vw",s=r==="wv"||r==="vw",a=r==="wu"||r==="uw";i&&(n=(1n<<BigInt(2*e))-n-1n);let c=nie(n,e,s,a,o);if(a){let{offset:[l,f],flips:[u,d]}=c;c.offset=[f,l],u===yr&&oe.add(c.offset,c.offset,$N),d===yr&&oe.subtract(c.offset,c.offset,$N)}if(s){let{offset:[l,f],flips:u}=c,d=(1<<e)-(l+f);u[0]=-u[0],c.offset[1]=d,c.flips=u}return c},nie=(t,e,r,o,n=kD)=>{let i=oe.create(),s=[jt,jt],a=BigInt(t),c=[];for(;a>0n||c.length<e;)c.push(Number(a%4n)),a=a>>2n;let l=o?UD:DD;for(let u=c.length-1;u>=0;u--)n&&rie(c,u,s,r,l),oe.multiply(s,s,GN(c[u]));s[0]=jt,s[1]=jt;for(let u=c.length-1;u>=0;u--){oe.scale(i,i,2);let d=tie(c[u],s);oe.add(i,i,d),oe.multiply(s,s,GN(c[u]))}return{q:c[0]||0,offset:eie(i),flips:s}};var Si=.1,VGe=[[Si*Math.cos(45*Math.PI/180),Si*Math.sin(45*Math.PI/180)],[Si*Math.cos(113*Math.PI/180),Si*Math.sin(113*Math.PI/180)],[Si*Math.cos(293*Math.PI/180),Si*Math.sin(293*Math.PI/180)],[Si*Math.cos(225*Math.PI/180),Si*Math.sin(225*Math.PI/180)]];vt.setMatrixArrayType(Float64Array);var iie=!1,sie=oe.clone(Dd),aie=oe.negate(oe.create(),Dd),qS=[0,1,2,3,4].map(t=>{let e=Ns.create();return Ns.fromRotation(e,N0*t),e}),XN=oe.create();function cie(t,e,r){let o=(iie?PD:Bne).clone();oe.transformMat2(XN,r.offset,MD),r.flips[0]===jt&&r.flips[1]===yr&&o.rotate180();let{q:n}=r,i=r.flips[0]+r.flips[1];return((i===-2||i===2)&&n>1||i===0&&(n===0||n===3))&&o.reflectY(),r.flips[0]===yr&&r.flips[1]===yr?o.rotate180():r.flips[0]===yr?o.translate(aie):r.flips[1]===yr&&o.translate(sie),o.translate(XN),o.scale(1/2**t),o.transform(qS[e]),o}function VD(t){let e=PD.clone();return e.transform(qS[t]),e}function lie(){let t=[];for(let e of qS)t.push(oe.transformMat2(oe.create(),k0,e));return t.reverse(),new KS(t)}vt.setMatrixArrayType(Float64Array);var fie=class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),this.vertices.length!==62)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(t){this.invocations++,this.invocations===1e4&&console.warn("Too many CRS invocations, results should be cached");for(let e of this.vertices)if(z.distance(t,e)<1e-5)return e;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){ao.forEach(t=>this.add(Nc(t.axis)))}addVertices(){let t=Math.atan(Pne);for(let e of ao)for(let r=0;r<5;r++){let o=(2*r+1)*Math.PI/5,n=Nc([o+e.angle,t]);z.transformQuat(n,n,e.quat),this.add(n)}}addMidpoints(){let t=Math.atan(z0);for(let e of ao)for(let r=0;r<5;r++){let o=2*r*Math.PI/5,n=Nc([o+e.angle,t]);z.transformQuat(n,n,e.quat),this.add(n)}}add(t){let e=z.normalize(z.create(),t);return this.vertices.find(o=>z.distance(e,o)<1e-5)?!1:(this.vertices.push(e),!0)}};vt.setMatrixArrayType(Float64Array);var uie=new fie,die=class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new Qne,this.gnomonic=new Kne}forward(t,e){let r=ao[e],o=Nc(t),n=z.create();z.transformQuat(n,o,r.inverseQuat);let i=zS(n),s=this.gnomonic.forward(i);s[1]=s[1]-r.angle;let a=this.getFaceTriangleIndex(s),c=this.shouldReflect(s),l=this.getFaceTriangle(a,c,!1),f=this.getSphericalTriangle(a,e,c);return this.polyhedral.forward(o,f,l)}inverse(t,e){let r=BN(t),o=this.getFaceTriangleIndex(r),n=this.shouldReflect(r),i=this.getFaceTriangle(o,n,!1),s=this.getSphericalTriangle(o,e,n),a=this.polyhedral.inverse(t,i,s);return zS(a)}shouldReflect(t){let[e,r]=t;return Une([e,this.normalizeGamma(r)])[0]>z0}getFaceTriangleIndex([t,e]){return(Math.floor(e/$o)+10)%10}getFaceTriangle(t,e=!1,r=!1){let o=t;return e&&(o+=r?20:10),this.faceTriangles[o]?this.faceTriangles[o]:(this.faceTriangles[o]=e?this._getReflectedFaceTriangle(t,r):this._getFaceTriangle(t),Object.freeze(this.faceTriangles[o]),this.faceTriangles[o])}_getFaceTriangle(t){let e=Math.floor((t+1)/2)%5,[r,o,n]=VD(e).getVertices(),i=oe.create();return oe.lerp(i,o,n,.5),t%2===0?[r,i,o]:[r,n,i]}_getReflectedFaceTriangle(t,e=!1){let[r,o,n]=this._getFaceTriangle(t).map(a=>oe.clone(a)),i=t%2===0;oe.negate(r,r);let s=i?o:n;return oe.scaleAndAdd(r,r,s,e?1+1/Math.cos(kS):2),[r,n,o]}getSphericalTriangle(t,e,r=!1){let o=10*e+t;return r&&(o+=120),this.sphericalTriangles[o]?this.sphericalTriangles[o]:(this.sphericalTriangles[o]=this._getSphericalTriangle(t,e,r),Object.freeze(this.sphericalTriangles[o]),this.sphericalTriangles[o])}_getSphericalTriangle(t,e,r=!1){let o=ao[e];return this.getFaceTriangle(t,r,!0).map(s=>{let[a,c]=BN(s),l=[a,c+o.angle],f=Nc(this.gnomonic.inverse(l));return z.transformQuat(f,f,o.quat),uie.getVertex(f)})}normalizeGamma(t){let e=t/N0,r=Math.round(e);return(e-r)*N0}},Dc=2,GS=30,YN=58n,hie=0n;function pie(t){if(t===0n)return-1;if(t&1n||(t&0b111n)===0b100n||(t&0b11111n)===0b10000n)return GS;let e=GS-1,r=t>>1n;if(r===0n)return-1;let o=Number(r&0xFFFFFFFFn),n;for(o===0?(r>>=32n,e-=16,n=Number(r)):n=o,n&65535||(n>>=16,e-=8),e>=6&&!(n&255)&&(n>>=8,e-=4),e>=4&&!(n&15)&&(n>>=4,e-=2);e>-1&&!(n&1);)e-=1,n=n>>(e<Dc?1:2);return e}function mie(t){let e=pie(t);if(e===-1)return{origin:ao[0],segment:0,S:0n,resolution:e};let r=YN,o=0;if(e===GS){let u=t&1n?1n:t&0b100n?3n:5n;r=YN+u,o=u===1n?0:u===3n?32:40}let n=Number(t>>r)+o,i,s;if(e===0)i=ao[n],s=0;else{let u=Math.floor(n/5);i=ao[u],s=(n+i.firstQuintant)%5}if(!i)throw new Error(`Could not parse origin: ${n}`);if(e<Dc)return{origin:i,segment:s,S:0n,resolution:e};let a=e-Dc+1,c=BigInt(2*a),l=(1n<<r)-1n,f=(t&l)>>r-c;return{origin:i,segment:s,S:f,resolution:e}}vt.setMatrixArrayType(Float64Array);var zGe=Ns.create(),gie=new die;function _ie({S:t,segment:e,origin:r,resolution:o}){let{quintant:n,orientation:i}=Yne(e,r);if(o===Dc-1)return VD(n);if(o===Dc-2)return lie();let s=o-Dc+1,a=oie(t,s,i);return cie(s,n,a)}function zD(t,{closedRing:e=!0,segments:r="auto"}={closedRing:!0,segments:"auto"}){if(t===hie)return[];let{S:o,segment:n,origin:i,resolution:s}=mie(t);r==="auto"&&(r=Math.max(1,Math.pow(2,6-s)));let u=_ie({S:o,segment:n,origin:i,resolution:s}).splitEdges(r).getVertices().map(h=>gie.inverse(h,i.id)).map(h=>LD(h)),d=Hne(u);return e&&d.push(d[0]),d.reverse(),d}function HD(t){return BigInt(`0x${t}`)}var jD=2;var yie=jD*D0/Math.sqrt(15),WD=new Array(31);WD[0]=jD*D0/Math.sqrt(3);for(let t=1;t<=30;t++)WD[t]=yie/(1<<t-1);vt.setMatrixArrayType(Float64Array);var Vd=kn(kd(),1);function W0(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let o=r[0]-e;o>180?r[0]-=360:o<-180&&(r[0]+=360)}}function xie(t,e,r){let[o,n]=(0,Vd.cellToLatLng)(t),i=e.length;W0(e,n);let s=e[0]===e[i-1]?i-1:i;for(let a=0;a<s;a++)e[a][0]=lt(n,e[a][0],r),e[a][1]=lt(o,e[a][1],r)}function $D(t,e,r){let o=t(e,r),[n,i]=(0,Vd.cellToLatLng)(o);return[i,n]}function ZS(t,e=1){let r=(0,Vd.cellToBoundary)(t,!0);return e!==1?xie(t,r,e):W0(r),r}function G0(t){let e=new Float64Array(t.length*2),r=0;for(let o of t)e[r++]=o[0],e[r++]=o[1];return e}var bie={getPentagon:{type:"accessor",value:t=>t.pentagon}},zd=class extends Or{indexToBounds(){let{data:e,getPentagon:r}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(o,n)=>{let i=r(o,n),s=zD(typeof i=="string"?HD(i):i,{closedRing:!0,segments:"auto"});return G0(s)}}}};zd.layerName="A5Layer";zd.defaultProps=bie;var XD=zd;function Aie(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function $0(t){if(Array.isArray(t))return t.map(e=>$0(e));if(t&&typeof t=="object"){let e={};for(let[r,o]of Object.entries(t))e[Aie(r)]=$0(o);return e}return t}var YD=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Tie=YD+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",vie="["+YD+"]["+Tie+"]*",Sie=new RegExp("^"+vie+"$");function X0(t,e){let r=[],o=e.exec(t);for(;o;){let n=[];n.startIndex=e.lastIndex-o[0].length;let i=o.length;for(let s=0;s<i;s++)n.push(o[s]);r.push(n),o=e.exec(t)}return r}var Uc=function(t){let e=Sie.exec(t);return!(e===null||typeof e>"u")};function KD(t){return typeof t<"u"}var Hd=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Y0=["__proto__","constructor","prototype"];var Cie={allowBooleanAttributes:!1,unpairedTags:[]};function eU(t,e){e=Object.assign({},Cie,e);let r=[],o=!1,n=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let i=0;i<t.length;i++)if(t[i]==="<"&&t[i+1]==="?"){if(i+=2,i=ZD(t,i),i.err)return i}else if(t[i]==="<"){let s=i;if(i++,t[i]==="!"){i=JD(t,i);continue}else{let a=!1;t[i]==="/"&&(a=!0,i++);let c="";for(;i<t.length&&t[i]!==">"&&t[i]!==" "&&t[i]!==" "&&t[i]!==`
`&&t[i]!=="\r";i++)c+=t[i];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),i--),!Bie(c)){let u;return c.trim().length===0?u="Invalid space after '<'.":u="Tag '"+c+"' is an invalid name.",qe("InvalidTag",u,Wt(t,i))}let l=Pie(t,i);if(l===!1)return qe("InvalidAttr","Attributes for '"+c+"' have open quote.",Wt(t,i));let f=l.value;if(i=l.index,f[f.length-1]==="/"){let u=i-f.length;f=f.substring(0,f.length-1);let d=QD(f,e);if(d===!0)o=!0;else return qe(d.err.code,d.err.msg,Wt(t,u+d.err.line))}else if(a)if(l.tagClosed){if(f.trim().length>0)return qe("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",Wt(t,s));if(r.length===0)return qe("InvalidTag","Closing tag '"+c+"' has not been opened.",Wt(t,s));{let u=r.pop();if(c!==u.tagName){let d=Wt(t,u.tagStartPos);return qe("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+d.line+", col "+d.col+") instead of closing tag '"+c+"'.",Wt(t,s))}r.length==0&&(n=!0)}}else return qe("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",Wt(t,i));else{let u=QD(f,e);if(u!==!0)return qe(u.err.code,u.err.msg,Wt(t,i-f.length+u.err.line));if(n===!0)return qe("InvalidXml","Multiple possible root nodes found.",Wt(t,i));e.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:s}),o=!0}for(i++;i<t.length;i++)if(t[i]==="<")if(t[i+1]==="!"){i++,i=JD(t,i);continue}else if(t[i+1]==="?"){if(i=ZD(t,++i),i.err)return i}else break;else if(t[i]==="&"){let u=Iie(t,i);if(u==-1)return qe("InvalidChar","char '&' is not expected.",Wt(t,i));i=u}else if(n===!0&&!qD(t[i]))return qe("InvalidXml","Extra text at the end",Wt(t,i));t[i]==="<"&&i--}}else{if(qD(t[i]))continue;return qe("InvalidChar","char '"+t[i]+"' is not expected.",Wt(t,i))}if(o){if(r.length==1)return qe("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Wt(t,r[0].tagStartPos));if(r.length>0)return qe("InvalidXml","Invalid '"+JSON.stringify(r.map(i=>i.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return qe("InvalidXml","Start tag expected.",1);return!0}function qD(t){return t===" "||t===" "||t===`
`||t==="\r"}function ZD(t,e){let r=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){let o=t.substr(r,e-r);if(e>5&&o==="xml")return qe("InvalidXml","XML declaration allowed only at the start of the document.",Wt(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function JD(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e<t.length;e++)if(t[e]==="<")r++;else if(t[e]===">"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}var Eie='"',wie="'";function Pie(t,e){let r="",o="",n=!1;for(;e<t.length;e++){if(t[e]===Eie||t[e]===wie)o===""?o=t[e]:o!==t[e]||(o="");else if(t[e]===">"&&o===""){n=!0;break}r+=t[e]}return o!==""?!1:{value:r,index:e,tagClosed:n}}var Mie=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function QD(t,e){let r=X0(t,Mie),o={};for(let n=0;n<r.length;n++){if(r[n][1].length===0)return qe("InvalidAttr","Attribute '"+r[n][2]+"' has no space in starting.",jd(r[n]));if(r[n][3]!==void 0&&r[n][4]===void 0)return qe("InvalidAttr","Attribute '"+r[n][2]+"' is without value.",jd(r[n]));if(r[n][3]===void 0&&!e.allowBooleanAttributes)return qe("InvalidAttr","boolean attribute '"+r[n][2]+"' is not allowed.",jd(r[n]));let i=r[n][2];if(!Lie(i))return qe("InvalidAttr","Attribute '"+i+"' is an invalid name.",jd(r[n]));if(!Object.prototype.hasOwnProperty.call(o,i))o[i]=1;else return qe("InvalidAttr","Attribute '"+i+"' is repeated.",jd(r[n]))}return!0}function Rie(t,e){let r=/\d/;for(t[e]==="x"&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(r))break}return-1}function Iie(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Rie(t,e);let r=0;for(;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(t[e]===";")break;return-1}return e}function qe(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function Lie(t){return Uc(t)}function Bie(t){return Uc(t)}function Wt(t,e){let r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function jd(t){return t.startIndex+t[1].length}var tU=t=>Hd.includes(t)?"__"+t:t,Oie={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:tU};function Fie(t,e){if(typeof t!="string")return;let r=t.toLowerCase();if(Hd.some(o=>r===o.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y0.some(o=>r===o.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function rU(t){return typeof t=="boolean"?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof t=="object"&&t!==null?{enabled:t.enabled!==!1,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null}:rU(!0)}var oU=function(t){let e=Object.assign({},Oie,t),r=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(let{value:o,name:n}of r)o&&Fie(o,n);return e.onDangerousProperty===null&&(e.onDangerousProperty=tU),e.processEntities=rU(e.processEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(o=>typeof o=="string"&&o.startsWith("*.")?".."+o.substring(2):o)),e};var K0;typeof Symbol!="function"?K0="@@xmlMetadata":K0=Symbol("XML Node Metadata");var Qt=class{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e,r){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child}),r!==void 0&&(this.child[this.child.length-1][K0]={startIndex:r})}static getMetaDataSymbol(){return K0}};var Gd=class{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,r){let o=Object.create(null),n=0;if(e[r+3]==="O"&&e[r+4]==="C"&&e[r+5]==="T"&&e[r+6]==="Y"&&e[r+7]==="P"&&e[r+8]==="E"){r=r+9;let i=1,s=!1,a=!1,c="";for(;r<e.length;r++)if(e[r]==="<"&&!a){if(s&&Us(e,"!ENTITY",r)){r+=7;let l,f;if([l,f,r]=this.readEntityExp(e,r+1,this.suppressValidationErr),f.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&n>=this.options.maxEntityCount)throw new Error(`Entity count (${n+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);let u=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");o[l]={regx:RegExp(`&${u};`,"g"),val:f},n++}}else if(s&&Us(e,"!ELEMENT",r)){r+=8;let{index:l}=this.readElementExp(e,r+1);r=l}else if(s&&Us(e,"!ATTLIST",r))r+=8;else if(s&&Us(e,"!NOTATION",r)){r+=9;let{index:l}=this.readNotationExp(e,r+1,this.suppressValidationErr);r=l}else if(Us(e,"!--",r))a=!0;else throw new Error("Invalid DOCTYPE");i++,c=""}else if(e[r]===">"){if(a?e[r-1]==="-"&&e[r-2]==="-"&&(a=!1,i--):i--,i===0)break}else e[r]==="["?s=!0:c+=e[r];if(i!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:o,i:r}}readEntityExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r])&&e[r]!=='"'&&e[r]!=="'";)r++;let n=e.substring(o,r);if(Wd(n),r=er(e,r),!this.suppressValidationErr){if(e.substring(r,r+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[r]==="%")throw new Error("Parameter entities are not supported")}let i="";if([r,i]=this.readIdentifierVal(e,r,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&i.length>this.options.maxEntitySize)throw new Error(`Entity "${n}" size (${i.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return r--,[n,i,r]}readNotationExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let n=e.substring(o,r);!this.suppressValidationErr&&Wd(n),r=er(e,r);let i=e.substring(r,r+6).toUpperCase();if(!this.suppressValidationErr&&i!=="SYSTEM"&&i!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${i}"`);r+=i.length,r=er(e,r);let s=null,a=null;if(i==="PUBLIC")[r,s]=this.readIdentifierVal(e,r,"publicIdentifier"),r=er(e,r),(e[r]==='"'||e[r]==="'")&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"));else if(i==="SYSTEM"&&([r,a]=this.readIdentifierVal(e,r,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:s,systemIdentifier:a,index:--r}}readIdentifierVal(e,r,o){let n="",i=e[r];if(i!=='"'&&i!=="'")throw new Error(`Expected quoted string, found "${i}"`);r++;let s=r;for(;r<e.length&&e[r]!==i;)r++;if(n=e.substring(s,r),e[r]!==i)throw new Error(`Unterminated ${o} value`);return r++,[r,n]}readElementExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let n=e.substring(o,r);if(!this.suppressValidationErr&&!Uc(n))throw new Error(`Invalid element name: "${n}"`);r=er(e,r);let i="";if(e[r]==="E"&&Us(e,"MPTY",r))r+=4;else if(e[r]==="A"&&Us(e,"NY",r))r+=2;else if(e[r]==="("){r++;let s=r;for(;r<e.length&&e[r]!==")";)r++;if(i=e.substring(s,r),e[r]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[r]}"`);return{elementName:n,contentModel:i.trim(),index:r}}readAttlistExp(e,r){r=er(e,r);let o=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;let n=e.substring(o,r);for(Wd(n),r=er(e,r),o=r;r<e.length&&!/\s/.test(e[r]);)r++;let i=e.substring(o,r);if(!Wd(i))throw new Error(`Invalid attribute name: "${i}"`);r=er(e,r);let s="";if(e.substring(r,r+8).toUpperCase()==="NOTATION"){if(s="NOTATION",r+=8,r=er(e,r),e[r]!=="(")throw new Error(`Expected '(', found "${e[r]}"`);r++;let c=[];for(;r<e.length&&e[r]!==")";){let l=r;for(;r<e.length&&e[r]!=="|"&&e[r]!==")";)r++;let f=e.substring(l,r);if(f=f.trim(),!Wd(f))throw new Error(`Invalid notation name: "${f}"`);c.push(f),e[r]==="|"&&(r++,r=er(e,r))}if(e[r]!==")")throw new Error("Unterminated list of notations");r++,s+=" ("+c.join("|")+")"}else{let c=r;for(;r<e.length&&!/\s/.test(e[r]);)r++;s+=e.substring(c,r);let l=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!l.includes(s.toUpperCase()))throw new Error(`Invalid attribute type: "${s}"`)}r=er(e,r);let a="";return e.substring(r,r+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",r+=8):e.substring(r,r+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",r+=7):[r,a]=this.readIdentifierVal(e,r,"ATTLIST"),{elementName:n,attributeName:i,attributeType:s,defaultValue:a,index:r}}},er=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function Us(t,e,r){for(let o=0;o<e.length;o++)if(e[o]!==t[r+o+1])return!1;return!0}function Wd(t){if(Uc(t))return t;throw new Error(`Invalid entity name ${t}`)}var Nie=/^[-+]?0x[a-fA-F0-9]+$/,Die=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Uie={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function JS(t,e={}){if(e=Object.assign({},Uie,e),!t||typeof t!="string")return t;let r=t.trim();if(r.length===0)return t;if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(r==="0")return 0;if(e.hex&&Nie.test(r))return Hie(r,16);if(isFinite(r)){if(r.includes("e")||r.includes("E"))return Vie(t,r,e);{let o=Die.exec(r);if(o){let n=o[1]||"",i=o[2],s=zie(o[3]),a=n?t[i.length+1]===".":t[i.length]===".";if(!e.leadingZeros&&(i.length>1||i.length===1&&!a))return t;{let c=Number(r),l=String(c);if(c===0)return c;if(l.search(/[eE]/)!==-1)return e.eNotation?c:t;if(r.indexOf(".")!==-1)return l==="0"||l===s||l===`${n}${s}`?c:t;let f=i?s:r;return i?f===l||n+f===l?c:t:f===l||f===n+l?c:t}}else return t}}else return jie(t,Number(r),e)}var kie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Vie(t,e,r){if(!r.eNotation)return t;let o=e.match(kie);if(o){let n=o[1]||"",i=o[3].indexOf("e")===-1?"E":"e",s=o[2],a=n?t[s.length+1]===i:t[s.length]===i;return s.length>1&&a?t:s.length===1&&(o[3].startsWith(`.${i}`)||o[3][0]===i)?Number(e):s.length>0?r.leadingZeros&&!a?(e=(o[1]||"")+o[3],Number(e)):t:Number(e)}else return t}function zie(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substring(0,t.length-1))),t}function Hie(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function jie(t,e,r){let o=e===1/0;switch(r.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return o?"Infinity":"-Infinity";case"original":default:return t}}function QS(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(let r of t)if(typeof r=="string"&&e===r||r instanceof RegExp&&r.test(e))return!0}:()=>!1}var ks=class{constructor(e,r={},o){this.pattern=e,this.separator=r.separator||".",this.segments=this._parse(e),this.data=o,this._hasDeepWildcard=this.segments.some(n=>n.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(n=>n.attrName!==void 0),this._hasPositionSelector=this.segments.some(n=>n.position!==void 0)}_parse(e){let r=[],o=0,n="";for(;o<e.length;)e[o]===this.separator?o+1<e.length&&e[o+1]===this.separator?(n.trim()&&(r.push(this._parseSegment(n.trim())),n=""),r.push({type:"deep-wildcard"}),o+=2):(n.trim()&&r.push(this._parseSegment(n.trim())),n="",o++):(n+=e[o],o++);return n.trim()&&r.push(this._parseSegment(n.trim())),r}_parseSegment(e){let r={type:"tag"},o=null,n=e,i=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(n=i[1]+i[3],i[2])){let f=i[2].slice(1,-1);f&&(o=f)}let s,a=n;if(n.includes("::")){let f=n.indexOf("::");if(s=n.substring(0,f).trim(),a=n.substring(f+2).trim(),!s)throw new Error(`Invalid namespace in pattern: ${e}`)}let c,l=null;if(a.includes(":")){let f=a.lastIndexOf(":"),u=a.substring(0,f).trim(),d=a.substring(f+1).trim();["first","last","odd","even"].includes(d)||/^nth\(\d+\)$/.test(d)?(c=u,l=d):c=a}else c=a;if(!c)throw new Error(`Invalid segment pattern: ${e}`);if(r.tag=c,s&&(r.namespace=s),o)if(o.includes("=")){let f=o.indexOf("=");r.attrName=o.substring(0,f).trim(),r.attrValue=o.substring(f+1).trim()}else r.attrName=o.trim();if(l){let f=l.match(/^nth\((\d+)\)$/);f?(r.position="nth",r.positionValue=parseInt(f[1],10)):r.position=l}return r}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}};var kc=class{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(e){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(e.pattern))return this;if(this._patterns.add(e.pattern),e.hasDeepWildcard())return this._deepWildcards.push(e),this;let r=e.length,n=e.segments[e.segments.length-1]?.tag;if(!n||n==="*")this._wildcardByDepth.has(r)||this._wildcardByDepth.set(r,[]),this._wildcardByDepth.get(r).push(e);else{let i=`${r}:${n}`;this._byDepthAndTag.has(i)||this._byDepthAndTag.set(i,[]),this._byDepthAndTag.get(i).push(e)}return this}addAll(e){for(let r of e)this.add(r);return this}has(e){return this._patterns.has(e.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(e){return this.findMatch(e)!==null}findMatch(e){let r=e.getDepth(),o=e.getCurrentTag(),n=`${r}:${o}`,i=this._byDepthAndTag.get(n);if(i){for(let a=0;a<i.length;a++)if(e.matches(i[a]))return i[a]}let s=this._wildcardByDepth.get(r);if(s){for(let a=0;a<s.length;a++)if(e.matches(s[a]))return s[a]}for(let a=0;a<this._deepWildcards.length;a++)if(e.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}};var Wie=new Set(["push","pop","reset","updateCurrent","restore"]),Vc=class{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(e,r=null,o=null){if(this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0){let f=this.path[this.path.length-1];f.values=void 0}let n=this.path.length;this.siblingStacks[n]||(this.siblingStacks[n]=new Map);let i=this.siblingStacks[n],s=o?`${o}:${e}`:e,a=i.get(s)||0,c=0;for(let f of i.values())c+=f;i.set(s,a+1);let l={tag:e,position:c,counter:a};o!=null&&(l.namespace=o),r!=null&&(l.values=r),this.path.push(l)}pop(){if(this.path.length===0)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;let e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){let r=this.path[this.path.length-1];e!=null&&(r.values=e,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){return this.path.length===0?void 0:this.path[this.path.length-1].values?.[e]}hasAttr(e){if(this.path.length===0)return!1;let r=this.path[this.path.length-1];return r.values!==void 0&&e in r.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,r=!0){let o=e||this.separator;if(o===this.separator&&r===!0){if(this._pathStringCache!==null&&this._pathStringCache!==void 0)return this._pathStringCache;let i=this.path.map(s=>r&&s.namespace?`${s.namespace}:${s.tag}`:s.tag).join(o);return this._pathStringCache=i,i}return this.path.map(i=>r&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(o)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(e){let r=e.segments;return r.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(r):this._matchSimple(r)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],n=this.path[r],i=r===this.path.length-1;if(!this._matchSegment(o,n,i))return!1}return!0}_matchWithDeepWildcard(e){let r=this.path.length-1,o=e.length-1;for(;o>=0&&r>=0;){let n=e[o];if(n.type==="deep-wildcard"){if(o--,o<0)return!0;let i=e[o],s=!1;for(let a=r;a>=0;a--){let c=a===this.path.length-1;if(this._matchSegment(i,this.path[a],c)){r=a-1,o--,s=!0;break}}if(!s)return!1}else{let i=r===this.path.length-1;if(!this._matchSegment(n,this.path[r],i))return!1;r--,o--}}return o<0}_matchSegment(e,r,o){if(e.tag!=="*"&&e.tag!==r.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==r.namespace)return!1;if(e.attrName!==void 0){if(!o||!r.values||!(e.attrName in r.values))return!1;if(e.attrValue!==void 0){let n=r.values[e.attrName];if(String(n)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!o)return!1;let n=r.counter??0;if(e.position==="first"&&n!==0)return!1;if(e.position==="odd"&&n%2!==1)return!1;if(e.position==="even"&&n%2!==0)return!1;if(e.position==="nth"&&n!==e.positionValue)return!1}return!0}matchesAny(e){return e.matchesAny(this)}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=e.path.map(r=>({...r})),this.siblingStacks=e.siblingStacks.map(r=>new Map(r))}readOnly(){let e=this;return new Proxy(e,{get(r,o,n){if(Wie.has(o))return()=>{throw new TypeError(`Cannot call '${o}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if(o==="path")return r._frozenPathCache===null&&(r._frozenPathCache=Object.freeze(r.path.map(s=>Object.freeze({...s})))),r._frozenPathCache;if(o==="siblingStacks")return r._frozenSiblingsCache===null&&(r._frozenSiblingsCache=Object.freeze(r.siblingStacks.map(s=>Object.freeze(new Map(s))))),r._frozenSiblingsCache;let i=Reflect.get(r,o,n);return typeof i=="function"?i.bind(r):i},set(r,o){throw new TypeError(`Cannot set property '${String(o)}' on a read-only Matcher.`)},deleteProperty(r,o){throw new TypeError(`Cannot delete property '${String(o)}' from a read-only Matcher.`)}})}};function Gie(t,e){if(!t)return{};let r=e.attributesGroupName?t[e.attributesGroupName]:t;if(!r)return{};let o={};for(let n in r)if(n.startsWith(e.attributeNamePrefix)){let i=n.substring(e.attributeNamePrefix.length);o[i]=r[n]}else o[n]=r[n];return o}function $ie(t){if(!t||typeof t!="string")return;let e=t.indexOf(":");if(e!==-1&&e>0){let r=t.substring(0,e);if(r!=="xmlns")return r}}var $d=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(o,n)=>nU(n,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(o,n)=>nU(n,16,"&#x")}},this.addExternalEntities=Xie,this.parseXml=Jie,this.parseTextData=Yie,this.resolveNameSpace=Kie,this.buildAttributesMap=Zie,this.isItStopNode=rse,this.replaceEntitiesValue=ese,this.readStopNodeData=ise,this.saveTextToParentTag=tse,this.addChild=Qie,this.ignoreAttributesFn=QS(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new Vc,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new kc;let r=this.options.stopNodes;if(r&&r.length>0){for(let o=0;o<r.length;o++){let n=r[o];typeof n=="string"?this.stopNodeExpressionsSet.add(new ks(n)):n instanceof ks&&this.stopNodeExpressionsSet.add(n)}this.stopNodeExpressionsSet.seal()}}};function Xie(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let o=e[r],n=o.replace(/[.\-+*:]/g,"\\.");this.lastEntities[o]={regex:new RegExp("&"+n+";","g"),val:t[o]}}}function Yie(t,e,r,o,n,i,s){let a=this.options;if(t!==void 0&&(a.trimValues&&!o&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t,e,r));let c=a.jPath?r.toString():r,l=a.tagValueProcessor(e,t,c,n,i);return l==null?t:typeof l!=typeof t||l!==t?l:a.trimValues||t.trim()===t?rC(t,a.parseTagValue,a.numberParseOptions):t}}function Kie(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var qie=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Zie(t,e,r){let o=this.options;if(o.ignoreAttributes!==!0&&typeof t=="string"){let n=X0(t,qie),i=n.length,s={},a=new Array(i),c=!1,l={};for(let d=0;d<i;d++){let h=this.resolveNameSpace(n[d][1]),p=n[d][4];if(h.length&&p!==void 0){let m=p;o.trimValues&&(m=m.trim()),m=this.replaceEntitiesValue(m,r,this.readonlyMatcher),a[d]=m,l[h]=m,c=!0}}c&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(l);let f=o.jPath?e.toString():this.readonlyMatcher,u=!1;for(let d=0;d<i;d++){let h=this.resolveNameSpace(n[d][1]);if(this.ignoreAttributesFn(h,f))continue;let p=o.attributeNamePrefix+h;if(h.length)if(o.transformAttributeName&&(p=o.transformAttributeName(p)),p=iU(p,o),n[d][4]!==void 0){let m=a[d],g=o.attributeValueProcessor(h,m,f);g==null?s[p]=m:typeof g!=typeof m||g!==m?s[p]=g:s[p]=rC(m,o.parseAttributeValue,o.numberParseOptions),u=!0}else o.allowBooleanAttributes&&(s[p]=!0,u=!0)}if(!u)return;if(o.attributesGroupName){let d={};return d[o.attributesGroupName]=s,d}return s}}var Jie=function(t){t=t.replace(/\r\n?/g,`
`);let e=new Qt("!xml"),r=e,o="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.docTypeEntitiesKeys=[],this.lastEntitiesKeys=Object.keys(this.lastEntities),this.htmlEntitiesKeys=this.options.htmlEntities?Object.keys(this.htmlEntities):[];let n=this.options,i=new Gd(n.processEntities),s=t.length;for(let a=0;a<s;a++)if(t[a]==="<"){let l=t.charCodeAt(a+1);if(l===47){let f=zc(t,">",a,"Closing Tag is not closed."),u=t.substring(a+2,f).trim();if(n.removeNSPrefix){let h=u.indexOf(":");h!==-1&&(u=u.substr(h+1))}u=eC(n.transformTagName,u,"",n).tagName,r&&(o=this.saveTextToParentTag(o,r,this.readonlyMatcher));let d=this.matcher.getCurrentTag();if(u&&n.unpairedTagsSet.has(u))throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);d&&n.unpairedTagsSet.has(d)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=this.tagsNodeStack.pop(),o="",a=f}else if(l===63){let f=tC(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(o=this.saveTextToParentTag(o,r,this.readonlyMatcher),!(n.ignoreDeclaration&&f.tagName==="?xml"||n.ignorePiTags)){let u=new Qt(f.tagName);u.add(n.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(u[":@"]=this.buildAttributesMap(f.tagExp,this.matcher,f.tagName)),this.addChild(r,u,this.readonlyMatcher,a)}a=f.closeIndex+1}else if(l===33&&t.charCodeAt(a+2)===45&&t.charCodeAt(a+3)===45){let f=zc(t,"-->",a+4,"Comment is not closed.");if(n.commentPropName){let u=t.substring(a+4,f-2);o=this.saveTextToParentTag(o,r,this.readonlyMatcher),r.add(n.commentPropName,[{[n.textNodeName]:u}])}a=f}else if(l===33&&t.charCodeAt(a+2)===68){let f=i.readDocType(t,a);this.docTypeEntities=f.entities,this.docTypeEntitiesKeys=Object.keys(this.docTypeEntities)||[],a=f.i}else if(l===33&&t.charCodeAt(a+2)===91){let f=zc(t,"]]>",a,"CDATA is not closed.")-2,u=t.substring(a+9,f);o=this.saveTextToParentTag(o,r,this.readonlyMatcher);let d=this.parseTextData(u,r.tagname,this.readonlyMatcher,!0,!1,!0,!0);d==null&&(d=""),n.cdataPropName?r.add(n.cdataPropName,[{[n.textNodeName]:u}]):r.add(n.textNodeName,d),a=f+2}else{let f=tC(t,a,n.removeNSPrefix);if(!f){let v=t.substring(Math.max(0,a-50),Math.min(s,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${v}"`)}let u=f.tagName,d=f.rawTagName,h=f.tagExp,p=f.attrExpPresent,m=f.closeIndex;if({tagName:u,tagExp:h}=eC(n.transformTagName,u,h,n),n.strictReservedNames&&(u===n.commentPropName||u===n.cdataPropName||u===n.textNodeName||u===n.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);r&&o&&r.tagname!=="!xml"&&(o=this.saveTextToParentTag(o,r,this.readonlyMatcher,!1));let g=r;g&&n.unpairedTagsSet.has(g.tagname)&&(r=this.tagsNodeStack.pop(),this.matcher.pop());let _=!1;h.length>0&&h.lastIndexOf("/")===h.length-1&&(_=!0,u[u.length-1]==="/"?(u=u.substr(0,u.length-1),h=u):h=h.substr(0,h.length-1),p=u!==h);let x=null,y={},b;b=$ie(d),u!==e.tagname&&this.matcher.push(u,{},b),u!==h&&p&&(x=this.buildAttributesMap(h,this.matcher,u),x&&(y=Gie(x,n))),u!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let T=a;if(this.isCurrentNodeStopNode){let v="";if(_)a=f.closeIndex;else if(n.unpairedTagsSet.has(u))a=f.closeIndex;else{let C=this.readStopNodeData(t,d,m+1);if(!C)throw new Error(`Unexpected end of ${d}`);a=C.i,v=C.tagContent}let w=new Qt(u);x&&(w[":@"]=x),w.add(n.textNodeName,v),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(r,w,this.readonlyMatcher,T)}else{if(_){({tagName:u,tagExp:h}=eC(n.transformTagName,u,h,n));let v=new Qt(u);x&&(v[":@"]=x),this.addChild(r,v,this.readonlyMatcher,T),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(n.unpairedTagsSet.has(u)){let v=new Qt(u);x&&(v[":@"]=x),this.addChild(r,v,this.readonlyMatcher,T),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=f.closeIndex;continue}else{let v=new Qt(u);if(this.tagsNodeStack.length>n.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(r),x&&(v[":@"]=x),this.addChild(r,v,this.readonlyMatcher,T),r=v}o="",a=m}}}else o+=t[a];return e.child};function Qie(t,e,r,o){this.options.captureMetaData||(o=void 0);let n=this.options.jPath?r.toString():r,i=this.options.updateTag(e.tagname,n,e[":@"]);i===!1||(typeof i=="string"&&(e.tagname=i),t.addChild(e,o))}function ese(t,e,r){let o=this.options.processEntities;if(!o||!o.enabled)return t;if(o.allowedTags){let n=this.options.jPath?r.toString():r;if(!(Array.isArray(o.allowedTags)?o.allowedTags.includes(e):o.allowedTags(e,n)))return t}if(o.tagFilter){let n=this.options.jPath?r.toString():r;if(!o.tagFilter(e,n))return t}for(let n of this.docTypeEntitiesKeys){let i=this.docTypeEntities[n],s=t.match(i.regx);if(s){if(this.entityExpansionCount+=s.length,o.maxTotalExpansions&&this.entityExpansionCount>o.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${o.maxTotalExpansions}`);let a=t.length;if(t=t.replace(i.regx,i.val),o.maxExpandedLength&&(this.currentExpandedLength+=t.length-a,this.currentExpandedLength>o.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${o.maxExpandedLength}`)}}if(t.indexOf("&")===-1)return t;for(let n of this.lastEntitiesKeys){let i=this.lastEntities[n],s=t.match(i.regex);if(s&&(this.entityExpansionCount+=s.length,o.maxTotalExpansions&&this.entityExpansionCount>o.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${o.maxTotalExpansions}`);t=t.replace(i.regex,i.val)}if(t.indexOf("&")===-1)return t;for(let n of this.htmlEntitiesKeys){let i=this.htmlEntities[n],s=t.match(i.regex);if(s&&(this.entityExpansionCount+=s.length,o.maxTotalExpansions&&this.entityExpansionCount>o.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${o.maxTotalExpansions}`);t=t.replace(i.regex,i.val)}return t=t.replace(this.ampEntity.regex,this.ampEntity.val),t}function tse(t,e,r,o){return t&&(o===void 0&&(o=e.child.length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,o),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function rse(){return this.stopNodeExpressionsSet.size===0?!1:this.matcher.matchesAny(this.stopNodeExpressionsSet)}function ose(t,e,r=">"){let o=0,n=[],i=t.length,s=r.charCodeAt(0),a=r.length>1?r.charCodeAt(1):-1;for(let c=e;c<i;c++){let l=t.charCodeAt(c);if(o)l===o&&(o=0);else if(l===34||l===39)o=l;else if(l===s)if(a!==-1){if(t.charCodeAt(c+1)===a)return{data:String.fromCharCode(...n),index:c}}else return{data:String.fromCharCode(...n),index:c};else if(l===9){n.push(32);continue}n.push(l)}}function zc(t,e,r,o){let n=t.indexOf(e,r);if(n===-1)throw new Error(o);return n+e.length-1}function nse(t,e,r,o){let n=t.indexOf(e,r);if(n===-1)throw new Error(o);return n}function tC(t,e,r,o=">"){let n=ose(t,e+1,o);if(!n)return;let i=n.data,s=n.index,a=i.search(/\s/),c=i,l=!0;a!==-1&&(c=i.substring(0,a),i=i.substring(a+1).trimStart());let f=c;if(r){let u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),l=c!==n.data.substr(u+1))}return{tagName:c,tagExp:i,closeIndex:s,attrExpPresent:l,rawTagName:f}}function ise(t,e,r){let o=r,n=1,i=t.length;for(;r<i;r++)if(t[r]==="<"){let s=t.charCodeAt(r+1);if(s===47){let a=nse(t,">",r,`${e} is not closed`);if(t.substring(r+2,a).trim()===e&&(n--,n===0))return{tagContent:t.substring(o,r),i:a};r=a}else if(s===63)r=zc(t,"?>",r+1,"StopNode is not closed.");else if(s===33&&t.charCodeAt(r+2)===45&&t.charCodeAt(r+3)===45)r=zc(t,"-->",r+3,"StopNode is not closed.");else if(s===33&&t.charCodeAt(r+2)===91)r=zc(t,"]]>",r,"StopNode is not closed.")-2;else{let a=tC(t,r,">");a&&((a&&a.tagName)===e&&a.tagExp[a.tagExp.length-1]!=="/"&&n++,r=a.closeIndex)}}}function rC(t,e,r){if(e&&typeof t=="string"){let o=t.trim();return o==="true"?!0:o==="false"?!1:JS(t,r)}else return KD(t)?t:""}function nU(t,e,r){let o=Number.parseInt(t,e);return o>=0&&o<=1114111?String.fromCodePoint(o):r+t+";"}function eC(t,e,r,o){if(t){let n=t(e);r===e&&(r=n),e=n}return e=iU(e,o),{tagName:e,tagExp:r}}function iU(t,e){if(Y0.includes(t))throw new Error(`[SECURITY] Invalid name: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);return Hd.includes(t)?e.onDangerousProperty(t):t}var oC=Qt.getMetaDataSymbol();function sse(t,e){if(!t||typeof t!="object")return{};if(!e)return t;let r={};for(let o in t)if(o.startsWith(e)){let n=o.substring(e.length);r[n]=t[o]}else r[o]=t[o];return r}function nC(t,e,r,o){return sU(t,e,r,o)}function sU(t,e,r,o){let n,i={};for(let s=0;s<t.length;s++){let a=t[s],c=ase(a);if(c!==void 0&&c!==e.textNodeName){let l=sse(a[":@"]||{},e.attributeNamePrefix);r.push(c,l)}if(c===e.textNodeName)n===void 0?n=a[c]:n+=""+a[c];else{if(c===void 0)continue;if(a[c]){let l=sU(a[c],e,r,o),f=lse(l,e);if(a[":@"]?cse(l,a[":@"],o,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),a[oC]!==void 0&&typeof l=="object"&&l!==null&&(l[oC]=a[oC]),i[c]!==void 0&&Object.prototype.hasOwnProperty.call(i,c))Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(l);else{let u=e.jPath?o.toString():o;e.isArray(c,u,f)?i[c]=[l]:i[c]=l}c!==void 0&&c!==e.textNodeName&&r.pop()}}}return typeof n=="string"?n.length>0&&(i[e.textNodeName]=n):n!==void 0&&(i[e.textNodeName]=n),i}function ase(t){let e=Object.keys(t);for(let r=0;r<e.length;r++){let o=e[r];if(o!==":@")return o}}function cse(t,e,r,o){if(e){let n=Object.keys(e),i=n.length;for(let s=0;s<i;s++){let a=n[s],c=a.startsWith(o.attributeNamePrefix)?a.substring(o.attributeNamePrefix.length):a,l=o.jPath?r.toString()+"."+c:r;o.isArray(a,l,!0,!0)?t[a]=[e[a]]:t[a]=e[a]}}}function lse(t,e){let{textNodeName:r}=e,o=Object.keys(t).length;return!!(o===0||o===1&&(t[r]||typeof t[r]=="boolean"||t[r]===0))}var Hc=class{constructor(e){this.externalEntities={},this.options=oU(e)}parse(e,r){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let i=eU(e,r);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}let o=new $d(this.options);o.addExternalEntities(this.externalEntities);let n=o.parseXml(e);return this.options.preserveOrder||n===void 0?n:nC(n,this.options,o.matcher,o.readonlyMatcher)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}static getMetaDataSymbol(){return Qt.getMetaDataSymbol()}};function iC(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(n,i,s,a)=>Boolean(e?.arrayPaths?.some(l=>i===l)),...e?._fastXML},o=fse(t,r);return e?.uncapitalizeKeys?$0(o):o}function fse(t,e){return new Hc({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var use="4.4.3",co={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:use,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:dse,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>iC(new TextDecoder().decode(t),{...co.options.xml,...e?.xml}),parseTextSync:(t,e)=>iC(t,{...co.options.xml,...e?.xml})};function dse(t){return t.startsWith("<?xml")}function aU(t,e){let r=co.parseTextSync?.(t,e),o=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof o=="string"?o:o.value||o.code||"Unknown error"}var hse="4.4.3",Xd={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:hse,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:pse,options:{wms:{throwOnError:!1}},parse:async(t,e)=>sC(new TextDecoder().decode(t),e),parseSync:(t,e)=>sC(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>sC(t,e)};function pse(t){return t.startsWith("<?xml")}function sC(t,e){let r={...Xd.options.wms,...e?.wms},o=aU(t,r),n=r.minimalErrors?o:`WMS Service error: ${o}`;if(r.throwOnError)throw new Error(n);return n}function Vs(t){return Array.isArray(t)?t:t?[t]:[]}function Yd(t){let e=Vs(t);return e.length>0&&e.every(r=>typeof r=="string")?e:[]}function Kd(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function q0(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function zs(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function aC(t,e){let r=co.parseTextSync?.(t,e),o=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,n=mse(o);if(e?.inheritedLayerProps)for(let i of n.layers)lU(i,null);return e?.includeRawJSON&&(n.json=o),e?.includeXMLText&&(n.xml=t),n}function mse(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Yd(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:q0(t.Service?.LayerLimit),maxWidth:q0(t.Service?.maxWidth),maxHeight:q0(t.Service?.maxHeight),layers:[],requests:gse(t.Capability?.Request),exceptions:_se(t.Exception)},r=Vs(t.Capability?.Layer);for(let o of r)e.layers.push(cU(o));for(let[o,n]of Object.entries(e))n===void 0&&delete e[o];return e}function gse(t){let e={};for(let[r,o]of Object.entries(t||{})){let n=Yd(o?.Format);e[r]={mimeTypes:n}}return e}function _se(t){if(Vs(t?.Format).length>0)return{mimeTypes:Yd(t)}}function cU(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Yd(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let o=t?.EX_GeographicBoundingBox&&yse(t?.EX_GeographicBoundingBox);o&&(e.geographicBoundingBox=o),o=t?.LatLonBoundingBox&&xse(t?.LatLonBoundingBox),o&&(e.geographicBoundingBox=o);let n=t?.BoundingBox&&bse(t?.BoundingBox);n&&n.length>0&&(e.boundingBoxes=n);let s=Vs(t?.Dimension).map(l=>Tse(l));s.length&&(e.dimensions=s),t?.opaque&&(e.opaque=zs(t?.opaque)),t?.cascaded&&(e.cascaded=zs(t?.cascaded)),t?.queryable&&(e.queryable=zs(t?.queryable));let a=Vs(t?.Layer),c=[];for(let l of a)c.push(cU(l));c.length>0&&(e.layers=c);for(let[l,f]of Object.entries(e))f===void 0&&delete e[l];return e}function yse(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:o,southBoundLatitude:n}=t;return[[e,n],[o,r]]}function xse(t){let{minx:e,miny:r,maxx:o,maxy:n}=t;return[[e,r],[o,n]]}function bse(t){return Vs(t).map(r=>Ase(r))}function Ase(t){let{CRS:e,SRS:r,minx:o,miny:n,maxx:i,maxy:s,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[Kd(o),Kd(n)],[Kd(i),Kd(s)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function Tse(t){let{name:e,units:r,value:o}=t,n={name:e,units:r,extent:o};return t.unitSymbol&&(n.unitSymbol=t.unitSymbol),t.default&&(n.defaultValue=t.default),t.multipleValues&&(n.multipleValues=zs(t.multipleValues)),t.nearestValue&&(n.nearestValue=zs(t.nearestValue)),t.current&&(n.current=zs(t.current)),n}function lU(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])lU(r,t)}var vse="4.4.3",jc={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:vse,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:Sse,options:{wms:{}},parse:async(t,e)=>aC(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>aC(t,e?.wms)};function Sse(t){return t.startsWith("<?xml")}function cC(t,e){let o=(co.parseTextSync?.(t,e)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(o)?o:[o]).map(i=>Cse(i))}}function Cse(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var fU={...jc,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>cC(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>cC(t,e)};function lC(t,e){return co.parseTextSync?.(t,e)}var uU={...jc,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>lC(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>lC(t,e)};var J0={name:"Web Map Service (OGC WMS)",id:"wms",module:"wms",version:"0.0.0",extensions:[],mimeTypes:[],type:"wms",fromUrl:!0,fromBlob:!1,defaultOptions:{wms:{}},testURL:t=>t.toLowerCase().includes("wms"),createDataSource:(t,e)=>new Z0(t,e)},Z0=class extends Sa{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,r){super(e,r,J0.defaultOptions),this.substituteCRS84=r.wms?.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...r.wmsParameters,...r.wms?.wmsParameters},this.vendorParameters=r.wms?.vendorParameters||r.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:o,...n}=e,i={bbox:r?[...r[0],...r[1]]:o,...n};return await this.getMap(i)}normalizeMetadata(e){return e}async getCapabilities(e,r){let o=this.getCapabilitiesURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();this._checkResponse(n,i);let s=await jc.parse(i,this.loadOptions);return this.capabilities=s,s}async getMap(e,r){let o=this.getMapURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();this._checkResponse(n,i);try{return await qn.parse(i,this.loadOptions)}catch{throw this._parseError(i)}}async getFeatureInfo(e,r){let o=this.getFeatureInfoURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();return this._checkResponse(n,i),await fU.parse(i,this.loadOptions)}async getFeatureInfoText(e,r){let o=this.getFeatureInfoURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();return this._checkResponse(n,i),new TextDecoder().decode(i)}async describeLayer(e,r){let o=this.describeLayerURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();return this._checkResponse(n,i),await uU.parse(i,this.loadOptions)}async getLegendGraphic(e,r){let o=this.getLegendGraphicURL(e,r),n=await this.fetch(o),i=await n.arrayBuffer();this._checkResponse(n,i);try{return await qn.parse(i,this.loadOptions)}catch{throw this._parseError(i)}}getCapabilitiesURL(e,r){let o={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",o,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let o={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",o,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:o,bbox:n}=e;e.bbox=o?[...o[0],...o[1]]:n;let i={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",i,r)}describeLayerURL(e,r){let o={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",o,r)}getLegendGraphicURL(e,r){let o={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",o,r)}_parseWMSUrl(e){let[r,o]=e.split("?"),n=o.split("&"),i={};for(let s of n){let[a,c]=s.split("=");i[a]=c}return{url:r,parameters:i}}_getWMSUrl(e,r,o){let n=this.url,i=!0,s={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...o},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(s))(!a.includes(c)||l)&&(n+=i?"?":"&",i=!1,n+=this._getURLParameter(c,l,r));return encodeURI(n)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,o){switch(e){case"crs":o.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":o.version==="1.3.0"&&(e="crs");break;case"bbox":let n=this._flipBoundingBox(r,o);n&&(r=n);break;case"x":o.version==="1.3.0"&&(e="i");break;case"y":o.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let o=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),n=e;return o?[n[1],n[0],n[3],n[2]]:n}async _fetchArrayBuffer(e){let r=await this.fetch(e),o=await r.arrayBuffer();return this._checkResponse(r,o),o}_checkResponse(e,r){let o=e.headers["content-type"];if(!e.ok||Xd.mimeTypes.includes(o)){let n=ji(this.loadOptions,{wms:{throwOnError:!0}}),i=Xd.parseSync?.(r,n);throw new Error(i)}}_parseError(e){let r=Xd.parseSync?.(e,this.options.core?.loadOptions);return new Error(r)}};var dU=6378137*Math.PI;function fC(t){let e=Oe(t);return e[0]=(e[0]/256-1)*dU,e[1]=(e[1]/256-1)*dU,e}var Ese={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},Wc=class extends Ne{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:o}){let{viewport:n}=this.context;e.dataChanged||r.serviceType!==o.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(n,"image source changed"),0)):ie(r.layers,o.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(n,"viewport changed")):this.debounce(()=>this.loadImage(n,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:o}=this.state;return r&&new H_({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:o.srs==="EPSG:4326"?Be.LNGLAT:Be.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:o}=this.state;return o?await this.state.imageSource.getFeatureInfoText?.({...o,query_layers:o.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof $n)return e.data;if(typeof e.data=="string")return yS(e.data,[J0],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:o,serviceType:n}=this.props;if(n==="wms"&&o.length===0)return;let i=e.getBounds(),{width:s,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let f={width:s,height:a,boundingBox:[[i[0],i[1]],[i[2],i[3]]],layers:o,crs:l};if(l==="EPSG:3857"){let u=fC([i[0],i[1]]),d=fC([i[2],i[3]]);f.boundingBox=[u,d]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let u=await this.state.imageSource.getImage(f);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:u,bounds:i,lastRequestParameters:f,lastRequestId:c}))}catch(u){this.raiseError(u,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,u)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),r)}};Wc.layerName="WMSLayer";Wc.defaultProps=Ese;var wse={getHeight:{type:"accessor",value:0},greatCircle:!0},qd=class extends z_{};qd.layerName="GreatCircleLayer";qd.defaultProps=wse;var hU=qd;var Q0=kn(uC(),1),Pse=3,Mse=30,Rse=2*Mse+1,mU=180/Math.PI;function _U(t,e,r){let o=1<<e;return[(t[0]+r[0])/o,(t[1]+r[1])/o]}function gU(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function yU(t){return[gU(t[0]),gU(t[1])]}function xU(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function bU([t,e,r]){let o=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*mU,o*mU]}function AU(t){let e=Q0.default.fromString(t,!0,10).toString(2);for(;e.length<Pse+Rse;)e="0"+e;let r=e.lastIndexOf("1"),o=e.substring(0,3),n=e.substring(3,r),i=n.length/2,s=Q0.default.fromString(o,!0,2).toString(10),a=Q0.default.fromString(n,!0,2).toString(4);for(;a.length<i;)a="0"+a;return`${s}/${a}`}function Ise(t,e,r,o){if(o===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let n=e[0];e[0]=e[1],e[1]=n}}function TU(t){let e=t.split("/"),r=parseInt(e[0],10),o=e[1],n=o.length,i=[0,0],s;for(let a=n-1;a>=0;a--){s=n-a;let c=o[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,s-1);Ise(u,i,l,f),i[0]+=u*l,i[1]+=u*f}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:s}}var vU=kn(uC(),1);function Lse(t){let e=t.padEnd(16,"0");return vU.default.fromString(e,16)}var Bse=100;function Ose({face:t,ij:e,level:r}){let o=[[0,0],[0,1],[1,1],[1,0],[0,0]],n=Math.max(1,Math.ceil(Bse*Math.pow(2,-r))),i=new Float64Array(4*n*2+2),s=0,a=0;for(let c=0;c<4;c++){let l=o[c].slice(0),f=o[c+1],u=(f[0]-l[0])/n,d=(f[1]-l[1])/n;for(let h=0;h<n;h++){l[0]+=u,l[1]+=d;let p=_U(e,r,l),m=yU(p),g=xU(t,m),_=bU(g);Math.abs(_[1])>89.999&&(_[0]=a);let x=_[0]-a;_[0]+=x>180?-360:x<-180?360:0,i[s++]=_[0],i[s++]=_[1],a=_[0]}}return i[s++]=i[0],i[s++]=i[1],i}function Fse(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=Lse(t)}return AU(t.toString())}function SU(t){let e=Fse(t),r=TU(e);return Ose(r)}var Nse={getS2Token:{type:"accessor",value:t=>t.token}},Jd=class extends Or{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(o,n)=>SU(r(o,n))}}};Jd.layerName="S2Layer";Jd.defaultProps=Nse;var CU=Jd;var dC=512;function Dse(t,e){let r=0,o=0,n=1<<t.length,i=n/dC;for(let s=0;s<t.length;s++){n>>=1;let a=parseInt(t[s]);a%2&&(r|=n),a>1&&(o|=n)}return[[r/i,dC-o/i],[(r+e)/i,dC-(o+e)/i]]}function EU(t,e=1){let[r,o]=Dse(t,e),[n,i]=pt(r),[s,a]=pt(o);return[s,i,s,a,n,a,n,i,s,i]}var Use={getQuadkey:{type:"accessor",value:t=>t.quadkey}},Qd=class extends Or{indexToBounds(){let{data:e,extruded:r,getQuadkey:o}=this.props,n=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(i,s)=>EU(o(i,s),n),updateTriggers:{getPolygon:n}}}};Qd.layerName="QuadkeyLayer";Qd.defaultProps=Use;var wU=Qd;var Hs=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:r,onLoad:o,onError:n}){let{index:i,id:s,bbox:a,userData:c,zoom:l}=this,f=this._loaderId;this._abortController=new AbortController;let{signal:u}=this._abortController,d=await r.scheduleRequest(this,m=>m.isSelected?1:-1);if(!d){this._isCancelled=!0;return}if(this._isCancelled){d.done();return}let h=null,p;try{h=await e({index:i,id:s,bbox:a,userData:c,zoom:l,signal:u})}catch(m){p=m||!0}finally{d.done()}if(f===this._loaderId){if(this._loader=void 0,this.content=h,this._isCancelled&&!h){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,p?n(p,this):o(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var Ze={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var PU=new E,kse=new E,Ci=class{constructor(e=[0,0,0],r=[0,0,0],o){o=o||PU.copy(e).add(r).scale(.5),this.center=new E(o),this.halfDiagonal=new E(r).subtract(this.center),this.minimum=new E(e),this.maximum=new E(r)}clone(){return new Ci(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,o=kse.from(e.normal),n=r.x*Math.abs(o.x)+r.y*Math.abs(o.y)+r.z*Math.abs(o.z),i=this.center.dot(o)+e.distance;return i-n>0?Ze.INSIDE:i+n<0?Ze.OUTSIDE:Ze.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=PU.from(e).subtract(this.center),{halfDiagonal:o}=this,n=0,i;return i=Math.abs(r.x)-o.x,i>0&&(n+=i*i),i=Math.abs(r.y)-o.y,i>0&&(n+=i*i),i=Math.abs(r.z)-o.z,i>0&&(n+=i*i),n}};var eh=new E,MU=new E,Fr=class{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new E,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=eh.from(r),this.center=new E().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Fr(this.center,this.radius)}union(e){let r=this.center,o=this.radius,n=e.center,i=e.radius,s=eh.copy(n).subtract(r),a=s.magnitude();if(o>=a+i)return this.clone();if(i>=a+o)return e.clone();let c=(o+a+i)*.5;return MU.copy(s).scale((-o+c)/a).add(r),this.center.copy(MU),this.radius=c,this}expand(e){let o=eh.from(e).subtract(this.center).magnitude();return o>this.radius&&(this.radius=o),this}transform(e){this.center.transform(e);let r=je.getScaling(eh,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let o=eh.from(e).subtract(this.center);return Math.max(0,o.len()-this.radius)}intersectPlane(e){let r=this.center,o=this.radius,i=e.normal.dot(r)+e.distance;return i<-o?Ze.OUTSIDE:i<o?Ze.INTERSECTING:Ze.INSIDE}};var Vse=new E,zse=new E,ey=new E,ty=new E,ry=new E,Hse=new E,jse=new E,En={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},lo=class{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new E().from(e),this.halfAxes=new ue(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),o=this.halfAxes.getColumn(2);return[new E(e).len(),new E(r).len(),new E(o).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),o=this.halfAxes.getColumn(2),n=new E(e).normalize(),i=new E(r).normalize(),s=new E(o).normalize();return new Sr().fromMatrix3(new ue([...n,...i,...s]))}fromCenterHalfSizeQuaternion(e,r,o){let n=new Sr(o),i=new ue().fromQuaternion(n);return i[0]=i[0]*r[0],i[1]=i[1]*r[0],i[2]=i[2]*r[0],i[3]=i[3]*r[1],i[4]=i[4]*r[1],i[5]=i[5]*r[1],i[6]=i[6]*r[2],i[7]=i[7]*r[2],i[8]=i[8]*r[2],this.center=new E().from(e),this.halfAxes=i,this}clone(){return new lo(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Fr){let r=this.halfAxes,o=r.getColumn(0,ey),n=r.getColumn(1,ty),i=r.getColumn(2,ry),s=Vse.copy(o).add(n).add(i);return e.center.copy(this.center),e.radius=s.magnitude(),e}intersectPlane(e){let r=this.center,o=e.normal,n=this.halfAxes,i=o.x,s=o.y,a=o.z,c=Math.abs(i*n[En.COLUMN0ROW0]+s*n[En.COLUMN0ROW1]+a*n[En.COLUMN0ROW2])+Math.abs(i*n[En.COLUMN1ROW0]+s*n[En.COLUMN1ROW1]+a*n[En.COLUMN1ROW2])+Math.abs(i*n[En.COLUMN2ROW0]+s*n[En.COLUMN2ROW1]+a*n[En.COLUMN2ROW2]),l=o.dot(r)+e.distance;return l<=-c?Ze.OUTSIDE:l>=c?Ze.INSIDE:Ze.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=zse.from(e).subtract(this.center),o=this.halfAxes,n=o.getColumn(0,ey),i=o.getColumn(1,ty),s=o.getColumn(2,ry),a=n.magnitude(),c=i.magnitude(),l=s.magnitude();n.normalize(),i.normalize(),s.normalize();let f=0,u;return u=Math.abs(r.dot(n))-a,u>0&&(f+=u*u),u=Math.abs(r.dot(i))-c,u>0&&(f+=u*u),u=Math.abs(r.dot(s))-l,u>0&&(f+=u*u),f}computePlaneDistances(e,r,o=[-0,-0]){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=this.center,a=this.halfAxes,c=a.getColumn(0,ey),l=a.getColumn(1,ty),f=a.getColumn(2,ry),u=Hse.copy(c).add(l).add(f).add(s),d=jse.copy(u).subtract(e),h=r.dot(d);return n=Math.min(h,n),i=Math.max(h,i),u.copy(s).add(c).add(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),u.copy(s).add(c).subtract(l).add(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),u.copy(s).add(c).subtract(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).add(l).add(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).add(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).subtract(l).add(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),s.copy(u).subtract(c).subtract(l).subtract(f),d.copy(u).subtract(e),h=r.dot(d),n=Math.min(h,n),i=Math.max(h,i),o[0]=n,o[1]=i,o}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,ey);r.transformAsPoint(e);let o=this.halfAxes.getColumn(1,ty);o.transformAsPoint(e);let n=this.halfAxes.getColumn(2,ry);return n.transformAsPoint(e),this.halfAxes=new ue([...r,...o,...n]),this}getTransform(){throw new Error("not implemented")}};var RU=new E,IU=new E,mt=class{constructor(e=[0,0,1],r=0){this.normal=new E,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return ht(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=RU.from(e),this.normal.from(r).normalize();let o=-this.normal.dot(e);return this.distance=o,this}fromCoefficients(e,r,o,n){return this.normal.set(e,r,o),ht(Ce(this.normal.len(),1)),this.distance=n,this}clone(){return new mt(this.normal,this.distance)}equals(e){return Ce(this.distance,e.distance)&&Ce(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=IU.copy(this.normal).transformAsVector(e).normalize(),o=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(o,r)}projectPointOntoPlane(e,r=[0,0,0]){let o=RU.from(e),n=this.getPointDistance(o),i=IU.copy(this.normal).scale(n);return o.subtract(i).to(r)}};var LU=[new E([1,0,0]),new E([0,1,0]),new E([0,0,1])],BU=new E,Wse=new E,at=class{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*LU.length;let r=e.center,o=e.radius,n=0;for(let i of LU){let s=this.planes[n],a=this.planes[n+1];s||(s=this.planes[n]=new mt),a||(a=this.planes[n+1]=new mt);let c=BU.copy(i).scale(-o).add(r);s.fromPointNormal(c,i);let l=BU.copy(i).scale(o).add(r),f=Wse.copy(i).negate();a.fromPointNormal(l,f),n+=2}return this}computeVisibility(e){let r=Ze.INSIDE;for(let o of this.planes)switch(e.intersectPlane(o)){case Ze.OUTSIDE:return Ze.OUTSIDE;case Ze.INTERSECTING:r=Ze.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(ht(Number.isFinite(r),"parentPlaneMask is required."),r===at.MASK_OUTSIDE||r===at.MASK_INSIDE)return r;let o=at.MASK_INSIDE,n=this.planes;for(let i=0;i<this.planes.length;++i){let s=i<31?1<<i:0;if(i<31&&!(r&s))continue;let a=n[i],c=e.intersectPlane(a);if(c===Ze.OUTSIDE)return at.MASK_OUTSIDE;c===Ze.INTERSECTING&&(o|=s)}return o}};at.MASK_OUTSIDE=4294967295;at.MASK_INSIDE=0;at.MASK_INDETERMINATE=2147483647;var uXe=new E,dXe=new E,hXe=new E,pXe=new E,mXe=new E;var AXe=new E,TXe=new E,vXe=new E,SXe=new E,CXe=new E,EXe=new E,wXe=new E,PXe=new E,MXe=new E,RXe=new E,IXe=new E,LXe=new E;var Xo=new ue,$se=new ue,Xse=new ue,oy=new ue,OU=new ue;function mC(t,e={}){let r=Cr.EPSILON20,o=10,n=0,i=0,s=$se,a=Xse;s.identity(),a.copy(t);let c=r*Yse(a);for(;i<o&&Kse(a)>c;)qse(a,oy),OU.copy(oy).transpose(),a.multiplyRight(oy),a.multiplyLeft(OU),s.multiplyRight(oy),++n>2&&(++i,n=0);return e.unitary=s.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function Yse(t){let e=0;for(let r=0;r<9;++r){let o=t[r];e+=o*o}return Math.sqrt(e)}var hC=[1,0,0],pC=[2,2,1];function Kse(t){let e=0;for(let r=0;r<3;++r){let o=t[Xo.getElementIndex(pC[r],hC[r])];e+=2*o*o}return Math.sqrt(e)}function qse(t,e){let r=Cr.EPSILON15,o=0,n=1;for(let l=0;l<3;++l){let f=Math.abs(t[Xo.getElementIndex(pC[l],hC[l])]);f>o&&(n=l,o=f)}let i=hC[n],s=pC[n],a=1,c=0;if(Math.abs(t[Xo.getElementIndex(s,i)])>r){let l=t[Xo.getElementIndex(s,s)],f=t[Xo.getElementIndex(i,i)],u=t[Xo.getElementIndex(s,i)],d=(l-f)/2/u,h;d<0?h=-1/(-d+Math.sqrt(1+d*d)):h=1/(d+Math.sqrt(1+d*d)),a=1/Math.sqrt(1+h*h),c=h*a}return ue.IDENTITY.to(e),e[Xo.getElementIndex(i,i)]=e[Xo.getElementIndex(s,s)]=a,e[Xo.getElementIndex(s,i)]=c,e[Xo.getElementIndex(i,s)]=-c,e}var Ei=new E,Zse=new E,Jse=new E,Qse=new E,eae=new E,tae=new ue,rae={diagonal:new ue,unitary:new ue};function th(t,e=new lo){if(!t||t.length===0)return e.halfAxes=new ue([0,0,0,0,0,0,0,0,0]),e.center=new E,e;let r=t.length,o=new E(0,0,0);for(let S of t)o.add(S);let n=1/r;o.multiplyByScalar(n);let i=0,s=0,a=0,c=0,l=0,f=0;for(let S of t){let A=Ei.copy(S).subtract(o);i+=A.x*A.x,s+=A.x*A.y,a+=A.x*A.z,c+=A.y*A.y,l+=A.y*A.z,f+=A.z*A.z}i*=n,s*=n,a*=n,c*=n,l*=n,f*=n;let u=tae;u[0]=i,u[1]=s,u[2]=a,u[3]=s,u[4]=c,u[5]=l,u[6]=a,u[7]=l,u[8]=f;let{unitary:d}=mC(u,rae),h=e.halfAxes.copy(d),p=h.getColumn(0,Jse),m=h.getColumn(1,Qse),g=h.getColumn(2,eae),_=-Number.MAX_VALUE,x=-Number.MAX_VALUE,y=-Number.MAX_VALUE,b=Number.MAX_VALUE,T=Number.MAX_VALUE,v=Number.MAX_VALUE;for(let S of t)Ei.copy(S),_=Math.max(Ei.dot(p),_),x=Math.max(Ei.dot(m),x),y=Math.max(Ei.dot(g),y),b=Math.min(Ei.dot(p),b),T=Math.min(Ei.dot(m),T),v=Math.min(Ei.dot(g),v);p=p.multiplyByScalar(.5*(b+_)),m=m.multiplyByScalar(.5*(T+x)),g=g.multiplyByScalar(.5*(v+y)),e.center.copy(p).add(m).add(g);let w=Zse.set(_-b,x-T,y-v).multiplyByScalar(.5),C=new ue([w[0],0,0,0,w[1],0,0,0,w[2]]);return e.halfAxes.multiplyRight(C),e}var Gc=512,FU=3,NU=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],DU=NU.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),oae=DU.concat([[.25,.5],[.75,.5]]),wi=class{constructor(e,r,o){this.x=e,this.y=r,this.z=o}get children(){if(!this._children){let e=this.x*2,r=this.y*2,o=this.z+1;this._children=[new wi(e,r,o),new wi(e,r+1,o),new wi(e+1,r,o),new wi(e+1,r+1,o)]}return this._children}update(e){let{viewport:r,cullingVolume:o,elevationBounds:n,minZ:i,maxZ:s,bounds:a,offset:c,project:l}=e,f=this.getBoundingVolume(n,c,l);if(a&&!this.insideBounds(a)||o.computeVisibility(f)<0)return!1;if(!this.childVisible){let{z:d}=this;if(d<s&&d>=i){let h=f.distanceTo(r.cameraPosition)*r.scale/r.height;d+=Math.floor(Math.log2(h))}if(d>=s)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let d of this.children)d.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}insideBounds([e,r,o,n]){let i=Math.pow(2,this.z),s=Gc/i;return this.x*s<o&&this.y*s<n&&(this.x+1)*s>e&&(this.y+1)*s>r}getBoundingVolume(e,r,o){if(o){let c=this.z<1?oae:this.z<2?DU:NU,l=[];for(let f of c){let u=ny(this.x+f[0],this.y+f[1],this.z);u[2]=e[0],l.push(o(u)),e[0]!==e[1]&&(u[2]=e[1],l.push(o(u)))}return th(l)}let n=Math.pow(2,this.z),i=Gc/n,s=this.x*i+r*Gc,a=Gc-(this.y+1)*i;return new Ci([s,a,e[0]],[s+i,a+i,e[1]])}};function UU(t,e,r,o){let n=t instanceof Oo&&t.resolution?t.projectPosition:null,i=Object.values(t.getFrustumPlanes()).map(({normal:h,distance:p})=>new mt(h.clone().negate(),p)),s=new at(i),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,f=t instanceof Mt&&t.pitch<=60?e:0;if(o){let[h,p,m,g]=o,_=Oe([h,g]),x=Oe([m,p]);o=[_[0],Gc-_[1],x[0],Gc-x[1]]}let u=new wi(0,0,0),d={viewport:t,project:n,cullingVolume:s,elevationBounds:[c,l],minZ:f,maxZ:e,bounds:o,offset:0};if(u.update(d),t instanceof Mt&&t.subViewports&&t.subViewports.length>1){for(d.offset=-1;u.update(d)&&!(--d.offset<-FU););for(d.offset=1;u.update(d)&&!(++d.offset>FU););}return u.getSelected()}var wn=512,nae=[-1/0,-1/0,1/0,1/0],Pi={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let o=0;o<r;o++)if(t[o]!==e[o])return!1;return!0}};function iy(t,e){let r=[e.transformAsPoint([t[0],t[1]]),e.transformAsPoint([t[2],t[1]]),e.transformAsPoint([t[0],t[3]]),e.transformAsPoint([t[2],t[3]])];return[Math.min(...r.map(n=>n[0])),Math.min(...r.map(n=>n[1])),Math.max(...r.map(n=>n[0])),Math.max(...r.map(n=>n[1]))]}function iae(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function Yo(t,e){if(!t||!t.length)return null;let{index:r,id:o}=e;if(Array.isArray(t)){let i=iae(o)%t.length;t=t[i]}let n=t;for(let i of Object.keys(r)){let s=new RegExp(`{${i}}`,"g");n=n.replace(s,String(r[i]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(n=n.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),n}function sae(t,e,r){let o;if(e&&e.length===2){let[n,i]=e,s=t.getBounds({z:n}),a=t.getBounds({z:i});o=[Math.min(s[0],a[0]),Math.min(s[1],a[1]),Math.max(s[2],a[2]),Math.max(s[3],a[3])]}else o=t.getBounds();return t.isGeospatial?[Math.max(o[0],r[0]),Math.max(o[1],r[1]),Math.min(o[2],r[2]),Math.min(o[3],r[3])]:[Math.max(Math.min(o[0],r[2]),r[0]),Math.max(Math.min(o[1],r[3]),r[1]),Math.min(Math.max(o[2],r[0]),r[2]),Math.min(Math.max(o[3],r[1]),r[3])]}function VU({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(n=>gC(n,e||0,r))}function gC(t,e,r){if(!Array.isArray(e)){let i=r.x-t.x,s=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},f=t.unproject([i,s],l),u=t.unproject([i+a,s],l),d=t.unproject([i,s+c],l),h=t.unproject([i+a,s+c],l);return[Math.min(f[0],u[0],d[0],h[0]),Math.min(f[1],u[1],d[1],h[1]),Math.max(f[0],u[0],d[0],h[0]),Math.max(f[1],u[1],d[1],h[1])]}let o=gC(t,e[0],r),n=gC(t,e[1],r);return[Math.min(o[0],n[0]),Math.min(o[1],n[1]),Math.max(o[2],n[2]),Math.max(o[3],n[3])]}function aae(t,e,r){return r?iy(t,r).map(n=>n*e/wn):t.map(o=>o*e/wn)}function _C(t,e){return Math.pow(2,t)*wn/e}function ny(t,e,r){let o=_C(r,wn),n=t/o*360-180,i=Math.PI-2*Math.PI*e/o,s=180/Math.PI*Math.atan(.5*(Math.exp(i)-Math.exp(-i)));return[n,s]}function kU(t,e,r,o){let n=_C(r,o);return[t/n*wn,e/n*wn]}function yC(t,e,r,o,n=wn){if(t.isGeospatial){let[l,f]=ny(e,r,o),[u,d]=ny(e+1,r+1,o);return{west:l,north:f,east:u,south:d}}let[i,s]=kU(e,r,o,n),[a,c]=kU(e+1,r+1,o,n);return{left:i,top:s,right:a,bottom:c}}function cae(t,e,r,o,n){let i=sae(t,null,o),s=_C(e,r),[a,c,l,f]=aae(i,s,n),u=[];for(let d=Math.floor(a);d<l;d++)for(let h=Math.floor(c);h<f;h++)u.push({x:d,y:h,z:e});return u}function xC({viewport:t,maxZoom:e,minZoom:r,zRange:o,extent:n,tileSize:i=wn,modelMatrix:s,modelMatrixInverse:a,zoomOffset:c=0,visibleMinZoom:l,visibleMaxZoom:f}){let u=t.isGeospatial?Math.round(t.zoom+Math.log2(wn/i)+c):Math.ceil(t.zoom+c);if(typeof r=="number"&&Number.isFinite(r)&&u<r){if(!n)return[];u=r}if(typeof e=="number"&&Number.isFinite(e)&&u>e&&(u=e),l!=null&&t.zoom<l)return[];if(f!=null&&t.zoom>f)return[];let d=n;return s&&a&&n&&!t.isGeospatial&&(d=iy(n,s)),t.isGeospatial?UU(t,u,o,n):cae(t,u,i,d||nae,a)}function bC(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function AC(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function zU(t){let e={},r;return o=>{for(let n in o)if(!lae(o[n],e[n])){r=t(o),e=o;break}return r}}function lae(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let o=0;o<r;o++)if(t[o]!==e[o])return!1;return!0}return!1}var HU=1,sy=2,fae="never",uae="no-overlap",rh="best-available",dae=5,hae={[rh]:mae,[uae]:gae,[fae]:()=>{}},pae={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},js=class{constructor(e){this._getCullBounds=zU(VU),this.opts={...pae,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new Gn({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new V,this._modelMatrixInverse=new V}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom)),this._viewport=null}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:o}={zRange:null,modelMatrix:null}){let n=o?new V(o):new V,i=!n.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!Ce(this._zRange,r)||i){i&&(this._modelMatrixInverse=n.clone().invert(),this._modelMatrix=n),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let s=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),s&&this._frameNumber++,this._frameNumber}isTileVisible(e,r,o){if(!e.isVisible)return!1;if(r&&this._viewport){let n=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:i}=e;for(let[s,a,c,l]of n){let f;if("west"in i)f=i.west<c&&i.east>s&&i.south<l&&i.north>a;else{if(o&&!V.IDENTITY.equals(o)){let[h,p,m,g]=iy([i.left,i.top,i.right,i.bottom],o);i={left:h,top:p,right:m,bottom:g}}let u=Math.min(i.top,i.bottom),d=Math.max(i.top,i.bottom);f=i.left<c&&i.right>s&&u<l&&d>a}if(f)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:o,zRange:n,modelMatrix:i,modelMatrixInverse:s}){let{tileSize:a,extent:c,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u}=this.opts;return xC({viewport:e,maxZoom:r,minZoom:o,zRange:n,tileSize:a,extent:c,modelMatrix:i,modelMatrixInverse:s,zoomOffset:l,visibleMinZoom:f,visibleMaxZoom:u})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:yC(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),o=Math.floor(e.y/2),n=e.z-1;return{x:r,y:o,z:n}}updateTileStates(){let e=this.opts.refinementStrategy||rh,r=new Array(this._cache.size),o=0;for(let n of this._cache.values())r[o++]=n.isVisible,n.isSelected=!1,n.isVisible=!1;for(let n of this._selectedTiles)n.isSelected=!0,n.isVisible=!0;(typeof e=="function"?e:hae[e])(Array.from(this._cache.values())),o=0;for(let n of this._cache.values())if(r[o++]!==n.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],o=0;for(let n of this._cache.values())n.isLoading&&(o++,!n.isSelected&&!n.isVisible&&r.push(n));for(;e>0&&o>e&&r.length>0;)r.shift().abort(),o--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let o=this._getNearestAncestor(r);r.parent=o,o?.children&&o.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,o=r.maxCacheSize??(r.maxCacheByteSize!==null?1/0:dae*this.selectedTiles.length),n=r.maxCacheByteSize??1/0;if(e.size>o||this._cacheByteSize>n){for(let[s,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!==null?a.byteLength:0,e.delete(s),this.opts.onTileUnload?.(a)),e.size<=o&&this._cacheByteSize<=n)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((s,a)=>s.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let o=this.getTileId(e),n=this._cache.get(o),i=!1;return!n&&r?(n=new Hs(e),Object.assign(n,this.getTileMetadata(n.index)),Object.assign(n,{id:o,zoom:this.getTileZoom(n.index)}),i=!0,this._cache.set(o,n),this._dirty=!0):n&&n.needsReload&&(i=!0),n&&i&&n.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),n}_getNearestAncestor(e){let{_minZoom:r=0}=this,o=e.index;for(;this.getTileZoom(o)>r;){o=this.getParentIndex(o);let n=this._getTile(o);if(n)return n}return null}};function mae(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!jU(e)&&TC(e);for(let e of t)e.isVisible=Boolean(e.state&sy)}function gae(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&jU(r);let e=Array.from(t).sort((r,o)=>r.zoom-o.zoom);for(let r of e)if(r.isVisible=Boolean(r.state&sy),r.children&&(r.isVisible||r.state&HU))for(let o of r.children)o.state=HU;else r.isSelected&&TC(r)}function jU(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=sy,!0;e=e.parent}return!1}function TC(t){for(let e of t.children)e.isLoaded||e.content?e.state|=sy:TC(e)}var _ae={TilesetClass:js,data:{type:"data",value:[]},dataComparator:Pi.equal,renderSubLayers:{type:"function",value:t=>new Os(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:rh,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null},oh=class extends Ne{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&(!e.content||!e.layers||e.layers.every(r=>r.isLoaded))))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,o=e.propsOrDataChanged||e.updateTriggersChanged,n=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?o&&(r.setOptions(this._getTilesetOptions()),n?r.reloadAll():r.tiles.forEach(i=>{i.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:o,refinementStrategy:n,extent:i,maxZoom:s,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:d}=this.props;return{maxCacheSize:r,maxCacheByteSize:o,maxZoom:s,minZoom:a,tileSize:e,refinementStrategy:n,extent:i,maxRequests:c,debounceTime:l,zoomOffset:f,visibleMinZoom:u,visibleMaxZoom:d,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:o}=this.props,n=e.update(this.context.viewport,{zRange:r,modelMatrix:o}),{isLoaded:i}=e,s=this.state.isLoaded!==i,a=this.state.frameNumber!==n;i&&(s||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:n}),this.state.isLoaded=i}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:o,fetch:n}=this.props,{signal:i}=e;return e.url=typeof r=="string"||Array.isArray(r)?Yo(r,e):null,o?o(e):n&&e.url?n(e.url,{propName:"data",layer:this,signal:i}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,o=r.props.tile,n=e.info;return n.picked&&(n.tile=o),n.sourceTile=o,n.sourceTileSubLayer=r,n}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){let{visibleMinZoom:e,visibleMaxZoom:r,minZoom:o,extent:n}=this.props,i=this.context.viewport.zoom;if(e!=null&&i<e||r!=null&&i>r||o!=null&&!n&&i<o){for(let a of this.state.tileset.tiles)a.layers=null;return[]}return this.state.tileset.tiles.map(a=>{let c=this.getSubLayerPropsByTile(a);if(!(!a.isLoaded&&!a.content))if(a.layers)c&&a.layers[0]&&Object.keys(c).some(l=>a.layers[0].props[l]!==c[l])&&(a.layers=a.layers.map(l=>l.clone(c)));else{let l=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:a.id,updateTriggers:this.props.updateTriggers}),data:a.content,_offset:0,tile:a});a.layers=kt(l,Boolean).map(f=>f.clone({tile:a,...c}))}return a.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:o}=e.props,{modelMatrix:n}=this.props;return this.state.tileset.isTileVisible(o,r,n?new V(n):null)}};oh.defaultProps=_ae;oh.layerName="TileLayer";var Ws=oh;var WU=`layout(std140) uniform tripsUniforms {
bool fadeTrail;
float trailLength;
float currentTime;
} trips;
`,GU={name:"trips",vs:WU,fs:WU,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};var yae={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},nh=class extends Go{getShaders(){let e=super.getShaders();return e.inject={"vs:#decl":`in float instanceTimestamps;
in float instanceNextTimestamps;
out float vTime;
`,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
`,"fs:#decl":`in float vTime;
`,"fs:#main-start":`if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {
discard;
}
`,"fs:DECKGL_FILTER_COLOR":`if(trips.fadeTrail) {
color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;
}
`},e.modules=[...e.modules,GU],e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:o,currentTime:n}=this.props,i={fadeTrail:r,trailLength:o,currentTime:n};this.state.model.shaderInputs.setProps({trips:i}),super.draw(e)}};nh.layerName="TripsLayer";nh.defaultProps=yae;var $U=nh;var XU=kn(kd(),1);var Nr=kn(kd(),1);var xae=10;function bae(t,e){let r;return t==null?r=e:typeof t=="object"?r={...t,coverage:e}:r={getHexagon:t,coverage:e},r}var Aae={...vi.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:t=>t.hexagon},extruded:!0},Mi=class extends Ne{initializeState(){Mi._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let o=this._calculateH3DataProps();this.setState(o)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,o=!1,{iterable:n,objectInfo:i}=Fe(this.props.data);for(let s of n){i.index++;let a=this.props.getHexagon(s,i),c=(0,Nr.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){o=!0;break}if((0,Nr.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,Nr.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:o,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:o}=this.state,{viewport:n}=this.context;return Boolean(n?.resolution)||o||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:o,centerHex:n}=this.state;if(r<0)return;let i=this.props.centerHexagon||(0,Nr.latLngToCell)(e.latitude,e.longitude,r);if(n===i)return;if(n)try{if((0,Nr.gridDistance)(n,i)*o<xae)return}catch{}let{unitsPerMeter:s}=e.distanceScales,a=ZS(i),[c,l]=(0,Nr.cellToLatLng)(i),[f,u]=e.projectFlat([l,c]);a=a.map(d=>{let h=e.projectFlat(d);return[(h[0]-f)/s[0],(h[1]-u)/s[1]]}),this.setState({centerHex:i,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:o,extruded:n,wireframe:i,stroked:s,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,getFillColor:d,getElevation:h,getLineColor:p,getLineWidth:m,transitions:g,updateTriggers:_}=this.props;return{elevationScale:e,extruded:n,coverage:o,wireframe:i,stroked:s,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:f,lineWidthMaxPixels:u,material:r,getElevation:h,getFillColor:d,getLineColor:p,getLineWidth:m,transitions:g,updateTriggers:{getFillColor:_.getFillColor,getElevation:_.getElevation,getLineColor:_.getLineColor,getLineWidth:_.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:o,coverage:n}=this.props,i=this.getSubLayerClass("hexagon-cell-hifi",vi),s=this._getForwardProps();return s.updateTriggers.getPolygon=bae(o.getHexagon,n),new i(s,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:s.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return G0(ZS(l,n))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:o}=this.props,n=this.getSubLayerClass("hexagon-cell",Wo),i=this._getForwardProps();return i.updateTriggers.getPosition=o.getHexagon,new n(i,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:i.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:$D.bind(null,r)})}};Mi.defaultProps=Aae;Mi.layerName="H3HexagonLayer";Mi._checkH3Lib=()=>{};var $c=Mi;var Tae={getHexagons:{type:"accessor",value:t=>t.hexagons}},ih=class extends Or{initializeState(){$c._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:o,getHexagons:n}=e,i=[],{iterable:s,objectInfo:a}=Fe(o);for(let c of s){a.index++;let l=n(c,a),f=(0,XU.cellsToMultiPolygon)(l,!0);for(let u of f){for(let d of u)W0(d);i.push(this.getSubLayerRow({polygon:u},c,a.index))}}this.setState({polygons:i})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:o,getLineWidth:n}=this.props;return{data:this.state.polygons,getPolygon:i=>i.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(o),getLineWidth:this.getSubLayerAccessor(n)}}};ih.layerName="H3ClusterLayer";ih.defaultProps=Tae;var YU=ih;q();var vC=Math.PI/180,ay=new Float32Array(16),KU=new Float32Array(12);function qU(t,e,r){let o=e[0]*vC,n=e[1]*vC,i=e[2]*vC,s=Math.sin(i),a=Math.sin(o),c=Math.sin(n),l=Math.cos(i),f=Math.cos(o),u=Math.cos(n),d=r[0],h=r[1],p=r[2];t[0]=d*u*f,t[1]=d*c*f,t[2]=d*-a,t[3]=h*(-c*l+u*a*s),t[4]=h*(u*l+c*a*s),t[5]=h*f*s,t[6]=p*(c*s+u*a*l),t[7]=p*(-u*s+c*a*l),t[8]=p*f*l}function ZU(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var cy={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(t,{startRow:e,endRow:r}){let{data:o,getOrientation:n,getScale:i,getTranslation:s,getTransformMatrix:a}=this.props,c=Array.isArray(a),l=c&&a.length===16,f=Array.isArray(i),u=Array.isArray(n),d=Array.isArray(s),h=l||!c&&Boolean(a(o[0]));h?t.constant=l:t.constant=u&&f&&d;let p=t.value;if(t.constant){let m;h?(ay.set(a),m=ZU(ay)):(m=KU,qU(m,n,i),m.set(s,9)),t.value=new Float32Array(m)}else{let m=e*t.size,{iterable:g,objectInfo:_}=Fe(o,e,r);for(let x of g){_.index++;let y;if(h)ay.set(l?a:a(x,_)),y=ZU(ay);else{y=KU;let b=u?n:n(x,_),T=f?i:i(x,_);qU(y,b,T),y.set(d?s:s(x,_),9)}p[m++]=y[0],p[m++]=y[1],p[m++]=y[2],p[m++]=y[3],p[m++]=y[4],p[m++]=y[5],p[m++]=y[6],p[m++]=y[7],p[m++]=y[8],p[m++]=y[9],p[m++]=y[10],p[m++]=y[11]}}}};function ly(t,e){return e==="cartesian"||e==="meter-offsets"||e==="default"&&!t.isGeospatial}var JU=`layout(std140) uniform simpleMeshUniforms {
float sizeScale;
bool composeModelMatrix;
bool hasTexture;
bool flatShading;
} simpleMesh;
`,QU={name:"simpleMesh",vs:JU,fs:JU,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};var e4=`#version 300 es
#define SHADER_NAME simple-mesh-layer-vs
in vec3 positions;
in vec3 normals;
in vec3 colors;
in vec2 texCoords;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in vec4 instanceColors;
in vec3 instancePickingColors;
in vec3 instanceModelMatrixCol0;
in vec3 instanceModelMatrixCol1;
in vec3 instanceModelMatrixCol2;
in vec3 instanceTranslation;
out vec2 vTexCoord;
out vec3 cameraPosition;
out vec3 normals_commonspace;
out vec4 position_commonspace;
out vec4 vColor;
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = texCoords;
geometry.pickingColor = instancePickingColors;
vTexCoord = texCoords;
cameraPosition = project.cameraPosition;
vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation;
if (simpleMesh.composeModelMatrix) {
DECKGL_FILTER_SIZE(pos, geometry);
normals_commonspace = project_normal(instanceModelMatrix * normals);
geometry.worldPosition += pos;
gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);
geometry.position = position_commonspace;
}
else {
pos = project_size(pos);
DECKGL_FILTER_SIZE(pos, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);
geometry.position = position_commonspace;
normals_commonspace = project_normal(instanceModelMatrix * normals);
}
geometry.normal = normals_commonspace;
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var t4=`#version 300 es
#define SHADER_NAME simple-mesh-layer-fs
precision highp float;
uniform sampler2D sampler;
in vec2 vTexCoord;
in vec3 cameraPosition;
in vec3 normals_commonspace;
in vec4 position_commonspace;
in vec4 vColor;
out vec4 fragColor;
void main(void) {
geometry.uv = vTexCoord;
vec3 normal;
if (simpleMesh.flatShading) {
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
} else {
normal = normals_commonspace;
}
vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
DECKGL_FILTER_COLOR(color, geometry);
vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
fragColor = vec4(lightColor, color.a * layer.opacity);
}
`;function SC(t){let e=1/0,r=1/0,o=1/0,n=-1/0,i=-1/0,s=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],u=a[l+1],d=a[l+2];e=f<e?f:e,r=u<r?u:r,o=d<o?d:o,n=f>n?f:n,i=u>i?u:i,s=d>s?d:s}return[[e,r,o],[n,i,s]]}function CC(t){let e=t.positions||t.POSITION;N.assert(e,'no "postions" or "POSITION" attribute in mesh');let r=e.value.length/e.size,o=t.COLOR_0||t.colors;o||(o={size:3,value:new Float32Array(r*3).fill(1)});let n=t.NORMAL||t.normals;n||(n={size:3,value:new Float32Array(r*3).fill(0)});let i=t.TEXCOORD_0||t.texCoords;return i||(i={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:o,normals:n,texCoords:i}}function r4(t){return t instanceof ce?(t.attributes=CC(t.attributes),t):t.attributes?new ce({...t,topology:"triangle-list",attributes:CC(t.attributes)}):new ce({topology:"triangle-list",attributes:CC(t)})}var vae=[0,0,0,255],Sae={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:vae},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}},sh=class extends _e{getShaders(){return super.getShaders({vs:e4,fs:t4,modules:[fe,nn,Se,QU]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;let{mesh:r}=this.props;if(!r)return null;if(e=r.header?.boundingBox,!e){let{attributes:o}=r4(r);o.POSITION=o.POSITION||o.positions,e=SC(o)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:cy}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e;if(r.mesh!==o.mesh||n.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),r.mesh){this.state.model=this.getModel(r.mesh);let i=r.mesh.attributes||r.mesh;this.setState({hasNormals:Boolean(i.NORMAL||i.normals)})}this.getAttributeManager().invalidateAll()}r.texture!==o.texture&&r.texture instanceof Y&&this.setTexture(r.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){let{model:r}=this.state;if(!r)return;let{viewport:o,renderPass:n}=this.context,{sizeScale:i,coordinateSystem:s,_instanced:a}=this.props,c={sizeScale:i,composeModelMatrix:!a||ly(o,s),flatShading:!this.state.hasNormals};r.shaderInputs.setProps({simpleMesh:c}),r.draw(n)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){let r=new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:r4(e),isInstanced:!0}),{texture:o}=this.props,{emptyTexture:n}=this.state,i={sampler:o||n,hasTexture:Boolean(o)};return r.shaderInputs.setProps({simpleMesh:i}),r}setTexture(e){let{emptyTexture:r,model:o}=this.state;if(o){let n={sampler:e||r,hasTexture:Boolean(e)};o.shaderInputs.setProps({simpleMesh:n})}}};sh.defaultProps=Sae;sh.layerName="SimpleMeshLayer";var Gs=sh;q();var be;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST=9728]="NEAREST",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(be||(be={}));function n4(t){return{addressModeU:o4(t.wrapS),addressModeV:o4(t.wrapT),magFilter:Cae(t.magFilter),...Eae(t.minFilter)}}function o4(t){switch(t){case be.CLAMP_TO_EDGE:return"clamp-to-edge";case be.REPEAT:return"repeat";case be.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function Cae(t){switch(t){case be.NEAREST:return"nearest";case be.LINEAR:return"linear";default:return}}function Eae(t){switch(t){case be.NEAREST:return{minFilter:"nearest"};case be.LINEAR:return{minFilter:"linear"};case be.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case be.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case be.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case be.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var EC=[St("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),St("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),St("normal","pbr_normalSampler","normalTexture",["normalTexture"]),St("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),St("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),St("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),St("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),St("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),St("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),St("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),St("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),St("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),St("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),St("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),St("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),St("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),St("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],wae=new Map(EC.map(t=>[t.slot,t]));function St(t,e,r,o){return{slot:t,binding:e,displayName:r,pathSegments:o,uvSetUniform:`${t}UVSet`,uvTransformUniform:`${t}UVTransform`}}function i4(){return EC}function uy(t){let e=wae.get(t);if(!e)throw new Error(`Unknown PBR texture transform slot ${t}`);return e}function dy(t){let e=t?.extensions?.KHR_texture_transform;return{offset:e?.offset?[e.offset[0],e.offset[1]]:[0,0],rotation:e?.rotation??0,scale:e?.scale?[e.scale[0],e.scale[1]]:[1,1]}}function wC(t){return t?.extensions?.KHR_texture_transform?.texCoord??t?.texCoord??0}function s4(t){return EC.find(e=>e.pathSegments.length===t.length&&e.pathSegments.every((r,o)=>t[o]===r))||null}function fy(t){let e=new ue().set(1,0,0,0,1,0,t.offset[0],t.offset[1],1),r=new ue().set(Math.cos(t.rotation),Math.sin(t.rotation),0,-Math.sin(t.rotation),Math.cos(t.rotation),0,0,0,1),o=new ue().set(t.scale[0],0,0,0,t.scale[1],0,0,0,1);return Array.from(e.multiplyRight(r).multiplyRight(o))}function a4(t,e){let r=new ue(fy(t)),o=new ue(fy(e)),n=new ue(r).invert();return Array.from(o.multiplyRight(n))}function Xc(t,e,r,o){let n={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};n.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:i}=o;return i&&(n.bindings.pbr_diffuseEnvSampler=i.diffuseEnvSampler.texture,n.bindings.pbr_specularEnvSampler=i.specularEnvSampler.texture,n.bindings.pbr_brdfLUT=i.brdfLutTexture.texture,n.uniforms.IBLenabled=!0,n.uniforms.scaleIBLAmbient=[1,1]),o?.pbrDebug&&(n.defines.PBR_DEBUG=!0,n.uniforms.scaleDiffBaseMR=[0,0,0,0],n.uniforms.scaleFGDSpec=[0,0,0,0]),r.NORMAL&&(n.defines.HAS_NORMALS=!0),r.TANGENT&&o?.useTangents&&(n.defines.HAS_TANGENTS=!0),r.TEXCOORD_0&&(n.defines.HAS_UV=!0),r.TEXCOORD_1&&(n.defines.HAS_UV_1=!0),r.JOINTS_0&&r.WEIGHTS_0&&(n.defines.HAS_SKIN=!0),r.COLOR_0&&(n.defines.HAS_COLORS=!0),o?.imageBasedLightingEnvironment&&(n.defines.USE_IBL=!0),o?.lights&&(n.defines.USE_LIGHTS=!0),e&&(o.validateAttributes!==!1&&Pae(e,r),Rae(t,e,n,r,o.gltf)),n}function Pae(t,e){let r=c4(t,0);r.length>0&&!e.TEXCOORD_0&&P.warn(`glTF material uses ${r.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();let o=c4(t,1);if(o.length>0&&!e.TEXCOORD_1&&P.warn(`glTF material uses ${o.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)(),Boolean(t.unlit||t.extensions?.KHR_materials_unlit)||e.NORMAL)return;let i=t.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";P.warn(`glTF primitive is missing NORMAL while using ${i}; shading will fall back to geometric normals`)()}function c4(t,e){let r=[];for(let o of i4()){let n=Mae(t,o.pathSegments);n&&wC(n)===e&&r.push(o.displayName)}return r}function Mae(t,e){let r=t;for(let o of e)if(r=r?.[o],!r)return null;return r}function Rae(t,e,r,o,n){if(r.uniforms.unlit=Boolean(e.unlit||e.extensions?.KHR_materials_unlit),e.pbrMetallicRoughness&&Bae(t,e.pbrMetallicRoughness,r,o,n),e.normalTexture){Ct(t,e.normalTexture,"pbr_normalSampler",r,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"normal"});let{scale:i=1}=e.normalTexture;r.uniforms.normalScale=i}if(e.occlusionTexture){Ct(t,e.occlusionTexture,"pbr_occlusionSampler",r,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"occlusion"});let{strength:i=1}=e.occlusionTexture;r.uniforms.occlusionStrength=i}switch(r.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0],e.emissiveTexture&&Ct(t,e.emissiveTexture,"pbr_emissiveSampler",r,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"emissive"}),Oae(t,e.extensions,r,n,o),e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:i=.5}=e;r.defines.ALPHA_CUTOFF=!0,r.uniforms.alphaCutoffEnabled=!0,r.uniforms.alphaCutoff=i;break}case"BLEND":P.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),Iae(r);break}}function Iae(t){t.parameters.blend=!0,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="src-alpha",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.blendEquation=be.FUNC_ADD,t.glParameters.blendFunc=[be.SRC_ALPHA,be.ONE_MINUS_SRC_ALPHA,be.ONE,be.ONE_MINUS_SRC_ALPHA]}function Lae(t){t.parameters.blend=!0,t.parameters.depthWriteEnabled=!1,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="one",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.depthMask=!1,t.glParameters.blendEquation=be.FUNC_ADD,t.glParameters.blendFunc=[be.ONE,be.ONE_MINUS_SRC_ALPHA,be.ONE,be.ONE_MINUS_SRC_ALPHA]}function Bae(t,e,r,o,n){e.baseColorTexture&&Ct(t,e.baseColorTexture,"pbr_baseColorSampler",r,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"baseColor"}),r.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&Ct(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",r,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:n,attributes:o,textureTransformSlot:"metallicRoughness"});let{metallicFactor:i=1,roughnessFactor:s=1}=e;r.uniforms.metallicRoughnessValues=[i,s]}function Oae(t,e,r,o,n={}){e&&(Fae(e)&&(r.defines.USE_MATERIAL_EXTENSIONS=!0),Nae(t,e.KHR_materials_specular,r,o,n),Dae(e.KHR_materials_ior,r),Uae(t,e.KHR_materials_transmission,r,o,n),kae(t,e.KHR_materials_volume,r,o,n),Vae(t,e.KHR_materials_clearcoat,r,o,n),zae(t,e.KHR_materials_sheen,r,o,n),Hae(t,e.KHR_materials_iridescence,r,o,n),jae(t,e.KHR_materials_anisotropy,r,o,n),Wae(e.KHR_materials_emissive_strength,r))}function Fae(t){return Boolean(t.KHR_materials_specular||t.KHR_materials_ior||t.KHR_materials_transmission||t.KHR_materials_volume||t.KHR_materials_clearcoat||t.KHR_materials_sheen||t.KHR_materials_iridescence||t.KHR_materials_anisotropy)}function Nae(t,e,r,o,n={}){e&&(e.specularColorFactor&&(r.uniforms.specularColorFactor=e.specularColorFactor),e.specularFactor!==void 0&&(r.uniforms.specularIntensityFactor=e.specularFactor),e.specularColorTexture&&Ct(t,e.specularColorTexture,"pbr_specularColorSampler",r,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"specularColor"}),e.specularTexture&&Ct(t,e.specularTexture,"pbr_specularIntensitySampler",r,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"specularIntensity"}))}function Dae(t,e){t?.ior!==void 0&&(e.uniforms.ior=t.ior)}function Uae(t,e,r,o,n={}){e&&(e.transmissionFactor!==void 0&&(r.uniforms.transmissionFactor=e.transmissionFactor),e.transmissionTexture&&Ct(t,e.transmissionTexture,"pbr_transmissionSampler",r,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"transmission"}),((e.transmissionFactor??0)>0||e.transmissionTexture)&&(P.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),Lae(r)))}function kae(t,e,r,o,n={}){e&&(e.thicknessFactor!==void 0&&(r.uniforms.thicknessFactor=e.thicknessFactor),e.thicknessTexture&&Ct(t,e.thicknessTexture,"pbr_thicknessSampler",r,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:o,attributes:n,textureTransformSlot:"thickness"}),e.attenuationDistance!==void 0&&(r.uniforms.attenuationDistance=e.attenuationDistance),e.attenuationColor&&(r.uniforms.attenuationColor=e.attenuationColor))}function Vae(t,e,r,o,n={}){e&&(e.clearcoatFactor!==void 0&&(r.uniforms.clearcoatFactor=e.clearcoatFactor),e.clearcoatRoughnessFactor!==void 0&&(r.uniforms.clearcoatRoughnessFactor=e.clearcoatRoughnessFactor),e.clearcoatTexture&&Ct(t,e.clearcoatTexture,"pbr_clearcoatSampler",r,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"clearcoat"}),e.clearcoatRoughnessTexture&&Ct(t,e.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",r,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"clearcoatRoughness"}),e.clearcoatNormalTexture&&Ct(t,e.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",r,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:o,attributes:n,textureTransformSlot:"clearcoatNormal"}))}function zae(t,e,r,o,n={}){e&&(e.sheenColorFactor&&(r.uniforms.sheenColorFactor=e.sheenColorFactor),e.sheenRoughnessFactor!==void 0&&(r.uniforms.sheenRoughnessFactor=e.sheenRoughnessFactor),e.sheenColorTexture&&Ct(t,e.sheenColorTexture,"pbr_sheenColorSampler",r,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"sheenColor"}),e.sheenRoughnessTexture&&Ct(t,e.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",r,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"sheenRoughness"}))}function Hae(t,e,r,o,n={}){e&&(e.iridescenceFactor!==void 0&&(r.uniforms.iridescenceFactor=e.iridescenceFactor),e.iridescenceIor!==void 0&&(r.uniforms.iridescenceIor=e.iridescenceIor),(e.iridescenceThicknessMinimum!==void 0||e.iridescenceThicknessMaximum!==void 0)&&(r.uniforms.iridescenceThicknessRange=[e.iridescenceThicknessMinimum??100,e.iridescenceThicknessMaximum??400]),e.iridescenceTexture&&Ct(t,e.iridescenceTexture,"pbr_iridescenceSampler",r,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"iridescence"}),e.iridescenceThicknessTexture&&Ct(t,e.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",r,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:o,attributes:n,textureTransformSlot:"iridescenceThickness"}))}function jae(t,e,r,o,n={}){e&&(e.anisotropyStrength!==void 0&&(r.uniforms.anisotropyStrength=e.anisotropyStrength),e.anisotropyRotation!==void 0&&(r.uniforms.anisotropyRotation=e.anisotropyRotation),e.anisotropyTexture&&Ct(t,e.anisotropyTexture,"pbr_anisotropySampler",r,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:o,attributes:n,textureTransformSlot:"anisotropy"}))}function Wae(t,e){t?.emissiveStrength!==void 0&&(e.uniforms.emissiveStrength=t.emissiveStrength)}function Ct(t,e,r,o,n={}){let{featureOptions:i={},gltf:s,attributes:a={},textureTransformSlot:c}=n,{define:l,enabledUniformName:f}=i,u=wC(e);if(u>1){P.warn(`Skipping ${String(r)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();return}if(u===1&&!a.TEXCOORD_1){P.warn(`Skipping ${String(r)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();return}let d=Gae(e,s),h=d.texture?.source?.image;if(!h){P.warn(`Skipping unresolved glTF texture for ${String(r)}`)();return}let p={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...d?.texture?.sampler},m={id:d.uniformName||d.id,sampler:n4(p)},g;if(h.compressed)g=Xae(t,h,m);else{let{width:_,height:x}=t.getExternalImageSize(h);g=t.createTexture({...m,width:_,height:x,data:h})}if(o.bindings[r]=g,l&&(o.defines[l]=!0),f&&(o.uniforms[f]=!0),c){let _=uy(c);o.uniforms[_.uvSetUniform]=u,o.uniforms[_.uvTransformUniform]=fy(dy(e))}o.generatedTextures.push(g)}function Gae(t,e){if(t.texture||t.index===void 0||!e?.textures)return t;let r=e.textures[t.index];return r?"texture"in r&&r.texture?{...r,...t,texture:r.texture}:"source"in r?{...t,texture:r}:t:t}function PC(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function l4(t){return t.textureFormat}function $ae(t,e,r){let{blockWidth:o=1,blockHeight:n=1}=bt.getInfo(r),i=1;for(let s=1;;s++){let a=Math.max(1,t>>s),c=Math.max(1,e>>s);if(a<o||c<n)break;i++}return i}function Xae(t,e,r){let o;if(Array.isArray(e.data)&&e.data[0]?.data?o=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?o=e.mipmaps:o=[],o.length===0||!o[0]?.data)return P.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),PC(t,r);let n=o[0],i=n.width??e.width??0,s=n.height??e.height??0;if(i<=0||s<=0)return P.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),PC(t,r);let a=l4(n);if(!a)return P.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),PC(t,r);let c=$ae(i,s,a),l=Math.min(o.length,c),f=1;for(let d=1;d<l;d++){let h=o[d];if(!h.data||h.width<=0||h.height<=0){P.warn(`createCompressedTexture: mip level ${d} has invalid data/dimensions, truncating`)();break}let p=l4(h);if(p&&p!==a){P.warn(`createCompressedTexture: mip level ${d} format '${p}' differs from base '${a}', truncating`)();break}let m=Math.max(1,i>>d),g=Math.max(1,s>>d);if(h.width!==m||h.height!==g){P.warn(`createCompressedTexture: mip level ${d} dimensions ${h.width}x${h.height} don't match expected ${m}x${g}, truncating`)();break}f++}let u=t.createTexture({...r,format:a,usage:Y.TEXTURE|Y.COPY_DST,width:i,height:s,mipLevels:f,data:n.data});for(let d=1;d<f;d++)u.writeData(o[d].data,{width:o[d].width,height:o[d].height,mipLevel:d});return u}function f4(t,e={}){let r=t.lights||t.extensions?.KHR_lights_punctual?.lights;if(!r||!Array.isArray(r)||r.length===0)return[];let o=[],n=Jae(t.nodes||[]),i=new Map;for(let s of t.nodes||[]){let a=s.light??s.extensions?.KHR_lights_punctual?.light;if(typeof a!="number")continue;let c=r[a];if(!c)continue;let l=Yae(c.color||[1,1,1],e.useByteColors??!0),f=c.intensity??1,u=c.range,d=u4(s,n,i);switch(c.type){case"directional":o.push(qae(d,l,f));break;case"point":o.push(Kae(d,l,f,u));break;case"spot":o.push(Zae(d,l,f,u,c.spot));break;default:break}}return o}function Yae(t,e){return e?t.map(r=>r*255):Oa(t,!1)}function Kae(t,e,r,o){let n=d4(t),i=[1,0,0];return o!==void 0&&o>0&&(i=[1,0,1/(o*o)]),{type:"point",position:n,color:e,intensity:r,attenuation:i}}function qae(t,e,r){return{type:"directional",direction:h4(t),color:e,intensity:r}}function Zae(t,e,r,o,n={}){let i=d4(t),s=h4(t),a=[1,0,0];return o!==void 0&&o>0&&(a=[1,0,1/(o*o)]),{type:"spot",position:i,direction:s,color:e,intensity:r,attenuation:a,innerConeAngle:n.innerConeAngle??0,outerConeAngle:n.outerConeAngle??Math.PI/4}}function Jae(t){let e=new Map;for(let r of t)for(let o of r.children||[])e.set(o.id,r);return e}function u4(t,e,r){let o=r.get(t.id);if(o)return o;let n=Qae(t),i=e.get(t.id),s=i?new V(u4(i,e,r)).multiplyRight(n):n;return r.set(t.id,s),s}function Qae(t){if(t.matrix)return new V(t.matrix);let e=new V;return t.translation&&e.translate(t.translation),t.rotation&&e.multiplyRight(new V().fromQuaternion(t.rotation)),t.scale&&e.scale(t.scale),e}function d4(t){return t.transformAsPoint([0,0,0])}function h4(t){return t.transformDirection([0,0,-1])}function p4(t){switch(t){case be.POINTS:return"point-list";case be.LINES:return"line-list";case be.LINE_STRIP:return"line-strip";case be.TRIANGLES:return"triangle-list";case be.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(t))}}q();var ece=`
struct VertexInputs {
@location(0) positions: vec3f,
#ifdef HAS_NORMALS
@location(1) normals: vec3f,
#endif
#ifdef HAS_TANGENTS
@location(2) TANGENT: vec4f,
#endif
#ifdef HAS_UV
@location(3) texCoords: vec2f,
#endif
#ifdef HAS_UV_1
@location(4) texCoords1: vec2f,
#endif
#ifdef HAS_SKIN
@location(5) JOINTS_0: vec4u,
@location(6) WEIGHTS_0: vec4f,
#endif
};
struct FragmentInputs {
@builtin(position) position: vec4f,
@location(0) pbrPosition: vec3f,
@location(1) pbrUV0: vec2f,
@location(2) pbrUV1: vec2f,
@location(3) pbrNormal: vec3f,
#ifdef HAS_TANGENTS
@location(4) pbrTangent: vec4f,
#endif
};
@vertex
fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
var outputs: FragmentInputs;
var position = vec4f(inputs.positions, 1.0);
var normal = vec3f(0.0, 0.0, 1.0);
var tangent = vec4f(1.0, 0.0, 0.0, 1.0);
var uv0 = vec2f(0.0, 0.0);
var uv1 = vec2f(0.0, 0.0);
#ifdef HAS_NORMALS
normal = inputs.normals;
#endif
#ifdef HAS_UV
uv0 = inputs.texCoords;
#endif
#ifdef HAS_UV_1
uv1 = inputs.texCoords1;
#endif
#ifdef HAS_TANGENTS
tangent = inputs.TANGENT;
#endif
#ifdef HAS_SKIN
let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);
position = skinMatrix * position;
normal = normalize((skinMatrix * vec4f(normal, 0.0)).xyz);
#ifdef HAS_TANGENTS
tangent = vec4f(normalize((skinMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w);
#endif
#endif
let worldPosition = pbrProjection.modelMatrix * position;
#ifdef HAS_NORMALS
normal = normalize((pbrProjection.normalMatrix * vec4f(normal, 0.0)).xyz);
#endif
#ifdef HAS_TANGENTS
let worldTangent = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);
outputs.pbrTangent = vec4f(worldTangent, tangent.w);
#endif
outputs.position = pbrProjection.modelViewProjectionMatrix * position;
outputs.pbrPosition = worldPosition.xyz / worldPosition.w;
outputs.pbrUV0 = uv0;
outputs.pbrUV1 = uv1;
outputs.pbrNormal = normal;
return outputs;
}
@fragment
fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {
fragmentInputs.pbr_vPosition = inputs.pbrPosition;
fragmentInputs.pbr_vUV0 = inputs.pbrUV0;
fragmentInputs.pbr_vUV1 = inputs.pbrUV1;
fragmentInputs.pbr_vNormal = inputs.pbrNormal;
#ifdef HAS_TANGENTS
let tangent = normalize(inputs.pbrTangent.xyz);
let bitangent = normalize(cross(inputs.pbrNormal, tangent)) * inputs.pbrTangent.w;
fragmentInputs.pbr_vTBN = mat3x3f(tangent, bitangent, inputs.pbrNormal);
#endif
return pbr_filterColor(vec4f(1.0));
}
`,tce=`#version 300 es
// in vec4 POSITION;
in vec4 positions;
#ifdef HAS_NORMALS
// in vec4 NORMAL;
in vec4 normals;
#endif
#ifdef HAS_TANGENTS
in vec4 TANGENT;
#endif
#ifdef HAS_UV
// in vec2 TEXCOORD_0;
in vec2 texCoords;
#endif
#ifdef HAS_UV_1
in vec2 texCoords1;
#endif
#ifdef HAS_SKIN
in uvec4 JOINTS_0;
in vec4 WEIGHTS_0;
#endif
void main(void) {
vec4 _NORMAL = vec4(0.);
vec4 _TANGENT = vec4(0.);
vec2 _TEXCOORD_0 = vec2(0.);
vec2 _TEXCOORD_1 = vec2(0.);
#ifdef HAS_NORMALS
_NORMAL = normals;
#endif
#ifdef HAS_TANGENTS
_TANGENT = TANGENT;
#endif
#ifdef HAS_UV
_TEXCOORD_0 = texCoords;
#endif
#ifdef HAS_UV_1
_TEXCOORD_1 = texCoords1;
#endif
vec4 pos = positions;
#ifdef HAS_SKIN
mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0);
pos = skinMat * pos;
_NORMAL = skinMat * _NORMAL;
_TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w);
#endif
pbr_setPositionNormalTangentUV(pos, _NORMAL, _TANGENT, _TEXCOORD_0, _TEXCOORD_1);
gl_Position = pbrProjection.modelViewProjectionMatrix * pos;
}
`,rce=`#version 300 es
out vec4 fragmentColor;
void main(void) {
vec3 pos = pbr_vPosition;
fragmentColor = pbr_filterColor(vec4(1.0));
}
`;function MC(t,e){let r=e.materialFactory||new un(t,{modules:[Po]}),o={...e.parsedPPBRMaterial.uniforms};delete o.camera;let n=Object.fromEntries(Object.entries({...o,...e.parsedPPBRMaterial.bindings}).filter(([s,a])=>r.ownsBinding(s)&&oce(a))),i=r.createMaterial({id:e.id,bindings:n});return i.setProps({pbrMaterial:o}),i}function m4(t,e){let{id:r,geometry:o,parsedPPBRMaterial:n,vertexCount:i,modelOptions:s={}}=e;P.info(4,"createGLTFModel defines: ",n.defines)();let a=[],c={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},l={id:r,source:ece,vs:tce,fs:rce,geometry:o,topology:o.topology,vertexCount:i,modules:[Po,_T],...s,defines:{...n.defines,...s.defines},parameters:{...c,...n.parameters,...s.parameters}},f=e.material||MC(t,{id:r?`${r}-material`:void 0,parsedPPBRMaterial:n});l.material=f;let u=new Q(t,l),d={...n.uniforms,...s.uniforms,...n.bindings,...s.bindings},h=nce(u.shaderInputs.getModules(),f,d);return u.shaderInputs.setProps(h),new Io({managedResources:a,model:u})}function oce(t){return t instanceof K||t instanceof Kt||t instanceof Pt||t instanceof Y||t instanceof wr}function nce(t,e,r){let o=new Map;for(let i of t){for(let s of Object.keys(i.uniformTypes||{}))o.set(s,i.name);for(let s of i.bindingLayout||[])o.set(s.name,i.name)}let n={};for(let[i,s]of Object.entries(r)){if(s===void 0)continue;let a=o.get(i);!a||e.ownsModule(a)||(n[a]||={},n[a][i]=s)}return n}var ice={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1,useByteColors:!0};function g4(t,e,r={}){let o={...ice,...r},n=new un(t,{modules:[Po]}),i=(e.materials||[]).map((u,d)=>MC(t,{id:uce(u,d),parsedPPBRMaterial:Xc(t,u,{},{...o,gltf:e,validateAttributes:!1}),materialFactory:n})),s=new Map;(e.materials||[]).forEach((u,d)=>{s.set(u.id,i[d])});let a=new Map;e.meshes.forEach((u,d)=>{let h=ace(t,u,e,s,o);a.set(u.id,h)});let c=new Map,l=new Map;return e.nodes.forEach((u,d)=>{let h=sce(t,u,o);c.set(d,h),l.set(u.id,h)}),e.nodes.forEach((u,d)=>{if(c.get(d).add((u.children??[]).map(({id:h})=>{let p=l.get(h);if(!p)throw new Error(`Cannot find child ${h} of node ${d}`);return p})),u.mesh){let h=a.get(u.mesh.id);if(!h)throw new Error(`Cannot find mesh child ${u.mesh.id} of node ${d}`);c.get(d).add(h)}}),{scenes:e.scenes.map(u=>{let d=(u.nodes||[]).map(({id:h})=>{let p=l.get(h);if(!p)throw new Error(`Cannot find child ${h} of scene ${u.name||u.id}`);return p});return new qt({id:u.name||u.id,children:d})}),materials:i,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:l,gltfNodeIndexToNodeMap:c}}function sce(t,e,r){return new qt({id:e.name||e.id,children:[],matrix:e.matrix,position:e.translation,rotation:e.rotation,scale:e.scale})}function ace(t,e,r,o,n){let s=(e.primitives||[]).map((c,l)=>cce({device:t,gltfPrimitive:c,primitiveIndex:l,gltfMesh:e,gltf:r,gltfMaterialIdToMaterialMap:o,options:n}));return new qt({id:e.name||e.id,children:s})}function cce({device:t,gltfPrimitive:e,primitiveIndex:r,gltfMesh:o,gltf:n,gltfMaterialIdToMaterialMap:i,options:s}){let a=e.name||`${o.name||o.id}-primitive-${r}`,c=p4(e.mode??4),l=e.indices?e.indices.count:lce(e.attributes),f=fce(a,e,c),u=Xc(t,e.material,f.attributes,{...s,gltf:n}),d=m4(t,{id:a,geometry:f,material:e.material&&i.get(e.material.id)||null,parsedPPBRMaterial:u,modelOptions:s.modelOptions,vertexCount:l});return d.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],d}function lce(t){let e=1/0;for(let r of Object.values(t))if(r){let{value:o,size:n,components:i}=r,s=n??i;o?.length!==void 0&&s>=1&&(e=Math.min(e,o.length/s))}if(!Number.isFinite(e))throw new Error("Could not determine vertex count from attributes");return e}function fce(t,e,r){let o={};for(let[n,i]of Object.entries(e.attributes)){let{components:s,size:a,value:c,normalized:l}=i;o[n]={size:a??s,value:c,normalized:l}}return new ce({id:t,topology:r,indices:e.indices?.value,attributes:o})}function uce(t,e){return t.name||t.id||`material-${e}`}q();q();function dce(t,e,r){switch(e){case"translation":return t.setPosition(r).updateMatrix();case"rotation":return t.setRotation(r).updateMatrix();case"scale":return t.setScale(r).updateMatrix();default:return P.warn(`Bad animation path ${e}`)(),null}}function _4(t,{input:e,interpolation:r,output:o},n,i){let s=RC(t,{input:e,interpolation:r,output:o},i);s&&dce(n,i,s)}function RC(t,{input:e,interpolation:r,output:o},n){let i=e[e.length-1];if(!Number.isFinite(i)||i<=0)return o[0]||null;let s=t%i,a=e.findIndex(u=>u>=s);if(a<0)return o[o.length-1]||null;let c=Math.max(0,a-1),l=e[c],f=e[a];switch(r){case"STEP":return o[c];case"LINEAR":if(f>l){let u=(s-l)/(f-l);return hce(n,o[c],o[a],u)}return o[c]||null;case"CUBICSPLINE":if(f>l){let u=(s-l)/(f-l),d=f-l,h=o[3*c+1],p=o[3*c+2],m=o[3*a+0],g=o[3*a+1];return pce({p0:h,outTangent0:p,inTangent1:m,p1:g,tDiff:d,ratio:u})}return o[3*c+1]||null;default:return P.warn(`Interpolation ${r} not supported`)(),null}}function hce(t,e,r,o){if(t==="rotation")return new Sr().slerp({start:e,target:r,ratio:o});let n=[];for(let i=0;i<e.length;i++)n[i]=o*r[i]+(1-o)*e[i];return n}function pce({p0:t,outTangent0:e,inTangent1:r,p1:o,tDiff:n,ratio:i}){let s=[];for(let a=0;a<t.length;a++){let c=e[a]*n,l=r[a]*n;s[a]=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*t[a]+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(-2*Math.pow(i,3)+3*Math.pow(i,2))*o[a]+(Math.pow(i,3)-Math.pow(i,2))*l}return s}var IC=class{animation;gltfNodeIdToNodeMap;materials;startTime=0;playing=!0;speed=1;materialTextureTransformState=new Map;constructor(e){if(this.animation=e.animation,this.gltfNodeIdToNodeMap=e.gltfNodeIdToNodeMap,this.materials=e.materials||[],this.animation.name||="unnamed",Object.assign(this,e),this.animation.channels.some(r=>r.type!=="node")&&!this.materials.length)throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`)}setTime(e){if(!this.playing)return;let o=(e/1e3-this.startTime)*this.speed;this.animation.channels.forEach(n=>{if(n.type==="node"){let{sampler:a,targetNodeId:c,path:l}=n,f=this.gltfNodeIdToNodeMap.get(c);if(!f)throw new Error(`Cannot find animation target node ${c}`);_4(o,a,f,l);return}let i=this.materials[n.targetMaterialIndex];if(!i)throw new Error(`Cannot find animation target material ${n.targetMaterialIndex} for ${n.pointer}`);let s=RC(o,n.sampler);s&&(n.type==="material"?mce(i,n,s):yce(i,n,s,this.materialTextureTransformState))})}},hy=class{animations;constructor(e){this.animations=e.animations.map((r,o)=>{let n=r.name||`Animation-${o}`;return new IC({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,materials:e.materials,animation:{name:n,channels:r.channels}})})}animate(e){P.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(e)}setTime(e){this.animations.forEach(r=>r.setTime(e))}getAnimations(){return this.animations}};function mce(t,e,r){let o=e.component!==void 0?{[e.property]:_ce(gce(t,e.property),e.component,r[0])}:{[e.property]:r.length===1?r[0]:r};t.setProps({pbrMaterial:o})}function gce(t,e){let o=t.shaderInputs.getUniformValues().pbrMaterial?.[e];return Array.isArray(o)?[...o]:[]}function _ce(t,e,r){let o=[...t];return o[e]=r,o}function yce(t,e,r,o){let n=uy(e.textureSlot),i=xce(o,t,e);switch(e.path){case"offset":e.component!==void 0?i.offset[e.component]=r[0]:i.offset=[r[0],r[1]];break;case"rotation":i.rotation=r[0];break;case"scale":e.component!==void 0?i.scale[e.component]=r[0]:i.scale=[r[0],r[1]];break}t.setProps({pbrMaterial:{[n.uvTransformUniform]:a4(e.baseTransform,i)}})}function xce(t,e,r){let o=t.get(e)||{},n=o[r.textureSlot];return n||(n={offset:[...r.baseTransform.offset],rotation:r.baseTransform.rotation,scale:[...r.baseTransform.scale]},o[r.textureSlot]=n,t.set(e,o)),n}q();var bce={supportLevel:"none",comment:"Not currently listed in the luma.gl glTF extension support registry."},y4={KHR_draco_mesh_compression:{supportLevel:"built-in",comment:"Decoded by loaders.gl before luma.gl builds the scenegraph."},EXT_meshopt_compression:{supportLevel:"built-in",comment:"Meshopt-compressed primitives are decoded during load."},KHR_mesh_quantization:{supportLevel:"built-in",comment:"Quantized accessors are unpacked before geometry creation."},KHR_lights_punctual:{supportLevel:"built-in",comment:"Parsed into luma.gl Light objects."},KHR_materials_unlit:{supportLevel:"built-in",comment:"Unlit materials bypass the default lighting path."},KHR_materials_emissive_strength:{supportLevel:"built-in",comment:"Applied by the stock PBR shader."},KHR_texture_basisu:{supportLevel:"built-in",comment:"BasisU / KTX2 textures pass through when the device supports them."},KHR_texture_transform:{supportLevel:"built-in",comment:"UV transforms are applied during load."},EXT_texture_webp:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},EXT_texture_avif:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},KHR_materials_specular:{supportLevel:"built-in",comment:"The stock shader now applies specular factors and textures to the dielectric F0 term."},KHR_materials_ior:{supportLevel:"built-in",comment:"The stock shader now drives dielectric reflectance from the glTF IOR value."},KHR_materials_transmission:{supportLevel:"built-in",comment:"The stock shader now applies transmission to the base layer and exposes transparency through alpha, without a scene-color refraction buffer."},KHR_materials_volume:{supportLevel:"built-in",comment:"Thickness and attenuation now tint transmitted light in the stock shader."},KHR_materials_clearcoat:{supportLevel:"built-in",comment:"The stock shader now adds a secondary clearcoat specular lobe."},KHR_materials_sheen:{supportLevel:"built-in",comment:"The stock shader now adds a sheen lobe for cloth-like materials."},KHR_materials_iridescence:{supportLevel:"built-in",comment:"The stock shader now tints specular response with a view-dependent thin-film iridescence approximation."},KHR_materials_anisotropy:{supportLevel:"built-in",comment:"The stock shader now shapes highlights and IBL response with an anisotropy-direction approximation."},KHR_materials_pbrSpecularGlossiness:{supportLevel:"loader-only",comment:"Extension data can be loaded, but it is not translated into the default metallic-roughness material path."},KHR_materials_variants:{supportLevel:"loader-only",comment:"Variant metadata can be loaded, but applications must choose and apply variants."},EXT_mesh_gpu_instancing:{supportLevel:"none",comment:"GPU instancing data is not yet converted into luma.gl instanced draw setup."},KHR_node_visibility:{supportLevel:"none",comment:"Node-visibility animations and toggles are not mapped onto runtime scenegraph state."},KHR_animation_pointer:{supportLevel:"parsed-and-wired",comment:"Selected node TRS, material factor, and KHR_texture_transform offset/rotation/scale pointers are wired to runtime updates; unsupported targets are skipped."},KHR_materials_diffuse_transmission:{supportLevel:"none",comment:"Diffuse-transmission shading is not implemented in the stock PBR shader."},KHR_materials_dispersion:{supportLevel:"none",comment:"Chromatic dispersion is not implemented in the stock PBR shader."},KHR_materials_volume_scatter:{supportLevel:"none",comment:"Volume scattering is not implemented in the stock PBR shader."},KHR_xmp:{supportLevel:"none",comment:"Metadata payloads remain in the loaded glTF, but luma.gl does not interpret them."},KHR_xmp_json_ld:{supportLevel:"none",comment:"Metadata is preserved in the glTF, but luma.gl does not interpret it."},EXT_lights_image_based:{supportLevel:"none",comment:"Use loadPBREnvironment() or custom environment setup instead."},EXT_texture_video:{supportLevel:"none",comment:"Video textures are not created automatically by the stock pipeline."},MSFT_lod:{supportLevel:"none",comment:"Level-of-detail switching is not implemented in the stock scenegraph loader."}};function x4(t){let r=Array.from(Ace(t)).sort().map(o=>{let n=y4[o]||bce;return[o,{extensionName:o,supported:n.supportLevel==="built-in"||n.supportLevel==="parsed-and-wired",supportLevel:n.supportLevel,comment:n.comment}]});return new Map(r)}function LC(t){return y4[t]||null}function Ace(t){let e=t,r=new Set;return py(r,t.extensionsUsed),py(r,t.extensionsRequired),py(r,e.extensionsRemoved),py(r,Object.keys(t.extensions||{})),(e.lights?.length||(t.nodes||[]).some(o=>"light"in o))&&r.add("KHR_lights_punctual"),(t.materials||[]).some(o=>{let n=o;return n.unlit||n.extensions?.KHR_materials_unlit})&&r.add("KHR_materials_unlit"),r}function py(t,e=[]){for(let r of e)t.add(r)}var Tce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},vce={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function BC(t){let e=vce[t.componentType],r=Tce[t.type],o=r*t.count,{buffer:n,byteOffset:i=0}=t.bufferView?.data??{};return{typedArray:new e(n,i+(t.byteOffset||0),o),components:r}}function b4(t){let e=t.animations||[],r=new Map,o=new Map;return e.flatMap((n,i)=>{let s=n.name||`Animation-${i}`,a=new Map,c=n.channels.flatMap(({sampler:l,target:f})=>{let u=a.get(l);if(!u){let h=n.samplers[l];if(!h)throw new Error(`Cannot find animation sampler ${l}`);let{input:p,interpolation:m="LINEAR",output:g}=h;u={input:Bce(t.accessors[p],r),interpolation:m,output:Oce(t.accessors[g],o)},a.set(l,u)}let d=Sce(t,f,u);return d?[d]:[]});return c.length?[{name:s,channels:c}]:[]})}function Sce(t,e,r){if(e.path==="pointer")return Cce(t,e,r);let o=A4(e.path);if(!o)return null;let n=t.nodes[e.node??0];if(!n)throw new Error(`Cannot find animation target ${e.node}`);return{type:"node",sampler:r,targetNodeId:n.id,path:o}}function Cce(t,e,r){let o=e.extensions?.KHR_animation_pointer?.pointer;if(typeof o!="string"||!o.startsWith("/"))return P.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;let n=Ice(o);switch(n[0]){case"nodes":return Ece(t,n,r,o);case"materials":return wce(t,n,r,o);default:return ah(o,`top-level target "${n[0]}" has no runtime animation mapping`),null}}function Ece(t,e,r,o){if(e.length!==3)return ah(o,"node pointers must use /nodes/{index}/{translation|rotation|scale|weights}"),null;let n=Number(e[1]),i=t.nodes[n];if(!Number.isInteger(n)||!i)return P.warn(`KHR_animation_pointer target ${o} references a missing node and will be skipped`)(),null;let s=A4(e[2]);return s?s==="weights"?(P.warn(`KHR_animation_pointer target ${o} will be skipped because morph weights are not implemented in GLTFAnimator`)(),null):{type:"node",sampler:r,targetNodeId:i.id,path:s}:(ah(o,`node property "${e[2]}" has no runtime animation mapping`),null)}function wce(t,e,r,o){if(e.length<3)return ah(o,"material pointers must include a material index and target property path"),null;let n=Number(e[1]),i=t.materials[n];if(!Number.isInteger(n)||!i)return P.warn(`KHR_animation_pointer target ${o} references a missing material and will be skipped`)(),null;let s=Pce(i,e.slice(2));return"reason"in s?(ah(o,s.reason),null):{sampler:r,pointer:o,targetMaterialIndex:n,...s}}function A4(t){switch(t){case"translation":case"rotation":case"scale":case"weights":return t;default:return null}}function Pce(t,e){let r=Mce(t,e);if(!("reason"in r)||r.reason!=="not-a-texture-transform-target")return r;switch(e.join("/")){case"pbrMetallicRoughness/baseColorFactor":return t.pbrMetallicRoughness?{type:"material",property:"baseColorFactor"}:{reason:De(e)};case"pbrMetallicRoughness/metallicFactor":return t.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:De(e)};case"pbrMetallicRoughness/roughnessFactor":return t.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:De(e)};case"normalTexture/scale":return t.normalTexture?{type:"material",property:"normalScale"}:{reason:De(e)};case"occlusionTexture/strength":return t.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:De(e)};case"emissiveFactor":return{type:"material",property:"emissiveFactor"};case"alphaCutoff":return{type:"material",property:"alphaCutoff"};case"extensions/KHR_materials_specular/specularFactor":return t.extensions?.KHR_materials_specular?{type:"material",property:"specularIntensityFactor"}:{reason:De(e)};case"extensions/KHR_materials_specular/specularColorFactor":return t.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:De(e)};case"extensions/KHR_materials_ior/ior":return t.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:De(e)};case"extensions/KHR_materials_transmission/transmissionFactor":return t.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:De(e)};case"extensions/KHR_materials_volume/thicknessFactor":return t.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:De(e)};case"extensions/KHR_materials_volume/attenuationDistance":return t.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:De(e)};case"extensions/KHR_materials_volume/attenuationColor":return t.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:De(e)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return t.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:De(e)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return t.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:De(e)};case"extensions/KHR_materials_sheen/sheenColorFactor":return t.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:De(e)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return t.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceIor":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:De(e)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:De(e)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return t.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:De(e)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return t.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:De(e)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return t.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:De(e)};default:return{reason:De(e)}}}function Mce(t,e){let r=e.lastIndexOf("extensions");if(r<0||e[r+1]!=="KHR_texture_transform"||r<1)return{reason:"not-a-texture-transform-target"};let o=s4(e.slice(0,r));if(!o)return{reason:Lce(e.slice(0,r))};let n=Rce(t,o.pathSegments);if(!n)return{reason:`texture-transform target "${e.slice(0,r).join("/")}" does not exist on the referenced material`};let i=e[r+2];if(i==="texCoord")return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if(i!=="offset"&&i!=="rotation"&&i!=="scale")return{reason:`KHR_texture_transform property "${i}" is not animatable; supported properties are offset, rotation, and scale`};let s=e[r+3];if(e.length>r+4)return{reason:`KHR_texture_transform.${i} does not support nested property paths`};let a;if(s!==void 0){if(a=Number(s),i==="rotation")return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(a)||a<0||a>1)return{reason:`KHR_texture_transform.${i} component index "${s}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:o.slot,path:i,component:a,baseTransform:dy(n)}}function Rce(t,e){let r=t;for(let o of e)if(r=r?.[o],!r)return null;return r}function Ice(t){return t.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}function De(t){let e=T4(t);if(e){let r=LC(e);if(r?.supportLevel==="none")return`${e} is referenced by this pointer, but ${r.comment.charAt(0).toLowerCase()}${r.comment.slice(1)}`}return`no runtime target exists for material property "${t.join("/")}"`}function Lce(t){let e=T4(t);if(e){let r=LC(e);if(r?.supportLevel==="none")return`${e} is referenced by this pointer, but ${r.comment.charAt(0).toLowerCase()}${r.comment.slice(1)}`}return`texture-transform target "${t.join("/")}" has no runtime texture-slot mapping`}function T4(t){let e=t.indexOf("extensions"),r=t[e+1];return e>=0&&r?r:null}function ah(t,e){P.warn(`KHR_animation_pointer target ${t} will be skipped because ${e}`)()}function Bce(t,e){if(e.has(t))return e.get(t);let{typedArray:r,components:o}=BC(t);v4(o===1,"accessorToJsArray1D must have exactly 1 component");let n=Array.from(r);return e.set(t,n),n}function Oce(t,e){if(e.has(t))return e.get(t);let{typedArray:r,components:o}=BC(t);v4(o>=1,"accessorToJsArray2D must have at least 1 component");let n=[];for(let i=0;i<r.length;i+=o)n.push(Array.from(r.slice(i,i+o)));return e.set(t,n),n}function v4(t,e){if(!t)throw new Error(e)}function OC(t,e,r){let{scenes:o,materials:n,gltfMeshIdToNodeMap:i,gltfNodeIdToNodeMap:s,gltfNodeIndexToNodeMap:a}=g4(t,e,r),c=b4(e),l=new hy({animations:c,gltfNodeIdToNodeMap:s,materials:n}),f=f4(e,{useByteColors:r?.useByteColors??!0}),u=x4(e),d=o.map(p=>S4(p.getBounds())),h=Fce(d);return{scenes:o,materials:n,animator:l,lights:f,extensionSupport:u,sceneBounds:d,modelBounds:h,gltfMeshIdToNodeMap:i,gltfNodeIdToNodeMap:s,gltfNodeIndexToNodeMap:a,gltf:e}}function S4(t){if(!t)return{bounds:null,center:[0,0,0],size:[0,0,0],radius:.5,recommendedOrbitDistance:1};let e=[[t[0][0],t[0][1],t[0][2]],[t[1][0],t[1][1],t[1][2]]],r=[e[1][0]-e[0][0],e[1][1]-e[0][1],e[1][2]-e[0][2]],o=[e[0][0]+r[0]*.5,e[0][1]+r[1]*.5,e[0][2]+r[2]*.5],n=Math.max(r[0],r[1],r[2])*.5,i=Math.max(.5*Math.hypot(r[0],r[1],r[2]),.001);return{bounds:e,center:o,size:r,radius:i,recommendedOrbitDistance:Math.max(Math.max(n,.001)/Math.tan(Math.PI/6)*1.15,i*1.1)}}function Fce(t){let e=null;for(let r of t)if(r.bounds){if(!e){e=[[...r.bounds[0]],[...r.bounds[1]]];continue}for(let o=0;o<3;o++)e[0][o]=Math.min(e[0][o],r.bounds[0][o]),e[1][o]=Math.max(e[1][o],r.bounds[1][o])}return S4(e)}var FC={};ze(FC,{createExtMeshFeatures:()=>Jce,decode:()=>Xce,encode:()=>Yce,name:()=>$ce});function ut(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var my={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gy={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var Nce=1.33,C4=["SCALAR","VEC2","VEC3","VEC4"],Dce=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Uce=new Map(Dce),kce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vce={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},zce={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function _y(t){return C4[t-1]||C4[0]}function Ri(t){let e=Uce.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function Yc(t,e){let r=zce[t.componentType],o=kce[t.type],n=Vce[t.componentType],i=t.count*o,s=t.count*o*n;ut(s>=0&&s<=e.byteLength);let a=gy[t.componentType],c=my[t.type];return{ArrayType:r,length:i,byteLength:s,componentByteSize:a,numberOfComponentsInElement:c}}function ch(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let o=e.map(s=>s.bufferView);r=r.filter(s=>!o.includes(s));let n=r.reduce((s,a)=>s+a.byteLength,0),i=e.reduce((s,a)=>{let{width:c,height:l}=a.image;return s+c*l},0);return n+Math.ceil(4*i*Nce)}function E4(t,e,r){let o=t.bufferViews[r];ut(o);let n=o.buffer,i=e[n];ut(i);let s=(o.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,o.byteLength)}function w4(t,e,r){let o=typeof r=="number"?t.accessors?.[r]:r;if(!o)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let n=t.bufferViews?.[o.bufferView||0];if(!n)throw new Error(`No gltf buffer view for accessor ${n}`);let{arrayBuffer:i,byteOffset:s}=e[n.buffer],a=(s||0)+(o.byteOffset||0)+(n.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=Yc(o,n),d=f*u,h=n.byteStride||d;if(typeof n.byteStride>"u"||n.byteStride===d)return new c(i,a,l);let p=new c(l);for(let m=0;m<o.count;m++){let g=new c(i,a+m*h,u);p.set(g,m*u)}return p}function Hce(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var ye=class{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||Hce(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){let r=this.getUsedExtensions().find(n=>n===e),o=this.getRequiredExtensions().find(n=>n===e);return typeof r=="string"||typeof o=="string"}getExtension(e){let r=this.getUsedExtensions().find(n=>n===e),o=this.json.extensions||{};return r?o[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(o=>o===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let o=this.json[e]&&this.json[e][r];if(!o)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return o}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,o=this.gltf.buffers[r];ut(o);let n=(e.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return w4(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),n=this.getBuffer(r.buffer).data,i=r.byteOffset||0;return new Uint8Array(n,i,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,o){return e.extensions=e.extensions||{},e.extensions[r]=o,this.registerUsedExtension(r),this}setObjectExtension(e,r,o){let n=e.extensions||{};n[r]=o}removeObjectExtension(e,r){let o=e?.extensions||{};if(o[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let n=this.json.extensionsRemoved;n.includes(r)||n.push(r)}delete o[r]}addExtension(e,r={}){return ut(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return ut(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:o}=e;this.json.nodes=this.json.nodes||[];let n={mesh:r};return o&&(n.matrix=o),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:o,material:n,mode:i=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:i}]};if(o){let c=this._addIndices(o);a.primitives[0].indices=c}return Number.isFinite(n)&&(a.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let o={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addImage(e,r){let o=qi(e),n=r||o?.mimeType,s={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(s),this.json.images.length-1}addBufferView(e,r=0,o=this.byteLength){let n=e.byteLength;ut(Number.isFinite(n)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let i={buffer:r,byteOffset:o,byteLength:n};return this.byteLength+=Wn(n,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,r){let o={bufferView:e,type:_y(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(o),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let o=this.addBufferView(e),n={min:r.min,max:r.max};(!n.min||!n.max)&&(n=this._getAccessorMinMax(e,r.size));let i={size:r.size,componentType:Ri(e),count:Math.round(e.length/r.size),min:n.min,max:n.max};return this.addAccessor(o,Object.assign(i,r))}addTexture(e){let{imageIndex:r}=e,o={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(o),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){let e=this.byteLength,r=new ArrayBuffer(e),o=new Uint8Array(r),n=0;for(let i of this.sourceBuffers||[])n=jb(i,o,n);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r],this.gltf.buffers=[{arrayBuffer:r,byteOffset:0,byteLength:r.byteLength}]}_removeStringFromArray(e,r){let o=!0;for(;o;){let n=e.indexOf(r);n>-1?e.splice(n,1):o=!1}}_addAttributes(e={}){let r={};for(let o in e){let n=e[o],i=this._getGltfAttributeName(o),s=this.addBinaryBuffer(n.value,n);r[i]=s}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let o={min:null,max:null};if(e.length<r)return o;o.min=[],o.max=[];let n=e.subarray(0,r);for(let i of n)o.min.push(i),o.max.push(i);for(let i=r;i<e.length;i+=r)for(let s=0;s<r;s++)o.min[0+s]=Math.min(o.min[0+s],e[i+s]),o.max[0+s]=Math.max(o.max[0+s],e[i+s]);return o}};function P4(t){return(t%1+1)%1}var M4={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},jce={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},R4={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function lh(t,e){return R4[e]*M4[t]}function Kc(t,e,r,o){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let n=t.getTypedArrayForBufferView(e),i=qc(n,"SCALAR",r,o+1);return i instanceof BigInt64Array||i instanceof BigUint64Array?null:i}function qc(t,e,r,o=1){let n=M4[e],i=jce[r],s=R4[r],a=o*n,c=a*s,l=t.buffer,f=t.byteOffset;return f%s!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new i(Ar(l),f,a)}function Zc(t,e,r){let o=`TEXCOORD_${e.texCoord||0}`,n=r.attributes[o],i=t.getTypedArrayForAccessor(n),s=t.gltf.json,a=e.index,c=s.textures?.[a]?.source;if(typeof c<"u"){let l=s.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){let u=[];for(let d=0;d<i.length;d+=2){let h=Wce(f,l,i,d,e.channels);u.push(h)}return u}}return[]}function yy(t,e,r,o,n){if(!r?.length)return;let i=[];for(let f of r){let u=o.findIndex(d=>d===f);u===-1&&(u=o.push(f)-1),i.push(u)}let s=new Uint32Array(i),a=t.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,c=t.addBufferView(s,a,0),l=t.addAccessor(c,{size:1,componentType:Ri(s),count:s.length});n.attributes[e]=l}function Wce(t,e,r,o,n=[0]){let i={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=r[o],a=r[o+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=Gce(s,a,t,c),f=0;for(let u of n){let d=typeof u=="number"?Object.values(i)[u]:i[u],h=l+d.offset,p=nf(t);if(p.data.length<=h)throw new Error(`${p.data.length} <= ${h}`);let m=p.data[h];f|=m<<d.shift}return f}function Gce(t,e,r,o=1){let n=r.width,i=P4(t)*(n-1),s=Math.round(i),a=r.height,c=P4(e)*(a-1),l=Math.round(c),f=r.components?r.components:o;return(l*n+s)*f}function xy(t,e,r,o,n){let i=[];for(let s=0;s<e;s++){let a=r[s],c=r[s+1]-r[s];if(c+a>o)break;let l=a/n,f=c/n;i.push(t.slice(l,l+f))}return i}function by(t,e,r){let o=[];for(let n=0;n<e;n++){let i=n*r;o.push(t.slice(i,i+r))}return o}function Ay(t,e,r,o){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(o){let n=[],i=new TextDecoder("utf8"),s=0;for(let a=0;a<t;a++){let c=o[a+1]-o[a];if(c+s<=e.length){let l=e.subarray(s,c+s),f=i.decode(l);n.push(f),s+=c}}return n}return[]}var Jc="EXT_mesh_features",$ce=Jc;async function Xce(t,e){let r=new ye(t);Kce(r,e)}function Yce(t,e){let r=new ye(t);return Zce(r,e),r.createBinaryChunk(),r.gltf}function Kce(t,e){let r=t.gltf.json;if(r.meshes)for(let o of r.meshes)for(let n of o.primitives)qce(t,n,e)}function qce(t,e,r){if(!r?.gltf?.loadBuffers)return;let n=e.extensions?.[Jc]?.featureIds;if(n)for(let i of n){let s;if(typeof i.attribute<"u"){let a=`_FEATURE_ID_${i.attribute}`,c=e.attributes[a];s=t.getTypedArrayForAccessor(c)}else typeof i.texture<"u"&&r?.gltf?.loadImages?s=Zc(t,i.texture,e):s=[];i.data=s}}function Zce(t,e){let r=t.gltf.json.meshes;if(r)for(let o of r)for(let n of o.primitives)Qce(t,n)}function Jce(t,e,r,o){e.extensions||(e.extensions={});let n=e.extensions[Jc];n||(n={featureIds:[]},e.extensions[Jc]=n);let{featureIds:i}=n,s={featureCount:r.length,propertyTable:o,data:r};i.push(s),t.addObjectExtension(e,Jc,n)}function Qce(t,e){let r=e.extensions?.[Jc];if(!r)return;let o=r.featureIds;o.forEach((n,i)=>{if(n.data){let{accessorKey:s,index:a}=ele(e.attributes),c=new Uint32Array(n.data);o[i]={featureCount:c.length,propertyTable:n.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});let l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:Ri(c),count:c.length});e.attributes[s]=f}})}function ele(t){let e="_FEATURE_ID_",r=Object.keys(t).filter(i=>i.indexOf(e)===0),o=-1;for(let i of r){let s=Number(i.substring(e.length));s>o&&(o=s)}return o++,{accessorKey:`${e}${o}`,index:o}}var UC={};ze(UC,{createExtStructuralMetadata:()=>Tle,decode:()=>rle,encode:()=>ole,name:()=>tle});var Qc="EXT_structural_metadata",tle=Qc;async function rle(t,e){let r=new ye(t);nle(r,e)}function ole(t,e){let r=new ye(t);return ble(r,e),r.createBinaryChunk(),r.gltf}function nle(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(Qc);r&&(e.gltf?.loadImages&&ile(t,r),sle(t,r))}function ile(t,e){let r=e.propertyTextures,o=t.gltf.json;if(r&&o.meshes)for(let n of o.meshes)for(let i of n.primitives)cle(t,r,i,e)}function sle(t,e){let r=e.schema;if(!r)return;let o=r.classes,n=e.propertyTables;if(o&&n)for(let i in o){let s=ale(n,i);s&&fle(t,r,s)}}function ale(t,e){for(let r of t)if(r.class===e)return r;return null}function cle(t,e,r,o){if(!e)return;let i=r.extensions?.[Qc]?.propertyTextures;if(i)for(let s of i){let a=e[s];lle(t,a,r,o)}}function lle(t,e,r,o){if(!e.properties)return;o.dataAttributeNames||(o.dataAttributeNames=[]);let n=e.class;for(let i in e.properties){let s=`${n}_${i}`,a=e.properties?.[i];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=Zc(t,a,r);l!==null&&(yy(t,s,l,c,r),a.data=c,o.dataAttributeNames.push(s))}}function fle(t,e,r){let o=e.classes?.[r.class];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let n=r.count;for(let i in o.properties){let s=o.properties[i],a=r.properties?.[i];if(a){let c=ule(t,e,s,n,a);a.data=c}}}function ule(t,e,r,o,n){let i=[],s=n.values,a=t.getTypedArrayForBufferView(s),c=dle(t,r,n,o),l=hle(t,n,o);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{i=ple(r,o,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{i=Ay(o,a,c,l);break}case"ENUM":{i=mle(e,r,o,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return i}function dle(t,e,r,o){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?Kc(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",o):null}function hle(t,e,r){return typeof e.stringOffsets<"u"?Kc(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function ple(t,e,r,o){let n=t.array,i=t.count,s=lh(t.type,t.componentType),a=r.byteLength/s,c;return t.componentType?c=qc(r,t.type,t.componentType,a):c=r,n?o?xy(c,e,o,r.length,s):i?by(c,e,i):[]:c}function mle(t,e,r,o,n){let i=e.enumType;if(!i)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let s=t.enums?.[i];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${i}`);let a=s.valueType||"UINT16",c=lh(e.type,a),l=o.byteLength/c,f=qc(o,e.type,a,l);if(f||(f=o),e.array){if(n)return gle({valuesData:f,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:o.length,elementSize:c,enumEntry:s});let u=e.count;return u?_le(f,r,u,s):[]}return DC(f,0,r,s)}function gle(t){let{valuesData:e,numberOfElements:r,arrayOffsets:o,valuesDataBytesLength:n,elementSize:i,enumEntry:s}=t,a=[];for(let c=0;c<r;c++){let l=o[c],f=o[c+1]-o[c];if(f+l>n)break;let u=l/i,d=f/i,h=DC(e,u,d,s);a.push(h)}return a}function _le(t,e,r,o){let n=[];for(let i=0;i<e;i++){let s=r*i,a=DC(t,s,r,o);n.push(a)}return n}function DC(t,e,r,o){let n=[];for(let i=0;i<r;i++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)n.push("");else{let s=t[e+i],a=yle(o,s);a?n.push(a.name):n.push("")}return n}function yle(t,e){for(let r of t.values)if(r.value===e)return r;return null}var xle="schemaClassId";function ble(t,e){let r=t.getExtension(Qc);if(r&&r.propertyTables)for(let o of r.propertyTables){let n=o.class,i=r.schema?.classes?.[n];o.properties&&i&&Ale(o,i,t)}}function Ale(t,e,r){for(let o in t.properties){let n=t.properties[o].data;if(n){let i=e.properties[o];if(i){let s=Cle(n,i,r);t.properties[o]=s}}}}function Tle(t,e,r=xle){let o=t.getExtension(Qc);o||(o=t.addExtension(Qc)),o.schema=vle(e,r,o.schema);let n=Sle(e,r,o.schema);return o.propertyTables||(o.propertyTables=[]),o.propertyTables.push(n)-1}function vle(t,e,r){let o=r??{id:"schema_id"},n={properties:{}};for(let i of t){let s={type:i.elementType,componentType:i.componentType};n.properties[i.name]=s}return o.classes={},o.classes[e]=n,o}function Sle(t,e,r){let o={class:e,count:0},n=0,i=r.classes?.[e];for(let s of t){if(n===0&&(n=s.values.length),n!==s.values.length&&s.values.length)throw new Error("Illegal values in attributes");i?.properties[s.name]&&(o.properties||(o.properties={}),o.properties[s.name]={values:0,data:s.values})}return o.count=n,o}function Cle(t,e,r){let o={values:0};if(e.type==="STRING"){let{stringData:n,stringOffsets:i}=Ple(t);o.stringOffsets=NC(i,r),o.values=NC(n,r)}else if(e.type==="SCALAR"&&e.componentType){let n=wle(t,e.componentType);o.values=NC(n,r)}return o}var Ele={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function wle(t,e){let r=[];for(let n of t)r.push(Number(n));let o=Ele[e];if(!o)throw new Error("Illegal component type");return new o(r)}function Ple(t){let e=new TextEncoder,r=[],o=0;for(let c of t){let l=e.encode(c);o+=l.length,r.push(l)}let n=new Uint8Array(o),i=[],s=0;for(let c of r)n.set(c,s),i.push(s),s+=c.length;i.push(s);let a=new Uint32Array(i);return{stringData:n,stringOffsets:a}}function NC(t,e){return e.gltf.buffers.push({arrayBuffer:Ar(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}var kC={};ze(kC,{decode:()=>Rle,name:()=>Mle});var I4="EXT_feature_metadata",Mle=I4;async function Rle(t,e){let r=new ye(t);Ile(r,e)}function Ile(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(I4);r&&(e.gltf?.loadImages&&Lle(t,r),Ble(t,r))}function Lle(t,e){let r=e.schema;if(!r)return;let o=r.classes,{featureTextures:n}=e;if(o&&n)for(let i in o){let s=o[i],a=Fle(n,i);a&&Dle(t,a,s)}}function Ble(t,e){let r=e.schema;if(!r)return;let o=r.classes,n=e.featureTables;if(o&&n)for(let i in o){let s=Ole(n,i);s&&Nle(t,r,s)}}function Ole(t,e){for(let r in t){let o=t[r];if(o.class===e)return o}return null}function Fle(t,e){for(let r in t){let o=t[r];if(o.class===e)return o}return null}function Nle(t,e,r){if(!r.class)return;let o=e.classes?.[r.class];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let n=r.count;for(let i in o.properties){let s=o.properties[i],a=r.properties?.[i];if(a){let c=Ule(t,e,s,n,a);a.data=c}}}function Dle(t,e,r){let o=e.class;for(let n in r.properties){let i=e?.properties?.[n];if(i){let s=jle(t,i,o);i.data=s}}}function Ule(t,e,r,o,n){let i=[],s=n.bufferView,a=t.getTypedArrayForBufferView(s),c=kle(t,r,n,o),l=Vle(t,r,n,o);return r.type==="STRING"||r.componentType==="STRING"?i=Ay(o,a,c,l):zle(r)&&(i=Hle(r,o,a,c)),i}function kle(t,e,r,o){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Kc(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",o):null}function Vle(t,e,r,o){return typeof r.stringOffsetBufferView<"u"?Kc(t,r.stringOffsetBufferView,r.offsetType||"UINT32",o):null}function zle(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function Hle(t,e,r,o){let n=t.type==="ARRAY",i=t.componentCount,s="SCALAR",a=t.componentType||t.type,c=lh(s,a),l=r.byteLength/c,f=qc(r,s,a,l);return n?o?xy(f,e,o,r.length,c):i?by(f,e,i):[]:f}function jle(t,e,r){let o=t.gltf.json;if(!o.meshes)return[];let n=[];for(let i of o.meshes)for(let s of i.primitives)Wle(t,r,e,n,s);return n}function Wle(t,e,r,o,n){let i={channels:r.channels,...r.texture},s=Zc(t,i,n);s&&yy(t,e,s,o,n)}var L4="4.4.3";var B4="4.4.3";var Ty={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},O4;async function zC(t){zp(t.modules);let e=Ib("basis");return e||(O4||=Gle(t),await O4)}async function Gle(t){let e=null,r=null;return[e,r]=await Promise.all([await br(Ty.TRANSCODER,"textures",t),await br(Ty.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await $le(e,r)}function $le(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t(r).then(n=>{let{BasisFile:i,initializeBasis:s}=n;s(),o({BasisFile:i})})})}var VC;async function HC(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(VC=VC||Xle(t),await VC)}async function Xle(t){let e=null,r=null;return[e,r]=await Promise.all([await br(Ty.ENCODER,"textures",t),await br(Ty.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await Yle(e,r)}function Yle(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t(r).then(n=>{let{BasisFile:i,KTX2File:s,initializeBasis:a,BasisEncoder:c}=n;a(),o({BasisFile:i,KTX2File:s,BasisEncoder:c})})})}var Kle=["","WEBKIT_","MOZ_"],F4={WEBGL_compressed_texture_s3tc:["bc1-rgb-unorm-webgl","bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"],WEBGL_compressed_texture_s3tc_srgb:["bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"],EXT_texture_compression_rgtc:["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"],EXT_texture_compression_bptc:["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"],WEBGL_compressed_texture_etc1:["etc1-rgb-unorm-webgl"],WEBGL_compressed_texture_etc:["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"],WEBGL_compressed_texture_pvrtc:["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"],WEBGL_compressed_texture_atc:["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"],WEBGL_compressed_texture_astc:["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]};var vy=null;function N4(t){if(!vy){t=t||qle()||void 0,vy=new Set;for(let e of Kle)for(let r in F4)if(t&&t.getExtension(`${e}${r}`))for(let o of F4[r])vy.add(o)}return vy}function qle(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var xr=[171,75,84,88,32,50,48,187,13,10,26,10];function D4(t){let e=new Uint8Array(t);return!(e.byteLength<xr.length||e[0]!==xr[0]||e[1]!==xr[1]||e[2]!==xr[2]||e[3]!==xr[3]||e[4]!==xr[4]||e[5]!==xr[5]||e[6]!==xr[6]||e[7]!==xr[7]||e[8]!==xr[8]||e[9]!==xr[9]||e[10]!==xr[10]||e[11]!==xr[11])}var U4=Promise.resolve(),z4={etc1:{basisFormat:0,compressed:!0,format:36196,textureFormat:"etc1-rgb-unorm-webgl"},etc2:{basisFormat:1,compressed:!0,format:37493,textureFormat:"etc2-rgba8unorm"},bc1:{basisFormat:2,compressed:!0,format:33776,textureFormat:"bc1-rgb-unorm-webgl"},bc3:{basisFormat:3,compressed:!0,format:33779,textureFormat:"bc3-rgba-unorm"},bc4:{basisFormat:4,compressed:!0,format:36283,textureFormat:"bc4-r-unorm"},bc5:{basisFormat:5,compressed:!0,format:36285,textureFormat:"bc5-rg-unorm"},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"bc7-m5":{basisFormat:7,compressed:!0,format:36492,textureFormat:"bc7-rgba-unorm"},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840,textureFormat:"pvrtc-rgb4unorm-webgl"},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842,textureFormat:"pvrtc-rgba4unorm-webgl"},"astc-4x4":{basisFormat:10,compressed:!0,format:37808,textureFormat:"astc-4x4-unorm"},"atc-rgb":{basisFormat:11,compressed:!0,format:35986,textureFormat:"atc-rgb-unorm-webgl"},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0,format:34798,textureFormat:"atc-rgbai-unorm-webgl"},rgba32:{basisFormat:13,compressed:!1,format:32856,textureFormat:"rgba8unorm"},rgb565:{basisFormat:14,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},bgr565:{basisFormat:15,compressed:!1,format:36194,textureFormat:"rgb565unorm-webgl"},rgba4444:{basisFormat:16,compressed:!1,format:32854,textureFormat:"rgba4unorm-webgl"}},YKe=Object.freeze(Object.keys(z4));async function Qle(t){let e=U4,r;U4=new Promise(o=>{r=o}),await e;try{return await t()}finally{r()}}async function H4(t,e={}){let r=Kl(e);return await Qle(async()=>{if(!e.basis?.containerFormat||e.basis.containerFormat==="auto"){if(D4(t)){let n=await HC(r);return k4(n.KTX2File,t,e)}let{BasisFile:o}=await zC(r);return jC(o,t,e)}switch(e.basis.module){case"encoder":let o=await HC(r);switch(e.basis.containerFormat){case"ktx2":return k4(o.KTX2File,t,e);case"basis":default:return jC(o.BasisFile,t,e)}case"transcoder":default:let{BasisFile:n}=await zC(r);return jC(n,t,e)}})}function jC(t,e,r){let o=new t(new Uint8Array(e));try{if(!o.startTranscoding())throw new Error("Failed to start basis transcoding");let n=o.getNumImages(),i=[];for(let s=0;s<n;s++){let a=o.getNumLevels(s),c=[];for(let l=0;l<a;l++)c.push(efe(o,s,l,r));i.push(c)}return i}finally{o.close(),o.delete()}}function efe(t,e,r,o){let n=t.getImageWidth(e,r),i=t.getImageHeight(e,r),s=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l,textureFormat:f}=j4(o,s),u=t.getImageTranscodedSizeInBytes(e,r,l),d=new Uint8Array(u);if(!t.transcodeImage(d,e,r,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:n,height:i,data:d,compressed:a,...c!==void 0?{format:c}:{},...f!==void 0?{textureFormat:f}:{},hasAlpha:s}}function k4(t,e,r){let o=new t(new Uint8Array(e));try{if(!o.startTranscoding())throw new Error("failed to start KTX2 transcoding");let n=o.getLevels(),i=[];for(let s=0;s<n;s++)i.push(tfe(o,s,r));return[i]}finally{o.close(),o.delete()}}function tfe(t,e,r){let{alphaFlag:o,height:n,width:i}=t.getImageLevelInfo(e,0,0),{compressed:s,format:a,basisFormat:c,textureFormat:l}=j4(r,o),f=t.getImageTranscodedSizeInBytes(e,0,0,c),u=new Uint8Array(f);if(!t.transcodeImage(u,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:i,height:n,data:u,compressed:s,...a!==void 0?{format:a}:{},...l!==void 0?{textureFormat:l}:{},levelSize:f,hasAlpha:o}}function j4(t,e){let r=t.basis?.format||"auto";r==="auto"&&(r=t.basis?.supportedTextureFormats?V4(t.basis.supportedTextureFormats):V4()),typeof r=="object"&&(r=e?r.alpha:r.noAlpha);let o=r.toLowerCase(),n=z4[o];if(!n)throw new Error(`Unknown Basis format ${r}`);return n}function V4(t=N4()){let e=new Set(t);return el(e,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":el(e,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:el(e,["bc1-rgb-unorm-webgl","bc1-rgb-unorm-srgb-webgl","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb"])?{alpha:"bc3",noAlpha:"bc1"}:el(e,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:el(e,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":e.has("etc1-rgb-unorm-webgl")?"etc1":el(e,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function el(t,e){return e.some(r=>t.has(r))}var W4={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:B4,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},WC={...W4,parse:H4};var tl=!0,G4=1735152710,XC=12,Sy=8,rfe=1313821514,ofe=5130562,nfe=0,ife=0,sfe=1;function afe(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function $4(t,e=0,r={}){let o=new DataView(t),{magic:n=G4}=r,i=o.getUint32(e,!1);return i===n||i===G4}function X4(t,e,r=0,o={}){let n=new DataView(e),i=afe(n,r+0),s=n.getUint32(r+4,tl),a=n.getUint32(r+8,tl);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:i,version:s,json:{},binChunks:[]}),r+=XC,t.version){case 1:return cfe(t,n,r);case 2:return lfe(t,n,r,o={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function cfe(t,e,r){le(t.header.byteLength>XC+Sy);let o=e.getUint32(r+0,tl),n=e.getUint32(r+4,tl);return r+=Sy,le(n===nfe),GC(t,e,r,o),r+=o,r+=$C(t,e,r,t.header.byteLength),r}function lfe(t,e,r,o){return le(t.header.byteLength>XC+Sy),ffe(t,e,r,o),r+t.header.byteLength}function ffe(t,e,r,o){for(;r+8<=t.header.byteLength;){let n=e.getUint32(r+0,tl),i=e.getUint32(r+4,tl);switch(r+=Sy,i){case rfe:GC(t,e,r,n);break;case ofe:$C(t,e,r,n);break;case ife:o.strict||GC(t,e,r,n);break;case sfe:o.strict||$C(t,e,r,n);break;default:break}r+=Wn(n,4)}return r}function GC(t,e,r,o){let n=new Uint8Array(e.buffer,r,o),s=new TextDecoder("utf8").decode(n);return t.json=JSON.parse(s),Wn(o,4)}function $C(t,e,r,o){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:o,arrayBuffer:e.buffer}),Wn(o,4)}function YC(t,e,r){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let n=r?.baseUrl||ufe(e?.core?.baseUrl);if(!n)throw new Error(`'baseUrl' must be provided to resolve relative url ${t}`);return n.endsWith("/")?`${n}${t}`:`${n}/${t}`}function ufe(t){if(!t)return;if(t.endsWith("/"))return t;let e=t.lastIndexOf("/");return e>=0?t.slice(0,e+1):""}var qC={};ze(qC,{decode:()=>vfe,name:()=>Tfe});var dfe="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",hfe="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",pfe=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),mfe=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),gfe={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},_fe={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Y4(t,e,r,o,n,i="NONE"){let s=await yfe();Afe(s,s.exports[_fe[n]],t,e,r,o,s.exports[gfe[i||"NONE"]])}var KC;async function yfe(){return KC||(KC=xfe()),KC}async function xfe(){let t=dfe;WebAssembly.validate(pfe)&&(t=hfe,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(bfe(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function bfe(t){let e=new Uint8Array(t.length);for(let o=0;o<t.length;++o){let n=t.charCodeAt(o);e[o]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let o=0;o<t.length;++o)e[r++]=e[o]<60?mfe[e[o]]:(e[o]-60)*64+e[++o];return e.buffer.slice(0,r)}function Afe(t,e,r,o,n,i,s){let a=t.exports.sbrk,c=o+3&-4,l=a(c*n),f=a(i.length),u=new Uint8Array(t.exports.memory.buffer);u.set(i,f);let d=e(l,o,n,f,i.length);if(d===0&&s&&s(l,c,n),r.set(u.subarray(l,l+o*n)),a(l-a(0)),d!==0)throw new Error(`Malformed buffer data: ${d}`)}var Cy="EXT_meshopt_compression",Tfe=Cy;async function vfe(t,e){let r=new ye(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;let o=[];for(let n of t.json.bufferViews||[])o.push(Sfe(r,n));await Promise.all(o),r.removeExtension(Cy)}async function Sfe(t,e){let r=t.getObjectExtension(e,Cy);if(r){let{byteOffset:o=0,byteLength:n=0,byteStride:i,count:s,mode:a,filter:c="NONE",buffer:l}=r,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+o,n),d=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await Y4(d,s,i,u,a,c),t.removeObjectExtension(e,Cy)}}var ZC={};ze(ZC,{name:()=>Cfe,preprocess:()=>Efe});var rl="EXT_texture_webp",Cfe=rl;function Efe(t,e){let r=new ye(t);if(!uA("image/webp")){if(r.getRequiredExtensions().includes(rl))throw new Error(`gltf: Required extension ${rl} not supported by browser`);return}let{json:o}=r;for(let n of o.textures||[]){let i=r.getObjectExtension(n,rl);i&&(n.source=i.source),r.removeObjectExtension(n,rl)}r.removeExtension(rl)}var JC={};ze(JC,{name:()=>wfe,preprocess:()=>Pfe});var Ey="KHR_texture_basisu",wfe=Ey;function Pfe(t,e){let r=new ye(t),{json:o}=r;for(let n of o.textures||[]){let i=r.getObjectExtension(n,Ey);i&&(n.source=i.source,r.removeObjectExtension(n,Ey))}r.removeExtension(Ey)}var rE={};ze(rE,{decode:()=>Wfe,encode:()=>Gfe,name:()=>Hfe,preprocess:()=>jfe});var Mfe="1.5.6",Rfe="1.4.1",QC=`https://www.gstatic.com/draco/versioned/decoders/${Mfe}`,gt={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},fh={[gt.DECODER]:`${QC}/${gt.DECODER}`,[gt.DECODER_WASM]:`${QC}/${gt.DECODER_WASM}`,[gt.FALLBACK_DECODER]:`${QC}/${gt.FALLBACK_DECODER}`,[gt.ENCODER]:`https://raw.githubusercontent.com/google/draco/${Rfe}/javascript/${gt.ENCODER}`},eE;async function q4(t={},e){let r=t.modules||{};return r.draco3d?eE||=r.draco3d.createDecoderModule({}).then(o=>({draco:o})):eE||=Ife(t,e),await eE}function K4(t,e){if(t&&typeof t=="object"){if(t.default)return t.default;if(t[e])return t[e]}return t}async function Ife(t,e){let r,o;switch(e){case"js":r=await br(fh[gt.FALLBACK_DECODER],"draco",t,gt.FALLBACK_DECODER);break;case"wasm":default:try{[r,o]=await Promise.all([await br(fh[gt.DECODER],"draco",t,gt.DECODER),await br(fh[gt.DECODER_WASM],"draco",t,gt.DECODER_WASM)])}catch{r=null,o=null}}return r=K4(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule,!r&&!tt&&([r,o]=await Promise.all([await br(fh[gt.DECODER],"draco",{...t,useLocalLibraries:!0},gt.DECODER),await br(fh[gt.DECODER_WASM],"draco",{...t,useLocalLibraries:!0},gt.DECODER_WASM)]),r=K4(r,"DracoDecoderModule"),r=r||globalThis.DracoDecoderModule),await Lfe(r,o)}function Lfe(t,e){if(typeof t!="function")throw new Error("DracoDecoderModule could not be loaded");let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t({...r,onModuleLoaded:n=>o({draco:n})})})}var Z4="4.4.3";function Q4(t,e,r){let o=ek(e.metadata),n=[],i=Bfe(e.attributes);for(let s in t){let a=t[s],c=J4(s,a,i[s]);n.push(c)}if(r){let s=J4("indices",r);n.push(s)}return{fields:n,metadata:o}}function Bfe(t){let e={};for(let r in t){let o=t[r];e[o.name||"undefined"]=o}return e}function J4(t,e,r){let o=r?ek(r.metadata):void 0;return iA(t,e,o)}function ek(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var tk={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Ofe={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},Ffe=4,uh=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let o=new this.draco.DecoderBuffer;o.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let n=this.decoder.GetEncodedGeometryType(o),i=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let s;switch(n){case this.draco.TRIANGULAR_MESH:s=this.decoder.DecodeBufferToMesh(o,i);break;case this.draco.POINT_CLOUD:s=this.decoder.DecodeBufferToPointCloud(o,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!s.ok()||!i.ptr){let d=`DRACO decompression failed: ${s.error_msg()}`;throw new Error(d)}let a=this._getDracoLoaderData(i,n,r),c=this._getMeshData(i,a,r),l=Ki(c.attributes),f=Q4(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:i.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(o),i&&this.draco.destroy(i)}}_getDracoLoaderData(e,r,o){let n=this._getTopLevelMetadata(e),i=this._getDracoAttributes(e,o);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:i}}_getDracoAttributes(e,r){let o={};for(let n=0;n<e.num_attributes();n++){let i=this.decoder.GetAttribute(e,n),s=this._getAttributeMetadata(e,n);o[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:n,metadata:s};let a=this._getQuantizationTransform(i,r);a&&(o[i.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(i,r);c&&(o[i.unique_id()].octahedron_transform=c)}return o}_getMeshData(e,r,o){let n=this._getMeshAttributes(r,e,o);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(o.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(e,r,o){let n={};for(let i of Object.values(e.attributes)){let s=this._deduceAttributeName(i,o);i.name=s;let a=this._getAttributeValues(r,i);if(a){let{value:c,size:l}=a;n[s]={value:c,size:l,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}}return n}_getTriangleListIndices(e){let o=e.num_faces()*3,n=o*Ffe,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,o).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),Ufe(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let o=Ofe[r.data_type];if(!o)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let n=r.num_components,s=e.num_points()*n,a=s*o.BYTES_PER_ELEMENT,c=Nfe(this.draco,o),l,f=this.draco._malloc(a);try{let u=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new o(this.draco.HEAPF32.buffer,f,s).slice()}finally{this.draco._free(f)}return{value:l,size:n}}_deduceAttributeName(e,r){let o=e.unique_id;for(let[s,a]of Object.entries(r.extraAttributes||{}))if(a===o)return s;let n=e.attribute_type;for(let s in tk)if(this.draco[s]===n)return tk[s];let i=r.attributeNameEntry||"name";return e.metadata[i]?e.metadata[i].string:`CUSTOM_ATTRIBUTE_${o}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let o=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(o)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},o=this.metadataQuerier.NumEntries(e);for(let n=0;n<o;n++){let i=this.metadataQuerier.GetEntryName(e,n);r[i]=this._getDracoMetadataField(e,i)}return r}_getDracoMetadataField(e,r){let o=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,o);let n=Dfe(o);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:n}}finally{this.draco.destroy(o)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:o=[]}=e,n=[...r,...o];for(let i of n)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(e,r){let{quantizedAttributes:o=[]}=r,n=e.attribute_type();if(o.map(s=>this.decoder[s]).includes(n)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(e))return{quantization_bits:s.quantization_bits(),range:s.range(),min_values:new Float32Array([1,2,3]).map(a=>s.min_value(a))}}finally{this.draco.destroy(s)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:o=[]}=r,n=e.attribute_type();if(o.map(s=>this.decoder[s]).includes(n)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(e))return{quantization_bits:s.quantization_bits()}}finally{this.draco.destroy(s)}}return null}};function Nfe(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function Dfe(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}function Ufe(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}var rk={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Z4,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},dh={...rk,parse:kfe};async function kfe(t,e){let{draco:r}=await q4(Kl(e),e?.draco?.decoderType||"wasm"),o=new uh(r);try{return o.parseSync(t,e?.draco)}finally{o.destroy()}}function ok(t){let e={};for(let r in t){let o=t[r];if(r!=="indices"){let n=tE(o);e[r]=n}}return e}function tE(t){let{buffer:e,size:r,count:o}=Vfe(t);return{value:e,size:r,byteOffset:0,count:o,type:_y(r),componentType:Ri(e)}}function Vfe(t){let e=t,r=1,o=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=zfe(e,Float32Array)),o=e.length/r),{buffer:e,size:r,count:o}}function zfe(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var Ii="KHR_draco_mesh_compression",Hfe=Ii;function jfe(t,e,r){let o=new ye(t);for(let n of nk(o))o.getObjectExtension(n,Ii)}async function Wfe(t,e,r){if(!e?.gltf?.decompressMeshes)return;let o=new ye(t),n=[];for(let i of nk(o))o.getObjectExtension(i,Ii)&&n.push($fe(o,i,e,r));await Promise.all(n),o.removeExtension(Ii)}function Gfe(t,e={}){let r=new ye(t);for(let o of r.json.meshes||[])Xfe(o,e),r.addRequiredExtension(Ii)}async function $fe(t,e,r,o){let n=t.getObjectExtension(e,Ii);if(!n)return;let i=t.getTypedArrayForBufferView(n.bufferView),s=Gi(i.buffer,i.byteOffset),a={...r};delete a["3d-tiles"];let c=await nr(s,dh,a,o),l=ok(c.attributes);for(let[f,u]of Object.entries(l))if(f in e.attributes){let d=e.attributes[f],h=t.getAccessor(d);h?.min&&h?.max&&(u.min=h.min,u.max=h.max)}e.attributes=l,c.indices&&(e.indices=tE(c.indices)),t.removeObjectExtension(e,Ii),Yfe(e)}function Xfe(t,e,r=4,o,n){if(!o.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let i=o.DracoWriter.encodeSync({attributes:t}),s=n?.parseSync?.({attributes:t}),a=o._addFauxAttributes(s.attributes),c=o.addBufferView(i);return{primitives:[{attributes:a,mode:r,extensions:{[Ii]:{bufferView:c,attributes:a}}}]}}function Yfe(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*nk(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var oE={};ze(oE,{decode:()=>Jfe,name:()=>Kfe});var Py="KHR_texture_transform",Kfe=Py,wy=new E,qfe=new ue,Zfe=new ue;async function Jfe(t,e){if(!new ye(t).hasExtension(Py)||!e.gltf?.loadBuffers)return;let n=t.json.materials||[];for(let i=0;i<n.length;i++)Qfe(i,t)}function Qfe(t,e){let r=e.json.materials?.[t],o=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],n=[];for(let i of o)i&&i?.extensions?.[Py]&&eue(e,t,i,n)}function eue(t,e,r,o){let n=tue(r,o);if(!n)return;let i=t.json.meshes||[];for(let s of i)for(let a of s.primitives){let c=a.material;Number.isFinite(c)&&e===c&&rue(t,a,n)}}function tue(t,e){let r=t.extensions?.[Py],{texCoord:o=0}=t,{texCoord:n=o}=r;if(!(e.findIndex(([s,a])=>s===o&&a===n)!==-1)){let s=iue(r);return o!==n&&(t.texCoord=n),e.push([o,n]),{originalTexCoord:o,texCoord:n,matrix:s}}return null}function rue(t,e,r){let{originalTexCoord:o,texCoord:n,matrix:i}=r,s=e.attributes[`TEXCOORD_${o}`];if(Number.isFinite(s)){let a=t.json.accessors?.[s];if(a&&a.bufferView!==void 0){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:d,length:h}=Yc(a,c),p=gy[a.componentType],m=my[a.type],g=c.byteStride||p*m,_=new Float32Array(h);for(let x=0;x<a.count;x++){let y=new d(l,u+x*g,2);wy.set(y[0],y[1],1),wy.transformByMatrix3(i),_.set([wy[0],wy[1]],x*m)}o===n?oue(a,t,_,a.bufferView):nue(n,a,e,t,_)}}}}function oue(t,e,r,o){t.componentType=5126,t.byteOffset=0;let s=(e.json.accessors||[]).reduce((l,f)=>f.bufferView===o?l+1:l,0)>1;e.buffers.push({arrayBuffer:Ar(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength});let a=e.buffers.length-1;if(e.json.bufferViews=e.json.bufferViews||[],s){e.json.bufferViews.push({buffer:a,byteLength:r.buffer.byteLength,byteOffset:0}),t.bufferView=e.json.bufferViews.length-1;return}let c=e.json.bufferViews[o];c&&(c.buffer=a,c.byteOffset=0,c.byteLength=r.buffer.byteLength,c.byteStride!==void 0&&delete c.byteStride)}function nue(t,e,r,o,n){o.buffers.push({arrayBuffer:Ar(n.buffer),byteOffset:0,byteLength:n.buffer.byteLength}),o.json.bufferViews=o.json.bufferViews||[];let i=o.json.bufferViews;i.push({buffer:o.buffers.length-1,byteLength:n.buffer.byteLength,byteOffset:0});let s=o.json.accessors;s&&(s.push({bufferView:i?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),r.attributes[`TEXCOORD_${t}`]=s.length-1)}function iue(t){let{offset:e=[0,0],rotation:r=0,scale:o=[1,1]}=t,n=new ue().set(1,0,0,0,1,0,e[0],e[1],1),i=qfe.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),s=Zfe.set(o[0],0,0,0,o[1],0,0,0,1);return n.multiplyRight(i).multiplyRight(s)}var nE={};ze(nE,{decode:()=>aue,encode:()=>cue,name:()=>sue});var $s="KHR_lights_punctual",sue=$s;async function aue(t){let e=new ye(t),{json:r}=e,o=e.getExtension($s);o&&(e.json.lights=o.lights,e.removeExtension($s));for(let n of r.nodes||[]){let i=e.getObjectExtension(n,$s);i&&(n.light=i.light),e.removeObjectExtension(n,$s)}}async function cue(t){let e=new ye(t),{json:r}=e;if(r.lights){let o=e.addExtension($s);ut(!o.lights),o.lights=r.lights,delete r.lights}if(e.json.lights){for(let o of e.json.lights){let n=o.node;e.addObjectExtension(n,$s,o)}delete e.json.lights}}var iE={};ze(iE,{decode:()=>fue,encode:()=>uue,name:()=>lue});var hh="KHR_materials_unlit",lue=hh;async function fue(t){let e=new ye(t),{json:r}=e;for(let o of r.materials||[])o.extensions&&o.extensions.KHR_materials_unlit&&(o.unlit=!0),e.removeObjectExtension(o,hh);e.removeExtension(hh)}function uue(t){let e=new ye(t),{json:r}=e;if(e.materials)for(let o of r.materials||[])o.unlit&&(delete o.unlit,e.addObjectExtension(o,hh,{}),e.addExtension(hh))}var sE={};ze(sE,{decode:()=>hue,encode:()=>pue,name:()=>due});var ph="KHR_techniques_webgl",due=ph;async function hue(t){let e=new ye(t),{json:r}=e,o=e.getExtension(ph);if(o){let n=mue(o,e);for(let i of r.materials||[]){let s=e.getObjectExtension(i,ph);s&&(i.technique=Object.assign({},s,n[s.technique]),i.technique.values=gue(i.technique,e)),e.removeObjectExtension(i,ph)}e.removeExtension(ph)}}async function pue(t,e){}function mue(t,e){let{programs:r=[],shaders:o=[],techniques:n=[]}=t,i=new TextDecoder;return o.forEach(s=>{if(Number.isFinite(s.bufferView))s.code=i.decode(e.getTypedArrayForBufferView(s.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(s=>{s.fragmentShader=o[s.fragmentShader],s.vertexShader=o[s.vertexShader]}),n.forEach(s=>{s.program=r[s.program]}),n}function gue(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(o=>{t.uniforms[o].value&&!(o in r)&&(r[o]=t.uniforms[o].value)}),Object.keys(r).forEach(o=>{typeof r[o]=="object"&&r[o].index!==void 0&&(r[o].texture=e.getTexture(r[o].index))}),r}var ik=[UC,FC,qC,ZC,JC,rE,nE,iE,sE,oE,kC];function sk(t,e={},r){let o=ik.filter(n=>ck(n.name,e));for(let n of o)n.preprocess?.(t,e,r)}async function ak(t,e={},r){let o=ik.filter(n=>ck(n.name,e));for(let n of o)await n.decode?.(t,e,r)}function ck(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var aE="KHR_binary_glTF";function lk(t){let e=new ye(t),{json:r}=e;for(let o of r.images||[]){let n=e.getObjectExtension(o,aE);n&&Object.assign(o,n),e.removeObjectExtension(o,aE)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(aE)}var fk={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},yue={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},cE=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let o=e.json;switch(o.asset&&o.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${o.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(o),this._convertTopLevelObjectsToArrays(o),lk(e),this._convertObjectIdsToArrayIndices(o),this._updateObjects(o),this._updateMaterial(o)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in fk)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let o=e[r];if(!(!o||Array.isArray(o))){e[r]=[];for(let n in o){let i=o[n];i.id=i.id||n;let s=e[r].length;e[r].push(i),this.idToIndexMap[r][n]=s}}}_convertObjectIdsToArrayIndices(e){for(let r in fk)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:o,indices:n,material:i}=r;for(let s in o)o[s]=this._convertIdToIndex(o[s],"accessor");n&&(r.indices=this._convertIdToIndex(n,"accessor")),i&&(r.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let o of e[r])for(let n in o){let i=o[n],s=this._convertIdToIndex(i,n);o[n]=s}}_convertIdToIndex(e,r){let o=yue[r];if(o in this.idToIndexMap){let n=this.idToIndexMap[o][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return n}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let o=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,n=e.textures.findIndex(i=>i.id===o);n!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:n})}}};function uk(t,e={}){return new cE().normalize(t,e)}async function dk(t,e,r=0,o,n){return xue(t,e,r,o),uk(t,{normalize:o?.gltf?.normalize}),sk(t,o,n),o?.gltf?.loadBuffers&&t.json.buffers&&await bue(t,o,n),o?.gltf?.loadImages&&await Aue(t,o,n),await ak(t,o,n),t}function xue(t,e,r,o){if(o.core?.baseUrl&&(t.baseUri=o.core?.baseUrl),e instanceof ArrayBuffer&&!$4(e,r,o.glb)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=Vb(e);else if(e instanceof ArrayBuffer){let s={};r=X4(s,e,r,o.glb),ut(s.type==="glTF",`Invalid GLB magic string ${s.type}`),t._glb=s,t.json=s.json}else ut(!1,"GLTF: must be ArrayBuffer or string");let n=t.json.buffers||[];if(t.buffers=new Array(n.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:s}=t._glb;t.buffers[0]={arrayBuffer:s[0].arrayBuffer,byteOffset:s[0].byteOffset,byteLength:s[0].byteLength}}let i=t.json.images||[];t.images=new Array(i.length).fill({})}async function bue(t,e,r){let o=t.json.buffers||[];for(let n=0;n<o.length;++n){let i=o[n];if(i.uri){let{fetch:s}=r;ut(s);let a=YC(i.uri,e,r),l=await(await r?.fetch?.(a))?.arrayBuffer?.();t.buffers[n]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete i.uri}else t.buffers[n]===null&&(t.buffers[n]={arrayBuffer:new ArrayBuffer(i.byteLength),byteOffset:0,byteLength:i.byteLength})}}async function Aue(t,e,r){let o=Tue(t),n=t.json.images||[],i=[];for(let s of o)i.push(vue(t,n[s],s,e,r));return await Promise.all(i)}function Tue(t){let e=new Set,r=t.json.textures||[];for(let o of r)o.source!==void 0&&e.add(o.source);return Array.from(e).sort()}async function vue(t,e,r,o,n){let i;if(e.uri&&!e.hasOwnProperty("bufferView")){let l=YC(e.uri,o,n),{fetch:f}=n;i=await(await f(l)).arrayBuffer(),e.bufferView={data:i}}if(Number.isFinite(e.bufferView)){let l=E4(t.json,t.buffers,e.bufferView);i=Gi(l.buffer,l.byteOffset,l.byteLength)}ut(i,"glTF image has no data");let s=o,a={...s,core:{...s?.core,mimeType:e.mimeType}},c=await nr(i,[qn,WC],a,n);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c[0]}),t.images=t.images||[],t.images[r]=c}var Pn={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:L4,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:Sue,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};async function Sue(t,e={},r){let o={...Pn.options,...e};o.gltf={...Pn.options.gltf,...o.gltf};let n=e?.glb?.byteOffset||0;return await dk({},t,n,o,r)}var Cue={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Eue={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Dr={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},wue={magFilter:Dr.TEXTURE_MAG_FILTER,minFilter:Dr.TEXTURE_MIN_FILTER,wrapS:Dr.TEXTURE_WRAP_S,wrapT:Dr.TEXTURE_WRAP_T},Pue={[Dr.TEXTURE_MAG_FILTER]:Dr.LINEAR,[Dr.TEXTURE_MIN_FILTER]:Dr.NEAREST_MIPMAP_LINEAR,[Dr.TEXTURE_WRAP_S]:Dr.REPEAT,[Dr.TEXTURE_WRAP_T]:Dr.REPEAT};function Mue(){return{id:"default-sampler",parameters:Pue}}function Rue(t){return Eue[t]}function Iue(t){return Cue[t]}var lE=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,r={}){let{json:o,buffers:n=[],images:i=[]}=e,{baseUri:s=""}=e;return ut(o),this.baseUri=s,this.buffers=n,this.images=i,this.jsonUnprocessed=o,this.json=this._resolveTree(e.json,r),this.json}_resolveTree(e,r={}){let o={...e};return this.json=o,e.bufferViews&&(o.bufferViews=e.bufferViews.map((n,i)=>this._resolveBufferView(n,i))),e.images&&(o.images=e.images.map((n,i)=>this._resolveImage(n,i))),e.samplers&&(o.samplers=e.samplers.map((n,i)=>this._resolveSampler(n,i))),e.textures&&(o.textures=e.textures.map((n,i)=>this._resolveTexture(n,i))),e.accessors&&(o.accessors=e.accessors.map((n,i)=>this._resolveAccessor(n,i))),e.materials&&(o.materials=e.materials.map((n,i)=>this._resolveMaterial(n,i))),e.meshes&&(o.meshes=e.meshes.map((n,i)=>this._resolveMesh(n,i))),e.nodes&&(o.nodes=e.nodes.map((n,i)=>this._resolveNode(n,i)),o.nodes=o.nodes.map((n,i)=>this._resolveNodeChildren(n))),e.skins&&(o.skins=e.skins.map((n,i)=>this._resolveSkin(n,i))),e.scenes&&(o.scenes=e.scenes.map((n,i)=>this._resolveScene(n,i))),typeof this.json.scene=="number"&&o.scenes&&(o.scene=o.scenes[this.json.scene]),o}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let o=e&&e[r];return o||console.warn(`glTF file error: Could not find ${e}[${r}]`),o}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(o=>this.getNode(o))}}_resolveNode(e,r){let o={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(o.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(o.camera=this.getCamera(e.camera)),e.skin!==void 0&&(o.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(o.mesh=e.meshes.reduce((n,i)=>{let s=this.getMesh(i);return n.id=s.id,n.primitives=n.primitives.concat(s.primitives),n},{primitives:[]})),o}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let o=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:o}}_resolveMesh(e,r){let o={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(o.primitives=e.primitives.map(n=>{let i={...n,attributes:{},indices:void 0,material:void 0},s=n.attributes;for(let a in s)i.attributes[a]=this.getAccessor(s[a]);return n.indices!==void 0&&(i.indices=this.getAccessor(n.indices)),n.material!==void 0&&(i.material=this.getMaterial(n.material)),i})),o}_resolveMaterial(e,r){let o={...e,id:e.id||`material-${r}`};if(o.normalTexture&&(o.normalTexture={...o.normalTexture},o.normalTexture.texture=this.getTexture(o.normalTexture.index)),o.occlusionTexture&&(o.occlusionTexture={...o.occlusionTexture},o.occlusionTexture.texture=this.getTexture(o.occlusionTexture.index)),o.emissiveTexture&&(o.emissiveTexture={...o.emissiveTexture},o.emissiveTexture.texture=this.getTexture(o.emissiveTexture.index)),o.emissiveFactor||(o.emissiveFactor=o.emissiveTexture?[1,1,1]:[0,0,0]),o.pbrMetallicRoughness){o.pbrMetallicRoughness={...o.pbrMetallicRoughness};let n=o.pbrMetallicRoughness;n.baseColorTexture&&(n.baseColorTexture={...n.baseColorTexture},n.baseColorTexture.texture=this.getTexture(n.baseColorTexture.index)),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture={...n.metallicRoughnessTexture},n.metallicRoughnessTexture.texture=this.getTexture(n.metallicRoughnessTexture.index))}return o}_resolveAccessor(e,r){let o=Rue(e.componentType),n=Iue(e.type),i=o*n,s={...e,id:e.id||`accessor-${r}`,bytesPerComponent:o,components:n,bytesPerElement:i,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(s.bufferView=this.getBufferView(e.bufferView)),s.bufferView){let a=s.bufferView.buffer,{ArrayType:c,byteLength:l}=Yc(s,s.bufferView),f=(s.bufferView.byteOffset||0)+(s.byteOffset||0)+a.byteOffset,u=Ta(a.arrayBuffer,f,l);s.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,s.bufferView.byteStride,s.bytesPerElement,s.count)),s.value=new c(u)}return s}_getValueFromInterleavedBuffer(e,r,o,n,i){let s=new Uint8Array(i*n);for(let a=0;a<i;a++){let c=r+a*o;s.set(new Uint8Array(e.arrayBuffer.slice(c,c+n)),a*n)}return s.buffer}_resolveTexture(e,r){return{...e,id:e.id||`texture-${r}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):Mue(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,r){let o={id:e.id||`sampler-${r}`,...e,parameters:{}};for(let n in o){let i=this._enumSamplerParameter(n);i!==void 0&&(o.parameters[i]=o[n])}return o}_enumSamplerParameter(e){return wue[e]}_resolveImage(e,r){let o={...e,id:e.id||`image-${r}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},n=this.images[r];return n&&(o.image=n),o}_resolveBufferView(e,r){let o=e.buffer,n=this.buffers[o].arrayBuffer,i=this.buffers[o].byteOffset||0;return e.byteOffset&&(i+=e.byteOffset),{id:`bufferView-${r}`,...e,buffer:this.buffers[o],data:new Uint8Array(n,i,e.byteLength)}}_resolveCamera(e,r){let o={...e,id:e.id||`camera-${r}`};return o.perspective,o.orthographic,o}};function Xs(t,e){return new lE().postProcess(t,e)}async function hk(t){let e=[];return t.scenes.forEach(r=>{r.traverse(o=>{})}),await Lue(()=>e.some(r=>!r.loaded))}async function Lue(t){for(;t();)await new Promise(e=>requestAnimationFrame(e))}var pk=`layout(std140) uniform scenegraphUniforms {
float sizeScale;
float sizeMinPixels;
float sizeMaxPixels;
mat4 sceneModelMatrix;
bool composeModelMatrix;
} scenegraph;
`,mk={name:"scenegraph",vs:pk,fs:pk,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}};var gk=`#version 300 es
#define SHADER_NAME scenegraph-layer-vertex-shader
in vec3 instancePositions;
in vec3 instancePositions64Low;
in vec4 instanceColors;
in vec3 instancePickingColors;
in vec3 instanceModelMatrixCol0;
in vec3 instanceModelMatrixCol1;
in vec3 instanceModelMatrixCol2;
in vec3 instanceTranslation;
in vec3 positions;
#ifdef HAS_UV
in vec2 texCoords;
#endif
#ifdef LIGHTING_PBR
#ifdef HAS_NORMALS
in vec3 normals;
#endif
#endif
out vec4 vColor;
#ifndef LIGHTING_PBR
#ifdef HAS_UV
out vec2 vTEXCOORD_0;
#endif
#endif
void main(void) {
#if defined(HAS_UV) && !defined(LIGHTING_PBR)
vTEXCOORD_0 = texCoords;
geometry.uv = texCoords;
#endif
geometry.worldPosition = instancePositions;
geometry.pickingColor = instancePickingColors;
mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
vec3 normal = vec3(0.0, 0.0, 1.0);
#ifdef LIGHTING_PBR
#ifdef HAS_NORMALS
normal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(normals, 0.0)).xyz;
#endif
#endif
float originalSize = project_size_to_pixel(scenegraph.sizeScale);
float clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels);
vec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * (clampedSize / originalSize) + instanceTranslation;
if(scenegraph.composeModelMatrix) {
DECKGL_FILTER_SIZE(pos, geometry);
geometry.normal = project_normal(normal);
geometry.worldPosition += pos;
gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
}
else {
pos = project_size(pos);
DECKGL_FILTER_SIZE(pos, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);
geometry.normal = project_normal(normal);
}
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
#ifdef LIGHTING_PBR
pbr_vPosition = geometry.position.xyz;
#ifdef HAS_NORMALS
pbr_vNormal = geometry.normal;
#endif
#ifdef HAS_UV
pbr_vUV0 = texCoords;
#else
pbr_vUV0 = vec2(0., 0.);
#endif
pbr_vUV1 = vec2(0., 0.);
geometry.uv = pbr_vUV0;
#endif
vColor = instanceColors;
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var _k=`#version 300 es
#define SHADER_NAME scenegraph-layer-fragment-shader
in vec4 vColor;
out vec4 fragColor;
#ifndef LIGHTING_PBR
#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)
in vec2 vTEXCOORD_0;
uniform sampler2D pbr_baseColorSampler;
#endif
#endif
void main(void) {
#ifdef LIGHTING_PBR
fragColor = vColor * pbr_filterColor(vec4(0));
geometry.uv = pbr_vUV0;
#else
#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)
fragColor = vColor * texture(pbr_baseColorSampler, vTEXCOORD_0);
geometry.uv = vTEXCOORD_0;
#else
fragColor = vColor;
#endif
#endif
fragColor.a *= layer.opacity;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var yk=[255,255,255,255],Bue={scenegraph:{type:"object",value:null,async:!0},getScene:t=>t&&t.scenes?typeof t.scene=="object"?t.scene:t.scenes[t.scene||0]:t,getAnimator:t=>t&&t.animator,_animations:null,onFirstDraw:{type:"function",value:()=>{}},sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:yk},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[Pn]},mh=class extends _e{getShaders(){let e={},r;this.props._lighting==="pbr"?(r=Po,e.LIGHTING_PBR=1):r={name:"pbrMaterial"};let o=[fe,Se,mk,r];return super.getShaders({defines:e,vs:gk,fs:_k,modules:o})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:yk,transition:!0},instanceModelMatrix:cy})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e;r.scenegraph!==o.scenegraph?this._updateScenegraph():r._animations!==o._animations&&this._applyAnimationsProp(this.state.animator,r._animations)}finalizeState(e){super.finalizeState(e),this._destroyScenegraphAssets()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){let e=this.props,{device:r}=this.context,o=null;if(e.scenegraph instanceof Rr)o={scenes:[e.scenegraph]};else if(e.scenegraph&&typeof e.scenegraph=="object"){let a=e.scenegraph,c=a.json?Xs(a):a,l=OC(r,c,this._getModelOptions());o=l,hk(l).then(()=>this.setNeedsRedraw()).catch(f=>{this.raiseError(f,"loading glTF")})}let n={layer:this,device:this.context.device},i=e.getScene(o,n),s=e.getAnimator(o,n);if(i instanceof qt){this._destroyScenegraphAssets(),this._applyAnimationsProp(s,e._animations);let a=[];i.traverse(c=>{c instanceof Io&&a.push(c.model)}),this.setState({scenegraph:i,animator:s,materials:o?.materials||null,models:a,firstDrawSignaled:!1}),this.getAttributeManager().invalidateAll()}else i!==null&&N.warn("invalid scenegraph:",i)()}_destroyScenegraphAssets(){this.state.scenegraph?.destroy(),this.state.materials?.forEach(e=>e.destroy()),this.state.scenegraph=null,this.state.animator=null,this.state.materials=null,this.state.models=[]}_applyAnimationsProp(e,r){if(!e||!r)return;let o=e.getAnimations();Object.keys(r).sort().forEach(n=>{let i=r[n];if(n==="*")o.forEach(s=>{Object.assign(s,i)});else if(Number.isFinite(Number(n))){let s=Number(n);s>=0&&s<o.length?Object.assign(o[s],i):N.warn(`animation ${n} not found`)()}else{let s=o.find(({animation:a})=>a.name===n);s?Object.assign(s,i):N.warn(`animation ${n} not found`)()}})}_getModelOptions(){let{_imageBasedLightingEnvironment:e}=this.props,r;return e&&(typeof e=="function"?r=e({gl:this.context.gl,layer:this}):r=e),{imageBasedLightingEnvironment:r,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.setTime(e.timeline.getTime()),this.setNeedsRedraw());let{viewport:r,renderPass:o}=this.context,{sizeScale:n,sizeMinPixels:i,sizeMaxPixels:s,coordinateSystem:a}=this.props,c={camera:r.cameraPosition},l=this.getNumInstances();this.state.scenegraph.traverse((f,{worldMatrix:u})=>{if(f instanceof Io){let{model:d}=f;d.setInstanceCount(l);let h={sizeScale:n,sizeMinPixels:i,sizeMaxPixels:s,composeModelMatrix:ly(r,a),sceneModelMatrix:u};d.shaderInputs.setProps({pbrProjection:c,scenegraph:h}),d.draw(o)}}),this.state.firstDrawSignaled||(this.state.firstDrawSignaled=!0,this.props.onFirstDraw?.())}};mh.defaultProps=Bue;mh.layerName="ScenegraphLayer";var My=mh;var xk=`layout(std140) uniform meshUniforms {
bool pickFeatureIds;
} mesh;
`,bk={name:"mesh",vs:xk,fs:xk,uniformTypes:{pickFeatureIds:"f32"}};var Ak=`#version 300 es
#define SHADER_NAME simple-mesh-layer-vs
in vec3 positions;
in vec3 normals;
in vec3 colors;
in vec2 texCoords;
in vec4 uvRegions;
in vec3 featureIdsPickingColors;
in vec4 instanceColors;
in vec3 instancePickingColors;
in vec3 instanceModelMatrixCol0;
in vec3 instanceModelMatrixCol1;
in vec3 instanceModelMatrixCol2;
out vec2 vTexCoord;
out vec3 cameraPosition;
out vec3 normals_commonspace;
out vec4 position_commonspace;
out vec4 vColor;
vec2 applyUVRegion(vec2 uv) {
#ifdef HAS_UV_REGIONS
return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
#else
return uv;
#endif
}
void main(void) {
vec2 uv = applyUVRegion(texCoords);
geometry.uv = uv;
if (mesh.pickFeatureIds) {
geometry.pickingColor = featureIdsPickingColors;
} else {
geometry.pickingColor = instancePickingColors;
}
mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
vTexCoord = uv;
cameraPosition = project.cameraPosition;
vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale;
vec3 projectedPosition = project_position(positions);
position_commonspace = vec4(projectedPosition, 1.0);
gl_Position = project_common_position_to_clipspace(position_commonspace);
geometry.position = position_commonspace;
normals_commonspace = project_normal(instanceModelMatrix * normals);
geometry.normal = normals_commonspace;
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
#ifdef MODULE_PBRMATERIAL
pbr_vPosition = geometry.position.xyz;
#ifdef HAS_NORMALS
pbr_vNormal = geometry.normal;
#endif
#ifdef HAS_UV
pbr_vUV0 = uv;
#else
pbr_vUV0 = vec2(0., 0.);
#endif
pbr_vUV1 = vec2(0., 0.);
geometry.uv = pbr_vUV0;
#endif
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var Tk=`#version 300 es
#define SHADER_NAME simple-mesh-layer-fs
precision highp float;
uniform sampler2D sampler;
in vec2 vTexCoord;
in vec3 cameraPosition;
in vec3 normals_commonspace;
in vec4 position_commonspace;
in vec4 vColor;
out vec4 fragColor;
void main(void) {
#ifdef MODULE_PBRMATERIAL
fragColor = vColor * pbr_filterColor(vec4(0));
geometry.uv = pbr_vUV0;
fragColor.a *= layer.opacity;
#else
geometry.uv = vTexCoord;
vec3 normal;
if (simpleMesh.flatShading) {
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
} else {
normal = normals_commonspace;
}
vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
fragColor = vec4(lightColor, color.a * layer.opacity);
#endif
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;function Oue(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var Fue={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},gh=class extends Gs{getShaders(){let e=super.getShaders();return e.modules.push(Po,bk),{...e,vs:Ak,fs:Tk}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e;r.pbrMaterial!==o.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props,{model:o}=this.state;if(!o)return;let n={pickFeatureIds:Boolean(r)},i={camera:this.context.viewport.cameraPosition};o.shaderInputs.setProps({pbrProjection:i,mesh:n}),super.draw(e)}getModel(e){let{id:r}=this.props,o=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:o});let n=this.getShaders();return Oue(e.attributes),new Q(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...n.defines,...o?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:o?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:o}=this.props,n=this.parseMaterial(e,o);this.setState({parsedPBRMaterial:n});let{pbr_baseColorSampler:i}=n.bindings,{emptyTexture:s}=this.state,a={sampler:i||s,hasTexture:Boolean(i)},{camera:c,...l}={...n.bindings,...n.uniforms};r.shaderInputs.setProps({simpleMesh:a,pbrMaterial:l})}}parseMaterial(e,r){let o=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return Xc(this.context.device,{unlit:o,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){let r=this.props.featureIds,o=new Uint8ClampedArray(r.length*e.size),n=[];for(let i=0;i<r.length;i++)this.encodePickingColor(r[i],n),o[i*3]=n[0],o[i*3+1]=n[1],o[i*3+2]=n[2];e.value=o}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};gh.layerName="MeshLayer";gh.defaultProps=Fue;var vk=gh;var Mn=6356752314245179e-9,Nue={radii:[6378137,6378137,Mn],radiiSquared:[6378137*6378137,6378137*6378137,Mn*Mn],oneOverRadii:[1/6378137,1/6378137,1/Mn],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(Mn*Mn)],maximumRadius:Math.max(6378137,6378137,Mn),centerToleranceSquared:.1};function Ry(t){return t}var jZe=new E;function Due(t,e=[],r=Ry){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Sk(t,e=[]){return Due(t,e,ve._cartographicRadians?Ry:SA)}function Uue(t,e,r=Ry){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function Ck(t,e){return Uue(t,e,ve._cartographicRadians?Ry:CA)}var Ek=1e-14,kue=new E,wk={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},fE={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},_h={east:new E,north:new E,up:new E,west:new E,south:new E,down:new E},Vue=new E,zue=new E,Hue=new E;function uE(t,e,r,o,n,i){let s=wk[e]&&wk[e][r];ht(s&&(!o||o===s));let a,c,l,f=kue.copy(n);if(Ce(f.x,0,Ek)&&Ce(f.y,0,Ek)){let d=Math.sign(f.z);a=Vue.fromArray(fE[e]),e!=="east"&&e!=="west"&&a.scale(d),c=zue.fromArray(fE[r]),r!=="east"&&r!=="west"&&c.scale(d),l=Hue.fromArray(fE[o]),o!=="east"&&o!=="west"&&l.scale(d)}else{let{up:d,east:h,north:p}=_h;h.set(-f.y,f.x,0).normalize(),t.geodeticSurfaceNormal(f,d),p.copy(d).cross(h);let{down:m,west:g,south:_}=_h;m.copy(d).scale(-1),g.copy(h).scale(-1),_.copy(p).scale(-1),a=_h[e],c=_h[r],l=_h[o]}return i[0]=a.x,i[1]=a.y,i[2]=a.z,i[3]=0,i[4]=c.x,i[5]=c.y,i[6]=c.z,i[7]=0,i[8]=l.x,i[9]=l.y,i[10]=l.z,i[11]=0,i[12]=f.x,i[13]=f.y,i[14]=f.z,i[15]=1,i}var ol=new E,jue=new E,Wue=new E;function Pk(t,e,r=[]){let{oneOverRadii:o,oneOverRadiiSquared:n,centerToleranceSquared:i}=e;ol.from(t);let s=ol.x,a=ol.y,c=ol.z,l=o.x,f=o.y,u=o.z,d=s*s*l*l,h=a*a*f*f,p=c*c*u*u,m=d+h+p,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;let _=jue;if(_.copy(t).scale(g),m<i)return _.to(r);let x=n.x,y=n.y,b=n.z,T=Wue;T.set(_.x*x*2,_.y*y*2,_.z*b*2);let v=(1-g)*ol.len()/(.5*T.len()),w=0,C,S,A,M;do{v-=w,C=1/(1+v*x),S=1/(1+v*y),A=1/(1+v*b);let B=C*C,O=S*S,F=A*A,X=B*C,G=O*S,j=F*A;M=d*B+h*O+p*F-1;let ne=-2*(d*X*x+h*G*y+p*j*b);w=M/ne}while(Math.abs(M)>Cr.EPSILON12);return ol.scale([C,S,A]).to(r)}var Iy=new E,Mk=new E,Xue=new E,fo=new E,Yue=new E,Ly=new E,de=class{constructor(e=0,r=0,o=0){this.centerToleranceSquared=Cr.EPSILON1,ht(e>=0),ht(r>=0),ht(o>=0),this.radii=new E(e,r,o),this.radiiSquared=new E(e*e,r*r,o*o),this.radiiToTheFourth=new E(e*e*e*e,r*r*r*r,o*o*o*o),this.oneOverRadii=new E(e===0?0:1/e,r===0?0:1/r,o===0?0:1/o),this.oneOverRadiiSquared=new E(e===0?0:1/(e*e),r===0?0:1/(r*r),o===0?0:1/(o*o)),this.minimumRadius=Math.min(e,r,o),this.maximumRadius=Math.max(e,r,o),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let o=Mk,n=Xue,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,o),n.copy(this.radiiSquared).scale(o);let s=Math.sqrt(o.dot(n));return n.scale(1/s),o.scale(i),n.add(o),n.to(r)}cartesianToCartographic(e,r=[0,0,0]){Ly.from(e);let o=this.scaleToGeodeticSurface(Ly,fo);if(!o)return;let n=this.geodeticSurfaceNormal(o,Mk),i=Yue;i.copy(Ly).subtract(o);let s=Math.atan2(n.y,n.x),a=Math.asin(n.z),c=Math.sign(Ke.dot(i,Ly))*Ke.length(i);return Ck([s,a,c],r)}eastNorthUpToFixedFrame(e,r=new V){return uE(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,o,n,i=new V){return uE(this,e,r,o,n,i)}geocentricSurfaceNormal(e,r=[0,0,0]){return Iy.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let o=Sk(e),n=o[0],i=o[1],s=Math.cos(i);return Iy.set(s*Math.cos(n),s*Math.sin(n),Math.sin(i)).normalize(),Iy.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Iy.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return Pk(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){fo.from(e);let o=fo.x,n=fo.y,i=fo.z,s=this.oneOverRadiiSquared,a=1/Math.sqrt(o*o*s.x+n*n*s.y+i*i*s.z);return fo.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return fo.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return fo.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,o=[0,0,0]){ht(Ce(this.radii.x,this.radii.y,Cr.EPSILON15)),ht(this.radii.z>0),fo.from(e);let n=fo.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-r))return fo.set(0,0,n).to(o)}};de.WGS84=new de(6378137,6378137,Mn);Xi();var By=class{item;previous;next;constructor(e,r,o){this.item=e,this.previous=r,this.next=o}};var Oy=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new By(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let o=e.next;e.next=r,this.tail===e?this.tail=r:o.previous=r,r.next=o,r.previous=e,++this._length}};var Fy=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Oy,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,o){r._cacheNode||(r._cacheNode=this._list.add(r),o&&o(e,r))}unloadTile(e,r,o){let n=r._cacheNode;n&&(this._list.remove(n),r._cacheNode=null,o&&o(e,r))}unloadTiles(e,r){let o=this._trimTiles;this._trimTiles=!1;let n=this._list,i=e.maximumMemoryUsage*1024*1024,s=this._sentinel,a=n.head;for(;a!==s&&(e.gpuMemoryUsageInBytes>i||o);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function Rk(t,e){le(t),le(e);let{rtcCenter:r,gltfUpAxis:o}=e,{computedTransform:n,boundingVolume:{center:i}}=t,s=new V(n);switch(r&&s.translate(r),o){case"Z":break;case"Y":let d=new V().rotateX(Math.PI/2);s=s.multiplyRight(d);break;case"X":let h=new V().rotateY(-Math.PI/2);s=s.multiplyRight(h);break;default:break}e.isQuantized&&s.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new E(i);e.cartesianModelMatrix=s,e.cartesianOrigin=a;let c=de.WGS84.cartesianToCartographic(a,new E),f=de.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=f.multiplyRight(s),e.cartographicOrigin=c;let u=que(e);u&&(e.cartesianModelMatrix=new V(s).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=V.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var Kue=1e6**2;function que(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,n=e.scenes?.[r]?.nodes?.[0];if(!n?.matrix)return null;let i=n.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Kue?null:n}var Ik=new E,dE=new E,hE=new at([new mt,new mt,new mt,new mt,new mt,new mt]);function Bk(t,e){let{cameraDirection:r,cameraUp:o,height:n}=t,{metersPerUnit:i}=t.distanceScales,s=Ny(t,t.center),a=de.WGS84.eastNorthUpToFixedFrame(s),c=t.unprojectPosition(t.cameraPosition),l=de.WGS84.cartographicToCartesian(c,new E),f=new E(a.transformAsVector(new E(r).scale(i))).normalize(),u=new E(a.transformAsVector(new E(o).scale(i))).normalize();Zue(t);let d=t.constructor,{longitude:h,latitude:p,width:m,bearing:g,zoom:_}=t,x=new d({longitude:h,latitude:p,height:n,width:m,bearing:g,zoom:_,pitch:0});return{camera:{position:l,direction:f,up:u},viewport:t,topDownViewport:x,height:n,cullingVolume:hE,frameNumber:e,sseDenominator:1.15}}function Ok(t,e,r){if(r===0||t.length<=r)return[t,[]];let o=[],{longitude:n,latitude:i}=e.viewport;for(let[l,f]of t.entries()){let[u,d]=f.header.mbs,h=Math.abs(n-u),p=Math.abs(i-d),m=Math.sqrt(p*p+h*h);o.push([l,m])}let s=o.sort((l,f)=>l[1]-f[1]),a=[];for(let l=0;l<r;l++)a.push(t[s[l][0]]);let c=[];for(let l=r;l<s.length;l++)c.push(t[s[l][0]]);return[a,c]}function Zue(t){let e=t.getFrustumPlanes(),r=Lk(e.near,t.cameraPosition),o=Ny(t,r),n=Ny(t,t.cameraPosition,dE),i=0;hE.planes[i++].fromPointNormal(o,Ik.copy(o).subtract(n));for(let s in e){if(s==="near")continue;let a=e[s],c=Lk(a,r,dE),l=Ny(t,c,dE);hE.planes[i++].fromPointNormal(l,Ik.copy(o).subtract(l))}}function Lk(t,e,r=new E){let o=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-o).add(e),r}function Ny(t,e,r=new E){let o=t.unprojectPosition(e);return de.WGS84.cartographicToCartesian(o,r)}var Jue=6378137,Que=6378137,pE=6356752314245179e-9,nl=new E;function Fk(t,e){if(t instanceof lo){let{halfAxes:r}=t,o=ede(r);return Math.log2(pE/(o+e[2]))}else if(t instanceof Fr){let{radius:r}=t;return Math.log2(pE/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:o}=t,n=Math.log2(Jue/r),i=Math.log2(Que/o);return(n+i)/2}return 1}function mE(t,e,r){de.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],nl);let o=Math.sqrt(Math.pow(nl[0]-r[0],2)+Math.pow(nl[1]-r[1],2)+Math.pow(nl[2]-r[2],2));return Math.log2(pE/(o+e[2]))}function Nk(t,e,r){let[o,n,i,s]=t;return mE({xmin:o,xmax:i,ymin:n,ymax:s,zmin:0,zmax:0},e,r)}function ede(t){t.getColumn(0,nl);let e=t.getColumn(1),r=t.getColumn(2);return nl.add(e).add(r).len()}var Gt={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},Rt;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(Rt||(Rt={}));var Ur;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(Ur||(Ur={}));var _t;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(_t||(_t={}));var Rn;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Rn||(Rn={}));var Dk={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function zk(t){return t!=null}var It=new E,Dy=new E,tde=new E,rde=new E,Ys=new E,Uk=new E,kk=new E,Vk=new E;function Uy(t,e,r){if(le(t,"3D Tile: boundingVolume must be defined"),t.box)return jk(t.box,e,r);if(t.region)return nde(t.region);if(t.sphere)return ode(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Hk(t,e){if(t.box)return ide(e);if(t.region){let[r,o,n,i,s,a]=t.region;return[[rt(r),rt(o),s],[rt(n),rt(i),a]]}if(t.sphere)return sde(e);throw new Error("Unkown boundingVolume type")}function jk(t,e,r){let o=new E(t[0],t[1],t[2]);e.transform(o,o);let n=[];if(t.length===10){let l=t.slice(3,6),f=new Sr;f.fromArray(t,6);let u=new E([1,0,0]),d=new E([0,1,0]),h=new E([0,0,1]);u.transformByQuaternion(f),u.scale(l[0]),d.transformByQuaternion(f),d.scale(l[1]),h.transformByQuaternion(f),h.scale(l[2]),n=[...u.toArray(),...d.toArray(),...h.toArray()]}else n=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let i=e.transformAsVector(n.slice(0,3)),s=e.transformAsVector(n.slice(3,6)),a=e.transformAsVector(n.slice(6,9)),c=new ue([i[0],i[1],i[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return zk(r)?(r.center=o,r.halfAxes=c,r):new lo(o,c)}function ode(t,e,r){let o=new E(t[0],t[1],t[2]);e.transform(o,o);let n=e.getScale(Dy),i=Math.max(Math.max(n[0],n[1]),n[2]),s=t[3]*i;return zk(r)?(r.center=o,r.radius=s,r):new Fr(o,s)}function nde(t){let[e,r,o,n,i,s]=t,a=de.WGS84.cartographicToCartesian([rt(e),rt(n),i],tde),c=de.WGS84.cartographicToCartesian([rt(o),rt(r),s],rde),l=new E().addVectors(a,c).multiplyByScalar(.5);return de.WGS84.cartesianToCartographic(l,Ys),de.WGS84.cartographicToCartesian([rt(o),Ys[1],Ys[2]],Uk),de.WGS84.cartographicToCartesian([Ys[0],rt(n),Ys[2]],kk),de.WGS84.cartographicToCartesian([Ys[0],Ys[1],s],Vk),jk([...l,...Uk.subtract(l),...kk.subtract(l),...Vk.subtract(l)],new V)}function ide(t){let e=Wk(),{halfAxes:r}=t,o=new E(r.getColumn(0)),n=new E(r.getColumn(1)),i=new E(r.getColumn(2));for(let s=0;s<2;s++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)It.copy(t.center),It.add(o),It.add(n),It.add(i),Gk(e,It),i.negate();n.negate()}o.negate()}return e}function sde(t){let e=Wk(),{center:r,radius:o}=t,n=de.WGS84.scaleToGeodeticSurface(r,It),i;n?i=de.WGS84.geodeticSurfaceNormal(n):i=new E(0,0,1);let s=new E(i[2],-i[1],0);s.len()>0?s.normalize():s=new E(0,1,0);let a=s.clone().cross(i);for(let c of[s,a,i]){Dy.copy(c).scale(o);for(let l=0;l<2;l++)It.copy(r),It.add(Dy),Gk(e,It),Dy.negate()}return e}function Wk(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Gk(t,e){de.WGS84.cartesianToCartographic(e,It),t[0][0]=Math.min(t[0][0],It[0]),t[0][1]=Math.min(t[0][1],It[1]),t[0][2]=Math.min(t[0][2],It[2]),t[1][0]=Math.max(t[1][0],It[0]),t[1][1]=Math.max(t[1][1],It[1]),t[1][2]=Math.max(t[1][2],It[2])}var MJe=new E,RJe=new E,IJe=new V,LJe=new E,BJe=new E,OJe=new E;function ade(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function cde(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,o=t.dynamicScreenSpaceErrorFactor;return ade(e,r)*o}return 0}function $k(t,e,r){let o=t.tileset,n=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,i=r?n:t.lodMetricValue;if(i===0)return 0;let s=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=o.options,f=i*a*(l||1)/(s*c);return f-=cde(o,s),f}var gE=new E,Xk=new E,Li=new E,Yk=new E,lde=new E,_E=new V,Kk=new V;function qk(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*yE(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function yE(t,e){let{topDownViewport:r}=e,o=t.header.mbs[1],n=t.header.mbs[0],i=t.header.mbs[2],s=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);de.WGS84.cartographicToCartesian(c,gE),Xk.copy(gE).subtract(a).normalize(),de.WGS84.eastNorthUpToFixedFrame(a,_E),Kk.copy(_E).invert(),Li.copy(gE).transform(Kk);let l=Math.sqrt(Li[0]*Li[0]+Li[1]*Li[1]),f=l*l/Li[2];Yk.copy([Li[0],Li[1],f]);let d=Yk.transform(_E).subtract(a).normalize(),p=Xk.cross(d).normalize().scale(s).add(a),m=de.WGS84.cartesianToCartographic(p),g=r.project([n,o,i]),_=r.project(m);return lde.copy(g).subtract(_).magnitude()}function Zk(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var yh=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return le(e<this._array.length),this._array[e]}set(e,r){le(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){le(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){le(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var fde={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Ko=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new yh;_emptyTraversalStack=new yh;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...fde,...e}}traverse(e,r,o){this.root=e,this.options={...this.options,...o},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let o=this._traversalStack;for(e._selectionDepth=1,o.push(e);o.length>0;){let i=o.pop(),s=!1;this.canTraverse(i,r)&&(this.updateChildTiles(i,r),s=this.updateAndPushChildren(i,r,o,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let a=i.parent,c=Boolean(!a||a._shouldRefine),l=!s;i.hasRenderContent?i.refine===Rt.ADD?(this.loadTile(i,r),this.selectTile(i,r)):i.refine===Rt.REPLACE&&(this.loadTile(i,r),l&&this.selectTile(i,r)):(this.emptyTiles[i.id]=i,this.loadTile(i,r),l&&this.selectTile(i,r)),this.touchTile(i,r),i._shouldRefine=s&&c}let n=new Date().getTime();(this.traversalFinished(r)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let o=e.children;for(let n of o)this.updateTile(n,r)}updateAndPushChildren(e,r,o,n){let{loadSiblings:i,skipLevelOfDetail:s}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===Rt.REPLACE&&e.hasRenderContent&&!s,l=!1,f=!0;for(let u of a)if(u._selectionDepth=n,u.isVisibleAndInRequestVolume?(o.find(u)&&o.delete(u),o.push(u),l=!0):(c||i)&&(this.loadTile(u,r),this.touchTile(u,r)),c){let d;if(u._inRequestVolume?u.hasRenderContent?d=u.contentAvailable:d=this.executeEmptyTraversal(u,r):d=!1,f=f&&d,!f)return!1}return l||(f=!1),f}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,o=!1){let n=e._screenSpaceError;return o&&(n=e.getScreenSpaceError(r,!0)),n>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let o=[];if(this.options.viewportTraversersMap)for(let n in this.options.viewportTraversersMap)this.options.viewportTraversersMap[n]===r.viewport.id&&o.push(n);else o.push(r.viewport.id);e.updateVisibility(r,o)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let o=!1;for(let n of e.children)n.updateVisibility(r),o=o||n.isVisibleAndInRequestVolume;return o}executeEmptyTraversal(e,r){let o=!0,n=this._emptyTraversalStack;for(n.push(e);n.length>0;){let i=n.pop(),s=!i.hasRenderContent&&this.canTraverse(i,r),a=!i.hasRenderContent&&i.children.length===0;if(!s&&!i.contentAvailable&&!a&&(o=!1),this.updateTile(i,r),i.isVisibleAndInRequestVolume||(this.loadTile(i,r),this.touchTile(i,r)),s){let c=i.children;for(let l of c)n.push(l)}}return e.hasEmptyContent||o}};var Jk=new E;function ude(t){return t!=null}var Ks=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Gt.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new V;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Ko({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new V;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(e,r,o,n=""){this.header=r,this.tileset=e,this.id=n||r.id,this.url=r.url,this.parent=o,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Gt.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Gt.UNLOADED}get contentExpired(){return this.contentState===Gt.EXPIRED}get contentFailed(){return this.contentState===Gt.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Hk(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case _t.I3S:return yE(this,e);case _t.TILES3D:return $k(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,o=this.refine===Rt.ADD||r;if(o&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Gt.UNLOADED)return-1;let n=this.parent,s=n&&(!o||this._screenSpaceError===0||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-s,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Gt.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Gt.UNLOADED,!1;try{let o=this.tileset.getTileUrl(this.contentUrl),n=this.tileset.loader,i=this.tileset.loadOptions[n.id]||{},s={...this.tileset.loadOptions,[n.id]:{...i,isTileset:this.type==="json",...this._getLoaderSpecificOptions(n.id)}};return this.content=await _r(o,n,s),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Gt.READY,this._onContentLoaded(),!0}catch(o){throw this.contentState=Gt.FAILED,o}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Gt.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let o=this.parent,n=o?o._visibilityPlaneMask:at.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let i=o?o.computedTransform:this.tileset.modelMatrix;this._updateTransform(i)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==at.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:o}=e,{boundingVolume:n}=this;return o.computeVisibilityWithPlaneMask(n,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return Jk.subVectors(r.center,e.position),e.direction.dot(Jk)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(ude(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Gt.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new V(e.transform):new V;let r=this.parent,o=this.tileset,n=r&&r.computedTransform?r.computedTransform.clone():o.modelMatrix.clone();this.computedTransform=new V(n).multiplyRight(this.transform);let i=r&&r._initialTransform?r._initialTransform.clone():new V;this._initialTransform=new V(i).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Gt.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=at.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||Rt.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=Uy(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=Uy(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=Uy(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new V){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return Zk(this.tileset.tileset)}}};var ky=class extends Ko{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let o=e.children.length>0;if(e.hasTilesetContent&&o){let s=e.children[0];this.updateTileVisibility(s,r),e._visible=s._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let n=e.refine===Rt.REPLACE,i=e._optimChildrenWithinParent===Dk.USE_OPTIMIZATION;if(n&&i&&o&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:o}=e;return!o||o.hasTilesetContent||o.refine!==Rt.ADD?!1:!this.shouldRefine(e,r,!0)}};var Vy=class{frameNumberMap=new Map;register(e,r){let o=this.frameNumberMap.get(e)||new Map,n=o.get(r)||0;o.set(r,n+1),this.frameNumberMap.set(e,o)}deregister(e,r){let o=this.frameNumberMap.get(e);if(!o)return;let n=o.get(r)||1;o.set(r,n-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var xE={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},zy=class{_statusMap;pendingTilesRegister=new Vy;constructor(){this._statusMap={}}add(e,r,o,n){if(!this._statusMap[r]){let{frameNumber:i,viewport:{id:s}}=n;this._statusMap[r]={request:e,callback:o,key:r,frameState:n,status:xE.REQUESTED},this.pendingTilesRegister.register(s,i),e().then(a=>{this._statusMap[r].status=xE.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,n)}).catch(a=>{this._statusMap[r].status=xE.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),o(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:o,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,o);let{frameNumber:i,viewport:{id:s}}=r;this.pendingTilesRegister.register(s,i),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var Hy=class extends Ko{_tileManager;constructor(e){super(e),this._tileManager=new zy}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=qk(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let o=e.header.children||[],n=e.children,i=e.tileset;for(let s of o){let a=`${s.id}-${r.viewport.id}`,c=n&&n.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(s.id,i);this._tileManager.find(a)?this._tileManager.update(a,r):(i.tileset.nodePages&&(l=()=>i.tileset.nodePagesTile.formTileFromNodePages(s.id)),this._tileManager.add(l,a,u=>this._onTileLoad(u,e,a),r))}}return!1}async _loadTile(e,r){let{loader:o}=r,n=r.getTileUrl(`${r.url}/nodes/${e}`),i={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await _r(n,o,i)}_onTileLoad(e,r,o){let n=new Ks(r.tileset,e,r,o);r.children.push(n);let i=this._tileManager.find(n.id).frameState;this.updateTile(n,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,i)}};var dde={description:"",ellipsoid:de.WGS84,modelMatrix:new V,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},jy="Tiles In Tileset(s)",bE="Tiles In Memory",Qk="Tiles In View",e6="Tiles To Render",t6="Tiles Loaded",AE="Tiles Loading",r6="Tiles Unloaded",o6="Failed Tile Loads",n6="Points/Vertices",TE="Tile Memory Use",i6="Maximum Screen Space Error",xh=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Fy;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...dde,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Ft.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Gn({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Et({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let o=e;return this.queryParams.length&&(o=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),o}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let o=[];for(let n of r){let i=n.id;this._needTraverse(i)?o.push(i):this.traverseCounter--}for(let n of r){let i=n.id;if(this.roots[i]||(this.roots[i]=this._initializeTileHeaders(this.tileset,null)),!o.includes(i))continue;let s=Bk(n,this._frameNumber);this._traverser.traverse(this.roots[i],s,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let o=this.frameStateData[r],n=Object.values(this._traverser.selectedTiles),[i,s]=Ok(n,e,this.options.maximumTilesSelected);o.selectedTiles=i;for(let a of s)a.unselect();o._requestedTiles=Object.values(this._traverser.requestedTiles),o._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let i in this.frameStateData){let s=this.frameStateData[i];this.selectedTiles=this.selectedTiles.concat(s.selectedTiles),this._requestedTiles=this._requestedTiles.concat(s._requestedTiles),this._emptyTiles=this._emptyTiles.concat(s._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(i=>i.id)),o=this.selectedTiles.some(i=>!i.tileDrawn),n=0;if(o){for(let i of r)this._heldTiles.add(i);for(let i of this._heldTiles){if(r.has(i))continue;let s=this._tiles[i];s&&s.contentAvailable?(s._selectedFrame=this._frameNumber,this.selectedTiles.push(s),n++):this._heldTiles.delete(i)}}else this._heldTiles=r;n>0&&setTimeout(()=>{this.selectTiles()},0);for(let i of this.selectedTiles)this._tiles[i.id]=i;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let o=new Set(e.map(s=>s.id)),n=new Set(r.map(s=>s.id)),i=e.filter(s=>!n.has(s.id)).length>0;return i=i||r.filter(s=>!o.has(s.id)).length>0,i}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let o of this.selectedTiles)o.contentAvailable&&o.content&&(e++,o.content.pointCount?r+=o.content.pointCount:r+=o.content.vertexCount);this.stats.get(Qk).count=this.selectedTiles.length,this.stats.get(e6).count=e,this.stats.get(n6).count=r,this.stats.get(i6).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===_t.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===_t.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===_t.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:o,xmax:n,ymin:i,ymax:s,zmin:a,zmax:c}=e;this.cartographicCenter=new E(o+(n-o)/2,i+(s-i)/2,a+(c-a)/2),this.cartesianCenter=new E,de.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=mE(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[o,n,i,s]=r;this.cartographicCenter=new E(o+(i-o)/2,n+(s-n)/2,0),this.cartesianCenter=new E,de.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Nk(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new E,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new E,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new E,de.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new E(0,0,-de.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=Fk(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(jy),this.stats.get(AE),this.stats.get(bE),this.stats.get(Qk),this.stats.get(e6),this.stats.get(t6),this.stats.get(r6),this.stats.get(o6),this.stats.get(n6),this.stats.get(TE,"memory"),this.stats.get(i6)}_initializeTileHeaders(e,r){let o=new Ks(this,e.root,r);if(r&&(r.children.push(o),o.depth=r.depth+1),this.type===_t.TILES3D){let n=[];for(n.push(o);n.length>0;){let i=n.pop();this.stats.get(jy).incrementCount();let s=i.header.children||[];for(let a of s){let c=new Ks(this,a,i);if(c.contentUrl?.includes("?session=")){let f=new URL(c.contentUrl).searchParams.get("session");f&&(this._queryParams.session=f)}i.children.push(c),c.depth=i.depth+1,n.push(c)}}}return o}_initializeTraverser(){let e;switch(this.type){case _t.TILES3D:e=ky;break;case _t.I3S:e=Hy;break;default:e=Ko}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(o){this._onTileLoadError(e,o instanceof Error?o:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(o6).incrementCount();let o=r.message||r.toString(),n=e.url;console.error(`A 3D tile failed to load: ${e.url} ${o}`),this.options.onTileError(e,o,n)}_onTileLoad(e,r){if(r){if(this.type===_t.I3S){let o=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(jy).reset(),this.stats.get(jy).addCount(o)}e&&e.content&&Rk(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===_t.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===_t.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(AE).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(AE).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(t6).incrementCount(),this.stats.get(bE).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(TE).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(bE).decrementCount(),this.stats.get(r6).incrementCount(),this.stats.get(TE).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let o of r.children)e.push(o);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,o=[];for(o.push(r);o.length>0;){e=o.pop();for(let n of e.children)o.push(n);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),o=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...o}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){let e=this.loadOptions.i3s;e&&typeof e=="object"&&"token"in e&&(this._queryParams.token=e.token)}};var Wy="4.4.3";var qs={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},IQe=Object.keys(qs);function vE(t,e,r){le(t instanceof ArrayBuffer);let o=new TextDecoder("utf8"),n=new Uint8Array(t,e,r);return o.decode(n)}function s6(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var hde={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Je={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},ae={...hde,...Je};var SE={[Je.DOUBLE]:Float64Array,[Je.FLOAT]:Float32Array,[Je.UNSIGNED_SHORT]:Uint16Array,[Je.UNSIGNED_INT]:Uint32Array,[Je.UNSIGNED_BYTE]:Uint8Array,[Je.BYTE]:Int8Array,[Je.SHORT]:Int16Array,[Je.INT]:Int32Array},pde={DOUBLE:Je.DOUBLE,FLOAT:Je.FLOAT,UNSIGNED_SHORT:Je.UNSIGNED_SHORT,UNSIGNED_INT:Je.UNSIGNED_INT,UNSIGNED_BYTE:Je.UNSIGNED_BYTE,BYTE:Je.BYTE,SHORT:Je.SHORT,INT:Je.INT},CE="Failed to convert GL type",dt=class{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in SE)if(SE[r]===e)return r;throw new Error(CE)}static fromName(e){let r=pde[e];if(!r)throw new Error(CE);return r}static getArrayType(e){switch(e){case Je.UNSIGNED_SHORT_5_6_5:case Je.UNSIGNED_SHORT_4_4_4_4:case Je.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=SE[e];if(!r)throw new Error(CE);return r}}static getByteSize(e){return dt.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(dt.getArrayType(e))}static createTypedArray(e,r,o=0,n){n===void 0&&(n=(r.byteLength-o)/dt.getByteSize(e));let i=ArrayBuffer.isView(r)?r.buffer:r,s=dt.getArrayType(e);return new s(i,o,n)}};function a6(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function EE(t,e=[0,0,0]){let r=t>>11&31,o=t>>5&63,n=t&31;return e[0]=r<<3,e[1]=o<<2,e[2]=n<<3,e}var HQe=1/256;var jQe=new Gr,WQe=new E,GQe=new Gr,$Qe=new Gr,XQe=new Uint8Array(1);function c6(t,e=255){return ee(t,0,e)/e*2-1}function l6(t){return t<0?-1:1}function f6(t,e,r,o){if(a6(o),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(o.x=c6(t,r),o.y=c6(e,r),o.z=1-(Math.abs(o.x)+Math.abs(o.y)),o.z<0){let n=o.x;o.x=(1-Math.abs(o.y))*l6(n),o.y=(1-Math.abs(n))*l6(o.y)}return o.normalize()}function wE(t,e,r){return f6(t,e,255,r)}var In=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,r=ae.UNSIGNED_INT,o=1){let n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,r,o,1,n.byteOffset):n}getPropertyArray(e,r,o){let n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(r=dt.fromName(n.componentType)),this._getTypedArrayFromBinary(e,r,o,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,r,n)}getProperty(e,r,o,n,i){let s=this.json[e];if(!s)return s;let a=this.getPropertyArray(e,r,o);if(o===1)return a[n];for(let c=0;c<o;++c)i[c]=a[o*n+c];return i}_getTypedArrayFromBinary(e,r,o,n,i){let s=this._cachedTypedArrays,a=s[e];return a||(a=dt.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+i,n*o),s[e]=a),a}_getTypedArrayFromArray(e,r,o){let n=this._cachedTypedArrays,i=n[e];if(!i){if(ArrayBuffer.isView(o)){let s=o.byteOffset,c=o.byteLength/dt.getByteSize(r);i=dt.createTypedArray(r,o.buffer,s,c)}else if(o instanceof ArrayBuffer)i=dt.createTypedArray(r,o);else{let s=dt.getArrayType(r);i=new s(o)}n[e]=i}return i}};var mde={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gde={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},_de={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function u6(t,e,r,o){let{componentType:n}=t;le(t.componentType);let i=typeof n=="string"?dt.fromName(n):n,s=mde[t.type],a=gde[t.type],c=_de[t.type];return r+=t.byteOffset,{values:dt.createTypedArray(i,e,r,s*o),type:i,size:s,unpacker:a,packer:c}}var qo=t=>t!==void 0;function d6(t,e,r){if(!e)return null;let o=t.getExtension("3DTILES_batch_table_hierarchy"),n=e.HIERARCHY;return n&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=n,o=n),o?yde(o,r):null}function yde(t,e){let r,o,n,i=t.instancesLength,s=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,f=i;qo(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,n=getBinaryAccessor(a),a=n.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,i));let u;if(qo(c))for(qo(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,n=getBinaryAccessor(c),c=n.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,i)),u=new Uint16Array(i),f=0,r=0;r<i;++r)u[r]=f,f+=c[r];qo(l)&&qo(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,n=getBinaryAccessor(l),l=n.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,f));let d=s.length;for(r=0;r<d;++r){let g=s[r].length,_=s[r].instances,x=getBinaryProperties(g,_,e);s[r].instances=combine(x,_)}let h=new Array(d).fill(0),p=new Uint16Array(i);for(r=0;r<i;++r)o=a[r],p[r]=h[o],++h[o];let m={classes:s,classIds:a,classIndexes:p,parentCounts:c,parentIndexes:u,parentIds:l};return Ade(m),m}function il(t,e,r){if(!t)return;let o=t.parentCounts;return t.parentIds?r(t,e):o>0?xde(t,e,r):bde(t,e,r)}function xde(t,e,r){let o=t.classIds,n=t.parentCounts,i=t.parentIds,s=t.parentIndexes,a=o.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,f=scratchStack;for(f.length=0,f.push(e);f.length>0;){if(e=f.pop(),c[e]===l)continue;c[e]=l;let u=r(t,e);if(qo(u))return u;let d=n[e],h=s[e];for(let p=0;p<d;++p){let m=i[h+p];m!==e&&f.push(m)}}return null}function bde(t,e,r){let o=!0;for(;o;){let n=r(t,e);if(qo(n))return n;let i=t.parentIds[e];o=i!==e,e=i}throw new Error("traverseHierarchySingleParent")}function Ade(t){let e=[],o=t.classIds.length;for(let n=0;n<o;++n)h6(t,n,stack)}function h6(t,e,r){let o=t.parentCounts,n=t.parentIds,i=t.parentIndexes,a=t.classIds.length;if(!qo(n))return;assert(e<a,`Parent index ${e} exceeds the total number of instances: ${a}`),assert(r.indexOf(e)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(e);let c=qo(o)?o[e]:1,l=qo(o)?i[e]:e;for(let f=0;f<c;++f){let u=n[l+f];u!==e&&h6(t,u,r)}r.pop(e)}function tr(t){return t!=null}var Gy=(t,e)=>t,Tde={HIERARCHY:!0,extensions:!0,extras:!0},Zs=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,o,n={}){le(o>=0),this.json=e||{},this.binary=r,this.featureCount=o,this._extensions=this.json?.extensions||{},this._properties={};for(let i in this.json)Tde[i]||(this._properties[i]=this.json[i]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=d6(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),le(typeof r=="string",r),this._hierarchy){let o=il(this._hierarchy,e,(n,i)=>{let s=n.classIds[i];return n.classes[s].name===r});return tr(o)}return!1}isExactClass(e,r){return le(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),le(typeof r=="string",r),tr(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=tr(r)?r:[],r.length=0;let o=Object.keys(this._properties);return r.push(...o),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),le(typeof r=="string",r),this._binaryProperties){let n=this._binaryProperties[r];if(tr(n))return this._getBinaryProperty(n,e)}let o=this._properties[r];if(tr(o))return Gy(o[e],!0);if(this._hierarchy){let n=this._getHierarchyProperty(e,r);if(tr(n))return n}}setProperty(e,r,o){let n=this.featureCount;if(this._checkBatchId(e),le(typeof r=="string",r),this._binaryProperties){let s=this._binaryProperties[r];if(s){this._setBinaryProperty(s,e,o);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,o))return;let i=this._properties[r];tr(i)||(this._properties[r]=new Array(n),i=this._properties[r]),i[e]=Gy(o,!0)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,r){return e.unpack(e.typedArray,r)}_setBinaryProperty(e,r,o){e.pack(o,e.typedArray,r)}_initializeBinaryProperties(){let e=null;for(let r in this._properties){let o=this._properties[r],n=this._initializeBinaryProperty(r,o);n&&(e=e||{},e[r]=n)}return e}_initializeBinaryProperty(e,r){if("byteOffset"in r){let o=r;le(this.binary,`Property ${e} requires a batch table binary.`),le(o.type,`Property ${e} requires a type.`);let n=u6(o,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:n.values,componentCount:n.size,unpack:n.unpacker,pack:n.packer}}return null}_hasPropertyInHierarchy(e,r){if(!this._hierarchy)return!1;let o=il(this._hierarchy,e,(n,i)=>{let s=n.classIds[i],a=n.classes[s].instances;return tr(a[r])});return tr(o)}_getPropertyNamesInHierarchy(e,r){il(this._hierarchy,e,(o,n)=>{let i=o.classIds[n],s=o.classes[i].instances;for(let a in s)s.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return il(this._hierarchy,e,(o,n)=>{let i=o.classIds[n],s=o.classes[i],a=o.classIndexes[n],c=s.instances[r];return tr(c)?tr(c.typedArray)?this._getBinaryProperty(c,a):Gy(c[a],!0):null})}_setHierarchyProperty(e,r,o,n){let i=il(this._hierarchy,r,(s,a)=>{let c=s.classIds[a],l=s.classes[c],f=s.classIndexes[a],u=l.instances[o];return tr(u)?(le(a===r,`Inherited property "${o}" is read-only.`),tr(u.typedArray)?this._setBinaryProperty(u,f,n):u[f]=Gy(n,!0),!0):!1});return tr(i)}};function Bi(t,e,r=0){let o=new DataView(e);if(t.magic=o.getUint32(r,!0),r+=4,t.version=o.getUint32(r,!0),r+=4,t.byteLength=o.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var sl=4,p6="b3dm tile in legacy format.";function al(t,e,r){let o=new DataView(e),n;t.header=t.header||{};let i=o.getUint32(r,!0);r+=sl;let s=o.getUint32(r,!0);r+=sl;let a=o.getUint32(r,!0);r+=sl;let c=o.getUint32(r,!0);return r+=sl,a>=570425344?(r-=sl*2,n=i,a=s,c=0,i=0,s=0,console.warn(p6)):c>=570425344&&(r-=sl,n=a,a=i,c=s,i=0,s=0,console.warn(p6)),t.header.featureTableJsonByteLength=i,t.header.featureTableBinaryByteLength=s,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=n,r}function cl(t,e,r,o){return r=vde(t,e,r,o),r=Sde(t,e,r,o),r}function vde(t,e,r,o){let{featureTableJsonByteLength:n,featureTableBinaryByteLength:i,batchLength:s}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:s||0},n&&n>0){let a=vE(e,r,n);t.featureTableJson=JSON.parse(a)}return r+=n||0,t.featureTableBinary=new Uint8Array(e,r,i),r+=i||0,r}function Sde(t,e,r,o){let{batchTableJsonByteLength:n,batchTableBinaryByteLength:i}=t.header||{};if(n&&n>0){let s=vE(e,r,n);t.batchTableJson=JSON.parse(s),r+=n,i&&i>0&&(t.batchTableBinary=new Uint8Array(e,r,i),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=i)}return r}function PE(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:o,isRGB565:n,pointCount:i=0}=t;if(o&&r){let s=new Uint8ClampedArray(i*3);for(let a=0;a<i;a++){let c=o[a],f=r.getProperty(c,"dimensions").map(u=>u*255);s[a*3]=f[0],s[a*3+1]=f[1],s[a*3+2]=f[2]}return{type:ae.UNSIGNED_BYTE,value:s,size:3,normalized:!0}}if(e&&n){let s=new Uint8ClampedArray(i*3);for(let a=0;a<i;a++){let c=EE(e[a]);s[a*3]=c[0],s[a*3+1]=c[1],s[a*3+2]=c[2]}return{type:ae.UNSIGNED_BYTE,value:s,size:3,normalized:!0}}return e&&e.length===i*3?{type:ae.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:ae.UNSIGNED_BYTE,value:e||new Uint8ClampedArray,size:4,normalized:!0}}var m6=new E;function g6(t,e){if(!e)return null;if(t.isOctEncoded16P){let r=new Float32Array((t.pointsLength||0)*3);for(let o=0;o<(t.pointsLength||0);o++)wE(e[o*2],e[o*2+1],m6),m6.toArray(r,o*3);return{type:ae.FLOAT,size:2,value:r}}return{type:ae.FLOAT,size:2,value:e}}function _6(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,Cde(t,e)):{type:ae.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}function Cde(t,e){let r=new E,o=new Float32Array(t.pointCount*3);for(let n=0;n<t.pointCount;n++)r.set(e[n*3],e[n*3+1],e[n*3+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(o,n*3);return o}async function y6(t,e,r,o,n){r=Bi(t,e,r),r=al(t,e,r),r=cl(t,e,r,o),Ede(t);let{featureTable:i,batchTable:s}=wde(t);return await Lde(t,i,s,o,n),Pde(t,i,o),Mde(t,i,s),Rde(t,i),r}function Ede(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}function wde(t){let e=new In(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",ae.FLOAT,3);let o=Ide(t,e);return{featureTable:e,batchTable:o}}function Pde(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.positions){if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",ae.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){let o=e.getPropertyArray("POSITION_QUANTIZED",ae.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=(1<<16)-1,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ae.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ae.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=_6(t,o,r)}}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function Mde(t,e,r){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.colors){let o=null;e.hasProperty("RGBA")?(o=e.getPropertyArray("RGBA",ae.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?o=e.getPropertyArray("RGB",ae.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(o=e.getPropertyArray("RGB565",ae.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=PE(t,o,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",ae.UNSIGNED_BYTE,4))}function Rde(t,e){if(t.attributes=t.attributes||{positions:null,colors:null,normals:null,batchIds:null},!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",ae.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",ae.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=g6(t,r)}}function Ide(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",ae.UNSIGNED_SHORT,1),t.batchIds)){let o=e.getGlobalProperty("BATCH_LENGTH");if(!o)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:n,batchTableBinary:i}=t;r=new Zs(n,i,o)}return r}async function Lde(t,e,r,o,n){let i,s,a,c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=e.getExtension("3DTILES_draco_point_compression");if(l){s=l.properties;let u=l.byteOffset,d=l.byteLength;if(!s||!Number.isFinite(u)||!d)throw new Error("Draco properties, byteOffset, and byteLength must be defined");i=(t.featureTableBinary||[]).slice(u,u+d),t.hasPositions=Number.isFinite(s.POSITION),t.hasColors=Number.isFinite(s.RGB)||Number.isFinite(s.RGBA),t.hasNormals=Number.isFinite(s.NORMAL),t.hasBatchIds=Number.isFinite(s.BATCH_ID),t.isTranslucent=Number.isFinite(s.RGBA)}if(!i)return!0;let f={buffer:i,properties:{...s,...a},featureTableProperties:s,batchTableProperties:a,dequantizeInShader:!1};return await Bde(t,f,o,n)}async function Bde(t,e,r,o){if(!o)return;let n={...r,draco:{...r?.draco,extraAttributes:e.batchTableProperties||{}}};delete n["3d-tiles"];let i=await nr(e.buffer,dh,n,o),s=i.attributes.POSITION&&i.attributes.POSITION.value,a=i.attributes.COLOR_0&&i.attributes.COLOR_0.value,c=i.attributes.NORMAL&&i.attributes.NORMAL.value,l=i.attributes.BATCH_ID&&i.attributes.BATCH_ID.value,f=s&&i.attributes.POSITION.value.quantization,u=c&&i.attributes.NORMAL.value.quantization;if(f){let h=i.POSITION.data.quantization,p=h.range;t.quantizedVolumeScale=new E(p,p,p),t.quantizedVolumeOffset=new E(h.minValues),t.quantizedRange=(1<<h.quantizationBits)-1,t.isQuantizedDraco=!0}u&&(t.octEncodedRange=(1<<i.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);let d={};if(e.batchTableProperties)for(let h of Object.keys(e.batchTableProperties))i.attributes[h]&&i.attributes[h].value&&(d[h.toLowerCase()]=i.attributes[h].value);t.attributes={positions:s,colors:PE(t,a,void 0),normals:c,batchIds:l,...d}}var $y={URI:0,EMBEDDED:1};function Xy(t,e,r,o){t.rotateYtoZ=!0;let n=(t.byteOffset||0)+(t.byteLength||0)-r;if(n===0)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=o?.["3d-tiles"]&&o["3d-tiles"].assetGltfUpAxis?o["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=Gi(e,r,n),t.gltfByteOffset=0,t.gltfByteLength=n,r%4===0||console.warn(`${t.type}: embedded glb is not aligned to a 4-byte boundary.`),(t.byteOffset||0)+(t.byteLength||0)}async function Yy(t,e,r,o){let n=r?.["3d-tiles"]||{};if(Ode(t,e,r),n.loadGLTF){if(!o)return;if(t.gltfUrl){let{fetch:i}=o,s=await i(t.gltfUrl,r?.core);t.gltfArrayBuffer=await s.arrayBuffer(),t.gltfByteOffset=0}if(t.gltfArrayBuffer){let i=await nr(t.gltfArrayBuffer,Pn,r,o);t.gltf=Xs(i),t.gpuMemoryUsageInBytes=ch(t.gltf),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength}}}function Ode(t,e,r){switch(e){case $y.URI:if(t.gltfArrayBuffer){let o=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),i=new TextDecoder().decode(o);t.gltfUrl=i.replace(/[\s\0]+$/,"")}delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case $y.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function x6(t,e,r,o,n){r=Fde(t,e,r,o,n),await Yy(t,$y.EMBEDDED,o,n);let i=t?.gltf?.extensions;return i&&i.CESIUM_RTC&&(t.rtcCenter=i.CESIUM_RTC.center),r}function Fde(t,e,r,o,n){r=Bi(t,e,r),r=al(t,e,r),r=cl(t,e,r,o),r=Xy(t,e,r,o);let i=new In(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=i.getGlobalProperty("RTC_CENTER",ae.FLOAT,3),r}async function b6(t,e,r,o,n){return r=Nde(t,e,r,o,n),await Yy(t,t.gltfFormat||0,o,n),r}function Nde(t,e,r,o,n){if(r=Bi(t,e,r),t.version!==1)throw new Error(`Instanced 3D Model version ${t.version} is not supported`);r=al(t,e,r);let i=new DataView(e);if(t.gltfFormat=i.getUint32(r,!0),r+=4,r=cl(t,e,r,o),r=Xy(t,e,r,o),!t?.header?.featureTableJsonByteLength||t.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let s=new In(t.featureTableJson,t.featureTableBinary),a=s.getGlobalProperty("INSTANCES_LENGTH");if(s.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=s.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=s.getGlobalProperty("RTC_CENTER",ae.FLOAT,3);let c=new Zs(t.batchTableJson,t.batchTableBinary,a);return Dde(t,s,c,a),r}function Dde(t,e,r,o){let n=new Array(o),i=new E,s=new E,a=new E,c=new E,l=new ue,f=new Sr,u=new E,d={},h=new V,p=[],m=[],g=[],_=[];for(let x=0;x<o;x++){let y;if(e.hasProperty("POSITION"))y=e.getProperty("POSITION",ae.FLOAT,3,x,i);else if(e.hasProperty("POSITION_QUANTIZED")){y=e.getProperty("POSITION_QUANTIZED",ae.UNSIGNED_SHORT,3,x,i);let A=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",ae.FLOAT,3);if(!A)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let M=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",ae.FLOAT,3);if(!M)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let B=65535;for(let O=0;O<3;O++)y[O]=y[O]/B*M[O]+A[O]}if(!y)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");i.copy(y),d.translation=i,t.normalUp=e.getProperty("NORMAL_UP",ae.FLOAT,3,x,p),t.normalRight=e.getProperty("NORMAL_RIGHT",ae.FLOAT,3,x,m);let b=!1;if(t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",ae.UNSIGNED_SHORT,2,x,p),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",ae.UNSIGNED_SHORT,2,x,m),t.octNormalUp)throw t.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");t.eastNorthUp?(de.WGS84.eastNorthUpToFixedFrame(i,h),h.getRotationMatrix3(l)):l.identity()}b&&(c.copy(s).cross(a).normalize(),l.setColumn(0,s),l.setColumn(1,a),l.setColumn(2,c)),f.fromMatrix3(l),d.rotation=f,u.set(1,1,1);let T=e.getProperty("SCALE",ae.FLOAT,1,x,g);Number.isFinite(T)&&u.multiplyByScalar(T);let v=e.getProperty("SCALE_NON_UNIFORM",ae.FLOAT,3,x,p);v&&u.scale(v),d.scale=u;let w=e.getProperty("BATCH_ID",ae.UNSIGNED_SHORT,1,x,_);w===void 0&&(w=x);let C=new V().fromQuaternion(d.rotation);h.identity(),h.translate(d.translation),h.multiplyRight(C),h.scale(d.scale);let S=h.clone();n[x]={modelMatrix:S,batchId:w}}t.instances=n}async function A6(t,e,r,o,n,i){r=Bi(t,e,r);let s=new DataView(e);for(t.tilesLength=s.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&(t.byteLength||0)-r>12;){let a={shape:"tile3d"};t.tiles.push(a),r=await i(e,r,o,n,a)}return r}async function T6(t,e,r,o){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!o)return e.byteLength;let n=await nr(e,Pn,r,o);t.gltf=Xs(n),t.gpuMemoryUsageInBytes=ch(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function ME(t,e=0,r,o,n={shape:"tile3d"}){switch(n.byteOffset=e,n.type=s6(t,e),n.type){case qs.COMPOSITE:return await A6(n,t,e,r,o,ME);case qs.BATCHED_3D_MODEL:return await x6(n,t,e,r,o);case qs.GLTF:return await T6(n,t,r,o);case qs.INSTANCED_3D_MODEL:return await b6(n,t,e,r,o);case qs.POINT_CLOUD:return await y6(n,t,e,r,o);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}async function RE(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let i=v6(t.slice(8,16)),s=new Uint8Array(t,24,i),c=new TextDecoder("utf8").decode(s),l=JSON.parse(c),f=v6(t.slice(16,24)),u=new ArrayBuffer(0);if(f&&(u=t.slice(24+i)),await Ky(l,l.tileAvailability,u,r),Array.isArray(l.contentAvailability))for(let d of l.contentAvailability)await Ky(l,d,u,r);else await Ky(l,l.contentAvailability,u,r);return await Ky(l,l.childSubtreeAvailability,u,r),l}async function Ky(t,e,r,o){let n=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof n!="number")return;let i=t.bufferViews[n],s=t.buffers[i.buffer];if(!o?.baseUrl)throw new Error("Url is not provided");if(!o.fetch)throw new Error("fetch is not provided");if(s.uri){let c=`${o?.baseUrl||""}/${s.uri}`,f=await(await o.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(f,i.byteOffset,i.byteLength);return}let a=t.buffers.slice(0,i.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+s.byteLength),i.byteOffset,i.byteLength)}function v6(t){let e=new DataView(t),r=e.getUint32(0,!0),o=e.getUint32(4,!0);return r+2**32*o}var qy={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Wy,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:RE,options:{}};zn();var kr=null;try{kr=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Ie(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Ie.prototype.__isLong__;Object.defineProperty(Ie.prototype,"__isLong__",{value:!0});function Lt(t){return(t&&t.__isLong__)===!0}function S6(t){var e=Math.clz32(t&-t);return t?31-e:e}Ie.isLong=Lt;var C6={},E6={};function Js(t,e){var r,o,n;return e?(t>>>=0,(n=0<=t&&t<256)&&(o=E6[t],o)?o:(r=xe(t,0,!0),n&&(E6[t]=r),r)):(t|=0,(n=-128<=t&&t<128)&&(o=C6[t],o)?o:(r=xe(t,t<0?-1:0,!1),n&&(C6[t]=r),r))}Ie.fromInt=Js;function Vr(t,e){if(isNaN(t))return e?Ln:uo;if(e){if(t<0)return Ln;if(t>=R6)return B6}else{if(t<=-P6)return rr;if(t+1>=P6)return L6}return t<0?Vr(-t,e).neg():xe(t%fl|0,t/fl|0,e)}Ie.fromNumber=Vr;function xe(t,e,r){return new Ie(t,e,r)}Ie.fromBits=xe;var Zy=Math.pow;function LE(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?Ln:uo;if(r=r||10,r<2||36<r)throw RangeError("radix");var o;if((o=t.indexOf("-"))>0)throw Error("interior hyphen");if(o===0)return LE(t.substring(1),e,r).neg();for(var n=Vr(Zy(r,8)),i=uo,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),c=parseInt(t.substring(s,s+a),r);if(a<8){var l=Vr(Zy(r,a));i=i.mul(l).add(Vr(c))}else i=i.mul(n),i=i.add(Vr(c))}return i.unsigned=e,i}Ie.fromString=LE;function ho(t,e){return typeof t=="number"?Vr(t,e):typeof t=="string"?LE(t,e):xe(t.low,t.high,typeof e=="boolean"?e:t.unsigned)}Ie.fromValue=ho;var w6=1<<16,Ude=1<<24,fl=w6*w6,R6=fl*fl,P6=R6/2,M6=Js(Ude),uo=Js(0);Ie.ZERO=uo;var Ln=Js(0,!0);Ie.UZERO=Ln;var ll=Js(1);Ie.ONE=ll;var I6=Js(1,!0);Ie.UONE=I6;var IE=Js(-1);Ie.NEG_ONE=IE;var L6=xe(-1,2147483647,!1);Ie.MAX_VALUE=L6;var B6=xe(-1,-1,!0);Ie.MAX_UNSIGNED_VALUE=B6;var rr=xe(0,-2147483648,!1);Ie.MIN_VALUE=rr;var D=Ie.prototype;D.toInt=function(){return this.unsigned?this.low>>>0:this.low};D.toNumber=function(){return this.unsigned?(this.high>>>0)*fl+(this.low>>>0):this.high*fl+(this.low>>>0)};D.toString=function(e){if(e=e||10,e<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(rr)){var r=Vr(e),o=this.div(r),n=o.mul(r).sub(this);return o.toString(e)+n.toInt().toString(e)}else return"-"+this.neg().toString(e);for(var i=Vr(Zy(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),l=s.sub(c.mul(i)).toInt()>>>0,f=l.toString(e);if(s=c,s.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}};D.getHighBits=function(){return this.high};D.getHighBitsUnsigned=function(){return this.high>>>0};D.getLowBits=function(){return this.low};D.getLowBitsUnsigned=function(){return this.low>>>0};D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(rr)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<<r);r--);return this.high!=0?r+33:r+1};D.isZero=function(){return this.high===0&&this.low===0};D.eqz=D.isZero;D.isNegative=function(){return!this.unsigned&&this.high<0};D.isPositive=function(){return this.unsigned||this.high>=0};D.isOdd=function(){return(this.low&1)===1};D.isEven=function(){return(this.low&1)===0};D.equals=function(e){return Lt(e)||(e=ho(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};D.eq=D.equals;D.notEquals=function(e){return!this.eq(e)};D.neq=D.notEquals;D.ne=D.notEquals;D.lessThan=function(e){return this.comp(e)<0};D.lt=D.lessThan;D.lessThanOrEqual=function(e){return this.comp(e)<=0};D.lte=D.lessThanOrEqual;D.le=D.lessThanOrEqual;D.greaterThan=function(e){return this.comp(e)>0};D.gt=D.greaterThan;D.greaterThanOrEqual=function(e){return this.comp(e)>=0};D.gte=D.greaterThanOrEqual;D.ge=D.greaterThanOrEqual;D.compare=function(e){if(Lt(e)||(e=ho(e)),this.eq(e))return 0;var r=this.isNegative(),o=e.isNegative();return r&&!o?-1:!r&&o?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};D.comp=D.compare;D.negate=function(){return!this.unsigned&&this.eq(rr)?rr:this.not().add(ll)};D.neg=D.negate;D.add=function(e){Lt(e)||(e=ho(e));var r=this.high>>>16,o=this.high&65535,n=this.low>>>16,i=this.low&65535,s=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,f=0,u=0,d=0,h=0;return h+=i+l,d+=h>>>16,h&=65535,d+=n+c,u+=d>>>16,d&=65535,u+=o+a,f+=u>>>16,u&=65535,f+=r+s,f&=65535,xe(d<<16|h,f<<16|u,this.unsigned)};D.subtract=function(e){return Lt(e)||(e=ho(e)),this.add(e.neg())};D.sub=D.subtract;D.multiply=function(e){if(this.isZero())return this;if(Lt(e)||(e=ho(e)),kr){var r=kr.mul(this.low,this.high,e.low,e.high);return xe(r,kr.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Ln:uo;if(this.eq(rr))return e.isOdd()?rr:uo;if(e.eq(rr))return this.isOdd()?rr:uo;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(M6)&&e.lt(M6))return Vr(this.toNumber()*e.toNumber(),this.unsigned);var o=this.high>>>16,n=this.high&65535,i=this.low>>>16,s=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,f=e.low&65535,u=0,d=0,h=0,p=0;return p+=s*f,h+=p>>>16,p&=65535,h+=i*f,d+=h>>>16,h&=65535,h+=s*l,d+=h>>>16,h&=65535,d+=n*f,u+=d>>>16,d&=65535,d+=i*l,u+=d>>>16,d&=65535,d+=s*c,u+=d>>>16,d&=65535,u+=o*f+n*l+i*c+s*a,u&=65535,xe(h<<16|p,u<<16|d,this.unsigned)};D.mul=D.multiply;D.divide=function(e){if(Lt(e)||(e=ho(e)),e.isZero())throw Error("division by zero");if(kr){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?kr.div_u:kr.div_s)(this.low,this.high,e.low,e.high);return xe(r,kr.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Ln:uo;var o,n,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Ln;if(e.gt(this.shru(1)))return I6;i=Ln}else{if(this.eq(rr)){if(e.eq(ll)||e.eq(IE))return rr;if(e.eq(rr))return ll;var s=this.shr(1);return o=s.div(e).shl(1),o.eq(uo)?e.isNegative()?ll:IE:(n=this.sub(e.mul(o)),i=o.add(n.div(e)),i)}else if(e.eq(rr))return this.unsigned?Ln:uo;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=uo}for(n=this;n.gte(e);){o=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(o)/Math.LN2),c=a<=48?1:Zy(2,a-48),l=Vr(o),f=l.mul(e);f.isNegative()||f.gt(n);)o-=c,l=Vr(o,this.unsigned),f=l.mul(e);l.isZero()&&(l=ll),i=i.add(l),n=n.sub(f)}return i};D.div=D.divide;D.modulo=function(e){if(Lt(e)||(e=ho(e)),kr){var r=(this.unsigned?kr.rem_u:kr.rem_s)(this.low,this.high,e.low,e.high);return xe(r,kr.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};D.mod=D.modulo;D.rem=D.modulo;D.not=function(){return xe(~this.low,~this.high,this.unsigned)};D.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};D.clz=D.countLeadingZeros;D.countTrailingZeros=function(){return this.low?S6(this.low):S6(this.high)+32};D.ctz=D.countTrailingZeros;D.and=function(e){return Lt(e)||(e=ho(e)),xe(this.low&e.low,this.high&e.high,this.unsigned)};D.or=function(e){return Lt(e)||(e=ho(e)),xe(this.low|e.low,this.high|e.high,this.unsigned)};D.xor=function(e){return Lt(e)||(e=ho(e)),xe(this.low^e.low,this.high^e.high,this.unsigned)};D.shiftLeft=function(e){return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):xe(0,this.low<<e-32,this.unsigned)};D.shl=D.shiftLeft;D.shiftRight=function(e){return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):xe(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};D.shr=D.shiftRight;D.shiftRightUnsigned=function(e){return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?xe(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?xe(this.high,0,this.unsigned):xe(this.high>>>e-32,0,this.unsigned)};D.shru=D.shiftRightUnsigned;D.shr_u=D.shiftRightUnsigned;D.rotateLeft=function(e){var r;return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?xe(this.high,this.low,this.unsigned):e<32?(r=32-e,xe(this.low<<e|this.high>>>r,this.high<<e|this.low>>>r,this.unsigned)):(e-=32,r=32-e,xe(this.high<<e|this.low>>>r,this.low<<e|this.high>>>r,this.unsigned))};D.rotl=D.rotateLeft;D.rotateRight=function(e){var r;return Lt(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?xe(this.high,this.low,this.unsigned):e<32?(r=32-e,xe(this.high<<r|this.low>>>e,this.low<<r|this.high>>>e,this.unsigned)):(e-=32,r=32-e,xe(this.low<<r|this.high>>>e,this.high<<r|this.low>>>e,this.unsigned))};D.rotr=D.rotateRight;D.toSigned=function(){return this.unsigned?xe(this.low,this.high,!1):this};D.toUnsigned=function(){return this.unsigned?this:xe(this.low,this.high,!0)};D.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};D.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};D.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Ie.fromBytes=function(e,r,o){return o?Ie.fromBytesLE(e,r):Ie.fromBytesBE(e,r)};Ie.fromBytesLE=function(e,r){return new Ie(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Ie.fromBytesBE=function(e,r){return new Ie(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var ul=Ie;var kde=16;function bh(t){t==="X"&&(t="");let e=t.padEnd(kde,"0");return ul.fromString(e,!0,16)}function BE(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let o=e;e*=4;let i=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-o-i.length).join("0")+i}function OE(t,e){let r=Vde(t).shiftRightUnsigned(2);return t.add(ul.fromNumber(2*e+1-4).multiply(r))}function Vde(t){return t.and(t.not().add(1))}var zde=3,Hde=30,jde=2*Hde+1,O6=180/Math.PI;function N6(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),o=e[1],n=o.length,i=0,s=[0,0];for(let a=n-1;a>=0;a--){i=n-a;let c=o[a],l=0,f=0;c==="1"?f=1:c==="2"?(l=1,f=1):c==="3"&&(l=1);let u=Math.pow(2,i-1);Wde(u,s,l,f),s[0]+=u*l,s[1]+=u*f}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:i}}function D6(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length<zde+jde;)e="0"+e;let r=e.lastIndexOf("1"),o=e.substring(0,3),n=e.substring(3,r),i=n.length/2,s=ul.fromString(o,!0,2).toString(10),a="";if(i!==0)for(a=ul.fromString(n,!0,2).toString(4);a.length<i;)a="0"+a;return`${s}/${a}`}function FE(t,e,r){let o=1<<e;return[(t[0]+r[0])/o,(t[1]+r[1])/o]}function F6(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function NE(t){return[F6(t[0]),F6(t[1])]}function DE(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function UE([t,e,r]){let o=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*O6,o*O6]}function Wde(t,e,r,o){if(o===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let n=e[0];e[0]=e[1],e[1]=n}}function U6(t){let e=FE(t.ij,t.level,[.5,.5]),r=NE(e),o=DE(t.face,r);return UE(o)}var Gde=100;function kE(t){let{face:e,ij:r,level:o}=t,n=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(Gde*Math.pow(2,-o))),s=new Float64Array(4*i*2+2),a=0,c=0;for(let l=0;l<4;l++){let f=n[l].slice(0),u=n[l+1],d=(u[0]-f[0])/i,h=(u[1]-f[1])/i;for(let p=0;p<i;p++){f[0]+=d,f[1]+=h;let m=FE(r,o,f),g=NE(m),_=DE(e,g),x=UE(_);Math.abs(x[1])>89.999&&(x[0]=c);let y=x[0]-c;x[0]+=y>180?-360:y<-180?360:0,s[a++]=x[0],s[a++]=x[1],c=x[0]}}return s[a++]=s[0],s[a++]=s[1],s}function dl(t){let e=$de(t);return N6(e)}function $de(t){if(t.indexOf("/")>0)return t;let e=bh(t);return D6(e)}function VE(t){let e=dl(t);return U6(e)}function V6(t){let e;if(t.face===2||t.face===5){let r=null,o=0;for(let n=0;n<4;n++){let i=`${t.face}/${n}`,s=dl(i),a=kE(s);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,o),o+=a.length}e=k6(r)}else{let r=kE(t);e=k6(r)}return e}function k6(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let o=0;o<t.length;o+=2)e.push(t[o]),r.push(t[o+1]);return e.sort((o,n)=>o-n),r.sort((o,n)=>o-n),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function zE(t,e){let r=e?.minimumHeight||0,o=e?.maximumHeight||0,n=dl(t),i=V6(n),s=i.west,a=i.south,c=i.east,l=i.north,f=[];return f.push(new E(s,l,r)),f.push(new E(c,l,r)),f.push(new E(c,a,r)),f.push(new E(s,a,r)),f.push(new E(s,l,o)),f.push(new E(c,l,o)),f.push(new E(c,a,o)),f.push(new E(s,a,o)),f}function Jy(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},o=zE(e,r),n=VE(e),i=n[0],s=n[1],a=de.WGS84.cartographicToCartesian([i,s,r.maximumHeight]),c=new E(a[0],a[1],a[2]);o.push(c);let l=th(o);return[...l.center,...l.halfAxes]}var Xde=4,Yde=8,Kde={QUADTREE:Xde,OCTREE:Yde};function qde(t,e,r){if(t?.box){let o=bh(t.s2VolumeInfo.token),n=OE(o,e),i=BE(n),s={...t.s2VolumeInfo};switch(s.token=i,r){case"OCTREE":let l=t.s2VolumeInfo,f=l.maximumHeight-l.minimumHeight,u=f/2,d=l.minimumHeight+f/2;l.minimumHeight=d-u,l.maximumHeight=d+u;break;default:break}return{box:Jy(s),s2VolumeInfo:s}}}async function jE(t){let{subtree:e,subtreeData:r={level:0,x:0,y:0,z:0},parentData:o={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:n=0,implicitOptions:i,loaderOptions:s,s2VolumeBox:a}=t,{subdivisionScheme:c,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:u,subtreesUriTemplate:d,basePath:h}=i,p={children:[],lodMetricValue:0,contentUrl:""};if(!f)return Eb.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),p;let m=o.localLevel+1,g=r.level+m;if(g>f)return p;let _=Kde[c],x=Math.log2(_),y=n&1,b=n>>1&1,T=n>>2&1,v=Qs(o.localX,y,1),w=Qs(o.localY,b,1),C=Qs(o.localZ,T,1),S=Qs(r.x,v,m),A=Qs(r.y,w,m),M=Qs(r.z,C,m),B=Qs(o.mortonIndex,n,x),O=m===l&&HE(e.childSubtreeAvailability,B),F,X,G,j;if(O){let pe=`${h}/${d}`,U=Qy(pe,g,S,A,M);F=await _r(U,qy,s),j=0,X={level:g,x:S,y:A,z:M},G={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else F=e,j=(_**m-1)/(_-1)+B,X=r,G={mortonIndex:B,localLevel:m,localX:v,localY:w,localZ:C};if(!HE(F.tileAvailability,j))return p;HE(F.contentAvailability,j)&&(p.contentUrl=Qy(u,g,S,A,M));for(let pe=0;pe<_;pe++){let U=qde(a,pe,c),re=await jE({subtree:F,subtreeData:X,parentData:G,childIndex:pe,implicitOptions:i,loaderOptions:s,s2VolumeBox:U});(re.contentUrl||re.children.length)&&p.children.push(re)}return p.contentUrl||p.children.length?Zde(p,{level:g,x:S,y:A,z:M},i,a):p}function HE(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&Eb.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?Boolean(r.constant):r.explicitBitstream?ehe(e,r.explicitBitstream):!1}function Zde(t,e,r,o){let{basePath:n,refine:i,getRefine:s,lodMetricType:a,getTileType:c,rootLodMetricValue:l,rootBoundingVolume:f}=r,u=t.contentUrl&&t.contentUrl.replace(`${n}/`,""),d=l/2**e.level,h=o?.box?{box:o.box}:f,p=Jde(h,e,r.subdivisionScheme);return{children:t.children,contentUrl:t.contentUrl,content:{uri:u},id:t.contentUrl,refine:s(i),type:c(t),lodMetricType:a,lodMetricValue:d,geometricError:d,transform:t.transform,boundingVolume:p}}function Jde(t,e,r){if(t.region){let{level:o,x:n,y:i,z:s}=e,[a,c,l,f,u,d]=t.region,h=2**o,p=(l-a)/h,[m,g]=[a+p*n,a+p*(n+1)],_=(f-c)/h,[x,y]=[c+_*i,c+_*(i+1)],b,T;if(r==="OCTREE"){let v=(d-u)/h;[b,T]=[u+v*s,u+v*(s+1)]}else[b,T]=[u,d];return{region:[m,x,g,y,b,T]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function Qs(t,e,r){return(t<<r)+e}function Qy(t,e,r,o,n){let i=Qde({level:e,x:r,y:o,z:n});return t.replace(/{level}|{x}|{y}|{z}/gi,s=>i[s])}function Qde(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function ehe(t,e){let r=Math.floor(t/8),o=t%8;return(e[r]>>o&1)===1}function GE(t,e=""){if(!e)return Ur.EMPTY;let o=e.split("?")[0].split(".").pop();switch(o){case"pnts":return Ur.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Ur.SCENEGRAPH;default:return o||Ur.EMPTY}}function $E(t){switch(t){case"REPLACE":case"replace":return Rt.REPLACE;case"ADD":case"add":return Rt.ADD;default:return t}}function WE(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let o=new URL(t,`${e}/`);return decodeURI(o.toString())}else if(t.startsWith("/"))return t;return Ft.resolve(e,t)}function z6(t,e){if(!t)return null;let r;if(t.content){let n=t.content.uri||t.content?.url;typeof n<"u"&&(r=WE(n,e))}return{...t,id:r,contentUrl:r,lodMetricType:Rn.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:GE(t,r),refine:$E(t.refine)}}async function W6(t,e,r){let o=null,n=j6(t.root);n&&t.root?o=await H6(t.root,t,e,n,r):o=z6(t.root,e);let i=[];for(i.push(o);i.length>0;){let s=i.pop()||{},a=s.children||[],c=[];for(let l of a){let f=j6(l),u;f?u=await H6(l,t,e,f,r):u=z6(l,e),u&&(c.push(u),i.push(u))}s.children=c}return o}async function H6(t,e,r,o,n){let{subdivisionScheme:i,maximumLevel:s,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=o,f=Qy(l,0,0,0,0),u=WE(f,r),d=await _r(u,qy,n),h=t.content?.uri,p=h?WE(h,r):"",m=e?.root?.refine,g=t.geometricError,_=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(_){let T={box:Jy(_),s2VolumeInfo:_};t.boundingVolume=T}let x=t.boundingVolume,y={contentUrlTemplate:p,subtreesUriTemplate:l,subdivisionScheme:i,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:s,refine:m,basePath:r,lodMetricType:Rn.GEOMETRIC_ERROR,rootLodMetricValue:g,rootBoundingVolume:x,getTileType:GE,getRefine:$E};return await the(t,r,d,y,n)}async function the(t,e,r,o,n){if(!t)return null;let{children:i,contentUrl:s}=await jE({subtree:r,implicitOptions:o,loaderOptions:n}),a,c=null;return s&&(a=s,c={uri:s.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:Rn.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:GE(t,a),refine:$E(t.refine),content:c||t.content,children:i}}function j6(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var ex={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Wy,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:rhe,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function rhe(t,e={},r){let o=e["3d-tiles"]||{},n;return o.isTileset==="auto"?n=r?.url&&r.url.indexOf(".json")!==-1:n=o.isTileset,n?ohe(t,e,r):nhe(t,e,r)}async function ohe(t,e,r){let o=JSON.parse(new TextDecoder().decode(t)),n=r?.url||"",i=ihe(n),s=await W6(o,i,e||{});return{...o,shape:"tileset3d",loader:ex,url:n,queryString:r?.queryString||"",basePath:i,root:s||o.root,type:_t.TILES3D,lodMetricType:Rn.GEOMETRIC_ERROR,lodMetricValue:o.root?.geometricError||0}}async function nhe(t,e,r){let o={content:{shape:"tile3d",featureIds:null}};return await ME(t,0,e,r,o.content),o.content}function ihe(t){return Ft.dirname(t)}var G6=[0],she={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:ex,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},Ah=class extends Ne{initializeState(){"onTileLoadFail"in this.props&&N.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:o}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),o.viewportChanged){let{activeViewports:n}=this.state;Object.keys(n).length&&(this._updateTileset(n),this.state.lastUpdatedViewports=n,this.state.activeViewports={})}if(o.propsChanged){let{layerMap:n}=this.state;for(let i in n)n[i].needsUpdate=!0}}finalizeState(e){this.state.tileset3d?.destroy(),this.state.tileset3d=null,this.state.layerMap={},this.state.activeViewports={},this.state.lastUpdatedViewports=null,super.finalizeState(e)}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:o}=this.state;this.internalState.viewport=e,r[e.id]=e;let n=o?.[e.id];(!n||!e.equals(n))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let o=r&&r.props.tile;return e.picked&&(e.object=o),e.sourceTile=o,e}filterSubLayer({layer:e,viewport:r,cullRect:o,isPicking:n}){let{tile:i}=e.props,{id:s}=r;if(!i.selected||!i.viewportIds.includes(s))return!1;if(n&&o&&i.content?.cartographicOrigin){let[a,c]=r.project(i.content.cartographicOrigin),l=o.x+o.width/2,f=o.y+o.height/2,u=Math.max(r.width,r.height)/4,d=a-l,h=c-f;if(d*d+h*h>u*u)return!1}return!0}_updateAutoHighlight(e){let r=e.sourceTile,o=this.state.layerMap[r?.id];o&&o.layer&&o.layer.updateAutoHighlight(e)}async _loadTileset(e){let r=this.props.loadOptions||{},o=this.props.loaders?.length?this.props.loaders:this.props.loader,n=Array.isArray(o)?o[0]:o,{tileset:i,...s}=r,a={loadOptions:{...s},...i},c=e;if("preload"in n&&typeof n.preload=="function"){let u=await n.preload(e,r);u.url&&(c=u.url),u.headers&&(a.loadOptions.core={...a.loadOptions.core,fetch:{...a.loadOptions.core?.fetch,headers:u.headers}}),Object.assign(a,u)}let l=await _r(c,n,a.loadOptions),f=new xh(l,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...a});this.setState({tileset3d:f,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(f)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:o}=this.context,n=Object.keys(e).length;!o||!n||!r||r.selectTiles(Object.values(e)).then(i=>{this.state.frameNumber!==i&&this.setState({frameNumber:i})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case Ur.POINTCLOUD:return this._makePointCloudLayer(e,r);case Ur.SCENEGRAPH:return this._make3DModelLayer(e);case Ur.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:o,pointCount:n,constantRGBA:i,cartographicOrigin:s,modelMatrix:a}=e.content,{positions:c,normals:l,colors:f}=o;if(!c)return null;let u=r&&r.props.data||{header:{vertexCount:n},attributes:{POSITION:c,NORMAL:l,COLOR_0:f}},{pointSize:d,getPointColor:h}=this.props,p=this.getSubLayerClass("pointcloud",e0);return new p({pointSize:d},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:Be.METER_OFFSETS,coordinateOrigin:s,modelMatrix:a,getColor:i||h,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:o,cartographicOrigin:n,modelMatrix:i}=e.content,s=this.getSubLayerClass("scenegraph",My);return new s({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:o||G6,scenegraph:r,coordinateSystem:Be.METER_OFFSETS,coordinateOrigin:n,modelMatrix:i,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,r){let o=e.content,{attributes:n,indices:i,modelMatrix:s,cartographicOrigin:a,coordinateSystem:c=Be.METER_OFFSETS,material:l,featureIds:f}=o,{_getMeshColor:u}=this.props,d=r&&r.props.mesh||new ce({topology:"triangle-list",attributes:ahe(n),indices:i}),h=this.getSubLayerClass("mesh",vk);return new h(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:d,data:G6,getColor:u(e),pbrMaterial:l,modelMatrix:s,coordinateOrigin:a,coordinateSystem:c,featureIds:f,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(o=>{let n=r[o.id]=r[o.id]||{tile:o},{layer:i}=n;return o.selected&&(i?n.needsUpdate&&(i=this._getSubLayer(o,i),n.needsUpdate=!1):i=this._getSubLayer(o)),n.layer=i,i}).filter(Boolean):null}};Ah.defaultProps=she;Ah.layerName="Tile3DLayer";var $6=Ah;function ahe(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var che=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function XE(t){return t>>1^-(t&1)}function lhe(t){let e=0,r={};for(let[o,n]of che){let i=n===8?t.getFloat64:t.getFloat32;r[o]=i.call(t,e,!0),e+=n}return{header:r,headerEndPosition:e}}function fhe(t,e){let r=e,o=3,n=t.getUint32(r,!0),i=new Uint16Array(n*o);r+=Uint32Array.BYTES_PER_ELEMENT;let s=Uint16Array.BYTES_PER_ELEMENT,a=n*s,c=r,l=c+a,f=l+a,u=0,d=0,h=0;for(let p=0;p<n;p++)u+=XE(t.getUint16(c+s*p,!0)),d+=XE(t.getUint16(l+s*p,!0)),h+=XE(t.getUint16(f+s*p,!0)),i[p]=u,i[p+n]=d,i[p+n*2]=h;return r+=a*3,{vertexData:i,vertexDataEndPosition:r}}function Th(t,e,r,o,n=!0){let i;if(o===2?i=new Uint16Array(t,e,r):i=new Uint32Array(t,e,r),!n)return i;let s=0;for(let a=0;a<i.length;++a){let c=i[a];i[a]=s-c,c===0&&++s}return i}function uhe(t,e,r){let o=r,n=3,s=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;o%s!==0&&(o+=s-o%s);let a=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=Th(t.buffer,o,c,s);return o+=c*s,{triangleIndicesEndPosition:o,triangleIndices:l}}function dhe(t,e,r){let o=r,n=3,s=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let c=Th(t.buffer,o,a,s,!1);o+=a*s;let l=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let f=Th(t.buffer,o,l,s,!1);o+=l*s;let u=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let d=Th(t.buffer,o,u,s,!1);o+=u*s;let h=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let p=Th(t.buffer,o,h,s,!1);return o+=h*s,{edgeIndicesEndPosition:o,westIndices:c,southIndices:f,eastIndices:d,northIndices:p}}function hhe(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function phe(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function mhe(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let o=e;for(;o<t.byteLength;){let n=t.getUint8(o,!0);o+=Uint8Array.BYTES_PER_ELEMENT;let i=t.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;let s=new DataView(t.buffer,o,i);switch(n){case 1:{r.vertexNormals=hhe(s);break}case 2:{r.waterMask=phe(s);break}default:}o+=i}return{extensions:r,extensionsEndPosition:o}}var ea={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},ghe={maxDecodingStep:ea.extensions};function YE(t,e){let r=Object.assign({},ghe,e),o=new DataView(t),{header:n,headerEndPosition:i}=lhe(o);if(r.maxDecodingStep<ea.vertices)return{header:n};let{vertexData:s,vertexDataEndPosition:a}=fhe(o,i);if(r.maxDecodingStep<ea.triangleIndices)return{header:n,vertexData:s};let{triangleIndices:c,triangleIndicesEndPosition:l}=uhe(o,s,a);if(r.maxDecodingStep<ea.edgeIndices)return{header:n,vertexData:s,triangleIndices:c};let{westIndices:f,southIndices:u,eastIndices:d,northIndices:h,edgeIndicesEndPosition:p}=dhe(o,s,l);if(r.maxDecodingStep<ea.extensions)return{header:n,vertexData:s,triangleIndices:c,westIndices:f,northIndices:h,eastIndices:d,southIndices:u};let{extensions:m}=mhe(o,p);return{header:n,vertexData:s,triangleIndices:c,westIndices:f,northIndices:h,eastIndices:d,southIndices:u,extensions:m}}function tx(t,e,r,o){let n=o?yhe(o,t.POSITION.value):_he(e),i=new t.POSITION.value.constructor(n.length*6),s=new t.TEXCOORD_0.value.constructor(n.length*4),a=new e.constructor(n.length*6);for(let l=0;l<n.length;l++){let f=n[l];xhe({edge:f,edgeIndex:l,attributes:t,skirtHeight:r,newPosition:i,newTexcoord0:s,newTriangles:a})}t.POSITION.value=ql(t.POSITION.value,i),t.TEXCOORD_0.value=ql(t.TEXCOORD_0.value,s);let c=e instanceof Array?e.concat(a):ql(e,a);return{attributes:t,triangles:c}}function _he(t){let e=[];for(let n=0;n<t.length;n+=3)e.push([t[n],t[n+1]]),e.push([t[n+1],t[n+2]]),e.push([t[n+2],t[n]]);e.sort((n,i)=>Math.min(...n)-Math.min(...i)||Math.max(...n)-Math.max(...i));let r=[],o=0;for(;o<e.length;)e[o][0]===e[o+1]?.[1]&&e[o][1]===e[o+1]?.[0]?o+=2:(r.push(e[o]),o++);return r}function yhe(t,e){t.westIndices.sort((o,n)=>e[3*o+1]-e[3*n+1]),t.eastIndices.sort((o,n)=>e[3*n+1]-e[3*o+1]),t.southIndices.sort((o,n)=>e[3*n]-e[3*o]),t.northIndices.sort((o,n)=>e[3*o]-e[3*n]);let r=[];for(let o in t){let n=t[o];for(let i=0;i<n.length-1;i++)r.push([n[i],n[i+1]])}return r}function xhe({edge:t,edgeIndex:e,attributes:r,skirtHeight:o,newPosition:n,newTexcoord0:i,newTriangles:s}){let a=r.POSITION.value.length,c=e*2,l=e*2+1;n.set(r.POSITION.value.subarray(t[0]*3,t[0]*3+3),c*3),n[c*3+2]=n[c*3+2]-o,n.set(r.POSITION.value.subarray(t[1]*3,t[1]*3+3),l*3),n[l*3+2]=n[l*3+2]-o,i.set(r.TEXCOORD_0.value.subarray(t[0]*2,t[0]*2+2),c*2),i.set(r.TEXCOORD_0.value.subarray(t[1]*2,t[1]*2+2),l*2);let f=e*2*3;s[f]=t[0],s[f+1]=a/3+l,s[f+2]=t[1],s[f+3]=a/3+l,s[f+4]=t[0],s[f+5]=a/3+c}function KE(t,e={}){let{bounds:r}=e,{header:o,vertexData:n,triangleIndices:i,westIndices:s,northIndices:a,eastIndices:c,southIndices:l}=YE(t,ea.triangleIndices),f=i,u=bhe(n,o,r),d=Ki(u);if(e?.skirtHeight){let{attributes:h,triangles:p}=tx(u,f,e.skirtHeight,{westIndices:s,northIndices:a,eastIndices:c,southIndices:l});u=h,f=p}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:d},schema:void 0,topology:"triangle-list",mode:4,indices:{value:f,size:1},attributes:u}}function bhe(t,e,r){let{minHeight:o,maxHeight:n}=e,[i,s,a,c]=r||[0,0,1,1],l=a-i,f=c-s,u=n-o,d=t.length/3,h=new Float32Array(d*3),p=new Float32Array(d*2);for(let m=0;m<d;m++){let g=t[m]/32767,_=t[m+d]/32767,x=t[m+d*2]/32767;h[3*m+0]=g*l+i,h[3*m+1]=_*f+s,h[3*m+2]=x*u+o,p[2*m+0]=g,p[2*m+1]=_}return{POSITION:{value:h,size:3},TEXCOORD_0:{value:p,size:2}}}var vh=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let o=0;o<this.numTriangles;o++){let n=o+2,i=0,s=0,a=0,c=0,l=0,f=0;for(n&1?a=c=l=r:i=s=f=r;(n>>=1)>1;){let d=i+a>>1,h=s+c>>1;n&1?(a=i,c=s,i=l,s=f):(i=a,s=c,a=l,c=f),l=d,f=h}let u=o*4;this.coords[u+0]=i,this.coords[u+1]=s,this.coords[u+2]=a,this.coords[u+3]=c}}createTile(e){return new qE(e,this)}},qE=class{constructor(e,r){let o=r.gridSize;if(e.length!==o*o)throw new Error(`Expected terrain data of length ${o*o} (${o} x ${o}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:o,gridSize:n}=this.martini,{terrain:i,errors:s}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=o[c+0],f=o[c+1],u=o[c+2],d=o[c+3],h=l+u>>1,p=f+d>>1,m=h+p-f,g=p+l-h,_=(i[f*n+l]+i[d*n+u])/2,x=p*n+h,y=Math.abs(_-i[x]);if(s[x]=Math.max(s[x],y),a<r){let b=(f+g>>1)*n+(l+m>>1),T=(d+g>>1)*n+(u+m>>1);s[x]=Math.max(s[x],s[b],s[T])}}}getMesh(e=0){let{gridSize:r,indices:o}=this.martini,{errors:n}=this,i=0,s=0,a=r-1;o.fill(0);function c(h,p,m,g,_,x){let y=h+m>>1,b=p+g>>1;Math.abs(h-_)+Math.abs(p-x)>1&&n[b*r+y]>e?(c(_,x,h,p,y,b),c(m,g,_,x,y,b)):(o[p*r+h]=o[p*r+h]||++i,o[g*r+m]=o[g*r+m]||++i,o[x*r+_]=o[x*r+_]||++i,s++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(i*2),f=new Uint32Array(s*3),u=0;function d(h,p,m,g,_,x){let y=h+m>>1,b=p+g>>1;if(Math.abs(h-_)+Math.abs(p-x)>1&&n[b*r+y]>e)d(_,x,h,p,y,b),d(m,g,_,x,y,b);else{let T=o[p*r+h]-1,v=o[g*r+m]-1,w=o[x*r+_]-1;l[2*T]=h,l[2*T+1]=p,l[2*v]=m,l[2*v+1]=g,l[2*w]=_,l[2*w+1]=x,f[u++]=T,f[u++]=v,f[u++]=w}}return d(0,0,a,a,a,0),d(a,a,0,0,0,a),{vertices:l,triangles:f}}};var Sh=class{constructor(e,r,o=r){this.data=e,this.width=r,this.height=o,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let n=r-1,i=o-1,s=this._addPoint(0,0),a=this._addPoint(n,0),c=this._addPoint(0,i),l=this._addPoint(n,i),f=this._addTriangle(l,s,c,-1,-1,-1);this._addTriangle(s,l,a,f,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let o=this._pending[r],n=2*this.triangles[o*3+0],i=2*this.triangles[o*3+1],s=2*this.triangles[o*3+2];this._findCandidate(e[n],e[n+1],e[i],e[i+1],e[s],e[s+1],o)}this._pendingLen=0}_findCandidate(e,r,o,n,i,s,a){let c=Math.min(e,o,i),l=Math.min(r,n,s),f=Math.max(e,o,i),u=Math.max(r,n,s),d=ta(o,n,i,s,c,l),h=ta(i,s,e,r,c,l),p=ta(e,r,o,n,c,l),m=n-r,g=e-o,_=s-n,x=o-i,y=r-s,b=i-e,T=ta(e,r,o,n,i,s),v=this.heightAt(e,r)/T,w=this.heightAt(o,n)/T,C=this.heightAt(i,s)/T,S=0,A=0,M=0,B=0;for(let O=l;O<=u;O++){let F=0;d<0&&_!==0&&(F=Math.max(F,Math.floor(-d/_))),h<0&&y!==0&&(F=Math.max(F,Math.floor(-h/y))),p<0&&m!==0&&(F=Math.max(F,Math.floor(-p/m)));let X=d+_*F,G=h+y*F,j=p+m*F,se=!1;for(let ne=c+F;ne<=f;ne++){if(X>=0&&G>=0&&j>=0){se=!0;let pe=v*X+w*G+C*j,U=Math.abs(pe-this.heightAt(ne,O));B+=U*U,U>S&&(S=U,A=ne,M=O)}else if(se)break;X+=_,G+=y,j+=m}d+=x,h+=b,p+=g}(A===e&&M===r||A===o&&M===n||A===i&&M===s)&&(S=0),this._candidates[2*a]=A,this._candidates[2*a+1]=M,this._rms[a]=B,this._queuePush(a,S,B)}_step(){let e=this._queuePop(),r=e*3+0,o=e*3+1,n=e*3+2,i=this.triangles[r],s=this.triangles[o],a=this.triangles[n],c=this.coords[2*i],l=this.coords[2*i+1],f=this.coords[2*s],u=this.coords[2*s+1],d=this.coords[2*a],h=this.coords[2*a+1],p=this._candidates[2*e],m=this._candidates[2*e+1],g=this._addPoint(p,m);if(ta(c,l,f,u,p,m)===0)this._handleCollinear(g,r);else if(ta(f,u,d,h,p,m)===0)this._handleCollinear(g,o);else if(ta(d,h,c,l,p,m)===0)this._handleCollinear(g,n);else{let _=this._halfedges[r],x=this._halfedges[o],y=this._halfedges[n],b=this._addTriangle(i,s,g,_,-1,-1,r),T=this._addTriangle(s,a,g,x,-1,b+1),v=this._addTriangle(a,i,g,y,b+2,T+1);this._legalize(b),this._legalize(T),this._legalize(v)}}_addPoint(e,r){let o=this.coords.length>>1;return this.coords.push(e,r),o}_addTriangle(e,r,o,n,i,s,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=o,this._halfedges[a+0]=n,this._halfedges[a+1]=i,this._halfedges[a+2]=s,n>=0&&(this._halfedges[n]=a+0),i>=0&&(this._halfedges[i]=a+1),s>=0&&(this._halfedges[s]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let o=e-e%3,n=r-r%3,i=o+(e+1)%3,s=o+(e+2)%3,a=n+(r+2)%3,c=n+(r+1)%3,l=this.triangles[s],f=this.triangles[e],u=this.triangles[i],d=this.triangles[a],h=this.coords;if(!Ahe(h[2*l],h[2*l+1],h[2*f],h[2*f+1],h[2*u],h[2*u+1],h[2*d],h[2*d+1]))return;let p=this._halfedges[i],m=this._halfedges[s],g=this._halfedges[a],_=this._halfedges[c];this._queueRemove(o/3),this._queueRemove(n/3);let x=this._addTriangle(l,d,u,-1,g,p,o),y=this._addTriangle(d,l,f,x,m,_,n);this._legalize(x+1),this._legalize(y+2)}_handleCollinear(e,r){let o=r-r%3,n=o+(r+1)%3,i=o+(r+2)%3,s=this.triangles[i],a=this.triangles[r],c=this.triangles[n],l=this._halfedges[n],f=this._halfedges[i],u=this._halfedges[r];if(u<0){let v=this._addTriangle(e,s,a,-1,f,-1,o),w=this._addTriangle(s,e,c,v,-1,l);this._legalize(v+1),this._legalize(w+2);return}let d=u-u%3,h=d+(u+2)%3,p=d+(u+1)%3,m=this.triangles[h],g=this._halfedges[h],_=this._halfedges[p];this._queueRemove(d/3);let x=this._addTriangle(s,a,e,f,-1,-1,o),y=this._addTriangle(a,m,e,_,-1,x+1,d),b=this._addTriangle(m,c,e,g,-1,y+1),T=this._addTriangle(c,s,e,l,x+2,b+1);this._legalize(x),this._legalize(y),this._legalize(b),this._legalize(T)}_queuePush(e,r,o){let n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(r),this._rmsSum+=o,this._queueUp(n)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let n=this._pending.indexOf(e);if(n!==-1)this._pending[n]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let o=this._queue.length-1;o!==r&&(this._queueSwap(r,o),this._queueDown(r,o)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let o=this._queue[e],n=this._queue[r];this._queue[e]=n,this._queue[r]=o,this._queueIndices[o]=r,this._queueIndices[n]=e;let i=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=i}_queueUp(e){let r=e;for(;;){let o=r-1>>1;if(o===r||!this._queueLess(r,o))break;this._queueSwap(o,r),r=o}}_queueDown(e,r){let o=e;for(;;){let n=2*o+1;if(n>=r||n<0)break;let i=n+1,s=n;if(i<r&&this._queueLess(i,n)&&(s=i),!this._queueLess(s,o))break;this._queueSwap(o,s),o=s}return o>e}};function ta(t,e,r,o,n,i){return(r-n)*(e-i)-(o-i)*(t-n)}function Ahe(t,e,r,o,n,i,s,a){let c=t-s,l=e-a,f=r-s,u=o-a,d=n-s,h=i-a,p=c*c+l*l,m=f*f+u*u,g=d*d+h*h;return c*(u*g-m*h)-l*(f*g-m*d)+p*(f*h-u*d)<0}function K6(t,e){let{meshMaxError:r,bounds:o,elevationDecoder:n}=e,{data:i,width:s,height:a}=t,c,l;switch(e.tesselator){case"martini":c=rx(i,s,a,n,e.tesselator),l=X6(r,s,c);break;case"delatin":c=rx(i,s,a,n,e.tesselator),l=Y6(r,s,a,c);break;default:s===a&&!(a&s-1)?(c=rx(i,s,a,n,"martini"),l=X6(r,s,c)):(c=rx(i,s,a,n,"delatin"),l=Y6(r,s,a,c));break}let{vertices:f}=l,{triangles:u}=l,d=The(f,c,s,a,o),h=Ki(d);if(e.skirtHeight){let{attributes:p,triangles:m}=tx(d,u,e.skirtHeight);d=p,u=m}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:h},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:d}}function X6(t,e,r){let o=e+1,i=new vh(o).createTile(r),{vertices:s,triangles:a}=i.getMesh(t);return{vertices:s,triangles:a}}function Y6(t,e,r,o){let n=new Sh(o,e+1,r+1);n.run(t);let{coords:i,triangles:s}=n;return{vertices:i,triangles:s}}function rx(t,e,r,o,n){let{rScaler:i,bScaler:s,gScaler:a,offset:c}=o,l=new Float32Array((e+1)*(r+1));for(let f=0,u=0;u<r;u++)for(let d=0;d<e;d++,f++){let h=f*4,p=t[h+0],m=t[h+1],g=t[h+2];l[f+u]=p*i+m*a+g*s+c}if(n==="martini"){for(let f=(e+1)*e,u=0;u<e;u++,f++)l[f]=l[f-e-1];for(let f=r,u=0;u<r+1;u++,f+=r+1)l[f]=l[f-1]}return l}function The(t,e,r,o,n){let i=r+1,s=t.length/2,a=new Float32Array(s*3),c=new Float32Array(s*2),[l,f,u,d]=n||[0,0,r,o],h=(u-l)/r,p=(d-f)/o;for(let m=0;m<s;m++){let g=t[m*2],_=t[m*2+1],x=_*i+g;a[3*m+0]=g*h+l,a[3*m+1]=-_*p+d,a[3*m+2]=e[x],c[2*m+0]=g/r,c[2*m+1]=_/o}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var ox="4.4.3";var nx={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:ox,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var q6={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:ox,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var vhe={...nx,parse:She};async function She(t,e,r){let o={...e,core:{...e?.core,mimeType:"application/x.image"},image:{...e?.image,type:"data"}},n=await nr(t,[],o,r),i={...vhe.options.terrain,...e?.terrain};return K6(n,i)}var iot={...q6,parseSync:(t,e)=>KE(t,e?.["quantized-mesh"]),parse:async(t,e)=>KE(t,e?.["quantized-mesh"])};var Z6=[1],Che={...Ws.defaultProps,elevationData:Pi,texture:{...Pi,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[nx]};function J6(t){return Array.isArray(t)?t.join(";"):t||""}var Ch=class extends Ne{updateState({props:e,oldProps:r}){let o=e.elevationData!==r.elevationData;if(o){let{elevationData:i}=e,s=i&&(Array.isArray(i)||Ehe(i));this.setState({isTiled:s})}let n=o||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&n){let i=this.loadTerrain(e);this.setState({terrain:i})}e.workerUrl&&N.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:o,meshMaxError:n,signal:i}){if(!e)return null;let s=this.getLoadOptions();s={...s,terrain:{skirtHeight:this.state.isTiled?n*2:0,...s?.terrain,bounds:r,meshMaxError:n,elevationDecoder:o}};let{fetch:a}=this.props;return a(e,{propName:"elevationData",layer:this,loadOptions:s,signal:i})}getTiledTerrainData(e){let{elevationData:r,fetch:o,texture:n,elevationDecoder:i,meshMaxError:s}=this.props,{viewport:a}=this.context,c=Yo(r,e),l=n&&Yo(n,e),{signal:f}=e,u=[0,0],d=[0,0];if(a.isGeospatial){let g=e.bbox;u=a.projectFlat([g.west,g.south]),d=a.projectFlat([g.east,g.north])}else{let g=e.bbox;u=[g.left,g.bottom],d=[g.right,g.top]}let h=[u[0],u[1],d[0],d[1]],p=this.loadTerrain({elevationData:c,bounds:h,elevationDecoder:i,meshMaxError:s,signal:f}),m=l?o(l,{propName:"texture",layer:this,loaders:[],signal:f}).catch(g=>null):Promise.resolve(null);return Promise.all([p,m])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",Gs),{color:o,wireframe:n,material:i}=this.props,{data:s}=e;if(!s)return null;let[a,c]=s;return new r(e,{data:Z6,mesh:a,texture:c,_instanced:!1,coordinateSystem:Be.CARTESIAN,getPosition:l=>[0,0,0],getColor:o,wireframe:n,material:i})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,o=e.map(s=>s.content).filter(Boolean).map(s=>s[0].header.boundingBox.map(c=>c[2]));if(o.length===0)return;let n=Math.min(...o.map(s=>s[0])),i=Math.max(...o.map(s=>s[1]));(!r||n<r[0]||i>r[1])&&this.setState({zRange:[n,i]})}renderLayers(){let{color:e,material:r,elevationData:o,texture:n,wireframe:i,meshMaxError:s,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:d,onTileLoad:h,onTileUnload:p,onTileError:m,maxCacheSize:g,maxCacheByteSize:_,refinementStrategy:x,zoomOffset:y}=this.props;if(this.state.isTiled)return new Ws(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:J6(o),texture:J6(n),meshMaxError:s,elevationDecoder:a,projectionMode:this.context.viewport.projectionMode,zoomOffset:y}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:f,extent:u,maxRequests:d,onTileLoad:h,onTileUnload:p,onTileError:m,maxCacheSize:g,maxCacheByteSize:_,refinementStrategy:x,zoomOffset:y});if(!o)return null;let b=this.getSubLayerClass("mesh",Gs);return new b(this.getSubLayerProps({id:"mesh"}),{data:Z6,mesh:this.state.terrain,texture:n,_instanced:!1,getPosition:T=>[0,0,0],getColor:e,material:r,wireframe:i})}};Ch.defaultProps=Che;Ch.layerName="TerrainLayer";var Q6=Ch,Ehe=t=>t.includes("{x}")&&(t.includes("{y}")||t.includes("{-y}"));var eV=`layout(std140) uniform brushingUniforms {
bool enabled;
highp int target;
vec2 mousePos;
float radius;
} brushing;
`,whe=`
in vec2 brushingTargets;
out float brushing_isVisible;
bool brushing_isPointInRange(vec2 position) {
if (!brushing.enabled) {
return true;
}
vec2 source_commonspace = project_position(position);
vec2 target_commonspace = project_position(brushing.mousePos);
float distance = length((target_commonspace - source_commonspace) / project.commonUnitsPerMeter.xy);
return distance <= brushing.radius;
}
bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
}
void brushing_setVisible(bool visible) {
brushing_isVisible = float(visible);
}
`,Phe=`
${eV}
${whe}
`,Mhe=`
in float brushing_isVisible;
`,Rhe=`
${eV}
${Mhe}
`,Ihe={source:0,target:1,custom:2,source_target:3},Lhe={"vs:DECKGL_FILTER_GL_POSITION":`
vec2 brushingTarget;
vec2 brushingSource;
if (brushing.target == 3) {
brushingTarget = geometry.worldPositionAlt.xy;
brushingSource = geometry.worldPosition.xy;
} else if (brushing.target == 0) {
brushingTarget = geometry.worldPosition.xy;
} else if (brushing.target == 1) {
brushingTarget = geometry.worldPositionAlt.xy;
} else {
brushingTarget = brushingTargets;
}
bool visible;
if (brushing.target == 3) {
visible = brushing_arePointsInRange(brushingSource, brushingTarget);
} else {
visible = brushing_isPointInRange(brushingTarget);
}
brushing_setVisible(visible);
`,"fs:DECKGL_FILTER_COLOR":`
if (brushing.enabled && brushing_isVisible < 0.5) {
discard;
}
`},tV={name:"brushing",dependencies:[We],vs:Phe,fs:Rhe,inject:Lhe,getUniforms:t=>{if(!t||!("viewport"in t))return{};let{brushingEnabled:e=!0,brushingRadius:r=1e4,brushingTarget:o="source",mousePosition:n,viewport:i}=t;return{enabled:Boolean(e&&n&&i.containsPixel(n)),radius:r,target:Ihe[o]||0,mousePos:n?i.unproject([n.x-i.x,n.y-i.y]):[0,0]}},uniformTypes:{enabled:"i32",target:"i32",mousePos:"vec2<f32>",radius:"f32"}};var Bhe={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},Eh=class extends st{getShaders(){return{modules:[tV]}}initializeState(e,r){let o=this.getAttributeManager();o&&o.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});let n=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=n,e.deck&&e.deck.eventManager.on({pointermove:n,pointerleave:n})}finalizeState(e,r){if(e.deck){let o=this.state.onMouseMove;e.deck.eventManager.off({pointermove:o,pointerleave:o})}}draw(e,r){let{viewport:o,mousePosition:n}=e.context,{brushingEnabled:i,brushingRadius:s,brushingTarget:a}=this.props,c={viewport:o,mousePosition:n,brushingEnabled:i,brushingRadius:s,brushingTarget:a};this.setShaderModuleProps({brushing:c})}};Eh.defaultProps=Bhe;Eh.extensionName="BrushingExtension";var rV=Eh;var oV=`layout(std140) uniform dataFilterUniforms {
bool useSoftMargin;
bool enabled;
bool transformSize;
bool transformColor;
vec4 min;
vec4 softMin;
vec4 softMax;
vec4 max;
vec4 min64High;
vec4 max64High;
highp uvec4 categoryBitMask;
} dataFilter;
`,Ohe=`
#ifdef DATAFILTER_TYPE
in DATAFILTER_TYPE filterValues;
#ifdef DATAFILTER_DOUBLE
in DATAFILTER_TYPE filterValues64Low;
#endif
#endif
#ifdef DATACATEGORY_TYPE
in DATACATEGORY_TYPE filterCategoryValues;
#endif
out float dataFilter_value;
#ifdef DATAFILTER_TYPE
float dataFilter_getMin(float _) {
return dataFilter.min.x;
}
vec2 dataFilter_getMin(vec2 _) {
return dataFilter.min.xy;
}
vec3 dataFilter_getMin(vec3 _) {
return dataFilter.min.xyz;
}
vec4 dataFilter_getMin(vec4 _) {
return dataFilter.min;
}
float dataFilter_getSoftMin(float _) {
return dataFilter.softMin.x;
}
vec2 dataFilter_getSoftMin(vec2 _) {
return dataFilter.softMin.xy;
}
vec3 dataFilter_getSoftMin(vec3 _) {
return dataFilter.softMin.xyz;
}
vec4 dataFilter_getSoftMin(vec4 _) {
return dataFilter.softMin;
}
float dataFilter_getSoftMax(float _) {
return dataFilter.softMax.x;
}
vec2 dataFilter_getSoftMax(vec2 _) {
return dataFilter.softMax.xy;
}
vec3 dataFilter_getSoftMax(vec3 _) {
return dataFilter.softMax.xyz;
}
vec4 dataFilter_getSoftMax(vec4 _) {
return dataFilter.softMax;
}
float dataFilter_getMax(float _) {
return dataFilter.max.x;
}
vec2 dataFilter_getMax(vec2 _) {
return dataFilter.max.xy;
}
vec3 dataFilter_getMax(vec3 _) {
return dataFilter.max.xyz;
}
vec4 dataFilter_getMax(vec4 _) {
return dataFilter.max;
}
float dataFilter_getMin64High(float _) {
return dataFilter.min64High.x;
}
vec2 dataFilter_getMin64High(vec2 _) {
return dataFilter.min64High.xy;
}
vec3 dataFilter_getMin64High(vec3 _) {
return dataFilter.min64High.xyz;
}
vec4 dataFilter_getMin64High(vec4 _) {
return dataFilter.min64High;
}
float dataFilter_getMax64High(float _) {
return dataFilter.max64High.x;
}
vec2 dataFilter_getMax64High(vec2 _) {
return dataFilter.max64High.xy;
}
vec3 dataFilter_getMax64High(vec3 _) {
return dataFilter.max64High.xyz;
}
vec4 dataFilter_getMax64High(vec4 _) {
return dataFilter.max64High;
}
#endif
float dataFilter_reduceValue(float value) {
return value;
}
float dataFilter_reduceValue(vec2 value) {
return min(value.x, value.y);
}
float dataFilter_reduceValue(vec3 value) {
return min(min(value.x, value.y), value.z);
}
float dataFilter_reduceValue(vec4 value) {
return min(min(value.x, value.y), min(value.z, value.w));
}
#ifdef DATAFILTER_TYPE
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
DATAFILTER_TYPE dataFilter_min = dataFilter_getMin(valueFromMin);
DATAFILTER_TYPE dataFilter_softMin = dataFilter_getSoftMin(valueFromMin);
DATAFILTER_TYPE dataFilter_softMax = dataFilter_getSoftMax(valueFromMin);
DATAFILTER_TYPE dataFilter_max = dataFilter_getMax(valueFromMin);
if (dataFilter.useSoftMargin) {
// smoothstep results are undefined if edge0 \u2265 edge1
// Fallback to ignore filterSoftRange if it is truncated by filterRange
DATAFILTER_TYPE leftInRange = mix(
smoothstep(dataFilter_min, dataFilter_softMin, valueFromMin),
step(dataFilter_min, valueFromMin),
step(dataFilter_softMin, dataFilter_min)
);
DATAFILTER_TYPE rightInRange = mix(
1.0 - smoothstep(dataFilter_softMax, dataFilter_max, valueFromMax),
step(valueFromMax, dataFilter_max),
step(dataFilter_max, dataFilter_softMax)
);
dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
} else {
dataFilter_value = dataFilter_reduceValue(
step(dataFilter_min, valueFromMin) * step(valueFromMax, dataFilter_max)
);
}
}
#endif
#ifdef DATACATEGORY_TYPE
void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
uint dataFilter_masks = dataFilter.categoryBitMask[category / 32u];
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
uvec2 dataFilter_masks = uvec2(
dataFilter.categoryBitMask[category.x / 32u],
dataFilter.categoryBitMask[category.y / 32u + 2u]
);
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
uvec3 dataFilter_masks = dataFilter.categoryBitMask.xyz;
#else // Four 32-bit masks
uvec4 dataFilter_masks = dataFilter.categoryBitMask;
#endif
// Shift mask and extract relevant bits
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) >> (category & 31u);
dataFilter_bits &= 1u;
#if DATACATEGORY_CHANNELS == 1
if (dataFilter_bits == 0u) dataFilter_value = 0.0;
#else
if (any(equal(dataFilter_bits, DATACATEGORY_TYPE(0u)))) dataFilter_value = 0.0;
#endif
}
#endif
`,nV=`
${oV}
${Ohe}
`,Fhe=`
in float dataFilter_value;
`,iV=`
${oV}
${Fhe}
`;function sV(t){if(!t||!("extensions"in t))return{};let{filterRange:e=[-1,1],filterEnabled:r=!0,filterTransformSize:o=!0,filterTransformColor:n=!0,categoryBitMask:i}=t,s=t.filterSoftRange||e,a=c=>Array.isArray(c)?[c[0]||0,c[1]||0,c[2]||0,c[3]||0]:[c,0,0,0];return{...Number.isFinite(e[0])?{min:a(e[0]),softMin:a(s[0]),softMax:a(s[1]),max:a(e[1])}:{min:a(e.map(c=>c[0])),softMin:a(s.map(c=>c[0])),softMax:a(s.map(c=>c[1])),max:a(e.map(c=>c[1]))},enabled:r,useSoftMargin:Boolean(t.filterSoftRange),transformSize:r&&o,transformColor:r&&n,...i&&{categoryBitMask:i}}}function Nhe(t){if(!t||!("extensions"in t))return{};let e=sV(t),r=e.min.map(Math.fround);e.min=e.min.map((n,i)=>n-r[i]),e.softMin=e.softMin.map((n,i)=>n-r[i]),e.min64High=r;let o=e.max.map(Math.fround);return e.max=e.max.map((n,i)=>n-o[i]),e.softMax=e.softMax.map((n,i)=>n-o[i]),e.max64High=o,e}var aV={"vs:#main-start":`
dataFilter_value = 1.0;
if (dataFilter.enabled) {
#ifdef DATAFILTER_TYPE
#ifdef DATAFILTER_DOUBLE
dataFilter_setValue(
filterValues - dataFilter_getMin64High(filterValues) + filterValues64Low,
filterValues - dataFilter_getMax64High(filterValues) + filterValues64Low
);
#else
dataFilter_setValue(filterValues, filterValues);
#endif
#endif
#ifdef DATACATEGORY_TYPE
dataFilter_setCategoryValue(filterCategoryValues);
#endif
}
`,"vs:#main-end":`
if (dataFilter_value == 0.0) {
gl_Position = vec4(0.);
}
`,"vs:DECKGL_FILTER_SIZE":`
if (dataFilter.transformSize) {
size = size * dataFilter_value;
}
`,"fs:DECKGL_FILTER_COLOR":`
if (dataFilter_value == 0.0) discard;
if (dataFilter.transformColor) {
color.a *= dataFilter_value;
}
`};function cV(t){return{useSoftMargin:"i32",enabled:"i32",transformSize:"i32",transformColor:"i32",min:"vec4<f32>",softMin:"vec4<f32>",softMax:"vec4<f32>",max:"vec4<f32>",min64High:"vec4<f32>",max64High:"vec4<f32>",categoryBitMask:"vec4<u32>"}}var lV={name:"dataFilter",vs:nV,fs:iV,inject:aV,getUniforms:sV,uniformTypesFromOptions:cV},fV={name:"dataFilter",vs:nV,fs:iV,inject:aV,getUniforms:Nhe,uniformTypesFromOptions:cV};var Dhe=`#version 300 es
#define SHADER_NAME data-filter-vertex-shader
#ifdef FLOAT_TARGET
in float filterIndices;
in float filterPrevIndices;
#else
in vec2 filterIndices;
in vec2 filterPrevIndices;
#endif
out vec4 vColor;
const float component = 1.0 / 255.0;
void main() {
#ifdef FLOAT_TARGET
dataFilter_value *= float(filterIndices != filterPrevIndices);
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
vColor = vec4(0.0, 0.0, 0.0, 1.0);
#else
// Float texture is not supported: pack result into 4 channels x 256 px x 64px
dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
float col = filterIndices.x;
float row = filterIndices.y * 4.0;
float channel = floor(row);
row = fract(row);
vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
#endif
gl_PointSize = 1.0;
}
`,Uhe=`#version 300 es
#define SHADER_NAME data-filter-fragment-shader
precision highp float;
in vec4 vColor;
out vec4 fragColor;
void main() {
if (dataFilter_value < 0.5) {
discard;
}
fragColor = vColor;
}
`,khe=["float32-renderable-webgl","texture-blend-float-webgl"];function uV(t){return khe.every(e=>t.features.has(e))}function dV(t,e){return e?t.createFramebuffer({width:1,height:1,colorAttachments:[t.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):t.createFramebuffer({width:256,height:64,colorAttachments:[t.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function hV(t,e,r,o){return r.defines.NON_INSTANCED_MODEL=1,o&&(r.defines.FLOAT_TARGET=1),new Q(t,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:Dhe,fs:Uhe,bufferLayout:e,...r})}var pV={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var zhe={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},Hhe={categorySize:0,filterSize:1,fp64:!1,countItems:!1},jhe={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},Whe={1:"float",2:"vec2",3:"vec3",4:"vec4"},wh=class extends st{constructor(e={}){super({...Hhe,...e})}getShaders(e){let{categorySize:r,filterSize:o,fp64:n}=e.opts,i={};r&&(i.DATACATEGORY_TYPE=jhe[r],i.DATACATEGORY_CHANNELS=r),o&&(i.DATAFILTER_TYPE=Whe[o],i.DATAFILTER_DOUBLE=Boolean(n));let s=n?fV:lV;return s.uniformTypes=s.uniformTypesFromOptions(e.opts),{modules:[s],defines:i}}initializeState(e,r){let o=this.getAttributeManager(),{categorySize:n,filterSize:i,fp64:s}=r.opts;o&&(i&&o.add({filterValues:{size:i,type:s?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),n&&o.add({filterCategoryValues:{size:n,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:n===1?c=>r._getCategoryKey.call(this,c,0):c=>c.map((l,f)=>r._getCategoryKey.call(this,l,f))}}));let{device:a}=this.context;if(o&&r.opts.countItems){let c=uV(a);o.add({filterVertexIndices:{size:c?1:2,vertexOffset:1,type:"unorm8",accessor:(u,{index:d})=>{let h=u&&u.__source?u.__source.index:d;return c?(h+1)%255:[(h+1)%255,Math.floor(h/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let l=dV(a,c),f=hV(a,o.getBufferLayouts({isInstanced:!1}),r.getShaders.call(this,r),c);this.setState({filterFBO:l,filterModel:f})}}updateState({props:e,oldProps:r,changeFlags:o},n){let i=this.getAttributeManager(),{categorySize:s}=n.opts;if(this.state.filterModel){let a=i.attributes.filterValues?.needsUpdate()||i.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==r.filterEnabled||e.filterRange!==r.filterRange||e.filterSoftRange!==r.filterSoftRange||e.filterCategories!==r.filterCategories;a&&this.setState({filterNeedsUpdate:a})}i?.attributes.filterCategoryValues&&((i.attributes.filterCategoryValues.needsUpdate()||!ie(e.filterCategories,r.filterCategories,2))&&this.setState({categoryBitMask:null}),o.dataChanged&&(this.setState({categoryMap:Array(s).fill(0).map(()=>({}))}),i.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,r){let o=this.state.filterFBO,n=this.state.filterModel,i=this.state.filterNeedsUpdate;this.state.categoryBitMask||r._updateCategoryBitMask.call(this,e,r);let{onFilteredItemsChange:s,extensions:a,filterEnabled:c,filterRange:l,filterSoftRange:f,filterTransformSize:u,filterTransformColor:d,filterCategories:h}=this.props,p={extensions:a,filterEnabled:c,filterRange:l,filterSoftRange:f,filterTransformSize:u,filterTransformColor:d,filterCategories:h};if(this.state.categoryBitMask&&(p.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:p}),i&&s&&n){let m=this.getAttributeManager(),{attributes:{filterValues:g,filterCategoryValues:_,filterVertexIndices:x}}=m;n.setVertexCount(this.getNumInstances());let y={...g?.getValue(),..._?.getValue(),...x?.getValue()};n.setAttributes(y),n.shaderInputs.setProps({dataFilter:p});let b=[0,0,o.width,o.height],T=n.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:o,parameters:{viewport:b},clearColor:[0,0,0,0]});n.setParameters(pV),n.draw(T),T.end();let v=n.device.readPixelsToArrayWebGL(o),w=0;for(let C=0;C<v.length;C++)w+=v[C];s({id:this.id,count:w}),this.state.filterNeedsUpdate=!1}}finalizeState(){let e=this.state.filterFBO,r=this.state.filterModel;e?.destroy(),r?.destroy()}_updateCategoryBitMask(e,r){let{categorySize:o}=r.opts;if(!o)return;let{filterCategories:n}=this.props,i=new Uint32Array([0,0,0,0]),s=o===1?[n]:n,a=o===1?128:o===2?64:32;for(let c=0;c<s.length;c++){let l=s[c];for(let f of l){let u=r._getCategoryKey.call(this,f,c);if(u<a){let d=c*(a/32)+Math.floor(u/32);i[d]+=Math.pow(2,u%32)}else N.warn(`Exceeded maximum number of categories (${a})`)()}}this.state.categoryBitMask=i}_getCategoryKey(e,r){let o=this.state.categoryMap[r];return e in o||(o[e]=Object.keys(o).length),o[e]}};wh.defaultProps=zhe;wh.extensionName="DataFilterExtension";var mV=wh;var gV=`const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
layout(std140) uniform project64Uniforms {
vec2 scale;
mat4 viewProjectionMatrix;
mat4 viewProjectionMatrix64Low;
} project64;
void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) {
#if defined(NVIDIA_FP64_WORKAROUND)
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64 * ONE);
#else
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64);
#endif
out_val[1] = sum_fp64(PI_FP64,
log_fp64(tan_fp64(sum_fp64(PI_4_FP64, radians_fp64(lnglat_fp64.zw) / 2.0))));
return;
}
void project_position_fp64(vec4 position_fp64, out vec2 out_val[2]) {
vec2 pos_fp64[2];
mercatorProject_fp64(position_fp64, pos_fp64);
out_val[0] = mul_fp64(pos_fp64[0], WORLD_SCALE_FP64);
out_val[1] = mul_fp64(pos_fp64[1], WORLD_SCALE_FP64);
return;
}
void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val[2]) {
vec4 position64xy = vec4(
position.x, position64xyLow.x,
position.y, position64xyLow.y);
project_position_fp64(position64xy, out_val);
}
vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) {
vec2 vertex_pos_clipspace[4];
vec2 viewProjectionMatrixFP64[16];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
viewProjectionMatrixFP64[4 * i + j] = vec2(
project64.viewProjectionMatrix[j][i],
project64.viewProjectionMatrix64Low[j][i]
);
}
}
mat4_vec4_mul_fp64(viewProjectionMatrixFP64, vertex_pos_modelspace,
vertex_pos_clipspace);
return vec4(
vertex_pos_clipspace[0].x,
vertex_pos_clipspace[1].x,
vertex_pos_clipspace[2].x,
vertex_pos_clipspace[3].x
);
}
vec4 project_position_to_clipspace(
vec3 position, vec3 position64xyLow, vec3 offset, out vec4 commonPosition
) {
vec2 offset64[4];
vec4_fp64(vec4(offset, 0.0), offset64);
float z = project_size(position.z);
vec2 projectedPosition64xy[2];
project_position_fp64(position.xy, position64xyLow.xy, projectedPosition64xy);
vec2 commonPosition64[4];
commonPosition64[0] = sum_fp64(offset64[0], projectedPosition64xy[0]);
commonPosition64[1] = sum_fp64(offset64[1], projectedPosition64xy[1]);
commonPosition64[2] = sum_fp64(offset64[2], vec2(z, 0.0));
commonPosition64[3] = vec2(1.0, 0.0);
commonPosition = vec4(projectedPosition64xy[0].x, projectedPosition64xy[1].x, z, 1.0);
return project_common_position_to_clipspace_fp64(commonPosition64);
}
vec4 project_position_to_clipspace(
vec3 position, vec3 position64xyLow, vec3 offset
) {
vec4 commonPosition;
return project_position_to_clipspace(
position, position64xyLow, offset, commonPosition
);
}
`;var{fp64ify:Ghe,fp64ifyMatrix4:$he}=Am,ix={name:"project64",dependencies:[We,Am],vs:gV,getUniforms:Yhe,uniformTypes:{scale:"vec2<f32>",viewProjectionMatrix:"mat4x4<f32>",viewProjectionMatrix64Low:"mat4x4<f32>"}},Xhe=Yt(Khe);function Yhe(t){if(t&&"viewport"in t){let{viewProjectionMatrix:e,scale:r}=t.viewport;return Xhe({viewProjectionMatrix:e,scale:r})}return{}}function Khe({viewProjectionMatrix:t,scale:e}){let r=$he(t),o=new Float32Array(16),n=new Float32Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let a=4*i+s,c=4*s+i;o[c]=r[2*a],n[c]=r[2*a+1]}return{scale:Ghe(e),viewProjectionMatrix:[...o],viewProjectionMatrix64Low:[...n]}}var sx=class extends st{getShaders(){let{coordinateSystem:e}=this.props;if(e!=="lnglat"&&e!=="default")throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[ix]}}draw(e,r){let{viewport:o}=e.context;this.setShaderModuleProps({project64:{viewport:o}})}};sx.extensionName="Fp64Extension";var _V=sx;var yV={inject:{"vs:#decl":`
in vec2 instanceDashArrays;
#ifdef HIGH_PRECISION_DASH
in float instanceDashOffsets;
#endif
out vec2 vDashArray;
out float vDashOffset;
`,"vs:#main-end":`
vDashArray = instanceDashArrays;
#ifdef HIGH_PRECISION_DASH
vDashOffset = instanceDashOffsets / width.x;
#else
vDashOffset = 0.0;
#endif
`,"fs:#decl":`
layout(std140) uniform pathStyleUniforms {
float dashAlignMode;
bool dashGapPickable;
} pathStyle;
in vec2 vDashArray;
in float vDashOffset;
`,"fs:#main-start":`
float solidLength = vDashArray.x;
float gapLength = vDashArray.y;
float unitLength = solidLength + gapLength;
float offset;
if (unitLength > 0.0) {
if (pathStyle.dashAlignMode == 0.0) {
offset = vDashOffset;
} else {
unitLength = vPathLength / round(vPathLength / unitLength);
offset = solidLength / 2.0;
}
float unitOffset = mod(vPathPosition.y + offset, unitLength);
if (gapLength > 0.0 && unitOffset > solidLength) {
if (path.capType <= 0.5) {
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
discard;
}
} else {
float distToEnd = length(vec2(
min(unitOffset - solidLength, unitLength - unitOffset),
vPathPosition.x
));
if (distToEnd > 1.0) {
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
discard;
}
}
}
}
}
`}},xV={inject:{"vs:#decl":`
in vec2 instanceDashArrays;
out vec2 vDashArray;
`,"vs:#main-end":`
vDashArray = instanceDashArrays;
`,"fs:#decl":`
layout(std140) uniform pathStyleUniforms {
bool dashGapPickable;
} pathStyle;
in vec2 vDashArray;
#define PI 3.141592653589793
`,"fs:#main-start":`
bool inDashGap = false;
float dashUnitLength = vDashArray.x + vDashArray.y;
if (dashUnitLength > 0.0 && scatterplot.stroked > 0.5) {
float _distToCenter = length(unitPosition) * outerRadiusPixels;
float innerRadius = innerUnitRadius * outerRadiusPixels;
if (_distToCenter >= innerRadius) {
float strokeWidth = (1.0 - innerUnitRadius) * outerRadiusPixels;
float midStrokeRadius = (innerUnitRadius + 1.0) * 0.5 * outerRadiusPixels;
float angle = atan(unitPosition.y, unitPosition.x) + PI;
float circumference = 2.0 * PI * midStrokeRadius;
float posAlongStroke = (angle / (2.0 * PI)) * circumference / strokeWidth;
float unitOffset = mod(posAlongStroke, dashUnitLength);
if (unitOffset > vDashArray.x) {
if (scatterplot.filled > 0.5) {
inDashGap = true;
} else {
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
discard;
}
}
}
}
}
`,"fs:#main-end":`
if (inDashGap) {
float alphaFactor = fragColor.a / max(vLineColor.a, 0.001);
fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor);
fragColor = picking_filterPickingColor(fragColor);
fragColor = picking_filterHighlightColor(fragColor);
}
`}},bV={inject:{"vs:#decl":`
in vec2 instanceDashArrays;
out vec2 vDashArray;
`,"vs:#main-end":`
vDashArray = instanceDashArrays;
`,"fs:#decl":`
layout(std140) uniform pathStyleUniforms {
bool dashGapPickable;
} pathStyle;
in vec2 vDashArray;
#define PI 3.141592653589793
float getPerimeterPosition(vec2 fragUV, vec2 dims, vec4 radii, float lineWidth) {
float width = dims.x;
float height = dims.y;
float maxRadius = min(width, height) * 0.5;
float rBL = min(radii.w, maxRadius);
float rTL = min(radii.z, maxRadius);
float rTR = min(radii.x, maxRadius);
float rBR = min(radii.y, maxRadius);
vec2 p = fragUV * dims;
float leftLen = height - rBL - rTL;
float topLen = width - rTL - rTR;
float rightLen = height - rTR - rBR;
float bottomLen = width - rBR - rBL;
float arcBL = PI * 0.5 * rBL;
float arcTL = PI * 0.5 * rTL;
float arcTR = PI * 0.5 * rTR;
float arcBR = PI * 0.5 * rBR;
float pos = 0.0;
float distLeft = p.x;
float distRight = width - p.x;
float distBottom = p.y;
float distTop = height - p.y;
float minDist = min(min(distLeft, distRight), min(distBottom, distTop));
if (p.x < rBL && p.y < rBL) {
vec2 c = vec2(rBL, rBL);
vec2 d = p - c;
float angle = atan(-d.x, -d.y);
pos = angle / (PI * 0.5) * arcBL;
} else if (p.x < rTL && p.y > height - rTL) {
vec2 c = vec2(rTL, height - rTL);
vec2 d = p - c;
float angle = atan(d.y, -d.x);
pos = arcBL + leftLen + angle / (PI * 0.5) * arcTL;
} else if (p.x > width - rTR && p.y > height - rTR) {
vec2 c = vec2(width - rTR, height - rTR);
vec2 d = p - c;
float angle = atan(d.x, d.y);
pos = arcBL + leftLen + arcTL + topLen + angle / (PI * 0.5) * arcTR;
} else if (p.x > width - rBR && p.y < rBR) {
vec2 c = vec2(width - rBR, rBR);
vec2 d = p - c;
float angle = atan(-d.y, d.x);
pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + angle / (PI * 0.5) * arcBR;
} else if (minDist == distLeft) {
pos = arcBL + clamp(p.y - rBL, 0.0, leftLen);
} else if (minDist == distTop) {
pos = arcBL + leftLen + arcTL + clamp(p.x - rTL, 0.0, topLen);
} else if (minDist == distRight) {
pos = arcBL + leftLen + arcTL + topLen + arcTR + clamp(height - rTR - p.y, 0.0, rightLen);
} else {
pos = arcBL + leftLen + arcTL + topLen + arcTR + rightLen + arcBR + clamp(width - rBR - p.x, 0.0, bottomLen);
}
return pos / lineWidth;
}
float getRectPerimeterPosition(vec2 fragUV, vec2 dims, float lineWidth) {
float width = dims.x;
float height = dims.y;
float distLeft = fragUV.x * width;
float distRight = (1.0 - fragUV.x) * width;
float distBottom = fragUV.y * height;
float distTop = (1.0 - fragUV.y) * height;
float minDist = min(min(distLeft, distRight), min(distBottom, distTop));
float pos = 0.0;
if (minDist == distLeft) {
pos = fragUV.y * height;
} else if (minDist == distTop) {
pos = height + fragUV.x * width;
} else if (minDist == distRight) {
pos = height + width + (1.0 - fragUV.y) * height;
} else {
pos = 2.0 * height + width + (1.0 - fragUV.x) * width;
}
return pos / lineWidth;
}
`,"fs:#main-start":`
bool inDashGap = false;
float dashUnitLength = vDashArray.x + vDashArray.y;
if (dashUnitLength > 0.0 && textBackground.stroked) {
float distToEdge;
bool hasRoundedCorners = textBackground.borderRadius != vec4(0.0);
if (hasRoundedCorners) {
distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);
} else {
distToEdge = rect(uv, dimensions);
}
if (distToEdge <= vLineWidth && distToEdge >= 0.0) {
float posAlongStroke;
if (hasRoundedCorners) {
posAlongStroke = getPerimeterPosition(uv, dimensions, textBackground.borderRadius, vLineWidth);
} else {
posAlongStroke = getRectPerimeterPosition(uv, dimensions, vLineWidth);
}
float unitOffset = mod(posAlongStroke, dashUnitLength);
if (unitOffset > vDashArray.x) {
if (vFillColor.a > 0.0) {
inDashGap = true;
} else {
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
discard;
}
}
}
}
}
`,"fs:#main-end":`
if (inDashGap) {
float alphaFactor = fragColor.a / max(vLineColor.a, 0.001);
fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor);
fragColor = picking_filterPickingColor(fragColor);
fragColor = picking_filterHighlightColor(fragColor);
}
`}},AV={inject:{"vs:#decl":`
in float instanceOffsets;
`,"vs:DECKGL_FILTER_SIZE":`
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
size *= offsetWidth;
`,"vs:#main-end":`
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
float offsetDir = sign(instanceOffsets);
vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;
vPathPosition.y *= offsetWidth;
vPathLength *= offsetWidth;
`,"fs:#main-start":`
float isInside;
isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
if (isInside == 0.0) {
discard;
}
`}};var qhe={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},Ph=class extends st{constructor({dash:e=!1,offset:r=!1,highPrecisionDash:o=!1}={}){super({dash:e||o,offset:r,highPrecisionDash:o})}getLayerType(e){if("pathTesselator"in e.state)return"path";let r=e.constructor.layerName;return r==="ScatterplotLayer"?"scatterplot":r==="TextBackgroundLayer"?"textBackground":null}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let r=e.getLayerType(this);if(!r)return null;if(r==="scatterplot"||r==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:r==="scatterplot"?xV.inject:bV.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let o={},n={};e.opts.dash&&(o=mi(o,yV),e.opts.highPrecisionDash&&(n.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(o=mi(o,AV));let{inject:i}=o;return{modules:[{name:"pathStyle",inject:i,uniformTypes:{dashAlignMode:"f32",dashGapPickable:"i32"}}],defines:n}}initializeState(e,r){let o=this.getAttributeManager(),n=r.getLayerType(this);!o||!n||(r.opts.dash&&o.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},...n==="path"&&r.opts.highPrecisionDash?{instanceDashOffsets:{size:1,accessor:"getPath",transform:r.getDashOffsets.bind(this)}}:{}}),n==="path"&&r.opts.offset&&o.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(e,r){if(r.isEnabled(this)&&r.opts.dash){let o=r.getLayerType(this);if(o==="scatterplot"||o==="textBackground"){let n={dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:n})}else{let n={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:n})}}}getDashOffsets(e){let r=[0],o=this.props.positionFormat==="XY"?2:3,n=Array.isArray(e[0]),i=n?e.length:e.length/o,s,a;for(let c=0;c<i-1;c++)s=n?e[c]:e.slice(c*o,c*o+o),s=this.projectPosition(s),c>0&&(r[c]=r[c-1]+Ke.dist(a,s)),a=s;return r[i-1]=0,r}};Ph.defaultProps=qhe;Ph.extensionName="PathStyleExtension";var TV=Ph;var vV=`layout(std140) uniform fillUniforms {
vec2 patternTextureSize;
bool patternEnabled;
bool patternMask;
vec2 uvCoordinateOrigin;
vec2 uvCoordinateOrigin64Low;
} fill;
`,Zhe=`
in vec4 fillPatternFrames;
in float fillPatternScales;
in vec2 fillPatternOffsets;
out vec2 fill_uv;
out vec4 fill_patternBounds;
out vec4 fill_patternPlacement;
`,Jhe=`
${vV}
${Zhe}
`,Qhe=`
uniform sampler2D fill_patternTexture;
in vec4 fill_patternBounds;
in vec4 fill_patternPlacement;
in vec2 fill_uv;
const float FILL_UV_SCALE = 512.0 / 40000000.0;
`,epe=`
${vV}
${Qhe}
`,tpe={"vs:DECKGL_FILTER_GL_POSITION":`
fill_uv = geometry.position.xy;
`,"vs:DECKGL_FILTER_COLOR":`
if (fill.patternEnabled) {
fill_patternBounds = fillPatternFrames / vec4(fill.patternTextureSize, fill.patternTextureSize);
fill_patternPlacement.xy = fillPatternOffsets;
fill_patternPlacement.zw = fillPatternScales * fillPatternFrames.zw;
}
`,"fs:DECKGL_FILTER_COLOR":`
if (fill.patternEnabled) {
vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;
vec2 patternUV = mod(mod(fill.uvCoordinateOrigin, scale) + fill.uvCoordinateOrigin64Low + fill_uv, scale) / scale;
patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);
vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;
vec4 patternColor = texture(fill_patternTexture, texCoords);
color.a *= patternColor.a;
if (!fill.patternMask) {
color.rgb = patternColor.rgb;
}
}
`};function rpe(t){if(!t)return{};let e={};if("fillPatternTexture"in t){let{fillPatternTexture:r}=t;e.fill_patternTexture=r,e.patternTextureSize=[r.width,r.height]}if("project"in t){let{fillPatternMask:r=!0,fillPatternEnabled:o=!0}=t,n=We.getUniforms(t.project),{commonOrigin:i}=n,s=[sc(i[0]),sc(i[1])];e.uvCoordinateOrigin=i.slice(0,2),e.uvCoordinateOrigin64Low=s,e.patternMask=r,e.patternEnabled=o}return e}var SV={name:"fill",vs:Jhe,fs:epe,inject:tpe,dependencies:[We],getUniforms:rpe,uniformTypes:{patternTextureSize:"vec2<f32>",patternEnabled:"i32",patternMask:"i32",uvCoordinateOrigin:"vec2<f32>",uvCoordinateOrigin64Low:"vec2<f32>"}};var ope={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:t=>t.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},Mh=class extends st{constructor({pattern:e=!1}={}){super({pattern:e})}isEnabled(e){return e.getAttributeManager()!==null&&!("pathTesselator"in e.state)}getShaders(e){return e.isEnabled(this)?{modules:[e.opts.pattern&&SV].filter(Boolean)}:null}initializeState(e,r){if(!r.isEnabled(this))return;let o=this.getAttributeManager();r.opts.pattern&&o.add({fillPatternFrames:{size:4,stepMode:"dynamic",accessor:"getFillPattern",transform:r.getPatternFrame.bind(this)},fillPatternScales:{size:1,stepMode:"dynamic",accessor:"getFillPatternScale",defaultValue:1},fillPatternOffsets:{size:2,stepMode:"dynamic",accessor:"getFillPatternOffset"}}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState({props:e,oldProps:r},o){o.isEnabled(this)&&e.fillPatternMapping&&e.fillPatternMapping!==r.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(e,r){if(!r.isEnabled(this))return;let{fillPatternAtlas:o,fillPatternEnabled:n,fillPatternMask:i}=this.props,s={project:e.shaderModuleProps.project,fillPatternEnabled:n,fillPatternMask:i,fillPatternTexture:o||this.state.emptyTexture};this.setShaderModuleProps({fill:s})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(e){let{fillPatternMapping:r}=this.getCurrentLayer().props,o=r&&r[e];return o?[o.x,o.y,o.width,o.height]:[0,0,0,0]}};Mh.defaultProps=ope;Mh.extensionName="FillStyleExtension";var CV=Mh;var npe={clipBounds:[0,0,1,1],clipByInstance:void 0},EV=`
layout(std140) uniform clipUniforms {
vec4 bounds;
} clip;
bool clip_isInBounds(vec2 position) {
return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];
}
`,ipe={name:"clip",vs:EV,uniformTypes:{bounds:"vec4<f32>"}},spe={"vs:#decl":`
out float clip_isVisible;
`,"vs:DECKGL_FILTER_GL_POSITION":`
clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
`,"fs:#decl":`
in float clip_isVisible;
`,"fs:DECKGL_FILTER_COLOR":`
if (clip_isVisible < 0.5) discard;
`},ape={name:"clip",fs:EV,uniformTypes:{bounds:"vec4<f32>"}},cpe={"vs:#decl":`
out vec2 clip_commonPosition;
`,"vs:DECKGL_FILTER_GL_POSITION":`
clip_commonPosition = geometry.position.xy;
`,"fs:#decl":`
in vec2 clip_commonPosition;
`,"fs:DECKGL_FILTER_COLOR":`
if (!clip_isInBounds(clip_commonPosition)) discard;
`},Rh=class extends st{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,e?{modules:[ipe],inject:spe}:{modules:[ape],inject:cpe}}draw(){let{clipBounds:e}=this.props,r={};if(this.state.clipByInstance)r.bounds=e;else{let o=this.projectPosition([e[0],e[1],0]),n=this.projectPosition([e[2],e[3],0]);r.bounds=[Math.min(o[0],n[0]),Math.min(o[1],n[1]),Math.max(o[0],n[0]),Math.max(o[1],n[1])]}this.setShaderModuleProps({clip:r})}};Rh.defaultProps=npe;Rh.extensionName="ClipExtension";var ax=Rh;var lpe=`
in float collisionPriorities;
uniform sampler2D collision_texture;
layout(std140) uniform collisionUniforms {
bool sort;
bool enabled;
} collision;
vec2 collision_getCoords(vec4 position) {
vec4 collision_clipspace = project_common_position_to_clipspace(position);
return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;
}
float collision_match(vec2 tex, vec3 pickingColor) {
vec4 collision_pickingColor = texture(collision_texture, tex);
float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));
float e = 0.001;
return step(delta, e);
}
float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
if (!collision.enabled) {
return 1.0;
}
// Visibility test, sample area of 5x5 pixels in order to fade in/out.
// Due to the locality, the lookups will be cached
// This reduces the flicker present when objects are shown/hidden
const int N = 2;
float accumulator = 0.0;
vec2 step = vec2(1.0 / project.viewportSize);
const float floatN = float(N);
vec2 delta = -floatN * step;
for(int i = -N; i <= N; i++) {
delta.x = -step.x * floatN;
for(int j = -N; j <= N; j++) {
accumulator += collision_match(texCoords + delta, pickingColor);
delta.x += step.x;
}
delta.y += step.y;
}
float W = 2.0 * floatN + 1.0;
return pow(accumulator / (W * W), 2.2);
}
`,fpe={"vs:#decl":`
float collision_fade = 1.0;
`,"vs:DECKGL_FILTER_GL_POSITION":`
if (collision.sort) {
float collisionPriority = collisionPriorities;
position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000
}
if (collision.enabled) {
vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
vec2 collision_texCoords = collision_getCoords(collision_common_position);
collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
if (collision_fade < 0.0001) {
// Position outside clip space bounds to discard
position = vec4(0.0, 0.0, 2.0, 1.0);
}
}
`,"vs:DECKGL_FILTER_COLOR":`
color.a *= collision_fade;
`},upe=t=>{if(!t||!("dummyCollisionMap"in t))return{};let{enabled:e,collisionFBO:r,drawToCollisionMap:o,dummyCollisionMap:n}=t;return{enabled:e&&!o,sort:Boolean(o),collision_texture:!o&&r?r.colorAttachments[0]:n}},wV={name:"collision",dependencies:[We],vs:lpe,inject:fpe,getUniforms:upe,uniformTypes:{sort:"i32",enabled:"i32"}};var Ih=class extends At{renderCollisionMap(e,r){let n=[0,0,0,0],i=[1,1,e.width-2*1,e.height-2*1];this.render({...r,clearColor:n,scissorRect:i,target:e,pass:"collision"})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}getShaderModuleProps(){return{collision:{drawToCollisionMap:!0},picking:{isActive:1,isAttribute:!1},lighting:{enabled:!1}}}};var ZE=2,Lh=class{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(e){this.context=e;let{device:r}=e;this.dummyCollisionMap=r.createTexture({width:1,height:1}),this.collisionFilterPass=new Ih(r,{id:"default-collision-filter"})}preRender({effects:e,layers:r,layerFilter:o,viewports:n,onViewportActive:i,views:s,isPicking:a,preRenderStats:c={}}){let{device:l}=this.context;if(a)return;let f=r.filter(({props:{visible:g,collisionEnabled:_}})=>g&&_);if(f.length===0){this.channels={};return}let u=e?.filter(g=>g.useInPicking&&c[g.id]),d=c["mask-effect"]?.didRender,h=this._groupByCollisionGroup(l,f),p=n[0],m=!this.lastViewport||!this.lastViewport.equals(p)||d;for(let g in h){let _=this.collisionFBOs[g],x=h[g],[y,b]=l.canvasContext.getPixelSize();_.resize({width:y/ZE,height:b/ZE}),this._render(x,{effects:u,layerFilter:o,onViewportActive:i,views:s,viewport:p,viewportChanged:m})}}_render(e,{effects:r,layerFilter:o,onViewportActive:n,views:i,viewport:s,viewportChanged:a}){let{collisionGroup:c}=e,l=this.channels[c];if(!l)return;let f=a||e===l||!ie(l.layers,e.layers,1)||e.layerBounds.some((u,d)=>!Ce(u,l.layerBounds[d]))||e.allLayersLoaded!==l.allLayersLoaded||e.layers.some(u=>u.props.transitions);if(this.channels[c]=e,f){this.lastViewport=s;let u=this.collisionFBOs[c];this.collisionFilterPass.renderCollisionMap(u,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:r,layerFilter:o,viewports:s?[s]:[],onViewportActive:n,views:i,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:u.device.canvasContext.getDevicePixelRatio()/ZE}}})}}_groupByCollisionGroup(e,r){let o={};for(let n of r){let i=n.props.collisionGroup,s=o[i];s||(s={collisionGroup:i,layers:[],layerBounds:[],allLayersLoaded:!0},o[i]=s),s.layers.push(n),s.layerBounds.push(n.getBounds()),n.isLoaded||(s.allLayersLoaded=!1)}for(let n of Object.keys(o))this.collisionFBOs[n]||this.createFBO(e,n),this.channels[n]||(this.channels[n]=o[n]);for(let n of Object.keys(this.collisionFBOs))o[n]||this.destroyFBO(n);return o}getShaderModuleProps(e){let{collisionGroup:r,collisionEnabled:o}=e.props,{collisionFBOs:n,dummyCollisionMap:i}=this,s=n[r];return{collision:{enabled:o&&Boolean(s),collisionFBO:s,dummyCollisionMap:i}}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(let e of Object.keys(this.collisionFBOs))this.destroyFBO(e);this.collisionFBOs={},this.lastViewport=void 0}createFBO(e,r){let{width:o,height:n}=e.getDefaultCanvasContext().canvas,i=e.createTexture({format:"rgba8unorm",width:o,height:n,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:o,height:n});this.collisionFBOs[r]=e.createFramebuffer({id:`collision-${r}`,width:o,height:n,colorAttachments:[i],depthStencilAttachment:s})}destroyFBO(e){let r=this.collisionFBOs[e];r.colorAttachments[0]?.destroy(),r.depthStencilAttachment?.destroy(),r.destroy(),delete this.collisionFBOs[e]}};var dpe={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},Bh=class extends st{getShaders(){return{modules:[wV]}}draw({shaderModuleProps:e}){e.collision?.drawToCollisionMap&&(this.props=this.clone(this.props.collisionTestProps).props)}initializeState(e,r){if(this.getAttributeManager()===null)return;this.context.deck?._addDefaultEffect(new Lh),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}};Bh.defaultProps=dpe;Bh.extensionName="CollisionFilterExtension";var PV=Bh;var MV=`layout(std140) uniform maskUniforms {
vec4 bounds;
highp int channel;
bool enabled;
bool inverted;
bool maskByInstance;
} mask;
`,hpe=`
vec2 mask_getCoords(vec4 position) {
return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy);
}
`,ppe=`
${MV}
${hpe}
`,mpe=`
uniform sampler2D mask_texture;
bool mask_isInBounds(vec2 texCoords) {
if (!mask.enabled) {
return true;
}
vec4 maskColor = texture(mask_texture, texCoords);
float maskValue = 1.0;
if (mask.channel == 0) {
maskValue = maskColor.r;
} else if (mask.channel == 1) {
maskValue = maskColor.g;
} else if (mask.channel == 2) {
maskValue = maskColor.b;
} else if (mask.channel == 3) {
maskValue = maskColor.a;
}
if (mask.inverted) {
return maskValue >= 0.5;
} else {
return maskValue < 0.5;
}
}
`,gpe=`
${MV}
${mpe}
`,_pe={"vs:#decl":`
out vec2 mask_texCoords;
`,"vs:#main-end":`
vec4 mask_common_position;
if (mask.maskByInstance) {
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
} else {
mask_common_position = geometry.position;
}
mask_texCoords = mask_getCoords(mask_common_position);
`,"fs:#decl":`
in vec2 mask_texCoords;
`,"fs:#main-start":`
if (mask.enabled) {
bool mask = mask_isInBounds(mask_texCoords);
// Debug: show extent of render target
// fragColor = vec4(mask_texCoords, 0.0, 1.0);
// fragColor = texture(mask_texture, mask_texCoords);
if (!mask) discard;
}
`},ype=t=>t&&"maskMap"in t?{mask_texture:t.maskMap}:t||{},RV={name:"mask",dependencies:[We],vs:ppe,fs:gpe,inject:_pe,getUniforms:ype,uniformTypes:{bounds:"vec4<f32>",channel:"i32",enabled:"i32",inverted:"i32",maskByInstance:"i32"}};var xpe={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"},Oh=class extends At{constructor(e,r){super(e,r);let{mapSize:o=2048}=r;this.maskMap=e.createTexture({format:"rgba8unorm",width:o,height:o,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=e.createFramebuffer({id:"maskmap",width:o,height:o,colorAttachments:[this.maskMap]})}render(e){let r=2**e.channel,o=[255,255,255,255];super.render({...e,clearColor:o,colorMask:r,target:this.fbo,pass:"mask"})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...xpe}}shouldDrawLayer(e){return e.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}};function hl(t,e){let r=[1/0,1/0,-1/0,-1/0];for(let o of t){let n=o.getBounds();if(n){let i=o.projectPosition(n[0],{viewport:e,autoOffset:!1}),s=o.projectPosition(n[1],{viewport:e,autoOffset:!1});r[0]=Math.min(r[0],i[0]),r[1]=Math.min(r[1],i[1]),r[2]=Math.max(r[2],s[0]),r[3]=Math.max(r[3],s[1])}}return Number.isFinite(r[0])?r:null}var bpe=2048;function pl(t){let{bounds:e,viewport:r,border:o=0}=t,{isGeospatial:n}=r;if(e[2]<=e[0]||e[3]<=e[1])return null;let i=r.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),{width:s,height:a,zoom:c}=t;if(c===void 0){s=s-o*2,a=a-o*2;let l=Math.min(s/(e[2]-e[0]),a/(e[3]-e[1]));c=Math.min(Math.log2(l),20)}else if(!s||!a){let l=2**c;s=Math.round(Math.abs(e[2]-e[0])*l),a=Math.round(Math.abs(e[3]-e[1])*l);let f=bpe-o*2;if(s>f||a>f){let u=f/Math.max(s,a);s=Math.round(s*u),a=Math.round(a*u),c+=Math.log2(u)}}return n?new Mt({id:r.id,x:o,y:o,width:s,height:a,longitude:i[0],latitude:i[1],zoom:c,orthographic:!0}):new Ac({id:r.id,x:o,y:o,width:s,height:a,target:i,zoom:c,flipY:!1})}function Ape(t,e){let r;if(e&&e.length===2){let[i,s]=e,a=t.getBounds({z:i}),c=t.getBounds({z:s});r=[Math.min(a[0],c[0]),Math.min(a[1],c[1]),Math.max(a[2],c[2]),Math.max(a[3],c[3])]}else r=t.getBounds();let o=t.projectPosition(r.slice(0,2)),n=t.projectPosition(r.slice(2,4));return[o[0],o[1],n[0],n[1]]}function ml(t,e,r){if(!t)return[0,0,1,1];let o=Ape(e,r),n=Tpe(o);return t[2]-t[0]<=n[2]-n[0]&&t[3]-t[1]<=n[3]-n[1]?t:[Math.max(t[0],n[0]),Math.max(t[1],n[1]),Math.min(t[2],n[2]),Math.min(t[3],n[3])]}function Tpe(t){let e=t[2]-t[0],r=t[3]-t[1],o=(t[0]+t[2])/2,n=(t[1]+t[3])/2;return[o-e,n-r,o+e,n+r]}var Fh=class{constructor(){this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.channels=[],this.masks=null}setup({device:e}){this.dummyMaskMap=e.createTexture({width:1,height:1}),this.maskPass=new Oh(e,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:e,layerFilter:r,viewports:o,onViewportActive:n,views:i,effects:s,isPicking:a}){let c=!1;if(a)return{didRender:c};let l=e.filter(h=>h.props.visible&&h.props.operation.includes("mask"));if(l.length===0)return this.masks=null,this.channels.length=0,{didRender:c};this.masks={};let f=this._sortMaskChannels(l),u=o[0],d=!this.lastViewport||!this.lastViewport.equals(u);if(u.resolution!==void 0)return N.warn("MaskExtension is not supported in GlobeView")(),{didRender:c};for(let h in f){let p=this._renderChannel(f[h],{layerFilter:r,onViewportActive:n,views:i,effects:s,viewport:u,viewportChanged:d});c||(c=p)}return{didRender:c}}_renderChannel(e,{layerFilter:r,onViewportActive:o,views:n,effects:i,viewport:s,viewportChanged:a}){let c=!1,l=this.channels[e.index];if(!l)return c;let f=e===l||e.layers.length!==l.layers.length||e.layers.some((u,d)=>u!==l.layers[d]||u.props.transitions)||e.layerBounds.some((u,d)=>u!==l.layerBounds[d]);if(e.bounds=l.bounds,e.maskBounds=l.maskBounds,this.channels[e.index]=e,f||a){this.lastViewport=s;let u=hl(e.layers,s);if(e.bounds=u&&ml(u,s),f||!Ce(e.bounds,l.bounds)){let{maskPass:d,maskMap:h}=this,p=u&&pl({bounds:e.bounds,viewport:s,width:h.width,height:h.height,border:1});e.maskBounds=p?p.getBounds():[0,0,1,1],d.render({pass:"mask",channel:e.index,layers:e.layers,layerFilter:r,viewports:p?[p]:[],onViewportActive:o,views:n,effects:i,shaderModuleProps:{project:{devicePixelRatio:1}}}),c=!0}}return this.masks[e.id]={index:e.index,bounds:e.maskBounds,coordinateOrigin:e.coordinateOrigin,coordinateSystem:e.coordinateSystem},c}_sortMaskChannels(e){let r={},o=0;for(let n of e){let{id:i}=n.root,s=r[i];if(!s){if(++o>4){N.warn("Too many mask layers. The max supported is 4")();continue}s={id:i,index:this.channels.findIndex(a=>a?.id===i),layers:[],layerBounds:[],coordinateOrigin:n.root.props.coordinateOrigin,coordinateSystem:n.root.props.coordinateSystem},r[i]=s}s.layers.push(n),s.layerBounds.push(n.getBounds())}for(let n=0;n<4;n++){let i=this.channels[n];(!i||!(i.id in r))&&(this.channels[n]=null)}for(let n in r){let i=r[n];i.index<0&&(i.index=this.channels.findIndex(s=>!s),this.channels[i.index]=i)}return r}getShaderModuleProps(){return{mask:{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}}}cleanup(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0}};var vpe={maskId:"",maskByInstance:void 0,maskInverted:!1},Nh=class extends st{initializeState(){this.context.deck?._addDefaultEffect(new Fh)}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(e=Boolean(this.props.maskByInstance)),this.state.maskByInstance=e,{modules:[RV]}}draw({context:e,shaderModuleProps:r}){let o={};o.maskByInstance=Boolean(this.state.maskByInstance);let{maskId:n,maskInverted:i}=this.props,{maskChannels:s}=r.mask||{},{viewport:a}=e;if(s&&s[n]){let{index:c,bounds:l,coordinateOrigin:f}=s[n],{coordinateSystem:u}=s[n];o.enabled=!0,o.channel=c,o.inverted=i,u===Be.DEFAULT&&(u=a.isGeospatial?Be.LNGLAT:Be.CARTESIAN);let d={modelMatrix:null,fromCoordinateOrigin:f,fromCoordinateSystem:u},h=this.projectPosition([l[0],l[1],0],d),p=this.projectPosition([l[2],l[3],0],d);o.bounds=[h[0],h[1],p[0],p[1]]}else n&&N.warn(`Could not find a mask layer with id: ${n}`)(),o.enabled=!1;this.setShaderModuleProps({mask:o})}};Nh.defaultProps=vpe;Nh.extensionName="MaskExtension";var IV=Nh;var zr={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},Spe=Object.keys(zr).map(t=>`const float TERRAIN_MODE_${t} = ${zr[t]}.0;`).join(`
`),LV=Spe+`
layout(std140) uniform terrainUniforms {
float mode;
vec4 bounds;
} terrain;
uniform sampler2D terrain_map;
`,Dh={name:"terrain",dependencies:[We],vs:LV+"out vec3 commonPos;",fs:LV+"in vec3 commonPos;",inject:{"vs:#main-start":`
if (terrain.mode == TERRAIN_MODE_SKIP) {
gl_Position = vec4(0.0);
return;
}
`,"vs:DECKGL_FILTER_GL_POSITION":`
commonPos = geometry.position.xyz;
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw;
position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
commonPos.z += project.commonOrigin.z;
}
if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
vec3 anchor = geometry.worldPosition;
anchor.z = 0.0;
vec3 anchorCommon = project_position(anchor);
vec2 texCoords = (anchorCommon.xy - terrain.bounds.xy) / terrain.bounds.zw;
if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
float terrainZ = texture(terrain_map, texCoords).r;
geometry.position.z += terrainZ;
position = project_common_position_to_clipspace(geometry.position);
}
}
`,"fs:#main-start":`
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
return;
}
`,"fs:DECKGL_FILTER_COLOR":`
if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) {
vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw;
vec4 pixel = texture(terrain_map, texCoords);
if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) {
color = pixel;
} else {
// pixel is premultiplied
color = pixel + color * (1.0 - pixel.a);
}
return;
}
`},getUniforms:(t={})=>{if(!t.dummyHeightMap)return{};if("terrainSkipRender"in t||"drawToTerrainHeightMap"in t){let{drawToTerrainHeightMap:e,heightMap:r,heightMapBounds:o,dummyHeightMap:n,terrainCover:i,useTerrainHeightMap:s,terrainSkipRender:a}=t,c=We.getUniforms(t.project),{commonOrigin:l}=c,f=a?zr.SKIP:zr.NONE,u=n,d=null;if(e)f=zr.WRITE_HEIGHT_MAP,d=o;else if(s&&r)f=zr.USE_HEIGHT_MAP,u=r,d=o;else if(i){let p=(t.isPicking?i.getPickingFramebuffer():i.getRenderFramebuffer())?.colorAttachments[0].texture;t.isPicking&&(f=zr.SKIP),p?(u=p,f=f===zr.SKIP?zr.USE_COVER_ONLY:zr.USE_COVER,d=i.bounds):t.isPicking&&!a&&(f=zr.NONE)}return{mode:f,terrain_map:u,bounds:d?[d[0]-l[0],d[1]-l[1],d[2]-d[0],d[3]-d[1]]:[0,0,0,0]}}return{mode:zr.NONE,terrain_map:t.dummyHeightMap,bounds:[0,0,0,0]}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};function Uh(t,e){return t.createFramebuffer({id:e.id,colorAttachments:[t.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},dimension:"2d",width:1,height:1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var cx=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=BV(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:r,layers:o,layerNeedsRedraw:n}){e&&(this.targetLayer=e);let i=r?this._updateViewport(r):!1,s=o?this._updateLayers(o):!1;if(n){for(let a of this.layers)if(n[a]){s=!0;break}}return s||i}_updateLayers(e){let r=!1;if(e=this.tile?Cpe(this.tile,e):e,e.length!==this.layers.length)r=!0;else for(let o=0;o<e.length;o++)if(e[o].id!==this.layers[o]){r=!0;break}return r&&(this.layers=e.map(o=>o.id)),r}_updateViewport(e){let r=this.targetLayer,o=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){o=!0,this.targetBounds=this.tile.boundingBox;let i=e.projectPosition(this.targetBounds[0]),s=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[i[0],i[1],s[0],s[1]]}}else this.targetBounds!==r.getBounds()&&(o=!0,this.targetBounds=r.getBounds(),this.targetBoundsCommon=hl([r],e));if(!this.targetBoundsCommon)return!1;let n=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let i=this.renderViewport?.zoom;o=o||n!==i;let s=ml(this.targetBoundsCommon,e),a=this.bounds;o=o||!a||s.some((c,l)=>c!==a[l]),this.bounds=s}return o&&(this.renderViewport=pl({bounds:this.bounds,zoom:n,viewport:e})),o}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=Uh(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=Uh(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:r})=>this.layers.includes(r))}delete(){let{fbo:e,pickingFbo:r}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),r&&(r.colorAttachments[0].destroy(),r.destroy())}};function Cpe(t,e){return e.filter(r=>{let o=BV(r);return o?Epe(t.boundingBox,o.boundingBox):!0})}function BV(t){for(;t;){let{tile:e}=t.props;if(e)return e;t=t.parent}return null}function Epe(t,e){return t&&e?t[0][0]<e[1][0]&&e[0][0]<t[1][0]&&t[0][1]<e[1][1]&&e[0][1]<t[1][1]:!1}var wpe={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},lx=class extends At{getRenderableLayers(e,r){let{layers:o}=r,n=[],i=this._getDrawLayerParams(e,r,!0);for(let s=0;s<o.length;s++){let a=o[s];!a.isComposite&&i[s].shouldDrawLayer&&n.push(a)}return n}renderHeightMap(e,r){let o=e.getRenderFramebuffer(),n=e.renderViewport;!o||!n||(o.resize(n),this.render({...r,target:o,pass:"terrain-height-map",layers:r.layers,viewports:[n],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,r){let o=e.getRenderFramebuffer(),n=e.renderViewport;if(!o||!n)return;let i=e.filterLayers(r.layers);o.resize(n),this.render({...r,target:o,pass:`terrain-cover-${e.id}`,layers:i,viewports:[n],clearColor:[0,0,0,0]})}getLayerParameters(e,r,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&wpe}}getShaderModuleProps(e,r,o){return{terrain:{project:o.project}}}};var fx=class extends Jr{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,r){let{layers:o}=r,n=[];this.drawParameters={},this._resetColorEncoder(r.pickZ);let i=this._getDrawLayerParams(e,r);for(let s=0;s<o.length;s++){let a=o[s];!a.isComposite&&i[s].shouldDrawLayer&&(n.push(a),this.drawParameters[a.id]=i[s].layerParameters)}return n}renderTerrainCover(e,r){let o=e.getPickingFramebuffer(),n=e.renderViewport;if(!o||!n)return;let i=e.filterLayers(r.layers),s=e.targetLayer;s.props.pickable&&i.unshift(s),o.resize(n);let c=this.drawParameters[s.id]?.blendColor?.[3]??0;this.render({...r,pickingFBO:o,pass:`terrain-cover-picking-${e.id}`,layers:i,viewports:[n],cullRect:void 0,deviceRect:n,pickZ:!1,clearColor:[0,0,0,c]})}getLayerParameters(e,r,o){let n;return this.drawParameters[e.id]?n=this.drawParameters[e.id]:(n=super.getLayerParameters(e,r,o),n.blend=!0),{...n,depthCompare:"always",blendAlphaSrcFactor:"constant"}}getShaderModuleProps(e,r,o){return{...super.getShaderModuleProps(e,r,o),terrain:{project:o.project}}}};var OV=2048,kh=class{static isSupported(e){return e.isTextureFormatRenderable("rgba32float")}constructor(e){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=e}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=Uh(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:r}){let o=e.length!==this.layers.length||e.some((i,s)=>i!==this.layers[s]||i.props.transitions||i.getBounds()!==this.layersBounds[s]);o&&(this.layers=e,this.layersBounds=e.map(i=>i.getBounds()),this.layersBoundsCommon=hl(e,r));let n=!this.lastViewport||!r.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(o||n){let i=ml(this.layersBoundsCommon,r);if(i[2]<=i[0]||i[3]<=i[1])return this.renderViewport=null,!1;this.bounds=i,this.lastViewport=r;let s=r.scale,a=(i[2]-i[0])*s,c=(i[3]-i[1])*s;return this.renderViewport=a>0||c>0?pl({bounds:[r.center[0]-1,r.center[1]-1,r.center[0]+1,r.center[1]+1],zoom:r.zoom,width:Math.min(a,OV),height:Math.min(c,OV),viewport:r}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var ux=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:r}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new lx(e,{id:"terrain"}),this.terrainPickingPass=new fx(e,{id:"terrain-picking"}),kh.isSupported(e)?this.heightMap=new kh(e):N.warn("Terrain offset mode is not supported by this browser")(),r._addDefaultShaderModule(Dh)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:r}=e,o=e.pass.startsWith("picking");this.isPicking=o,this.isDrapingEnabled=!0;let n=r[0],i=(o?this.terrainPickingPass:this.terrainPass).getRenderableLayers(n,e),s=i.filter(l=>l.props.operation.includes("terrain"));if(s.length===0)return;o||i.filter(f=>f.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(s,n,e);let a=i.filter(l=>l.state.terrainDrawMode==="drape"),c=e.effects?.filter(l=>l!==this);this._updateTerrainCovers(s,a,n,{...e,effects:c})}getShaderModuleProps(e,r){if(e.props.operation.includes("mask"))return{terrain:{dummyHeightMap:this.dummyHeightMap}};let{terrainDrawMode:o}=e.state,n=this.isDrapingEnabled?this.terrainCovers.get(e.id)??null:null;return this.isPicking&&e.props.operation.includes("terrain")&&(e.state._hasPickingCover=Boolean(n?.getPickingFramebuffer())),{terrain:{project:r.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:n,useTerrainHeightMap:o==="offset",terrainSkipRender:o==="drape"||!e.props.operation.includes("draw")}}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let r of this.terrainCovers.values())r.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(Dh)}_updateHeightMap(e,r,o){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:r})||this.terrainPass.renderHeightMap(this.heightMap,{...o,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,r,o,n){let i={};for(let s of r)s.state.terrainCoverNeedsRedraw&&(i[s.id]=!0,s.state.terrainCoverNeedsRedraw=!1);for(let s of this.terrainCovers.values())s.isDirty=s.isDirty||s.shouldUpdate({layerNeedsRedraw:i});for(let s of e)this._updateTerrainCover(s,r,o,n);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,r,o,n){let i=this.isPicking?this.terrainPickingPass:this.terrainPass,s=this.terrainCovers.get(e.id);s||(s=new cx(e),this.terrainCovers.set(e.id,s));try{let a=s.shouldUpdate({targetLayer:e,viewport:o,layers:r});(this.isPicking||s.isDirty||a)&&(i.renderTerrainCover(s,{...n,layers:r,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(s.isDirty=!1))}catch(a){e.raiseError(a,`Error rendering terrain cover ${s.id}`)}}_pruneTerrainCovers(){let e=[];for(let[r,o]of this.terrainCovers)o.isActive||e.push(r);for(let r of e)this.terrainCovers.delete(r)}};var Ppe={terrainDrawMode:void 0},Vh=class extends st{getShaders(){return{modules:[Dh]}}initializeState(){this.context.deck?._addDefaultEffect(new ux)}updateState(e){let{props:r,oldProps:o}=e;if(this.state.terrainDrawMode&&r.terrainDrawMode===o.terrainDrawMode&&r.extruded===o.extruded)return;let{terrainDrawMode:n}=r;if(!n){let i=this.props.extruded,s=this.getAttributeManager()?.attributes,a=s&&"instancePositions"in s;n=i||a?"offset":"drape"}this.setState({terrainDrawMode:n})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Vh.defaultProps=Ppe;Vh.extensionName="TerrainExtension";var FV=Vh;function NV(t,e,r){switch(t.type){case"Point":return Rpe(t,e,r);case"LineString":return Mpe(t,e,r);case"Polygon":return DV(t,e,r);default:let o=t;throw new Error(`Unsupported geometry type: ${o?.type}`)}}function DV(t,e=-1/0,r=1/0){let{positions:o}=t,n=t.polygonIndices.value.filter(c=>c>=e&&c<=r),i=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(n.length>2)){let c=[];for(let l=0;l<i.length-1;l++){let f=i[l],u=i[l+1],d=dx(o,f,u);c.push(d)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<n.length-1;c++){let l=n[c],f=n[c+1],u=DV(t,l,f).coordinates;a.push(u)}return{type:"MultiPolygon",coordinates:a}}function Mpe(t,e=-1/0,r=1/0){let{positions:o}=t,n=t.pathIndices.value.filter(a=>a>=e&&a<=r);if(!(n.length>2))return{type:"LineString",coordinates:dx(o,n[0],n[1])};let s=[];for(let a=0;a<n.length-1;a++){let c=dx(o,n[a],n[a+1]);s.push(c)}return{type:"MultiLineString",coordinates:s}}function Rpe(t,e,r){let{positions:o}=t,n=dx(o,e,r);return n.length>1?{type:"MultiPoint",coordinates:n}:{type:"Point",coordinates:n[0]}}function dx(t,e,r){e=e||0,r=r||t.value.length/t.size;let o=[];for(let n=e;n<r;n++){let i=Array();for(let s=n*t.size;s<(n+1)*t.size;s++)i.push(Number(t.value[s]));o.push(i)}return o}function hx(t,e,r){let o=Ipe(t),n=Object.keys(o).filter(i=>o[i]!==Array);return Lpe(t,{propArrayTypes:o,...e},{numericPropKeys:r&&r.numericPropKeys||n,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function Ipe(t){let e={};for(let r of t)if(r.properties)for(let o in r.properties){let n=r.properties[o];e[o]=Upe(n,e[o])}return e}function Lpe(t,e,r){let{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:i,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:d,coordLength:h}=e,{numericPropKeys:p=[],PositionDataType:m=Float32Array,triangulate:g=!0}=r,_=t[0]&&"id"in t[0],x=t.length>65535?Uint32Array:Uint16Array,y={type:"Point",positions:new m(o*h),globalFeatureIds:new x(o),featureIds:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},b={type:"LineString",pathIndices:i>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new m(i*h),globalFeatureIds:new x(i),featureIds:a>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},T={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new m(c*h),globalFeatureIds:new x(c),featureIds:u>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};g&&(T.triangles=[]);for(let w of[y,b,T])for(let C of p){let S=d[C];w.numericProps[C]=new S(w.positions.length/h)}b.pathIndices[s]=i,T.polygonIndices[l]=c,T.primitivePolygonIndices[f]=c;let v={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let w of t){let C=w.geometry,S=w.properties||{};switch(C.type){case"Point":Bpe(C,y,v,h,S),y.properties.push(QE(S,p)),_&&y.fields.push({id:w.id}),v.pointFeature++;break;case"LineString":Ope(C,b,v,h,S),b.properties.push(QE(S,p)),_&&b.fields.push({id:w.id}),v.lineFeature++;break;case"Polygon":Fpe(C,T,v,h,S),T.properties.push(QE(S,p)),_&&T.fields.push({id:w.id}),v.polygonFeature++;break;default:throw new Error("Invalid geometry type")}v.feature++}return Dpe(y,b,T,h)}function Bpe(t,e,r,o,n){e.positions.set(t.data,r.pointPosition*o);let i=t.data.length/o;ew(e,n,r.pointPosition,i),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+i),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+i),r.pointPosition+=i}function Ope(t,e,r,o,n){e.positions.set(t.data,r.linePosition*o);let i=t.data.length/o;ew(e,n,r.linePosition,i),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+i),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+i);for(let s=0,a=t.indices.length;s<a;++s){let c=t.indices[s],l=s===a-1?t.data.length:t.indices[s+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/o}}function Fpe(t,e,r,o,n){e.positions.set(t.data,r.polygonPosition*o);let i=t.data.length/o;ew(e,n,r.polygonPosition,i),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+i),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+i);for(let s=0,a=t.indices.length;s<a;++s){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[s],f=t.indices[s],u=t.indices[s+1];for(let h=0,p=f.length;h<p;++h){let m=f[h],g=h===p-1?u===void 0?t.data.length:u[0]:f[h+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(g-m)/o}let d=r.polygonPosition;Npe(e,l,f,{startPosition:c,endPosition:d,coordLength:o})}}function Npe(t,e,r,{startPosition:o,endPosition:n,coordLength:i}){if(!t.triangles)return;let s=o*i,a=n*i,c=t.positions.subarray(s,a),l=r[0],f=r.slice(1).map(d=>(d-l)/i),u=bS(c,f,i,e);for(let d=0,h=u.length;d<h;++d)t.triangles.push(o+u[d])}function JE(t,e){let r={};for(let o in t)r[o]={value:t[o],size:e};return r}function Dpe(t,e,r,o){let n={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:JE(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:o},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:JE(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:o},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:JE(r.numericProps,1)}};return n.polygons&&r.triangles&&(n.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),n}function ew(t,e,r,o){for(let n in t.numericProps)if(n in e){let i=e[n];t.numericProps[n].fill(i,r,r+o)}}function QE(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}function Upe(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function zh(t,e){let r=e?.globalFeatureId;return r!==void 0?kpe(t,r):Vpe(t,e?.type)}function kpe(t,e){let r=UV(t);for(let o of r){let n=0,i=o.featureIds.value[0];for(let s=0;s<o.featureIds.value.length;s++){let a=o.featureIds.value[s];if(a!==i){if(e===o.globalFeatureIds.value[n])return px(o,n,s);n=s,i=a}}if(e===o.globalFeatureIds.value[n])return px(o,n,o.featureIds.value.length)}throw new Error(`featureId:${e} not found`)}function Vpe(t,e){let r=UV(t,e);return zpe(r)}function UV(t,e){let r=[];return t.points&&(t.points.type="Point",r.push(t.points)),t.lines&&(t.lines.type="LineString",r.push(t.lines)),t.polygons&&(t.polygons.type="Polygon",r.push(t.polygons)),r}function zpe(t){let e=[];for(let r of t){if(r.featureIds.value.length===0)continue;let o=0,n=r.featureIds.value[0];for(let i=0;i<r.featureIds.value.length;i++){let s=r.featureIds.value[i];s!==n&&(e.push(px(r,o,i)),o=i,n=s)}e.push(px(r,o,r.featureIds.value.length))}return e}function px(t,e,r){let o=NV(t,e,r),n=jpe(t,e,r),i=Hpe(t,e,r);return{type:"Feature",geometry:o,properties:n,...i}}function Hpe(t,e=0,r){return t.fields&&t.fields[t.featureIds.value[e]]}function jpe(t,e=0,r){let o=Object.assign({},t.properties[t.featureIds.value[e]]);for(let n in t.numericProps)o[n]=t.numericProps[n].value[e];return o}var sw=kn(GV(),1);function ame(t){let e=0;for(let r=0,o=t.length-1,n,i;r<t.length;o=r++)n=t[r],i=t[o],e+=(i[0]-n[0])*(n[1]+i[1]);return e}function ow(t,e){if(Array.isArray(t[0])){for(let o of t)ow(o,e);return}let r=t;r[0]/=e,r[1]/=e}function $V(t,e){for(let r=0;r<t.length;++r)t[r]/=e}function nw(t,e,r){if(typeof t[0][0]!="number"){for(let s of t)nw(s,e,r);return}let o=r*Math.pow(2,e.z),n=r*e.x,i=r*e.y;for(let s=0;s<t.length;s++){let a=t[s];a[0]=(a[0]+n)*360/o-180;let c=180-(a[1]+i)*360/o;a[1]=360/Math.PI*Math.atan(Math.exp(c*Math.PI/180))-90}}function XV(t,e,r){let{x:o,y:n,z:i}=e,s=r*Math.pow(2,i),a=r*o,c=r*n;for(let l=0,f=t.length;l<f;l+=2){t[l]=(t[l]+a)*360/s-180;let u=180-(t[l+1]+c)*360/s;t[l+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function YV(t){let e=t.length;if(e<=1)return[t];let r=[],o,n;for(let i=0;i<e;i++){let s=ame(t[i]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(o&&r.push(o),o=[t[i]]):o&&o.push(t[i]))}return o&&r.push(o),r}function KV(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[xi(t.data)]],indices:[t.indices]};let o=[],n=[],i=[],s=[],a,c=0;for(let l,f=0,u;f<e;f++){u=t.indices[f]-c,l=t.indices[f+1]-c||t.data.length;let d=t.data.slice(u,l),h=xi(d);if(h===0){let p=t.data.slice(0,u),m=t.data.slice(l);t.data=p.concat(m),c+=l-u;continue}a===void 0&&(a=h<0),a===h<0?(s.length&&(o.push(i),n.push(s)),s=[u],i=[h]):(i.push(h),s.push(u))}return i&&o.push(i),s.length&&n.push(s),{type:r,areas:o,indices:n,data:t.data}}var ra=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(e,r,o,n,i,s){this.properties={},this.extent=o,this.type=0,this.id=null,this._pbf=e,this._geometry=-1,this._keys=n,this._values=i,this._geometryInfo=s,e.readFields(cme,this,r)}toGeoJSONFeature(e,r){let o=this.loadGeometry();switch(e){case"wgs84":return qV(this,o,n=>nw(n,r,this.extent));default:return qV(this,o,ow)}}toBinaryFeature(e,r){let o=this.loadFlatGeometry();switch(e){case"wgs84":return this._toBinaryCoordinates(o,n=>XV(n,r,this.extent));default:return this._toBinaryCoordinates(o,$V)}}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,o=1,n=0,i=0,s=0,a=1/0,c=-1/0,l=1/0,f=-1/0;for(;e.pos<r;){if(n<=0){let u=e.readVarint();o=u&7,n=u>>3}if(n--,o===1||o===2)i+=e.readSVarint(),s+=e.readSVarint(),i<a&&(a=i),i>c&&(c=i),s<l&&(l=s),s>f&&(f=s);else if(o!==7)throw new Error(`unknown command ${o}`)}return[a,l,c,f]}_toBinaryCoordinates(e,r){let o;r(e.data,this.extent);let n=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=e.indices.length,o={type:"Point",...e};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=e.indices.length,this._geometryInfo.linePositionsCount+=e.data.length/n,o={type:"LineString",...e};break;case 3:o=KV(e),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=o.indices.length;for(let s of o.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=o.data.length/n;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:o,properties:this.properties};return this.id!==null&&(i.id=this.id),i}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,o=1,n=0,i=0,s=0,a=[],c;for(;e.pos<r;){if(n<=0){let l=e.readVarint();o=l&7,n=l>>3}switch(n--,o){case 1:case 2:i+=e.readSVarint(),s+=e.readSVarint(),o===1&&(c&&a.push(c),c=[]),c&&c.push([i,s]);break;case 7:c&&c.push(c[0].slice());break;default:throw new Error(`unknown command ${o}`)}}return c&&a.push(c),a}loadFlatGeometry(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,o=1,n,i=0,s=0,a=0,c=0,l=[],f=[];for(;e.pos<r;)if(i<=0&&(n=e.readVarint(),o=n&7,i=n>>3),i--,o===1||o===2)s+=e.readSVarint(),a+=e.readSVarint(),o===1&&l.push(c),f.push(s,a),c+=2;else if(o===7){if(c>0){let u=l[l.length-1];f.push(f[u],f[u+1]),c+=2}}else throw new Error(`unknown command ${o}`);return{data:f,indices:l}}};k(ra,"types",["Unknown","Point","LineString","Polygon"]);function qV(t,e,r){let o=ra.types[t.type],n,i,s;switch(t.type){case 1:let c=[];for(n=0;n<e.length;n++)c[n]=e[n][0];s=c,r(s,t.extent);break;case 2:for(s=e,n=0;n<s.length;n++)r(s[n],t.extent);break;case 3:for(s=YV(e),n=0;n<s.length;n++)for(i=0;i<s[n].length;i++)r(s[n][i],t.extent);break;default:throw new Error("illegal vector tile type")}s.length===1?s=s[0]:o=`Multi${o}`;let a={type:"Feature",geometry:{type:o,coordinates:s},properties:t.properties};return t.id!==null&&(a.properties||={},a.properties.id=t.id),a}function cme(t,e,r){e&&r&&(t===1?e.id=r.readVarint():t===2?lme(r,e):t===3?e.type=r.readVarint():t===4&&(e._geometry=r.pos))}function lme(t,e){let r=t.readVarint()+t.pos;for(;t.pos<r;){let o=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[o]=n}}var _x=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(fme,this,r),this.length=this._features.length}getGeoJSONFeature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new ra(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let o=this._pbf.readVarint()+this._pbf.pos;return new ra(this._pbf,o,this.extent,this._keys,this._values,r)}};function fme(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(ume(r)))}function ume(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let o=t.readVarint()>>3;e=o===1?t.readString():o===2?t.readFloat():o===3?t.readDouble():o===4?t.readVarint64():o===5?t.readVarint():o===6?t.readSVarint():o===7?t.readBoolean():null}return e}var Hh=class{layers;constructor(e,r){this.layers=e.readFields(dme,{},r)}};function dme(t,e,r){if(t===3&&r){let o=new _x(r,r.readVarint()+r.pos);o.length&&e&&(e[o.name]=o)}}function aw(t,e){let r=pme(e),o=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(o){case"columnar-table":return{shape:"columnar-table",data:iw(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:ZV(t,r)};case"geojson":return ZV(t,r);case"binary-geometry":return iw(t,r);case"binary":return iw(t,r);default:throw new Error(o||"undefined shape")}}function iw(t,e){let[r,o]=hme(t,e),n=hx(r,o);return n.byteLength=t.byteLength,n}function hme(t,e){let r=[],o={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,o];let n=new Hh(new sw.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(n.layers)).forEach(s=>{let a=n.layers[s];if(a)for(let c=0;c<a.length;c++){let l=a.getBinaryFeature(c,o),f=gme(l,e,s);r.push(f)}}),[r,o]}function ZV(t,e){if(t.byteLength<=0)return[];let r=[],o=new Hh(new sw.default(t));return(Array.isArray(e.layers)?e.layers:Object.keys(o.layers)).forEach(i=>{let s=o.layers[i];if(s)for(let a=0;a<s.length;a++){let c=s.getGeoJSONFeature(a),l=mme(c,e,i);r.push(l)}}),r}function pme(t){if(!t?.mvt)throw new Error("mvt options required");if(t.mvt?.coordinates==="wgs84"&&!t.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return t.gis&&Wl.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),t.mvt}function mme(t,e,r){let o=t.toGeoJSONFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&(o.properties||={},o.properties[e.layerProperty]=r),o}function gme(t,e,r){let o=t.toBinaryFeature(e.coordinates||"local",e.tileIndex);return e.layerProperty&&o.properties&&(o.properties[e.layerProperty]=r),o}var JV={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var _me="4.4.3",yx={...JV,dataType:null,batchType:null,version:_me,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},yme={...yx,parse:async(t,e)=>aw(t,e),parseSync:aw,binary:!0};var xme={Point:QV,MultiPoint:bme,LineString:ez,MultiLineString:Ame,Polygon:tz,MultiPolygon:Tme};function QV([t,e],[r,o],n){let i=lt(r[0],o[0],t),s=lt(r[1],o[1],e);return n.unprojectFlat([i,s])}function cw(t,e,r){return t.map(o=>QV(o,e,r))}function bme(t,e,r){return cw(t,e,r)}function ez(t,e,r){return cw(t,e,r)}function Ame(t,e,r){return t.map(o=>ez(o,e,r))}function tz(t,e,r){return t.map(o=>cw(o,e,r))}function Tme(t,e,r){return t.map(o=>tz(o,e,r))}function rz(t,e,r){let o=r.projectFlat([e.west,e.north]),n=r.projectFlat([e.east,e.south]),i=[o,n];return{...t,coordinates:xme[t.type](t.coordinates,i,r)}}var vme=["points","lines","polygons"];function lw(t,e,r,o){for(let n of vme){let i=t[n]&&Sme(t[n],e,r,o);if(i>=0)return i}return-1}function Sme(t,e,r,o){let n=t.featureIds.value;if(!n.length)return-1;let i=0,s=n[n.length-1]+1;if(o){let c=Cme(t,o);if(c)i=c[0],s=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,f)=>l===r&&n[f]>=i&&n[f]<s);return c>=0?t.globalFeatureIds.value[c]:-1}else e?a=oz(t.properties,c=>c[e]===r,i,s):t.fields&&(a=oz(t.fields,c=>c.id===r,i,s));return a>=0?Eme(t,a):-1}function Cme(t,e){if(!t.__layers){let r={},{properties:o}=t;for(let n=0;n<o.length;n++){let{layerName:i}=o[n];i&&(r[i]?r[i][1]=n:r[i]=[n,n])}t.__layers=r}return t.__layers[e]}function Eme(t,e){if(!t.__ids){let r=[],o=t.featureIds.value,n=t.globalFeatureIds.value;for(let i=0;i<o.length;i++)r[o[i]]=n[i];t.__ids=r}return t.__ids[e]}function oz(t,e,r,o){for(let n=r;n<o;n++)if(e(t[n],n))return n;return-1}var fw=512,wme={...Os.defaultProps,data:Pi,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[yx],binary:!0},jh=class extends Ws{initializeState(){super.initializeState();let e=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:e,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:e,oldProps:r,context:o,changeFlags:n}){n.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:r,context:o,changeFlags:n}),this._setWGS84PropertyForTiles());let{highlightColor:i}=e;i!==r.highlightColor&&Array.isArray(i)&&this.setState({highlightColor:i})}async _updateTileData(){let e=this.props.data,r=null;if(typeof e=="string"&&!bC(e)){let{onDataLoad:o,fetch:n}=this.props;this.setState({data:null,tileJSON:null});try{r=await n(e,{propName:"data",layer:this,loaders:[]})}catch(i){this.raiseError(i,"loading TileJSON"),e=null}o&&o(r,{propName:"data",layer:this})}else e&&typeof e=="object"&&"tilejson"in e&&(r=e);r&&(e=r.tiles),this.setState({data:e,tileJSON:r})}_getTilesetOptions(){let e=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:o,maxZoom:n}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>o&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(n)||r.maxzoom<n)&&(e.maxZoom=r.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){let{data:r,binary:o}=this.state,{index:n,signal:i}=e,s=Yo(r,e);if(!s)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,core:{...a?.core,mimeType:"application/x-protobuf"},mvt:{...a?.mvt,shape:o?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:n}},c(s,{propName:"data",layer:this,loadOptions:a,signal:i})}renderSubLayers(e){let{x:r,y:o,z:n}=e.tile.index,i=Math.pow(2,n),s=fw/i,a=-s,c=fw*r/i,l=fw*(1-o/i),f=new V().scale([s,a,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=f,e.coordinateOrigin=[c,l,0],e.coordinateSystem=Be.CARTESIAN,e.extensions=[...e.extensions||[],new ax]);let u=super.renderSubLayers(e);return this.state.binary&&!(u instanceof Os)&&N.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),u}_updateAutoHighlight(e){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:o,hoveredFeatureLayerName:n}=this.state,i=e.object,s=null,a=null;i&&(s=uw(i,r),a=nz(i));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(e)),(o!==s||n!==a)&&this.setState({highlightColor:c,hoveredFeatureId:s,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){let r=super.getPickingInfo(e);if(this.state.binary&&r.index!==-1){let{data:o}=e.sourceLayer.props;r.object=zh(o,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=sz(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){let{hoveredFeatureId:r,hoveredFeatureLayerName:o,binary:n}=this.state,{uniqueIdProperty:i,highlightedFeatureId:s}=this.props,a=e.content,c=iz(s);if(!(iz(r)||c))return-1;let f=c?s:r;return Array.isArray(a)?a.findIndex(u=>{let d=uw(u,i)===f,h=c||nz(u)===o;return d&&h}):a&&n?lw(a,i,f,c?"":o):-1}_pickObjects(e){let{deck:r,viewport:o}=this.context,n=o.width,i=o.height,s=o.x,a=o.y,c=[this.id];return r.pickObjects({x:s,y:a,width:n,height:i,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),o=new Set,n=[];for(let i of r){let s=uw(i.object,this.props.uniqueIdProperty);s===void 0?n.push(i.object):o.has(s)||(o.add(s),n.push(i.object))}return n}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(o=>{o.hasOwnProperty(e)||Object.defineProperty(o,e,{get:()=>{if(!o.content)return null;if(this.state.binary&&Array.isArray(o.content)&&!o.content.length)return[];let{bbox:n}=o;if(o._contentWGS84===void 0&&AC(n)){let i=this.state.binary?zh(o.content):o.content;o._contentWGS84=i.map(s=>sz(s,n,this.context.viewport))}return o._contentWGS84}})})}};jh.layerName="MVTLayer";jh.defaultProps=wme;var az=jh;function uw(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function nz(t){return t.properties?.layerName||null}function iz(t){return t!=null&&t!==""}function sz(t,e,r){let o={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(o.geometry,"coordinates",{get:()=>rz(t.geometry,e,r).coordinates}),o}var cz="0123456789bcdefghjkmnpqrstuvwxyz",lz={};for(let t=0;t<cz.length;t++)lz[cz.charAt(t)]=t;var Pme=-90,Mme=90,Rme=-180,Ime=180;function Lme(t){let e=!0,r=Mme,o=Pme,n=Ime,i=Rme,s,a=0;for(let c=0,l=t.length;c<l;c++){let f=t[c].toLowerCase();a=lz[f];for(let u=4;u>=0;u--){let d=a>>u&1;e?(s=(n+i)/2,d===1?i=s:n=s):(s=(r+o)/2,d===1?o=s:r=s),e=!e}}return[o,i,r,n]}function fz(t){let[e,r,o,n]=Lme(t);return[n,o,n,e,r,e,r,o,n,o]}var Bme={getGeohash:{type:"accessor",value:t=>t.geohash}},Wh=class extends Or{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(o,n)=>fz(r(o,n))}}};Wh.layerName="GeohashLayer";Wh.defaultProps=Bme;var uz=Wh;var dw={};ze(dw,{Buffer:()=>K,BufferTransform:()=>ur,CubeGeometry:()=>dn,Device:()=>Xt,Framebuffer:()=>Eo,Geometry:()=>ce,GroupNode:()=>qt,Model:()=>Q,ModelNode:()=>Io,ScenegraphNode:()=>Rr,SphereGeometry:()=>ru,Texture:()=>Y,TextureTransform:()=>fi,attachDevice:()=>Dme,createDevice:()=>Ume,enforceWebGL2:()=>kme,getSupportedAdapters:()=>Fme,setDefaultDeviceProps:()=>Nme,stats:()=>Ome});q();q();var{stats:Ome,getSupportedAdapters:Fme,setDefaultDeviceProps:Nme,attachDevice:Dme,createDevice:Ume,enforceWebGL2:kme}=Co;var hw={};ze(hw,{fetchFile:()=>Ea,load:()=>Kn,parse:()=>Yn,registerLoaders:()=>of});var xx=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let r=this.props,o={...this.props,...e};if(this.props=o,!this.map)return;this._update(r,o)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:r,container:o}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:o,maxZoom:24,...e.mapOptions,...dz(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(o,"offsetWidth",{get:()=>this.width}),Object.defineProperty(o,"clientWidth",{get:()=>this.width}),Object.defineProperty(o,"offsetHeight",{get:()=>this.height}),Object.defineProperty(o,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let n=e.width!==r.width||e.height!==r.height;n&&(this.width=r.width,this.height=r.height,this.map.resize());let i=e.viewState,s=r.viewState,a=s.latitude!==i.latitude||s.longitude!==i.longitude||s.zoom!==i.zoom||s.pitch!==i.pitch||s.bearing!==i.bearing;return a&&this.map.jumpTo(dz(s)),n||a}};function dz(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var hz={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function Vme(t){let{container:e=document.body}=t;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let o=document.createElement("div");e.appendChild(o),Object.assign(o.style,hz);let n=document.createElement("canvas");return e.appendChild(n),Object.assign(n.style,hz),{container:e,mapCanvas:o,deckCanvas:n}}var Gh=class extends An{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:o}=Vme(e),n=e.viewState||e.initialViewState,i=Number.isFinite(n&&n.latitude),{map:s=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:o,...e}),s&&s.Map?this._map=i&&new xx({...e,width:0,height:0,viewState:n,container:r,mapLib:s}):this._map=s}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,r){if(this._map){let o=this.getViewports()[0];o&&this._map.setProps({width:o.width,height:o.height,viewState:o})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,dw);Object.assign(globalThis.loaders,hw);function pz({pointCount:t,getBinId:e}){let r=new Map;for(let o=0;o<t;o++){let n=e(o);if(n===null)continue;let i=r.get(String(n));i?i.points.push(o):(i={id:n,index:r.size,points:[o]},r.set(String(n),i))}return Array.from(r.values())}function mz({bins:t,dimensions:e,target:r}){let o=t.length*e;(!r||r.length<o)&&(r=new Float32Array(o));for(let n=0;n<t.length;n++){let{id:i}=t[n];Array.isArray(i)?r.set(i,n*e):r[n]=i}return r}var zme=t=>t.length,gz=(t,e)=>{let r=0;for(let o of t)r+=e(o);return r},Hme=(t,e)=>t.length===0?NaN:gz(t,e)/t.length,jme=(t,e)=>{let r=1/0;for(let o of t){let n=e(o);n<r&&(r=n)}return r},Wme=(t,e)=>{let r=-1/0;for(let o of t){let n=e(o);n>r&&(r=n)}return r},_z={COUNT:zme,SUM:gz,MEAN:Hme,MIN:jme,MAX:Wme};function yz({bins:t,getValue:e,operation:r,target:o}){(!o||o.length<t.length)&&(o=new Float32Array(t.length));let n=1/0,i=-1/0;for(let s=0;s<t.length;s++){let{points:a}=t[s];o[s]=r(a,e),o[s]<n&&(n=o[s]),o[s]>i&&(i=o[s])}return{value:o,domain:[n,i]}}function pw(t,e,r){let o={};for(let i of t.sources||[]){let s=e[i];if(s)o[i]=Gme(s);else throw new Error(`Cannot find attribute ${i}`)}let n={};return i=>{for(let s in o)n[s]=o[s](i);return t.getValue(n,i,r)}}function Gme(t){let e=t.value,{offset:r=0,stride:o,size:n}=t.getAccessor(),i=e.BYTES_PER_ELEMENT,s=r/i,a=o?o/i:n;if(n===1)return t.isConstant?()=>e[0]:l=>{let f=s+a*l;return e[f]};let c;return t.isConstant?(c=Array.from(e),()=>c):(c=new Array(n),l=>{let f=s+a*l;for(let u=0;u<n;u++)c[u]=e[f+u];return c})}var $t=class{constructor(e){this.bins=[],this.binIds=null,this.results=[],this.dimensions=e.dimensions,this.channelCount=e.getValue.length,this.props={...e,binOptions:{},pointCount:0,operations:[],customOperations:[],attributes:{}},this.needsUpdate=!0,this.setProps(e)}destroy(){}get binCount(){return this.bins.length}setProps(e){let r=this.props;if(e.binOptions&&(ie(e.binOptions,r.binOptions,2)||this.setNeedsUpdate()),e.operations)for(let o=0;o<this.channelCount;o++)e.operations[o]!==r.operations[o]&&this.setNeedsUpdate(o);if(e.customOperations)for(let o=0;o<this.channelCount;o++)Boolean(e.customOperations[o])!==Boolean(r.customOperations[o])&&this.setNeedsUpdate(o);e.pointCount!==void 0&&e.pointCount!==r.pointCount&&this.setNeedsUpdate(),e.attributes&&(e.attributes={...r.attributes,...e.attributes}),Object.assign(this.props,e)}setNeedsUpdate(e){e===void 0?this.needsUpdate=!0:this.needsUpdate!==!0&&(this.needsUpdate=this.needsUpdate||[],this.needsUpdate[e]=!0)}update(){if(this.needsUpdate===!0){this.bins=pz({pointCount:this.props.pointCount,getBinId:pw(this.props.getBin,this.props.attributes,this.props.binOptions)});let e=mz({bins:this.bins,dimensions:this.dimensions,target:this.binIds?.value});this.binIds={value:e,type:"float32",size:this.dimensions}}for(let e=0;e<this.channelCount;e++)if(this.needsUpdate===!0||this.needsUpdate[e]){let r=this.props.customOperations[e]||_z[this.props.operations[e]],{value:o,domain:n}=yz({bins:this.bins,getValue:pw(this.props.getValue[e],this.props.attributes,void 0),operation:r,target:this.results[e]?.value});this.results[e]={value:o,domain:n,type:"float32",size:1},this.props.onUpdate?.({channel:e})}this.needsUpdate=!1}preDraw(){}getBins(){return this.binIds}getResult(e){return this.results[e]}getResultDomain(e){return this.results[e]?.domain??[1/0,-1/0]}getBin(e){let r=this.bins[e];if(!r)return null;let o=new Array(this.channelCount);for(let n=0;n<o.length;n++){let i=this.results[n];o[n]=i?.value[e]}return{id:r.id,value:o,count:r.points.length,pointIndices:r.points}}};function bx(t,e,r){return t.createFramebuffer({width:e,height:r,colorAttachments:[t.createTexture({width:e,height:r,format:"rgba32float",sampler:{minFilter:"nearest",magFilter:"nearest"}})]})}var $me=`layout(std140) uniform binSorterUniforms {
ivec4 binIdRange;
ivec2 targetSize;
} binSorter;
`,xz={name:"binSorter",vs:$me,uniformTypes:{binIdRange:"vec4<i32>",targetSize:"vec2<i32>"}};var Az=[1,2,4,8],bz=3e38,Xme={SUM:0,MEAN:0,MIN:0,MAX:0,COUNT:0},$h=1024,Ax=class{constructor(e,r){this.binsFBO=null,this.device=e,this.model=Kme(e,r)}get texture(){return this.binsFBO?this.binsFBO.colorAttachments[0].texture:null}destroy(){this.model.destroy(),this.binsFBO?.colorAttachments[0].texture.destroy(),this.binsFBO?.destroy()}getBinValues(e){if(!this.binsFBO)return null;let r=e%$h,o=Math.floor(e/$h),n=this.device.readPixelsToArrayWebGL(this.binsFBO,{sourceX:r,sourceY:o,sourceWidth:1,sourceHeight:1}).buffer;return new Float32Array(n)}setDimensions(e,r){let o=$h,n=Math.ceil(e/o);this.binsFBO?this.binsFBO.height<n&&this.binsFBO.resize({width:o,height:n}):this.binsFBO=bx(this.device,o,n);let i={binIdRange:[r[0][0],r[0][1],r[1]?.[0]||0,r[1]?.[1]||0],targetSize:[this.binsFBO.width,this.binsFBO.height]};this.model.shaderInputs.setProps({binSorter:i})}setModelProps(e){let r=this.model;e.attributes&&r.setAttributes(e.attributes),e.constantAttributes&&r.setConstantAttributes(e.constantAttributes),e.vertexCount!==void 0&&r.setVertexCount(e.vertexCount),e.shaderModuleProps&&r.shaderInputs.setProps(e.shaderModuleProps)}update(e){if(!this.binsFBO)return;let r=Yme(e);this._updateBins("SUM",r.SUM+r.MEAN),this._updateBins("MIN",r.MIN),this._updateBins("MAX",r.MAX)}_updateBins(e,r){if(r===0)return;r|=Az[3];let o=this.model,n=this.binsFBO,i=e==="MAX"?-bz:e==="MIN"?bz:0,s=this.device.beginRenderPass({id:`gpu-aggregation-${e}`,framebuffer:n,parameters:{viewport:[0,0,n.width,n.height],colorMask:r},clearColor:[i,i,i,0],clearDepth:!1,clearStencil:!1});o.setParameters({blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:e==="MAX"?"max":e==="MIN"?"min":"add",blendAlphaOperation:"add"}),o.draw(s),s.end()}};function Yme(t){let e={...Xme};for(let r=0;r<t.length;r++){let o=t[r];o&&(e[o]+=Az[r])}return e}function Kme(t,e){let r=e.vs;e.dimensions===2&&(r+=`
void getBin(out int binId) {
ivec2 binId2;
getBin(binId2);
if (binId2.x < binSorter.binIdRange.x || binId2.x >= binSorter.binIdRange.y) {
binId = -1;
} else {
binId = (binId2.y - binSorter.binIdRange.z) * (binSorter.binIdRange.y - binSorter.binIdRange.x) + binId2.x;
}
}
`);let o=`#version 300 es
#define SHADER_NAME gpu-aggregation-sort-bins-vertex
${r}
out vec3 v_Value;
void main() {
int binIndex;
getBin(binIndex);
binIndex = binIndex - binSorter.binIdRange.x;
if (binIndex < 0) {
gl_Position = vec4(0.);
return;
}
int row = binIndex / binSorter.targetSize.x;
int col = binIndex - row * binSorter.targetSize.x;
vec2 position = (vec2(col, row) + 0.5) / vec2(binSorter.targetSize) * 2.0 - 1.0;
gl_Position = vec4(position, 0.0, 1.0);
gl_PointSize = 1.0;
#if NUM_CHANNELS == 3
getValue(v_Value);
#elif NUM_CHANNELS == 2
getValue(v_Value.xy);
#else
getValue(v_Value.x);
#endif
}
`,n=`#version 300 es
#define SHADER_NAME gpu-aggregation-sort-bins-fragment
precision highp float;
in vec3 v_Value;
out vec4 fragColor;
void main() {
fragColor.xyz = v_Value;
#ifdef MODULE_GEOMETRY
geometry.uv = vec2(0.);
DECKGL_FILTER_COLOR(fragColor, geometry);
#endif
fragColor.w = 1.0;
}
`;return new Q(t,{bufferLayout:e.bufferLayout,modules:[...e.modules||[],xz],defines:{...e.defines,NON_INSTANCED_MODEL:1,NUM_CHANNELS:e.channelCount},isInstanced:!1,vs:o,fs:n,topology:"point-list",disableWarnings:!0})}var qme=`layout(std140) uniform aggregatorTransformUniforms {
ivec4 binIdRange;
bvec3 isCount;
bvec3 isMean;
float naN;
} aggregatorTransform;
`,Tz={name:"aggregatorTransform",vs:qme,uniformTypes:{binIdRange:"vec4<i32>",isCount:"vec3<f32>",isMean:"vec3<f32>",naN:"f32"}};var mw=3e38,Tx=class{constructor(e,r){this.binBuffer=null,this.valueBuffer=null,this._domains=null,this.device=e,this.channelCount=r.channelCount,this.transform=Zme(e,r),this.domainFBO=bx(e,2,1)}destroy(){this.transform.destroy(),this.binBuffer?.destroy(),this.valueBuffer?.destroy(),this.domainFBO.colorAttachments[0].texture.destroy(),this.domainFBO.destroy()}get domains(){if(!this._domains){let e=this.device.readPixelsToArrayWebGL(this.domainFBO).buffer,r=new Float32Array(e);this._domains=[[-r[4],r[0]],[-r[5],r[1]],[-r[6],r[2]]].slice(0,this.channelCount)}return this._domains}setDimensions(e,r){let{model:o,transformFeedback:n}=this.transform;o.setVertexCount(e);let i={binIdRange:[r[0][0],r[0][1],r[1]?.[0]||0,r[1]?.[1]||0]};o.shaderInputs.setProps({aggregatorTransform:i});let s=e*r.length*4;(!this.binBuffer||this.binBuffer.byteLength<s)&&(this.binBuffer?.destroy(),this.binBuffer=this.device.createBuffer({byteLength:s}),n.setBuffer("binIds",this.binBuffer));let a=e*this.channelCount*4;(!this.valueBuffer||this.valueBuffer.byteLength<a)&&(this.valueBuffer?.destroy(),this.valueBuffer=this.device.createBuffer({byteLength:a}),n.setBuffer("values",this.valueBuffer))}update(e,r){if(!e)return;let o=this.transform,n=this.domainFBO,i=[0,1,2].map(c=>r[c]==="COUNT"?1:0),s=[0,1,2].map(c=>r[c]==="MEAN"?1:0),a={isCount:i,isMean:s,bins:e};o.model.shaderInputs.setProps({aggregatorTransform:a}),o.run({id:"gpu-aggregation-domain",framebuffer:n,parameters:{viewport:[0,0,2,1]},clearColor:[-mw,-mw,-mw,0],clearDepth:!1,clearStencil:!1}),this._domains=null}};function Zme(t,e){let r=`#version 300 es
#define SHADER_NAME gpu-aggregation-domain-vertex
uniform sampler2D bins;
#if NUM_DIMS == 1
out float binIds;
#else
out vec2 binIds;
#endif
#if NUM_CHANNELS == 1
flat out float values;
#elif NUM_CHANNELS == 2
flat out vec2 values;
#else
flat out vec3 values;
#endif
const float NAN = intBitsToFloat(-1);
void main() {
int row = gl_VertexID / SAMPLER_WIDTH;
int col = gl_VertexID - row * SAMPLER_WIDTH;
vec4 weights = texelFetch(bins, ivec2(col, row), 0);
vec3 value3 = mix(
mix(weights.rgb, vec3(weights.a), aggregatorTransform.isCount),
weights.rgb / max(weights.a, 1.0),
aggregatorTransform.isMean
);
if (weights.a == 0.0) {
value3 = vec3(NAN);
}
#if NUM_DIMS == 1
binIds = float(gl_VertexID + aggregatorTransform.binIdRange.x);
#else
int y = gl_VertexID / (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);
int x = gl_VertexID - y * (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);
binIds.y = float(y + aggregatorTransform.binIdRange.z);
binIds.x = float(x + aggregatorTransform.binIdRange.x);
#endif
#if NUM_CHANNELS == 3
values = value3;
#elif NUM_CHANNELS == 2
values = value3.xy;
#else
values = value3.x;
#endif
gl_Position = vec4(0., 0., 0., 1.);
// This model renders into a 2x1 texture to obtain min and max simultaneously.
// See comments in fragment shader
gl_PointSize = 2.0;
}
`,o=`#version 300 es
#define SHADER_NAME gpu-aggregation-domain-fragment
precision highp float;
#if NUM_CHANNELS == 1
flat in float values;
#elif NUM_CHANNELS == 2
flat in vec2 values;
#else
flat in vec3 values;
#endif
out vec4 fragColor;
void main() {
vec3 value3;
#if NUM_CHANNELS == 3
value3 = values;
#elif NUM_CHANNELS == 2
value3.xy = values;
#else
value3.x = values;
#endif
if (isnan(value3.x)) discard;
// This shader renders into a 2x1 texture with blending=max
// The left pixel yields the max value of each channel
// The right pixel yields the min value of each channel
if (gl_FragCoord.x < 1.0) {
fragColor = vec4(value3, 1.0);
} else {
fragColor = vec4(-value3, 1.0);
}
}
`;return t.type==="webgl"&&t.getExtension("GL_ARB_shader_bit_encoding"),new ur(t,{vs:r,fs:o,topology:"point-list",modules:[Tz],parameters:{blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},defines:{NUM_DIMS:e.dimensions,NUM_CHANNELS:e.channelCount,SAMPLER_WIDTH:$h},varyings:["binIds","values"],disableWarnings:!0})}var Qe=class{static isSupported(e){return e.features.has("float32-renderable-webgl")&&e.features.has("texture-blend-float-webgl")}constructor(e,r){this.binCount=0,this.binIds=null,this.results=[],this.device=e,this.dimensions=r.dimensions,this.channelCount=r.channelCount,this.props={...r,pointCount:0,binIdRange:[[0,0]],operations:[],attributes:{},binOptions:{}},this.needsUpdate=new Array(this.channelCount).fill(!0),this.binSorter=new Ax(e,r),this.aggregationTransform=new Tx(e,r),this.setProps(r)}getBins(){let e=this.aggregationTransform.binBuffer;return e?(this.binIds?.buffer!==e&&(this.binIds={buffer:e,type:"float32",size:this.dimensions}),this.binIds):null}getResult(e){let r=this.aggregationTransform.valueBuffer;return!r||e>=this.channelCount?null:(this.results[e]?.buffer!==r&&(this.results[e]={buffer:r,type:"float32",size:1,stride:this.channelCount*4,offset:e*4}),this.results[e])}getResultDomain(e){return this.aggregationTransform.domains[e]}getBin(e){if(e<0||e>=this.binCount)return null;let{binIdRange:r}=this.props,o;if(this.dimensions===1)o=[e+r[0][0]];else{let[[a,c],[l]]=r,f=c-a;o=[e%f+a,Math.floor(e/f)+l]}let n=this.binSorter.getBinValues(e);if(!n)return null;let i=n[3],s=[];for(let a=0;a<this.channelCount;a++){let c=this.props.operations[a];c==="COUNT"?s[a]=i:i===0?s[a]=NaN:s[a]=c==="MEAN"?n[a]/i:n[a]}return{id:o,value:s,count:i}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(e){let r=this.props;if("binIdRange"in e&&!ie(e.binIdRange,r.binIdRange,2)){let o=e.binIdRange;if(N.assert(o.length===this.dimensions),this.dimensions===1){let[[n,i]]=o;this.binCount=i-n}else{let[[n,i],[s,a]]=o;this.binCount=(i-n)*(a-s)}this.binSorter.setDimensions(this.binCount,o),this.aggregationTransform.setDimensions(this.binCount,o),this.setNeedsUpdate()}if(e.operations)for(let o=0;o<this.channelCount;o++)e.operations[o]!==r.operations[o]&&this.setNeedsUpdate(o);if(e.pointCount!==void 0&&e.pointCount!==r.pointCount&&(this.binSorter.setModelProps({vertexCount:e.pointCount}),this.setNeedsUpdate()),e.binOptions&&(ie(e.binOptions,r.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:e.binOptions})),e.attributes){let o={},n={};for(let i of Object.values(e.attributes))for(let[s,a]of Object.entries(i.getValue()))ArrayBuffer.isView(a)?n[s]=a:a&&(o[s]=a);this.binSorter.setModelProps({attributes:o,constantAttributes:n})}e.shaderModuleProps&&this.binSorter.setModelProps({shaderModuleProps:e.shaderModuleProps}),Object.assign(this.props,e)}setNeedsUpdate(e){e===void 0?this.needsUpdate.fill(!0):this.needsUpdate[e]=!0}update(){}preDraw(){if(!this.needsUpdate.some(Boolean))return;let{operations:e}=this.props,r=this.needsUpdate.map((o,n)=>o?e[n]:null);this.binSorter.update(r),this.aggregationTransform.update(this.binSorter.texture,e);for(let o=0;o<this.channelCount;o++)this.needsUpdate[o]&&(this.needsUpdate[o]=!1,this.props.onUpdate?.({channel:o}))}};var vx=class extends Ne{get isDrawable(){return!0}initializeState(){this.getAttributeManager().remove(["instancePickingColors"])}updateState(e){super.updateState(e);let r=this.getAggregatorType();if(e.changeFlags.extensionsChanged||this.state.aggregatorType!==r){this.state.aggregator?.destroy();let o=this.createAggregator(r);return o.setProps({attributes:this.getAttributeManager()?.attributes}),this.setState({aggregator:o,aggregatorType:r}),!0}return!1}finalizeState(e){super.finalizeState(e),this.state.aggregator.destroy()}updateAttributes(e){let{aggregator:r}=this.state;r.setProps({attributes:e});for(let o in e)this.onAttributeChange(o);r.update()}draw({shaderModuleProps:e}){let{aggregator:r}=this.state;r.setProps({shaderModuleProps:e}),r.preDraw()}_getAttributeManager(){return new pr(this.context.device,{id:this.props.id,stats:this.context.stats})}};vx.layerName="AggregationLayer";var Zo=vx;var Oi=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function gw(t,e=!1,r=Float32Array){let o;if(Number.isFinite(t[0]))o=new r(t);else{o=new r(t.length*4);let n=0;for(let i=0;i<t.length;i++){let s=t[i];o[n++]=s[0],o[n++]=s[1],o[n++]=s[2],o[n++]=Number.isFinite(s[3])?s[3]:255}}if(e)for(let n=0;n<o.length;n++)o[n]/=255;return o}var Sx={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function yl(t,e){t.setSampler({minFilter:Sx[e],magFilter:Sx[e]})}function xl(t,e,r="linear"){let o=gw(e,!1,Uint8Array);return t.createTexture({format:"rgba8unorm",sampler:{minFilter:Sx[r],magFilter:Sx[r],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:o,width:o.length/4,height:1})}var vz=`#version 300 es
#define SHADER_NAME screen-grid-layer-vertex-shader
#define RANGE_COUNT 6
in vec2 positions;
in vec2 instancePositions;
in float instanceWeights;
in vec3 instancePickingColors;
uniform sampler2D colorRange;
out vec4 vColor;
vec4 interp(float value, vec2 domain, sampler2D range) {
float r = (value - domain.x) / (domain.y - domain.x);
return texture(range, vec2(r, 0.5));
}
void main(void) {
if (isnan(instanceWeights)) {
gl_Position = vec4(0.);
return;
}
vec2 pos = instancePositions * screenGrid.gridSizeClipspace + positions * screenGrid.cellSizeClipspace;
pos.x = pos.x - 1.0;
pos.y = 1.0 - pos.y;
gl_Position = vec4(pos, 0., 1.);
vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);
vColor.a *= layer.opacity;
picking_setPickingColor(instancePickingColors);
}
`;var Sz=`#version 300 es
#define SHADER_NAME screen-grid-layer-fragment-shader
precision highp float;
in vec4 vColor;
out vec4 fragColor;
void main(void) {
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var Jme=`layout(std140) uniform screenGridUniforms {
vec2 cellSizeClipspace;
vec2 gridSizeClipspace;
vec2 colorDomain;
} screenGrid;
`,Cz={name:"screenGrid",vs:Jme,uniformTypes:{cellSizeClipspace:"vec2<f32>",gridSizeClipspace:"vec2<f32>",colorDomain:"vec2<f32>"}};var Cx=class extends _e{getShaders(){return super.getShaders({vs:vz,fs:Sz,modules:[Se,Cz]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceWeights:{size:1,type:"float32",accessor:"getWeight"}}),this.state.model=this._getModel()}updateState(e){super.updateState(e);let{props:r,oldProps:o,changeFlags:n}=e,i=this.state.model;if(o.colorRange!==r.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=xl(this.context.device,r.colorRange,r.colorScaleType);let s={colorRange:this.state.colorTexture};i.shaderInputs.setProps({screenGrid:s})}else o.colorScaleType!==r.colorScaleType&&yl(this.state.colorTexture,r.colorScaleType);if(o.cellMarginPixels!==r.cellMarginPixels||o.cellSizePixels!==r.cellSizePixels||n.viewportChanged){let{width:s,height:a}=this.context.viewport,{cellSizePixels:c,cellMarginPixels:l}=this.props,f=Math.max(c-l,0),u={gridSizeClipspace:[c/s*2,c/a*2],cellSizeClipspace:[f/s*2,f/a*2]};i.shaderInputs.setProps({screenGrid:u})}}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}draw({uniforms:e}){let r=this.props.colorDomain(),o=this.state.model,n={colorDomain:r};o.shaderInputs.setProps({screenGrid:n}),o.draw(this.context.renderPass)}_getModel(){return new Q(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new ce({topology:"triangle-strip",attributes:{positions:{value:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}}),isInstanced:!0})}};Cx.layerName="ScreenGridCellLayer";var Ez=Cx;var Qme=`layout(std140) uniform binOptionsUniforms {
float cellSizePixels;
} binOptions;
`,wz={name:"binOptions",vs:Qme,uniformTypes:{cellSizePixels:"f32"}};var ege={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0},colorRange:Oi,colorScaleType:"linear",getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM"},Xh=class extends Zo{getAggregatorType(){return this.props.gpuAggregation&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){return e==="cpu"||!Qe.isSupported(this.context.device)?new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:r},o,n)=>{let i=this.context.viewport,s=i.project(r),a=n.cellSizePixels;return s[0]<0||s[0]>=i.width||s[1]<0||s[1]>=i.height?null:[Math.floor(s[0]/a),Math.floor(s[1]/a)]}},getValue:[{sources:["counts"],getValue:({counts:r})=>r}]}):new Qe(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,wz],vs:`
in vec3 positions;
in vec3 positions64Low;
in float counts;
void getBin(out ivec2 binId) {
vec4 pos = project_position_to_clipspace(positions, positions64Low, vec3(0.0));
vec2 screenCoords = vec2(pos.x / pos.w + 1.0, 1.0 - pos.y / pos.w) / 2.0 * project.viewportSize.xy / project.devicePixelRatio;
vec2 gridCoords = floor(screenCoords / binOptions.cellSizePixels);
binId = ivec2(gridCoords);
}
void getValue(out float weight) {
weight = counts;
}
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{cellSizePixels:s,aggregation:a}=o;if(r||i.dataChanged||i.updateTriggersChanged||i.viewportChanged||a!==n.aggregation||s!==n.cellSizePixels){let{width:c,height:l}=this.context.viewport,{aggregator:f}=this.state;f instanceof Qe&&f.setProps({binIdRange:[[0,Math.ceil(c/s)],[0,Math.ceil(l/s)]]}),f.setProps({pointCount:this.getNumInstances(),operations:[a],binOptions:{cellSizePixels:s}})}return i.viewportChanged&&this.state.aggregator.setNeedsUpdate(),r}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate();break;case"counts":r.setNeedsUpdate(0);break;default:}}renderLayers(){let{aggregator:e}=this.state,r=this.getSubLayerClass("cells",Ez),o=e.getBins(),n=e.getResult(0);return new r(this.props,this.getSubLayerProps({id:"cell-layer"}),{data:{length:e.binCount,attributes:{getBin:o,getWeight:n}},dataComparator:(i,s)=>i.length===s.length,updateTriggers:{getBin:[o],getWeight:[n]},parameters:{depthWriteEnabled:!1,...this.props.parameters},colorDomain:()=>this.props.colorDomain||e.getResultDomain(0),extensions:[]})}getPickingInfo(e){let r=e.info,{index:o}=r;if(o>=0){let n=this.state.aggregator.getBin(o),i;n&&(i={col:n.id[0],row:n.id[1],value:n.value[0],count:n.count},n.pointIndices&&(i.pointIndices=n.pointIndices,i.points=Array.isArray(this.props.data)?n.pointIndices.map(s=>this.props.data[s]):[])),r.object=i}return r}};Xh.layerName="ScreenGridLayer";Xh.defaultProps=ege;var Pz=Xh;var Fi=class{constructor(e,r){this.props={scaleType:"linear",lowerPercentile:0,upperPercentile:100},this.domain=null,this.cutoff=null,this.input=e,this.inputLength=r,this.attribute=e}getScalePercentile(){if(!this._percentile){let e=Mz(this.input,this.inputLength);this._percentile=rge(e)}return this._percentile}getScaleOrdinal(){if(!this._ordinal){let e=Mz(this.input,this.inputLength);this._ordinal=tge(e)}return this._ordinal}getCutoff({scaleType:e,lowerPercentile:r,upperPercentile:o}){if(e==="quantile")return[r,o-1];if(r>0||o<100){let{domain:n}=this.getScalePercentile(),i=n[Math.floor(r)-1]??-1/0,s=n[Math.floor(o)-1]??1/0;if(e==="ordinal"){let{domain:a}=this.getScaleOrdinal();i=a.findIndex(c=>c>=i),s=a.findIndex(c=>c>s)-1,s===-2&&(s=a.length-1)}return[i,s]}return null}update(e){let r=this.props;if(e.scaleType!==r.scaleType)switch(e.scaleType){case"quantile":{let{attribute:o}=this.getScalePercentile();this.attribute=o,this.domain=[0,99];break}case"ordinal":{let{attribute:o,domain:n}=this.getScaleOrdinal();this.attribute=o,this.domain=[0,n.length-1];break}default:this.attribute=this.input,this.domain=null}return(e.scaleType!==r.scaleType||e.lowerPercentile!==r.lowerPercentile||e.upperPercentile!==r.upperPercentile)&&(this.cutoff=this.getCutoff(e)),this.props=e,this}};function tge(t){let e=new Set;for(let n of t)Number.isFinite(n)&&e.add(n);let r=Array.from(e).sort(),o=new Map;for(let n=0;n<r.length;n++)o.set(r[n],n);return{attribute:{value:t.map(n=>Number.isFinite(n)?o.get(n):NaN),type:"float32",size:1},domain:r}}function rge(t,e=100){let r=Array.from(t).filter(Number.isFinite).sort(oge),o=0,n=Math.max(1,e),i=new Array(n-1);for(;++o<n;)i[o-1]=nge(r,o/n);return{attribute:{value:t.map(s=>Number.isFinite(s)?ige(i,s):NaN),type:"float32",size:1},domain:i}}function Mz(t,e){let r=(t.stride??4)/4,o=(t.offset??0)/4,n=t.value;if(!n){let s=t.buffer?.readSyncWebGL(0,r*4*e);s&&(n=new Float32Array(s.buffer),t.value=n)}if(r===1)return n.subarray(0,e);let i=new Float32Array(e);for(let s=0;s<e;s++)i[s]=n[s*r+o];return i}function oge(t,e){return t-e}function nge(t,e){let r=t.length;if(e<=0||r<2)return t[0];if(e>=1)return t[r-1];let o=(r-1)*e,n=Math.floor(o),i=t[n],s=t[n+1];return i+(s-i)*(o-n)}function ige(t,e){let r=0,o=t.length;for(;r<o;){let n=r+o>>>1;t[n]>e?o=n:r=n+1}return r}function bl({dataBounds:t,getBinId:e,padding:r=0}){let o=[t[0],t[1],[t[0][0],t[1][1]],[t[1][0],t[0][1]]].map(c=>e(c)),n=Math.min(...o.map(c=>c[0]))-r,i=Math.min(...o.map(c=>c[1]))-r,s=Math.max(...o.map(c=>c[0]))+r+1,a=Math.max(...o.map(c=>c[1]))+r+1;return[[n,s],[i,a]]}var Rz=Math.PI/3,Ex=2*Math.sin(Rz),wx=1.5,Iz=Array.from({length:6},(t,e)=>{let r=e*Rz;return[Math.sin(r),-Math.cos(r)]});function Px([t,e],r){let o=Math.round(e=e/r/wx),n=Math.round(t=t/r/Ex-(o&1)/2),i=e-o;if(Math.abs(i)*3>1){let s=t-n,a=n+(t<n?-1:1)/2,c=o+(e<o?-1:1),l=t-a,f=e-c;s*s+i*i>l*l+f*f&&(n=a+(o&1?1:-1)/2,o=c)}return[n,o]}var Lz=`
const vec2 DIST = vec2(${Ex}, ${wx});
ivec2 pointToHexbin(vec2 p, float radius) {
p /= radius * DIST;
float pj = round(p.y);
float pjm2 = mod(pj, 2.0);
p.x -= pjm2 * 0.5;
float pi = round(p.x);
vec2 d1 = p - vec2(pi, pj);
if (abs(d1.y) * 3. > 1.) {
vec2 v2 = step(0.0, d1) - 0.5;
v2.y *= 2.0;
vec2 d2 = d1 - v2;
if (dot(d1, d1) > dot(d2, d2)) {
pi += v2.x + pjm2 - 0.5;
pj += v2.y;
}
}
return ivec2(pi, pj);
}
`;function _w([t,e],r){return[(t+(e&1)/2)*r*Ex,e*r*wx]}var Bz=`
const vec2 DIST = vec2(${Ex}, ${wx});
vec2 hexbinCentroid(vec2 binId, float radius) {
binId.x += fract(binId.y * 0.5);
return binId * DIST * radius;
}
`;var Oz=`#version 300 es
#define SHADER_NAME hexagon-cell-layer-vertex-shader
in vec3 positions;
in vec3 normals;
in vec2 instancePositions;
in float instanceElevationValues;
in float instanceColorValues;
in vec3 instancePickingColors;
uniform sampler2D colorRange;
out vec4 vColor;
${Bz}
float interp(float value, vec2 domain, vec2 range) {
float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);
return mix(range.x, range.y, r);
}
vec4 interp(float value, vec2 domain, sampler2D range) {
float r = (value - domain.x) / (domain.y - domain.x);
return texture(range, vec2(r, 0.5));
}
void main(void) {
geometry.pickingColor = instancePickingColors;
if (isnan(instanceColorValues) ||
instanceColorValues < hexagon.colorDomain.z ||
instanceColorValues > hexagon.colorDomain.w ||
instanceElevationValues < hexagon.elevationDomain.z ||
instanceElevationValues > hexagon.elevationDomain.w
) {
gl_Position = vec4(0.);
return;
}
vec2 commonPosition = hexbinCentroid(instancePositions, column.radius) + (hexagon.originCommon - project.commonOrigin.xy);
commonPosition += positions.xy * column.radius * column.coverage;
geometry.position = vec4(commonPosition, 0.0, 1.0);
geometry.normal = project_normal(normals);
float elevation = 0.0;
if (column.extruded) {
elevation = interp(instanceElevationValues, hexagon.elevationDomain.xy, hexagon.elevationRange);
elevation = project_size(elevation);
geometry.position.z = (positions.z + 1.0) / 2.0 * elevation;
}
gl_Position = project_common_position_to_clipspace(geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vColor = interp(instanceColorValues, hexagon.colorDomain.xy, colorRange);
vColor.a *= layer.opacity;
if (column.extruded) {
vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var sge=`layout(std140) uniform hexagonUniforms {
vec4 colorDomain;
vec4 elevationDomain;
vec2 elevationRange;
vec2 originCommon;
} hexagon;
`,Fz={name:"hexagon",vs:sge,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>"}};var Mx=class extends Wo{getShaders(){let e=super.getShaders();return e.modules.push(Fz),{...e,vs:Oz}}initializeState(){super.initializeState();let e=this.getAttributeManager();e.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),e.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e,n=this.state.fillModel;if(o.colorRange!==r.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=xl(this.context.device,r.colorRange,r.colorScaleType);let i={colorRange:this.state.colorTexture};n.shaderInputs.setProps({hexagon:i})}else o.colorScaleType!==r.colorScaleType&&yl(this.state.colorTexture,r.colorScaleType)}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}draw({uniforms:e}){let{radius:r,hexOriginCommon:o,elevationRange:n,elevationScale:i,extruded:s,coverage:a,colorDomain:c,elevationDomain:l}=this.props,f=this.props.colorCutoff||[-1/0,1/0],u=this.props.elevationCutoff||[-1/0,1/0],d=this.state.fillModel;d.setVertexCount(this.state.fillVertexCount);let h={colorDomain:[Math.max(c[0],f[0]),Math.min(c[1],f[1]),Math.max(c[0]-1,f[0]),Math.min(c[1]+1,f[1])],elevationDomain:[Math.max(l[0],u[0]),Math.min(l[1],u[1]),Math.max(l[0]-1,u[0]),Math.min(l[1]+1,u[1])],elevationRange:[n[0]*i,n[1]*i],originCommon:o};d.shaderInputs.setProps({column:{extruded:s,coverage:a,radius:r},hexagon:h}),d.draw(this.context.renderPass)}};Mx.layerName="HexagonCellLayer";var Nz=Mx;var age=`layout(std140) uniform binOptionsUniforms {
vec2 hexOriginCommon;
float radiusCommon;
} binOptions;
`,Dz={name:"binOptions",vs:age,uniformTypes:{hexOriginCommon:"vec2<f32>",radiusCommon:"f32"}};function Uz(){}var cge={gpuAggregation:!0,colorDomain:null,colorRange:Oi,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:Uz,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:Uz,radius:{type:"number",min:1,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},hexagonAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},Yh=class extends Zo{getAggregatorType(){let{gpuAggregation:e,hexagonAggregator:r,getColorValue:o,getElevationValue:n}=this.props;return e&&(r||o||n)?(N.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):e&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){if(e==="cpu"){let{hexagonAggregator:r,radius:o}=this.props;return new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:n},i,s)=>{if(r)return r(n,o);let c=this.state.aggregatorViewport.projectPosition(n),{radiusCommon:l,hexOriginCommon:f}=s;return Px([c[0]-f[0],c[1]-f[1]],l)}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:n})=>n},{sources:["elevationWeights"],getValue:({elevationWeights:n})=>n}]})}return new Qe(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,Dz],vs:`
in vec3 positions;
in vec3 positions64Low;
in float colorWeights;
in float elevationWeights;
${Lz}
void getBin(out ivec2 binId) {
vec3 positionCommon = project_position(positions, positions64Low);
binId = pointToHexbin(positionCommon.xy, binOptions.radiusCommon);
}
void getValue(out vec2 value) {
value = vec2(colorWeights, elevationWeights);
}
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from(Fe(o.data).iterable)),r||i.dataChanged||o.radius!==n.radius||o.getColorValue!==n.getColorValue||o.getElevationValue!==n.getElevationValue||o.colorAggregation!==n.colorAggregation||o.elevationAggregation!==n.elevationAggregation){this._updateBinOptions();let{radiusCommon:a,hexOriginCommon:c,binIdRange:l,dataAsArray:f}=this.state;if(s.setProps({binIdRange:l,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{radiusCommon:a,hexOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),f){let{getColorValue:u,getElevationValue:d}=this.props;s.setProps({customOperations:[u&&(h=>u(h.map(p=>f[p]),{indices:h,data:o.data})),d&&(h=>d(h.map(p=>f[p]),{indices:h,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),r}_updateBinOptions(){let e=this.getBounds(),r=1,o=[0,0],n=[[0,1],[0,1]],i=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2],{radius:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);r=c[0]*a;let l=Px(i.projectFlat(s),r);s=i.unprojectFlat(_w(l,r));let f=i.constructor;i=i.isGeospatial?new f({longitude:s[0],latitude:s[1],zoom:12}):new ot({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],n=bl({dataBounds:e,getBinId:u=>{let d=i.projectFlat(u);return d[0]-=o[0],d[1]-=o[1],Px(d,r)},padding:1})}this.setState({radiusCommon:r,hexOriginCommon:o,binIdRange:n,aggregatorViewport:i})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate({channel:e}){let r=this.getCurrentLayer().props,{aggregator:o}=this.state;if(e===0){let n=o.getResult(0);this.setState({colors:new Fi(n,o.binCount)}),r.onSetColorDomain(o.getResultDomain(0))}else if(e===1){let n=o.getResult(1);this.setState({elevations:new Fi(n,o.binCount)}),r.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate(),this._updateBinOptions();let{radiusCommon:o,hexOriginCommon:n,binIdRange:i}=this.state;r.setProps({binIdRange:i,binOptions:{radiusCommon:o,hexOriginCommon:n}});break;case"colorWeights":r.setNeedsUpdate(0);break;case"elevationWeights":r.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:e,radiusCommon:r,hexOriginCommon:o}=this.state,{elevationScale:n,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:l,transitions:f,colorScaleType:u,lowerPercentile:d,upperPercentile:h,colorDomain:p,elevationScaleType:m,elevationLowerPercentile:g,elevationUpperPercentile:_,elevationDomain:x}=this.props,y=this.getSubLayerClass("cells",Nz),b=e.getBins(),T=this.state.colors?.update({scaleType:u,lowerPercentile:d,upperPercentile:h}),v=this.state.elevations?.update({scaleType:m,lowerPercentile:g,upperPercentile:_});return!T||!v?null:new y(this.getSubLayerProps({id:"cells"}),{data:{length:e.binCount,attributes:{getBin:b,getColorValue:T.attribute,getElevationValue:v.attribute}},dataComparator:(w,C)=>w.length===C.length,updateTriggers:{getBin:[b],getColorValue:[T.attribute],getElevationValue:[v.attribute]},diskResolution:6,vertices:Iz,radius:r,hexOriginCommon:o,elevationScale:n,colorRange:i,colorScaleType:u,elevationRange:s,extruded:a,coverage:c,material:l,colorDomain:T.domain||p||e.getResultDomain(0),elevationDomain:v.domain||x||e.getResultDomain(1),colorCutoff:T.cutoff,elevationCutoff:v.cutoff,transitions:f&&{getFillColor:f.getColorValue||f.getColorWeight,getElevation:f.getElevationValue||f.getElevationWeight},extensions:[]})}getPickingInfo(e){let r=e.info,{index:o}=r;if(o>=0){let n=this.state.aggregator.getBin(o),i;if(n){let s=_w(n.id,this.state.radiusCommon),a=this.context.viewport.unprojectFlat(s);i={col:n.id[0],row:n.id[1],position:a,colorValue:n.value[0],elevationValue:n.value[1],count:n.count},n.pointIndices&&(i.pointIndices=n.pointIndices,i.points=Array.isArray(this.props.data)?n.pointIndices.map(c=>this.props.data[c]):[])}r.object=i}return r}};Yh.layerName="HexagonLayer";Yh.defaultProps=cge;var kz=Yh;var W=.16666666666666666,R={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},Al=[R.W,R.SW,R.S],Tl=[R.S,R.SE,R.E],vl=[R.E,R.NE,R.N],Sl=[R.NW,R.W,R.N],Cl=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5]],El=[[-W,-.5],[W,-.5],[.5,-W],[.5,W]],wl=[[.5,-W],[.5,W],[W,.5],[-W,.5]],Pl=[[-.5,W],[-.5,-W],[W,.5],[-W,.5]],Vz=[R.W,R.SW,R.SE,R.E],zz=[R.S,R.SE,R.NE,R.N],Hz=[R.NW,R.W,R.E,R.NE],jz=[R.NW,R.SW,R.S,R.N],Wz=[[-.5,W],[-.5,-W],[.5,-W],[.5,W]],Gz=[[-W,-.5],[W,-.5],[W,.5],[-W,.5]],lge=[R.NW,R.SW,R.SE,R.NE],$z=[R.NW,R.SW,R.SE,R.E,R.N],Xz=[R.W,R.SW,R.SE,R.NE,R.N],Yz=[R.NW,R.W,R.S,R.SE,R.NE],Kz=[R.NW,R.SW,R.S,R.E,R.NE],qz=[R.NW,R.W,[.5,-W],[.5,W],R.N],Zz=[[-W,-.5],[W,-.5],R.E,R.NE,R.N],Jz=[[-.5,W],[-.5,-W],R.S,R.SE,R.E],Qz=[R.W,R.SW,R.S,[W,.5],[-W,.5]],eH=[R.NW,R.W,[-W,-.5],[W,-.5],R.N],tH=[[-.5,W],[-.5,-W],R.E,R.NE,R.N],rH=[R.S,R.SE,R.E,[W,.5],[-W,.5]],oH=[R.W,R.SW,R.S,[.5,-W],[.5,W]],nH=[R.W,R.SW,R.SE,R.E,[W,.5],[-W,.5]],iH=[[-.5,W],[-.5,-W],R.S,R.SE,R.NE,R.N],sH=[R.NW,R.W,[-W,-.5],[W,-.5],R.E,R.NE],aH=[R.NW,R.SW,R.S,[.5,-W],[.5,W],R.N],Ml=[R.W,R.SW,R.S,R.E,R.NE,R.N],Rl=[R.NW,R.W,R.S,R.SE,R.E,R.N],Rx=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],R.E,R.NE,R.N],Ix=[R.W,R.SW,R.S,[.5,-W],[.5,W],[W,.5],[-W,.5]],Lx=[R.NW,R.W,[-W,-.5],[W,-.5],[.5,-W],[.5,W],R.N],Bx=[[-.5,W],[-.5,-W],R.S,R.SE,R.E,[W,.5],[-W,.5]],cH=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],[.5,-W],[.5,W],[W,.5],[-W,.5]],lH={0:[],1:[[R.W,R.S]],2:[[R.S,R.E]],3:[[R.W,R.E]],4:[[R.N,R.E]],5:{0:[[R.W,R.S],[R.N,R.E]],1:[[R.W,R.N],[R.S,R.E]]},6:[[R.N,R.S]],7:[[R.W,R.N]],8:[[R.W,R.N]],9:[[R.N,R.S]],10:{0:[[R.W,R.N],[R.S,R.E]],1:[[R.W,R.S],[R.N,R.E]]},11:[[R.N,R.E]],12:[[R.W,R.E]],13:[[R.S,R.E]],14:[[R.W,R.S]],15:[]};function H(t){return parseInt(t,4)}var fH={[H("0000")]:[],[H("2222")]:[],[H("2221")]:[Al],[H("2212")]:[Tl],[H("2122")]:[vl],[H("1222")]:[Sl],[H("0001")]:[Al],[H("0010")]:[Tl],[H("0100")]:[vl],[H("1000")]:[Sl],[H("2220")]:[Cl],[H("2202")]:[El],[H("2022")]:[wl],[H("0222")]:[Pl],[H("0002")]:[Cl],[H("0020")]:[El],[H("0200")]:[wl],[H("2000")]:[Pl],[H("0011")]:[Vz],[H("0110")]:[zz],[H("1100")]:[Hz],[H("1001")]:[jz],[H("2211")]:[Vz],[H("2112")]:[zz],[H("1122")]:[Hz],[H("1221")]:[jz],[H("2200")]:[Wz],[H("2002")]:[Gz],[H("0022")]:[Wz],[H("0220")]:[Gz],[H("1111")]:[lge],[H("1211")]:[$z],[H("2111")]:[Xz],[H("1112")]:[Yz],[H("1121")]:[Kz],[H("1011")]:[$z],[H("0111")]:[Xz],[H("1110")]:[Yz],[H("1101")]:[Kz],[H("1200")]:[qz],[H("0120")]:[Zz],[H("0012")]:[Jz],[H("2001")]:[Qz],[H("1022")]:[qz],[H("2102")]:[Zz],[H("2210")]:[Jz],[H("0221")]:[Qz],[H("1002")]:[eH],[H("2100")]:[tH],[H("0210")]:[rH],[H("0021")]:[oH],[H("1220")]:[eH],[H("0122")]:[tH],[H("2012")]:[rH],[H("2201")]:[oH],[H("0211")]:[nH],[H("2110")]:[iH],[H("1102")]:[sH],[H("1021")]:[aH],[H("2011")]:[nH],[H("0112")]:[iH],[H("1120")]:[sH],[H("1201")]:[aH],[H("2101")]:[Ml],[H("0121")]:[Ml],[H("1012")]:[Rl],[H("1210")]:[Rl],[H("0101")]:{0:[Al,vl],1:[Ml],2:[Ml]},[H("1010")]:{0:[Sl,Tl],1:[Rl],2:[Rl]},[H("2121")]:{0:[Ml],1:[Ml],2:[Al,vl]},[H("1212")]:{0:[Rl],1:[Rl],2:[Sl,Tl]},[H("2120")]:{0:[Rx],1:[Rx],2:[Cl,vl]},[H("2021")]:{0:[Ix],1:[Ix],2:[Al,wl]},[H("1202")]:{0:[Lx],1:[Lx],2:[Sl,El]},[H("0212")]:{0:[Bx],1:[Bx],2:[Tl,Pl]},[H("0102")]:{0:[Cl,vl],1:[Rx],2:[Rx]},[H("0201")]:{0:[Al,wl],1:[Ix],2:[Ix]},[H("1020")]:{0:[Sl,El],1:[Lx],2:[Lx]},[H("2010")]:{0:[Tl,Pl],1:[Bx],2:[Bx]},[H("2020")]:{0:[Pl,El],1:[cH],2:[Cl,wl]},[H("0202")]:{0:[wl,Cl],1:[cH],2:[Pl,El]}};function Kh(t,e){return Number.isNaN(t)?0:Array.isArray(e)?t<e[0]?0:t<e[1]?1:2:t>=e?1:0}function uH(t){let{x:e,y:r,xRange:o,yRange:n,getValue:i,threshold:s}=t,a=e<o[0],c=e>=o[1]-1,l=r<n[0],f=r>=n[1]-1,u=a||c||l||f,d=0,h,p,m,g;if(a||f)m=0;else{let y=i(e,r+1);m=Kh(y,s),d+=y}if(c||f)g=0;else{let y=i(e+1,r+1);g=Kh(y,s),d+=y}if(c||l)p=0;else{let y=i(e+1,r);p=Kh(y,s),d+=y}if(a||l)h=0;else{let y=i(e,r);h=Kh(y,s),d+=y}let _=-1;Number.isFinite(s)&&(_=m<<3|g<<2|p<<1|h),Array.isArray(s)&&(_=m<<6|g<<4|p<<2|h);let x=0;return u||(x=Kh(d/4,s)),{code:_,meanCode:x}}function dH(t){let{x:e,y:r,z:o,code:n,meanCode:i}=t,s=fH[n];Array.isArray(s)||(s=s[i]);let a=e+1,c=r+1,l=[];return s.forEach(f=>{let u=[];f.forEach(d=>{let h=a+d[0],p=c+d[1];u.push([h,p,o])}),l.push(u)}),l}function hH(t){let{x:e,y:r,z:o,code:n,meanCode:i}=t,s=lH[n];Array.isArray(s)||(s=s[i]);let a=e+1,c=r+1,l=[];return s.forEach(f=>{f.forEach(u=>{let d=a+u[0],h=c+u[1];l.push([d,h,o])})}),l}function pH({contours:t,getValue:e,xRange:r,yRange:o}){let n=[],i=[],s=0,a=0;for(let c=0;c<t.length;c++){let l=t[c],f=l.zIndex??c,{threshold:u}=l;for(let d=r[0]-1;d<r[1];d++)for(let h=o[0]-1;h<o[1];h++){let{code:p,meanCode:m}=uH({getValue:e,threshold:u,x:d,y:h,xRange:r,yRange:o}),g={x:d,y:h,z:f,code:p,meanCode:m};if(Array.isArray(u)){let _=dH(g);for(let x of _)i[a++]={vertices:x,contour:l}}else{let _=hH(g);_.length>0&&(n[s++]={vertices:_,contour:l})}}}return{lines:n,polygons:i}}function mH(t){let{aggregator:e,binIdRange:r,channel:o}=t;if(e instanceof Qe){let n=e.getResult(o)?.buffer;if(n){let i=new Float32Array(n.readSyncWebGL().buffer);return fge(i,r)}}if(e instanceof $t){let n=e.getResult(o)?.value,i=e.getBins()?.value;if(i&&n)return uge(n,i,e.binCount)}return null}function fge(t,e){let[[r,o],[n,i]]=e,s=o-r,a=i-n;return(c,l)=>(c-=r,l-=n,c<0||c>=s||l<0||l>=a?NaN:t[l*s+c])}function uge(t,e,r){let o={};for(let n=0;n<r;n++){let i=e[n*2],s=e[n*2+1];o[i]=o[i]||{},o[i][s]=t[n]}return(n,i)=>o[n]?.[i]??NaN}var dge=`layout(std140) uniform binOptionsUniforms {
vec2 cellOriginCommon;
vec2 cellSizeCommon;
} binOptions;
`,gH={name:"binOptions",vs:dge,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};var _H=[255,255,255,255],hge=1,pge={cellSize:{type:"number",min:1,value:1e3},gridOrigin:{type:"array",compare:!0,value:[0,0]},getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:1}],optional:!0,compare:3},zOffset:.005},qh=class extends Zo{getAggregatorType(){return this.props.gpuAggregation&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){return e==="cpu"?new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:r},o,n)=>{let s=this.state.aggregatorViewport.projectPosition(r),{cellSizeCommon:a,cellOriginCommon:c}=n;return[Math.floor((s[0]-c[0])/a[0]),Math.floor((s[1]-c[1])/a[1])]}},getValue:[{sources:["counts"],getValue:({counts:r})=>r}],onUpdate:this._onAggregationUpdate.bind(this)}):new Qe(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,gH],vs:`
in vec3 positions;
in vec3 positions64Low;
in float counts;
void getBin(out ivec2 binId) {
vec3 positionCommon = project_position(positions, positions64Low);
vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
binId = ivec2(gridCoords);
}
void getValue(out float value) {
value = counts;
}
`}),onUpdate:this._onAggregationUpdate.bind(this)})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{aggregator:s}=this.state;if(r||i.dataChanged||o.cellSize!==n.cellSize||!ie(o.gridOrigin,n.gridOrigin,1)||o.aggregation!==n.aggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:l}=this.state;s.setProps({binIdRange:l,pointCount:this.getNumInstances(),operations:[o.aggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c}})}return ie(n.contours,o.contours,2)||this.setState({contourData:null}),r}_updateBinOptions(){let e=this.getBounds(),r=[1,1],o=[0,0],n=[[0,1],[0,1]],i=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2],{cellSize:a,gridOrigin:c}=this.props,{unitsPerMeter:l}=i.getDistanceScales(s);r[0]=l[0]*a,r[1]=l[1]*a;let f=i.projectFlat(s);o=[Math.floor((f[0]-c[0])/r[0])*r[0]+c[0],Math.floor((f[1]-c[1])/r[1])*r[1]+c[1]],s=i.unprojectFlat(o);let u=i.constructor;i=i.isGeospatial?new u({longitude:s[0],latitude:s[1],zoom:12}):new ot({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],n=bl({dataBounds:e,getBinId:d=>{let h=i.projectFlat(d);return[Math.floor((h[0]-o[0])/r[0]),Math.floor((h[1]-o[1])/r[1])]}})}this.setState({cellSizeCommon:r,cellOriginCommon:o,binIdRange:n,aggregatorViewport:i})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate(){let{aggregator:e,binIdRange:r}=this.state;this.setState({aggregatedValueReader:mH({aggregator:e,binIdRange:r,channel:0}),contourData:null})}_getContours(){let{aggregatedValueReader:e}=this.state;if(!e)return null;if(!this.state.contourData){let{binIdRange:r}=this.state,{contours:o}=this.props,n=pH({contours:o,getValue:e,xRange:r[0],yRange:r[1]});this.state.contourData=n}return this.state.contourData}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:n,binIdRange:i}=this.state;r.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:n}});break;case"counts":r.setNeedsUpdate(0);break;default:}}renderLayers(){let e=this._getContours();if(!e)return null;let{lines:r,polygons:o}=e,{zOffset:n}=this.props,{cellOriginCommon:i,cellSizeCommon:s}=this.state,a=this.getSubLayerClass("lines",Go),c=this.getSubLayerClass("bands",Ti),l=new V().translate([i[0],i[1],0]).scale([s[0],s[1],n]),f=r&&r.length>0&&new a(this.getSubLayerProps({id:"lines"}),{data:r,coordinateSystem:Be.CARTESIAN,modelMatrix:l,getPath:d=>d.vertices,getColor:d=>d.contour.color??_H,getWidth:d=>d.contour.strokeWidth??hge,widthUnits:"pixels"}),u=o&&o.length>0&&new c(this.getSubLayerProps({id:"bands"}),{data:o,coordinateSystem:Be.CARTESIAN,modelMatrix:l,getPolygon:d=>d.vertices,getFillColor:d=>d.contour.color??_H});return[f,u]}getPickingInfo(e){let r=e.info,{object:o}=r;return o&&(r.object={contour:o.contour}),r}};qh.layerName="ContourLayer";qh.defaultProps=pge;var yH=qh;var xH=`#version 300 es
#define SHADER_NAME grid-cell-layer-vertex-shader
in vec3 positions;
in vec3 normals;
in vec2 instancePositions;
in float instanceElevationValues;
in float instanceColorValues;
in vec3 instancePickingColors;
uniform sampler2D colorRange;
out vec4 vColor;
float interp(float value, vec2 domain, vec2 range) {
float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);
return mix(range.x, range.y, r);
}
vec4 interp(float value, vec2 domain, sampler2D range) {
float r = (value - domain.x) / (domain.y - domain.x);
return texture(range, vec2(r, 0.5));
}
void main(void) {
geometry.pickingColor = instancePickingColors;
if (isnan(instanceColorValues) ||
instanceColorValues < grid.colorDomain.z ||
instanceColorValues > grid.colorDomain.w ||
instanceElevationValues < grid.elevationDomain.z ||
instanceElevationValues > grid.elevationDomain.w
) {
gl_Position = vec4(0.);
return;
}
vec2 commonPosition = (instancePositions + (positions.xy + 1.0) / 2.0 * column.coverage) * grid.sizeCommon + grid.originCommon - project.commonOrigin.xy;
geometry.position = vec4(commonPosition, 0.0, 1.0);
geometry.normal = project_normal(normals);
float elevation = 0.0;
if (column.extruded) {
elevation = interp(instanceElevationValues, grid.elevationDomain.xy, grid.elevationRange);
elevation = project_size(elevation);
geometry.position.z = (positions.z + 1.0) / 2.0 * elevation;
}
gl_Position = project_common_position_to_clipspace(geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vColor = interp(instanceColorValues, grid.colorDomain.xy, colorRange);
vColor.a *= layer.opacity;
if (column.extruded) {
vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var mge=`layout(std140) uniform gridUniforms {
vec4 colorDomain;
vec4 elevationDomain;
vec2 elevationRange;
vec2 originCommon;
vec2 sizeCommon;
} grid;
`,bH={name:"grid",vs:mge,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>",sizeCommon:"vec2<f32>"}};var Zh=class extends Wo{getShaders(){let e=super.getShaders();return e.modules.push(bH),{...e,vs:xH}}initializeState(){super.initializeState();let e=this.getAttributeManager();e.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),e.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(e){super.updateState(e);let{props:r,oldProps:o}=e,n=this.state.fillModel;if(o.colorRange!==r.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=xl(this.context.device,r.colorRange,r.colorScaleType);let i={colorRange:this.state.colorTexture};n.shaderInputs.setProps({grid:i})}else o.colorScaleType!==r.colorScaleType&&yl(this.state.colorTexture,r.colorScaleType)}finalizeState(e){super.finalizeState(e),this.state.colorTexture?.destroy()}_updateGeometry(){let e=new dn;this.state.fillModel.setGeometry(e)}draw({uniforms:e}){let{cellOriginCommon:r,cellSizeCommon:o,elevationRange:n,elevationScale:i,extruded:s,coverage:a,colorDomain:c,elevationDomain:l}=this.props,f=this.props.colorCutoff||[-1/0,1/0],u=this.props.elevationCutoff||[-1/0,1/0],d=this.state.fillModel,h={colorDomain:[Math.max(c[0],f[0]),Math.min(c[1],f[1]),Math.max(c[0]-1,f[0]),Math.min(c[1]+1,f[1])],elevationDomain:[Math.max(l[0],u[0]),Math.min(l[1],u[1]),Math.max(l[0]-1,u[0]),Math.min(l[1]+1,u[1])],elevationRange:[n[0]*i,n[1]*i],originCommon:r,sizeCommon:o};d.shaderInputs.setProps({column:{extruded:s,coverage:a},grid:h}),d.draw(this.context.renderPass)}};Zh.layerName="GridCellLayer";var gge=`layout(std140) uniform binOptionsUniforms {
vec2 cellOriginCommon;
vec2 cellSizeCommon;
} binOptions;
`,AH={name:"binOptions",vs:gge,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};function TH(){}var _ge={gpuAggregation:!0,colorDomain:null,colorRange:Oi,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:TH,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:TH,cellSize:{type:"number",min:0,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},gridAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},Jh=class extends Zo{getAggregatorType(){let{gpuAggregation:e,gridAggregator:r,getColorValue:o,getElevationValue:n}=this.props;return e&&(r||o||n)?(N.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):e&&Qe.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(e){if(e==="cpu"){let{gridAggregator:r,cellSize:o}=this.props;return new $t({dimensions:2,getBin:{sources:["positions"],getValue:({positions:n},i,s)=>{if(r)return r(n,o);let c=this.state.aggregatorViewport.projectPosition(n),{cellSizeCommon:l,cellOriginCommon:f}=s;return[Math.floor((c[0]-f[0])/l[0]),Math.floor((c[1]-f[1])/l[1])]}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:n})=>n},{sources:["elevationWeights"],getValue:({elevationWeights:n})=>n}]})}return new Qe(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[fe,AH],vs:`
in vec3 positions;
in vec3 positions64Low;
in float colorWeights;
in float elevationWeights;
void getBin(out ivec2 binId) {
vec3 positionCommon = project_position(positions, positions64Low);
vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
binId = ivec2(gridCoords);
}
void getValue(out vec2 value) {
value = vec2(colorWeights, elevationWeights);
}
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(e){let r=super.updateState(e),{props:o,oldProps:n,changeFlags:i}=e,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from(Fe(o.data).iterable)),r||i.dataChanged||o.cellSize!==n.cellSize||o.getColorValue!==n.getColorValue||o.getElevationValue!==n.getElevationValue||o.colorAggregation!==n.colorAggregation||o.elevationAggregation!==n.elevationAggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:l,dataAsArray:f}=this.state;if(s.setProps({binIdRange:l,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),f){let{getColorValue:u,getElevationValue:d}=this.props;s.setProps({customOperations:[u&&(h=>u(h.map(p=>f[p]),{indices:h,data:o.data})),d&&(h=>d(h.map(p=>f[p]),{indices:h,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),r}_updateBinOptions(){let e=this.getBounds(),r=[1,1],o=[0,0],n=[[0,1],[0,1]],i=this.context.viewport;if(e&&Number.isFinite(e[0][0])){let s=[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2],{cellSize:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);r[0]=c[0]*a,r[1]=c[1]*a;let l=i.projectFlat(s);o=[Math.floor(l[0]/r[0])*r[0],Math.floor(l[1]/r[1])*r[1]],s=i.unprojectFlat(o);let f=i.constructor;i=i.isGeospatial?new f({longitude:s[0],latitude:s[1],zoom:12}):new ot({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],n=bl({dataBounds:e,getBinId:u=>{let d=i.projectFlat(u);return[Math.floor((d[0]-o[0])/r[0]),Math.floor((d[1]-o[1])/r[1])]}})}this.setState({cellSizeCommon:r,cellOriginCommon:o,binIdRange:n,aggregatorViewport:i})}draw(e){e.shaderModuleProps.project&&(e.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(e)}_onAggregationUpdate({channel:e}){let r=this.getCurrentLayer().props,{aggregator:o}=this.state;if(e===0){let n=o.getResult(0);this.setState({colors:new Fi(n,o.binCount)}),r.onSetColorDomain(o.getResultDomain(0))}else if(e===1){let n=o.getResult(1);this.setState({elevations:new Fi(n,o.binCount)}),r.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(e){let{aggregator:r}=this.state;switch(e){case"positions":r.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:n,binIdRange:i}=this.state;r.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:n}});break;case"colorWeights":r.setNeedsUpdate(0);break;case"elevationWeights":r.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:e,cellOriginCommon:r,cellSizeCommon:o}=this.state,{elevationScale:n,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:l,transitions:f,colorScaleType:u,lowerPercentile:d,upperPercentile:h,colorDomain:p,elevationScaleType:m,elevationLowerPercentile:g,elevationUpperPercentile:_,elevationDomain:x}=this.props,y=this.getSubLayerClass("cells",Zh),b=e.getBins(),T=this.state.colors?.update({scaleType:u,lowerPercentile:d,upperPercentile:h}),v=this.state.elevations?.update({scaleType:m,lowerPercentile:g,upperPercentile:_});return!T||!v?null:new y(this.getSubLayerProps({id:"cells"}),{data:{length:e.binCount,attributes:{getBin:b,getColorValue:T.attribute,getElevationValue:v.attribute}},dataComparator:(w,C)=>w.length===C.length,updateTriggers:{getBin:[b],getColorValue:[T.attribute],getElevationValue:[v.attribute]},cellOriginCommon:r,cellSizeCommon:o,elevationScale:n,colorRange:i,colorScaleType:u,elevationRange:s,extruded:a,coverage:c,material:l,colorDomain:T.domain||p||e.getResultDomain(0),elevationDomain:v.domain||x||e.getResultDomain(1),colorCutoff:T.cutoff,elevationCutoff:v.cutoff,transitions:f&&{getFillColor:f.getColorValue||f.getColorWeight,getElevation:f.getElevationValue||f.getElevationWeight},extensions:[]})}getPickingInfo(e){let r=e.info,{index:o}=r;if(o>=0){let n=this.state.aggregator.getBin(o),i;n&&(i={col:n.id[0],row:n.id[1],colorValue:n.value[0],elevationValue:n.value[1],count:n.count},n.pointIndices&&(i.pointIndices=n.pointIndices,i.points=Array.isArray(this.props.data)?n.pointIndices.map(s=>this.props.data[s]):[])),r.object=i}return r}};Jh.layerName="GridLayer";Jh.defaultProps=_ge;var vH=Jh;function CH(t){let e=t.map(a=>a[0]),r=t.map(a=>a[1]),o=Math.min.apply(null,e),n=Math.max.apply(null,e),i=Math.min.apply(null,r),s=Math.max.apply(null,r);return[o,i,n,s]}function EH(t,e){return e[0]>=t[0]&&e[2]<=t[2]&&e[1]>=t[1]&&e[3]<=t[3]}var SH=new Float32Array(12);function yw(t,e=2){let r=0;for(let o of t)for(let n=0;n<e;n++)SH[r++]=o[n]||0;return SH}function wH(t,e,r){let[o,n,i,s]=t,a=i-o,c=s-n,l=a,f=c;a/c<e/r?l=e/r*c:f=r/e*a,l<e&&(l=e,f=r);let u=(i+o)/2,d=(s+n)/2;return[u-l/2,d-f/2,u+l/2,d+f/2]}function PH(t,e){let[r,o,n,i]=e;return[(t[0]-r)/(n-r),(t[1]-o)/(i-o)]}var MH=`#version 300 es
#define SHADER_NAME heatp-map-layer-vertex-shader
uniform sampler2D maxTexture;
in vec3 positions;
in vec2 texCoords;
out vec2 vTexCoords;
out float vIntensityMin;
out float vIntensityMax;
void main(void) {
gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
vTexCoords = texCoords;
vec4 maxTexture = texture(maxTexture, vec2(0.5));
float maxValue = triangle.aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
float minValue = maxValue * triangle.threshold;
if (triangle.colorDomain[1] > 0.) {
maxValue = triangle.colorDomain[1];
minValue = triangle.colorDomain[0];
}
vIntensityMax = triangle.intensity / maxValue;
vIntensityMin = triangle.intensity / minValue;
}
`;var RH=`#version 300 es
#define SHADER_NAME triangle-layer-fragment-shader
precision highp float;
uniform sampler2D weightsTexture;
uniform sampler2D colorTexture;
in vec2 vTexCoords;
in float vIntensityMin;
in float vIntensityMax;
out vec4 fragColor;
vec4 getLinearColor(float value) {
float factor = clamp(value * vIntensityMax, 0., 1.);
vec4 color = texture(colorTexture, vec2(factor, 0.5));
color.a *= min(value * vIntensityMin, 1.0);
return color;
}
void main(void) {
vec4 weights = texture(weightsTexture, vTexCoords);
float weight = weights.r;
if (triangle.aggregationMode > 0.5) {
weight /= max(1.0, weights.a);
}
if (weight <= 0.) {
discard;
}
vec4 linearColor = getLinearColor(weight);
linearColor.a *= layer.opacity;
fragColor = linearColor;
}
`;var IH=`layout(std140) uniform triangleUniforms {
float aggregationMode;
vec2 colorDomain;
float intensity;
float threshold;
} triangle;
`,LH={name:"triangle",vs:IH,fs:IH,uniformTypes:{aggregationMode:"f32",colorDomain:"vec2<f32>",intensity:"f32",threshold:"f32"}};var Ox=class extends _e{getShaders(){return super.getShaders({vs:MH,fs:RH,modules:[fe,LH]})}initializeState({device:e}){this.setState({model:this._getModel(e)})}_getModel(e){let{vertexCount:r,data:o}=this.props;return new Q(e,{...this.getShaders(),id:this.props.id,attributes:o.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-strip",vertexCount:r})}draw(){let{model:e}=this.state,{aggregationMode:r,colorDomain:o,intensity:n,threshold:i,colorTexture:s,maxTexture:a,weightsTexture:c}=this.props,l={aggregationMode:r,colorDomain:o,intensity:n,threshold:i,colorTexture:s,maxTexture:a,weightsTexture:c};e.shaderInputs.setProps({triangle:l}),e.draw(this.context.renderPass)}};Ox.layerName="TriangleLayer";var BH=Ox;function OH(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}var Fx=class extends Ne{initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:OH(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:r}=e;if(r.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:r,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:r,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,r={}){let{props:o,oldProps:n,changeFlags:i}=e,{compareAll:s=!1,dimension:a}=r,{ignoreProps:c}=this.state,{props:l,accessors:f=[]}=a,{updateTriggersChanged:u}=i;if(i.dataChanged)return!0;if(u){if(u.all)return!0;for(let d of f)if(u[d])return!0}if(s)return i.extensionsChanged?!0:xc({oldProps:n,newProps:o,ignoreProps:c,propTypes:this.constructor._propTypes});for(let d of l)if(o[d]!==n[d])return!0;return!1}isAttributeChanged(e){let{changedAttributes:r}=this.state;return e?r&&r[e]!==void 0:!yge(r)}_getAttributeManager(){return new pr(this.context.device,{id:this.props.id,stats:this.context.stats})}};Fx.layerName="AggregationLayer";var FH=Fx;function yge(t){let e=!0;for(let r in t){e=!1;break}return e}var Nx=`#version 300 es
in vec3 positions;
in vec3 positions64Low;
in float weights;
out vec4 weightsTexture;
void main()
{
weightsTexture = vec4(weights * weight.weightsScale, 0., 0., 1.);
float radiusTexels = project_pixel_size(weight.radiusPixels) * weight.textureWidth / (weight.commonBounds.z - weight.commonBounds.x);
gl_PointSize = radiusTexels * 2.;
vec3 commonPosition = project_position(positions, positions64Low);
gl_Position.xy = (commonPosition.xy - weight.commonBounds.xy) / (weight.commonBounds.zw - weight.commonBounds.xy) ;
gl_Position.xy = (gl_Position.xy * 2.) - (1.);
gl_Position.w = 1.0;
}
`;var Dx=`#version 300 es
in vec4 weightsTexture;
out vec4 fragColor;
float gaussianKDE(float u){
return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666);
}
void main()
{
float dist = length(gl_PointCoord - vec2(0.5, 0.5));
if (dist > 0.5) {
discard;
}
fragColor = weightsTexture * gaussianKDE(2. * dist);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;var NH=`#version 300 es
uniform sampler2D inTexture;
out vec4 outTexture;
void main()
{
int yIndex = gl_VertexID / int(maxWeight.textureSize);
int xIndex = gl_VertexID - (yIndex * int(maxWeight.textureSize));
vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / maxWeight.textureSize;
outTexture = texture(inTexture, uv);
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
gl_PointSize = 1.0;
}
`;var DH=`#version 300 es
in vec4 outTexture;
out vec4 fragColor;
void main() {
fragColor = outTexture;
fragColor.g = outTexture.r / max(1.0, outTexture.a);
}
`;var xge=`layout(std140) uniform weightUniforms {
vec4 commonBounds;
float radiusPixels;
float textureWidth;
float weightsScale;
} weight;
`,UH={name:"weight",vs:xge,uniformTypes:{commonBounds:"vec4<f32>",radiusPixels:"f32",textureWidth:"f32",weightsScale:"f32"}},kH={name:"maxWeight",vs:`layout(std140) uniform maxWeightUniforms {
float textureSize;
} maxWeight;
`,uniformTypes:{textureSize:"f32"}};var bge=2,xw={format:"rgba8unorm",dimension:"2d",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},VH=[0,0],Age={SUM:0,MEAN:1},Tge={getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:Oi,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},vge=["float32-renderable-webgl","texture-blend-float-webgl"],Sge={data:{props:["radiusPixels"]}},Qh=class extends FH{getShaders(e){let r=[fe];return e.modules&&(r=[...r,...e.modules]),super.getShaders({...e,modules:r})}initializeState(){super.initializeAggregationLayer(Sge),this.setState({colorDomain:VH}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:r,oldProps:o}=e,n=this._getChangeFlags(e);if((n.dataChanged||n.viewportChanged)&&(n.boundsChanged=this._updateBounds(n.dataChanged),this._updateTextureRenderingBounds()),n.dataChanged||n.boundsChanged){if(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0}),n.dataChanged){let i=this.getShaders({vs:Nx,fs:Dx});this._createWeightsTransform(i)}}else n.viewportZoomChanged&&this._debouncedUpdateWeightmap();r.colorRange!==o.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:r,triTexCoordBuffer:o,maxWeightsTexture:n,colorTexture:i,colorDomain:s}=this.state,{updateTriggers:a,intensity:c,threshold:l,aggregation:f}=this.props,u=this.getSubLayerClass("triangle",BH);return new u(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:"default",data:{attributes:{positions:r,texCoords:o}},vertexCount:4,maxTexture:n,colorTexture:i,aggregationMode:Age[f]||0,weightsTexture:e,intensity:c,threshold:l,colorDomain:s})}finalizeState(e){super.finalizeState(e);let{weightsTransform:r,weightsTexture:o,maxWeightTransform:n,maxWeightsTexture:i,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:c,updateTimer:l}=this.state;r?.destroy(),o?.destroy(),n?.destroy(),i?.destroy(),s?.destroy(),a?.destroy(),c?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new pr(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let r={},{dimensions:o}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:o.data})&&"aggregation is dirty",r.viewportChanged=e.changeFlags.viewportChanged;let{zoom:n}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==n)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:e,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...xw,width:e,height:e,format:r}),maxWeightsTexture:this.context.device.createTexture({...xw,width:1,height:1,format:r})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:r}=this.props,o=Math.min(r,e.limits.maxTextureDimension2D),n=vge.every(a=>e.features.has(a)),i=n?"rgba32float":"rgba8unorm",s=n?1:1/255;this.setState({textureSize:o,format:i,weightsScale:s}),n||N.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:r}=this.state,{weightsTexture:o}=this.state,n=this.getAttributeManager();r?.destroy(),r=new fi(this.context.device,{id:`${this.id}-weights-transform`,...e,bufferLayout:n.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",modules:[...e.modules,UH]}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:r,weightsTexture:o,maxWeightsTexture:n}=this.state,i=this.getShaders({vs:Nx,fs:Dx});this._createWeightsTransform(i);let s=this.getShaders({vs:NH,fs:DH,modules:[kH]}),a=new fi(e,{id:`${this.id}-max-weights-transform`,targetTexture:n,...s,vertexCount:r*r,topology:"point-list",parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}}),c={inTexture:o,textureSize:r};a.model.shaderInputs.setProps({maxWeight:c}),this.setState({weightsTexture:o,maxWeightsTexture:n,maxWeightTransform:a,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:Nx,fs:Dx,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:r}=this.context,o=[r.unproject([0,0]),r.unproject([r.width,0]),r.unproject([0,r.height]),r.unproject([r.width,r.height])].map(a=>a.map(Math.fround)),n=CH(o),i={visibleWorldBounds:n,viewportCorners:o},s=!1;if(e||!this.state.worldBounds||!EH(this.state.worldBounds,n)){let a=this._worldToCommonBounds(n),c=this._commonToWorldBounds(a);this.props.coordinateSystem==="lnglat"&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let l=this._worldToCommonBounds(c);i.worldBounds=c,i.normalizedCommonBounds=l,s=!0}return this.setState(i),s}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:r,normalizedCommonBounds:o,viewportCorners:n}=this.state,{viewport:i}=this.context;e.write(yw(n,3));let s=n.map(a=>PH(i.projectPosition(a),o));r.write(yw(s,2))}_updateColorTexture(e){let{colorRange:r}=e.props,{colorTexture:o}=this.state,n=gw(r,!1,Uint8Array);o?.destroy(),o=this.context.device.createTexture({...xw,data:n,width:r.length,height:1}),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:e,colorDomain:r,aggregation:o}=this.props,{worldBounds:n,textureSize:i,weightsScale:s,weightsTexture:a}=this.state,c=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let l=this._worldToCommonBounds(n,{useLayerCoordinateSystem:!0});if(r&&o==="SUM"){let{viewport:y}=this.context,b=y.distanceScales.metersPerUnit[2]*(l[2]-l[0])/i;this.state.colorDomain=[r[0]*b*s,r[1]*b*s]}else this.state.colorDomain=r||VH;let u=this.getAttributeManager().getAttributes(),d=this.getModuleSettings();this._setModelAttributes(c.model,u),c.model.setVertexCount(this.getNumInstances());let h={radiusPixels:e,commonBounds:l,textureWidth:i,weightsScale:s,weightsTexture:a},{viewport:p,devicePixelRatio:m,coordinateSystem:g,coordinateOrigin:_}=d,{modelMatrix:x}=this.props;c.model.shaderInputs.setProps({project:{viewport:p,devicePixelRatio:m,modelMatrix:x,coordinateSystem:g,coordinateOrigin:_},weight:h}),c.run({parameters:{viewport:[0,0,i,i]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:r}=this.state,{debounceTimeout:o}=this.props;e?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),o)),this.setState({updateTimer:r})}_worldToCommonBounds(e,r={}){let{useLayerCoordinateSystem:o=!1}=r,[n,i,s,a]=e,{viewport:c}=this.context,{textureSize:l}=this.state,{coordinateSystem:f}=this.props,u=o&&(f==="lnglat-offsets"||f==="meter-offsets"),d=u?c.projectPosition(this.props.coordinateOrigin):[0,0],h=l*bge/c.scale,p,m;return o&&!u?(p=this.projectPosition([n,i,0]),m=this.projectPosition([s,a,0])):(p=c.projectPosition([n,i,0]),m=c.projectPosition([s,a,0])),wH([p[0]-d[0],p[1]-d[1],m[0]-d[0],m[1]-d[1]],h,h)}_commonToWorldBounds(e){let[r,o,n,i]=e,{viewport:s}=this.context,a=s.unprojectPosition([r,o]),c=s.unprojectPosition([n,i]);return a.slice(0,2).concat(c.slice(0,2))}};Qh.layerName="HeatmapLayer";Qh.defaultProps=Tge;var zH=Qh;Au();var Ux="deck-gl-google-maps-container",bw=85.05113;function kx(t,e,r,o){if(r){if(r.userData._googleMap===t)return r;Vx(r)}let n={click:null,rightclick:null,dblclick:null,mousemove:null,mouseout:null},i=new An({...o,useDevicePixels:o.useDevicePixels??!0,style:o.interleaved?null:{pointerEvents:"none"},parent:Cge(e,o.style),views:new di({repeat:!0}),initialViewState:{longitude:0,latitude:0,zoom:1},controller:!1});for(let s in n)n[s]=t.addListener(s,a=>wge(i,s,a));return i.userData._googleMap=t,i.userData._eventListeners=n,i}function Cge(t,e){let r=document.createElement("div");r.style.position="absolute",Object.assign(r.style,e);let n=t.getMap().getDiv().querySelector(`#${Ux}`);return n?n.appendChild(r):"getPanes"in t&&t.getPanes()?.overlayLayer.appendChild(r),r}function Vx(t){let{_eventListeners:e}=t.userData;for(let r in e)e[r]&&e[r].remove();t.finalize()}function HH(t,e){let{width:r,height:o}=WH(t),n=e.getProjection(),i=t.getBounds();if(!i)return{width:r,height:o,left:0,top:0};let s=i.getNorthEast(),a=i.getSouthWest(),c=n.fromLatLngToDivPixel(s),l=n.fromLatLngToDivPixel(a),f=Aw(n,r/2,o/2),u=new google.maps.LatLng(0,f[0]),d=n.fromLatLngToContainerPixel(u),h=n.fromLatLngToDivPixel(u);if(!c||!l||!h||!d)return{width:r,height:o,left:0,top:0};let p=Math.round(h.x-d.x),m=h.y-d.y,g=Aw(n,r/2,0),_=Aw(n,r/2,o),x=f[1],y=f[0];if(Math.abs(x)>bw){x=x>0?bw:-bw;let S=new google.maps.LatLng(x,y),A=n.fromLatLngToContainerPixel(S);m+=A.y-o/2}m=Math.round(m);let T=180*new Gr(g).sub(_).verticalAngle()/Math.PI;T<0&&(T+=360);let v=t.getHeading()||0,w=t.getZoom()-1,C;if(T===0)C=o?(l.y-c.y)/o:1;else if(T===v){let S=new Gr([c.x,c.y]).sub([l.x,l.y]).len(),A=new Gr([r,-o]).len();C=A?S/A:1}return w+=Math.log2(C||1),{width:r,height:o,left:p,top:m,zoom:w,bearing:T,pitch:t.getTilt(),latitude:x,longitude:y}}function jH(t,e){let{width:r,height:o}=WH(t),{center:n,heading:i,tilt:s,zoom:a}=e.getCameraParams(),c=25,l=o?r/o:1,f=.75,u=3e14,d=new V().perspective({fovy:c*Math.PI/180,aspect:l,near:f,far:u}),h=.5*d[5];return{width:r,height:o,viewState:{altitude:h,bearing:i,latitude:n.lat(),longitude:n.lng(),pitch:s,projectionMatrix:d,repeat:!0,zoom:a-1}}}function WH(t){let e=t.getDiv().firstChild;return{width:e.offsetWidth,height:e.offsetHeight}}function Aw(t,e,r){let o=new google.maps.Point(e,r),n=t.fromContainerPixelToLatLng(o);return[n.lng(),n.lat()]}function Ege(t,e){if(t.pixel)return t.pixel;let r=e.getViewports()[0].project([t.latLng.lng(),t.latLng.lat()]);return{x:r[0],y:r[1]}}function wge(t,e,r){if(!t.isInitialized)return;let o={type:e,offsetCenter:Ege(r,t),srcEvent:r};switch(e){case"click":case"rightclick":o.type="click",o.tapCount=1,t._onPointerDown(o),t._onEvent(o);break;case"dblclick":o.type="click",o.tapCount=2,t._onEvent(o);break;case"mousemove":o.type="pointermove",t._onPointerMove(o);break;case"mouseout":o.type="pointerleave",t._onPointerMove(o);break;default:return}}var Pge=()=>!1,Mge={depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],blendEquation:32774};function zx(){}var GH={interleaved:!0},ep=class{constructor(e){this.props={},this._map=null,this._deck=null,this._overlay=null,this._positioningOverlay=null,this._externalFramebuffer=null,this.setProps({...GH,...e})}setMap(e){if(e===this._map)return;let{VECTOR:r,UNINITIALIZED:o}=google.maps.RenderingType;this._map&&(!e&&this._map.getRenderingType()===r&&this.props.interleaved&&this._overlay.requestRedraw(),this._overlay?.setMap(null),this._positioningOverlay?.setMap(null),this._map=null),e&&(this._map=e,e.getRenderingType()!==o?this._createOverlay(e):e.addListener("renderingtype_changed",()=>{this._createOverlay(e)}))}setProps(e){if(Object.assign(this.props,e),this._deck){let r=this._deck.props.parent||this._deck.getCanvas()?.parentElement;if(e.style&&r){let o=r.style;Object.assign(o,e.style),e.style=null}this._deck.setProps(e)}}pickObject(e){return this._deck&&this._deck.pickObject(e)}pickMultipleObjects(e){return this._deck&&this._deck.pickMultipleObjects(e)}pickObjects(e){return this._deck&&this._deck.pickObjects(e)}finalize(){this.setMap(null),this._deck&&(Vx(this._deck),this._deck=null)}_createOverlay(e){let{VECTOR:r,UNINITIALIZED:o}=google.maps.RenderingType,n=e.getRenderingType();if(n===o)return;n===r&&google.maps.WebGLOverlayView?this._createOverlayVector(e):this._createOverlayRaster(e)}_createOverlayVector(e){let r=this.props.interleaved??GH.interleaved,o=new google.maps.OverlayView;o.onAdd=this._onAddVectorOverlay.bind(this),o.draw=this._updateContainerSize.bind(this),o.onRemove=this._onRemove.bind(this),this._positioningOverlay=o,this._positioningOverlay.setMap(e);let n=new google.maps.WebGLOverlayView;n.onAdd=zx,n.onContextRestored=r?this._onContextRestored.bind(this):zx,n.onDraw=this._onDrawVector.bind(this),n.onContextLost=r?this._onContextLost.bind(this):zx,n.onRemove=r?this._onRemove.bind(this):zx,this._overlay=n,this._overlay.setMap(e)}_createOverlayRaster(e){let r=new google.maps.OverlayView;r.onAdd=this._onAdd.bind(this),r.draw=this._onDrawRaster.bind(this),r.onRemove=this._onRemove.bind(this),this._overlay=r,this._overlay.setMap(e)}_onAdd(){this._deck=kx(this._map,this._overlay,this._deck,this.props)}_onAddVectorOverlay(){let e=this._positioningOverlay,r=e.getPanes();if(r){let o=document.createElement("div");o.id=Ux,o.style.position="absolute",r.overlayLayer.appendChild(o)}this._deck=kx(this._map,e,this._deck,this.props)}_updateContainerSize(){if(!this._map)return;let e=this._map.getDiv().querySelector(`#${Ux}`);if(!e)return;let r=this._map.getDiv().firstChild;if(!r)return;let o=r.offsetWidth,n=r.offsetHeight;e.style.width=`${o}px`,e.style.height=`${n}px`,e.style.left=`${-o/2}px`,e.style.top=`${-n/2}px`}_onContextRestored({gl:e}){if(!this._map||!this._overlay)return;let r=()=>{this._overlay&&this._overlay.requestRedraw()},o=kx(this._map,this._overlay,this._deck,{gl:e,_customRender:r,...this.props});this._deck=o;let n=o.animationLoop;n._renderFrame=()=>{let i=e.getParameter(34964);o.device.withParametersWebGL({},()=>{n.props.onRender(n.animationProps)}),e.bindBuffer(34962,i)}}_onContextLost(){this._deck&&(Vx(this._deck),this._deck=null)}_onRemove(){this._deck?.setProps({layerFilter:Pge})}_onDrawRaster(){if(!this._deck||!this._map)return;let e=this._deck,{width:r,height:o,left:n,top:i,...s}=HH(this._map,this._overlay),c=e.getCanvas()?.parentElement||e.props.parent;if(c){let f=c.style;f.left=`${n}px`,f.top=`${i}px`}let l=1e4;e.setProps({width:r,height:o,viewState:{altitude:l,...s}}),e.redraw()}_onDrawVector({gl:e,transformer:r}){if(!this._deck||!this._map)return;let o=this._deck,{interleaved:n}=this.props;if(o.setProps({...jH(this._map,r),...n&&{width:null,height:null}}),n&&o.isInitialized){let i=o.device;if(i instanceof Zt){let s=i.getParametersWebGL(36006),a=null;if(s){if(this._externalFramebuffer?.handle!==s){this._externalFramebuffer?.wrapper.destroy();let c=i.createFramebuffer({handle:s,width:e.canvas.width,height:e.canvas.height});this._externalFramebuffer={handle:s,wrapper:c}}a=this._externalFramebuffer.wrapper}o.setProps({_framebuffer:a})}o.needsRedraw({clearRedrawFlags:!0}),i instanceof Zt&&(i.setParametersWebGL({viewport:[0,0,e.canvas.width,e.canvas.height],scissor:[0,0,e.canvas.width,e.canvas.height],stencilFunc:[519,0,255,519,0,255]}),i.withParametersWebGL(Mge,()=>{o._drawLayers("google-vector",{clearCanvas:!1})}))}else n||o.redraw()}};var tp=class{constructor(e){ge(e.id,"id is required"),this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.slot=e.slot,this.beforeId=e.beforeId,this.map=null}onAdd(e,r){this.map=e}render(e,r){this.map&&$H(this.map.__deck,this.map,this,r)}};var Tw="__UNDEFINED__";function Il(t){return t.props.beforeId?`deck-layer-group-before:${t.props.beforeId}`:t.props.slot?`deck-layer-group-slot:${t.props.slot}`:"deck-layer-group-last"}function XH(t,e,r){if(!t||!t.style||!t.style._loaded)return;let o=kt(r,Boolean);if(e!==r){let s=kt(e,Boolean),a=new Set(s.map(l=>Il(l))),c=new Set(o.map(l=>Il(l)));for(let l of a)c.has(l)||t.getLayer(l)&&t.removeLayer(l)}let n={};for(let s of o){let a=Il(s),c=t.getLayer(a);if(c){let l=c.implementation||c;n[a]=l}else{let l=new tp({id:a,slot:s.props.slot,beforeId:s.props.beforeId});n[a]=l,t.addLayer(l,s.props.beforeId)}}let i=t.style._order;for(let[s,a]of Object.entries(n)){let c=a.beforeId||Tw,l=c===Tw?i.length:i.indexOf(c);if(l===-1)continue;if(i.indexOf(s)!==l-1){let u=c===Tw?void 0:c;t.moveLayer(s,u)}}}var oa="mapbox",vw=512,Rge=Math.PI/180;function KH({map:t,deck:e}){if(t.__deck)return t.__deck;let r=e.props._customRender,o=e.props.onLoad,n={...e.props,_customRender:()=>{t.triggerRepaint(),r?.("")}};return n.views||(n.views=rp(t)),Object.assign(n,{width:null,height:null,touchAction:"unset",viewState:Ll(t)}),e.isInitialized?YH(e,t):n.onLoad=()=>{o?.(),YH(e,t)},e.setProps(n),t.__deck=e,t.on("render",()=>{e.isInitialized&&Lge(e,t)}),e}function YH(t,e){let r=()=>{t.isInitialized?Bge(t,e):e.off("move",r)};e.on("move",r)}function qH(t){t.__deck?.finalize(),t.__deck=null}function Hx(t,e){return e?{depthWriteEnabled:!0,depthCompare:"less-equal",depthBias:0,blend:!0,blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"}:{}}function $H(t,e,r,o){if(!t.isInitialized)return;let{currentViewport:n}=t.userData,i=!1;n||(n=ZH(t,e,o),t.userData.currentViewport=n,i=!0),n&&t._drawLayers("mapbox-repaint",{viewports:[n],layerFilter:s=>{if(t.props.layerFilter&&!t.props.layerFilter(s))return!1;let a=s.layer;return a.props.beforeId===r.beforeId&&a.props.slot===r.slot},clearStack:i,clearCanvas:!1})}function Sw(t){let e=t.getProjection?.(),r=e?.type||e?.name;if(r==="globe")return"globe";if(r&&r!=="mercator")throw new Error("Unsupported projection");return"mercator"}function rp(t){return Sw(t)==="globe"?new k_({id:oa}):new di({id:oa})}function Ll(t){let{lng:e,lat:r}=t.getCenter(),o={longitude:(e+540)%360-180,latitude:r,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return t.getTerrain?.()&&Ige(t,o),o}function Ige(t,e){if(t.getFreeCameraOptions){let{position:r}=t.getFreeCameraOptions();if(!r||r.z===void 0)return;let o=t.transform.height,{longitude:n,latitude:i,pitch:s}=e,a=r.x*vw,c=(1-r.y)*vw,l=r.z*vw,f=Oe([n,i]),u=a-f[0],d=c-f[1],h=Math.sqrt(u*u+d*d),p=s*Rge,m=1.5*o,g=p<.001?m*Math.cos(p)/l:m*Math.sin(p)/h;e.zoom=Math.log2(g);let _=m*Math.cos(p)/g,x=l-_;e.position=[0,0,x/fs(i)]}else typeof t.transform.elevation=="number"&&(e.position=[0,0,t.transform.elevation])}function ZH(t,e,r){let o=Ll(e),n=t.getView(oa)||rp(e);r&&(n.props.nearZMultiplier=.2);let i=r?.nearZ??e.transform._nearZ,s=r?.farZ??e.transform._farZ;return Number.isFinite(i)&&(o.nearZ=i/e.transform.height,o.farZ=s/e.transform.height),n.makeViewport({width:t.width,height:t.height,viewState:o})}function Lge(t,e){let o=kt(t.props.layers,Boolean).some(a=>a&&!e.getLayer(Il(a))),n=t.getViewports(),i=n.findIndex(a=>a.id===oa),s=n.length>1||i<0;if(o||s){if(i>=0){n=n.slice();let a=ZH(t,e);a?n[i]=a:n.splice(i,1)}t._drawLayers("mapbox-repaint",{viewports:n,layerFilter:a=>(!t.props.layerFilter||t.props.layerFilter(a))&&(a.viewport.id!==oa||!e.getLayer(Il(a.layer))),clearCanvas:!1})}else{let a=t.device,c=a?.gl;t.props.onBeforeRender?.({device:a,gl:c}),t.props.onAfterRender?.({device:a,gl:c})}t.userData.currentViewport=null}function Bge(t,e){t.setProps({viewState:Ll(e)}),t.needsRedraw({clearRedrawFlags:!0})}var op=class{constructor(e){this._handleStyleChange=()=>{if(this._resolveLayers(this._map,this._deck,this._props.layers,this._props.layers),!this._map)return;Sw(this._map)&&this._deck?.setProps({views:this._getViews(this._map)})},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:o,clientHeight:n}=this._map.getContainer();Object.assign(this._container.style,{width:`${o}px`,height:`${n}px`})}},this._updateViewState=()=>{let o=this._deck,n=this._map;o&&n&&(o.setProps({views:this._getViews(n),viewState:Ll(n)}),o.isInitialized&&o.redraw())},this._handleMouseEvent=o=>{let n=this._deck;if(!n||!n.isInitialized)return;let i={type:o.type,offsetCenter:o.point,srcEvent:o},s=this._lastMouseDownPoint;switch(!o.point&&s&&(i.deltaX=o.originalEvent.clientX-s.clientX,i.deltaY=o.originalEvent.clientY-s.clientY,i.offsetCenter={x:s.x+i.deltaX,y:s.y+i.deltaY}),i.type){case"mousedown":n._onPointerDown(i),this._lastMouseDownPoint={...o.point,clientX:o.originalEvent.clientX,clientY:o.originalEvent.clientY};break;case"dragstart":i.type="panstart",n._onEvent(i);break;case"drag":i.type="panmove",n._onEvent(i);break;case"dragend":i.type="panend",n._onEvent(i);break;case"click":i.tapCount=1,n._onEvent(i);break;case"dblclick":i.type="click",i.tapCount=2,n._onEvent(i);break;case"mousemove":i.type="pointermove",n._onPointerMove(i);break;case"mouseout":i.type="pointerleave",n._onPointerMove(i);break;default:return}};let{interleaved:r=!1}=e;this._interleaved=r,this._props=this.filterProps(e)}filterProps(e){let{interleaved:r=!1,useDevicePixels:o,...n}=e;return!r&&o!==void 0&&(n.useDevicePixels=o),n}setProps(e){this._interleaved&&e.layers&&this._resolveLayers(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,this.filterProps(e)),this._deck&&this._map&&this._deck.setProps({...this._props,views:this._getViews(this._map),parameters:{...Hx(this._map,this._interleaved),...this._props.parameters}})}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new An({...this._props,parent:r,parameters:{...Hx(e,!1),...this._props.parameters},views:this._getViews(e),viewState:Ll(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(e){let r=e.painter.context.gl;return r instanceof WebGLRenderingContext&&N.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=KH({map:e,deck:new An({...this._props,views:this._getViews(e),gl:r,parameters:{...Hx(e,!0),...this._props.parameters}})}),e.on("styledata",this._handleStyleChange),this._resolveLayers(e,this._deck,[],this._props.layers),document.createElement("div")}_resolveLayers(e,r,o,n){XH(e,o,n)}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),this._resolveLayers(e,this._deck,this._props.layers,[]),qH(e)}getDefaultPosition(){return"top-left"}pickObject(e){return ge(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return ge(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return ge(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}_getViews(e){if(!this._props.views)return rp(e);let r=Array.isArray(this._props.views)?this._props.views:[this._props.views];return r.some(n=>n.id===oa)?this._props.views:[rp(e),...r]}};var Xx,Re,r8,Oge,na,JH,o8,Cw,Mw,Ew,ww,Fge,np={},n8=[],Nge=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Rw=Array.isArray;function Ni(t,e){for(var r in e)t[r]=e[r];return t}function i8(t){var e=t.parentNode;e&&e.removeChild(t)}function Dge(t,e,r){var o,n,i,s={};for(i in e)i=="key"?o=e[i]:i=="ref"?n=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?Xx.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return Wx(t,s,o,n,null)}function Wx(t,e,r,o,n){var i={type:t,props:e,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n??++r8,__i:-1,__u:0};return n==null&&Re.vnode!=null&&Re.vnode(i),i}function Di(t){return t.children}function Gx(t,e){this.props=t,this.context=e}function ia(t,e){if(e==null)return t.__?ia(t.__,t.__i+1):null;for(var r;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null)return r.__e;return typeof t.type=="function"?ia(t):null}function s8(t){var e,r;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null){t.__e=t.__c.base=r.__e;break}return s8(t)}}function QH(t){(!t.__d&&(t.__d=!0)&&na.push(t)&&!$x.__r++||JH!==Re.debounceRendering)&&((JH=Re.debounceRendering)||o8)($x)}function $x(){var t,e,r,o,n,i,s,a;for(na.sort(Cw);t=na.shift();)t.__d&&(e=na.length,o=void 0,i=(n=(r=t).__v).__e,s=[],a=[],r.__P&&((o=Ni({},n)).__v=n.__v+1,Re.vnode&&Re.vnode(o),Iw(r.__P,o,n,r.__n,r.__P.namespaceURI,32&n.__u?[i]:null,s,i??ia(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,l8(s,o,a),o.__e!=i&&s8(o)),na.length>e&&na.sort(Cw));$x.__r=0}function a8(t,e,r,o,n,i,s,a,c,l,f){var u,d,h,p,m,g=o&&o.__k||n8,_=e.length;for(r.__d=c,Uge(r,e,g),c=r.__d,u=0;u<_;u++)(h=r.__k[u])!=null&&typeof h!="boolean"&&typeof h!="function"&&(d=h.__i===-1?np:g[h.__i]||np,h.__i=u,Iw(t,h,d,n,i,s,a,c,l,f),p=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Lw(d.ref,null,h),f.push(h.ref,h.__c||p,h)),m==null&&p!=null&&(m=p),65536&h.__u||d.__k===h.__k?c=c8(h,c,t):typeof h.type=="function"&&h.__d!==void 0?c=h.__d:p&&(c=p.nextSibling),h.__d=void 0,h.__u&=-196609);r.__d=c,r.__e=m}function Uge(t,e,r){var o,n,i,s,a,c=e.length,l=r.length,f=l,u=0;for(t.__k=[],o=0;o<c;o++)s=o+u,(n=t.__k[o]=(n=e[o])==null||typeof n=="boolean"||typeof n=="function"?null:typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n.constructor==String?Wx(null,n,null,null,null):Rw(n)?Wx(Di,{children:n},null,null,null):n.constructor===void 0&&n.__b>0?Wx(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n)!=null?(n.__=t,n.__b=t.__b+1,a=kge(n,r,s,f),n.__i=a,i=null,a!==-1&&(f--,(i=r[a])&&(i.__u|=131072)),i==null||i.__v===null?(a==-1&&u--,typeof n.type!="function"&&(n.__u|=65536)):a!==s&&(a==s-1?u--:a==s+1?u++:a>s?f>c-s?u+=a-s:u--:a<s&&(a==s-u?u-=a-s:u++),a!==o+u&&(n.__u|=65536))):(i=r[s])&&i.key==null&&i.__e&&!(131072&i.__u)&&(i.__e==t.__d&&(t.__d=ia(i)),Pw(i,i,!1),r[s]=null,f--);if(f)for(o=0;o<l;o++)(i=r[o])!=null&&!(131072&i.__u)&&(i.__e==t.__d&&(t.__d=ia(i)),Pw(i,i))}function c8(t,e,r){var o,n;if(typeof t.type=="function"){for(o=t.__k,n=0;o&&n<o.length;n++)o[n]&&(o[n].__=t,e=c8(o[n],e,r));return e}t.__e!=e&&(e&&t.type&&!r.contains(e)&&(e=ia(t)),r.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType===8);return e}function kge(t,e,r,o){var n=t.key,i=t.type,s=r-1,a=r+1,c=e[r];if(c===null||c&&n==c.key&&i===c.type&&!(131072&c.__u))return r;if(o>(c!=null&&!(131072&c.__u)?1:0))for(;s>=0||a<e.length;){if(s>=0){if((c=e[s])&&!(131072&c.__u)&&n==c.key&&i===c.type)return s;s--}if(a<e.length){if((c=e[a])&&!(131072&c.__u)&&n==c.key&&i===c.type)return a;a++}}return-1}function e8(t,e,r){e[0]==="-"?t.setProperty(e,r??""):t[e]=r==null?"":typeof r!="number"||Nge.test(e)?r:r+"px"}function jx(t,e,r,o,n){var i;e:if(e==="style")if(typeof r=="string")t.style.cssText=r;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)r&&e in r||e8(t.style,e,"");if(r)for(e in r)o&&r[e]===o[e]||e8(t.style,e,r[e])}else if(e[0]==="o"&&e[1]==="n")i=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in t||e==="onFocusOut"||e==="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=r,r?o?r.u=o.u:(r.u=Mw,t.addEventListener(e,i?ww:Ew,i)):t.removeEventListener(e,i?ww:Ew,i);else{if(n=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&e[4]!=="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&r==1?"":r))}}function t8(t){return function(e){if(this.l){var r=this.l[e.type+t];if(e.t==null)e.t=Mw++;else if(e.t<r.u)return;return r(Re.event?Re.event(e):e)}}}function Iw(t,e,r,o,n,i,s,a,c,l){var f,u,d,h,p,m,g,_,x,y,b,T,v,w,C,S,A=e.type;if(e.constructor!==void 0)return null;128&r.__u&&(c=!!(32&r.__u),i=[a=e.__e=r.__e]),(f=Re.__b)&&f(e);e:if(typeof A=="function")try{if(_=e.props,x="prototype"in A&&A.prototype.render,y=(f=A.contextType)&&o[f.__c],b=f?y?y.props.value:f.__:o,r.__c?g=(u=e.__c=r.__c).__=u.__E:(x?e.__c=u=new A(_,b):(e.__c=u=new Gx(_,b),u.constructor=A,u.render=zge),y&&y.sub(u),u.props=_,u.state||(u.state={}),u.context=b,u.__n=o,d=u.__d=!0,u.__h=[],u._sb=[]),x&&u.__s==null&&(u.__s=u.state),x&&A.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Ni({},u.__s)),Ni(u.__s,A.getDerivedStateFromProps(_,u.__s))),h=u.props,p=u.state,u.__v=e,d)x&&A.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),x&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(x&&A.getDerivedStateFromProps==null&&_!==h&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(_,b),!u.__e&&(u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(_,u.__s,b)===!1||e.__v===r.__v)){for(e.__v!==r.__v&&(u.props=_,u.state=u.__s,u.__d=!1),e.__e=r.__e,e.__k=r.__k,e.__k.forEach(function(M){M&&(M.__=e)}),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);u._sb=[],u.__h.length&&s.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(_,u.__s,b),x&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(h,p,m)})}if(u.context=b,u.props=_,u.__P=t,u.__e=!1,v=Re.__r,w=0,x){for(u.state=u.__s,u.__d=!1,v&&v(e),f=u.render(u.props,u.state,u.context),C=0;C<u._sb.length;C++)u.__h.push(u._sb[C]);u._sb=[]}else do u.__d=!1,v&&v(e),f=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++w<25);u.state=u.__s,u.getChildContext!=null&&(o=Ni(Ni({},o),u.getChildContext())),x&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(h,p)),a8(t,Rw(S=f!=null&&f.type===Di&&f.key==null?f.props.children:f)?S:[S],e,r,o,n,i,s,a,c,l),u.base=e.__e,e.__u&=-161,u.__h.length&&s.push(u),g&&(u.__E=u.__=null)}catch(M){if(e.__v=null,c||i!=null){for(e.__u|=c?160:32;a&&a.nodeType===8&&a.nextSibling;)a=a.nextSibling;i[i.indexOf(a)]=null,e.__e=a}else e.__e=r.__e,e.__k=r.__k;Re.__e(M,e,r)}else i==null&&e.__v===r.__v?(e.__k=r.__k,e.__e=r.__e):e.__e=Vge(r.__e,e,r,o,n,i,s,c,l);(f=Re.diffed)&&f(e)}function l8(t,e,r){e.__d=void 0;for(var o=0;o<r.length;o++)Lw(r[o],r[++o],r[++o]);Re.__c&&Re.__c(e,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(i){i.call(n)})}catch(i){Re.__e(i,n.__v)}})}function Vge(t,e,r,o,n,i,s,a,c){var l,f,u,d,h,p,m,g=r.props,_=e.props,x=e.type;if(x==="svg"?n="http://www.w3.org/2000/svg":x==="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),i!=null){for(l=0;l<i.length;l++)if((h=i[l])&&"setAttribute"in h==!!x&&(x?h.localName===x:h.nodeType===3)){t=h,i[l]=null;break}}if(t==null){if(x===null)return document.createTextNode(_);t=document.createElementNS(n,x,_.is&&_),i=null,a=!1}if(x===null)g===_||a&&t.data===_||(t.data=_);else{if(i=i&&Xx.call(t.childNodes),g=r.props||np,!a&&i!=null)for(g={},l=0;l<t.attributes.length;l++)g[(h=t.attributes[l]).name]=h.value;for(l in g)if(h=g[l],l!="children"){if(l=="dangerouslySetInnerHTML")u=h;else if(l!=="key"&&!(l in _)){if(l=="value"&&"defaultValue"in _||l=="checked"&&"defaultChecked"in _)continue;jx(t,l,null,h,n)}}for(l in _)h=_[l],l=="children"?d=h:l=="dangerouslySetInnerHTML"?f=h:l=="value"?p=h:l=="checked"?m=h:l==="key"||a&&typeof h!="function"||g[l]===h||jx(t,l,h,g[l],n);if(f)a||u&&(f.__html===u.__html||f.__html===t.innerHTML)||(t.innerHTML=f.__html),e.__k=[];else if(u&&(t.innerHTML=""),a8(t,Rw(d)?d:[d],e,r,o,x==="foreignObject"?"http://www.w3.org/1999/xhtml":n,i,s,i?i[0]:r.__k&&ia(r,0),a,c),i!=null)for(l=i.length;l--;)i[l]!=null&&i8(i[l]);a||(l="value",p!==void 0&&(p!==t[l]||x==="progress"&&!p||x==="option"&&p!==g[l])&&jx(t,l,p,g[l],n),l="checked",m!==void 0&&m!==t[l]&&jx(t,l,m,g[l],n))}return t}function Lw(t,e,r){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(n){Re.__e(n,r)}}function Pw(t,e,r){var o,n;if(Re.unmount&&Re.unmount(t),(o=t.ref)&&(o.current&&o.current!==t.__e||Lw(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){Re.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(n=0;n<o.length;n++)o[n]&&Pw(o[n],e,r||typeof t.type!="function");r||t.__e==null||i8(t.__e),t.__c=t.__=t.__e=t.__d=void 0}function zge(t,e,r){return this.constructor(t,r)}function te(t,e,r){var o,n,i,s;Re.__&&Re.__(t,e),n=(o=typeof r=="function")?null:r&&r.__k||e.__k,i=[],s=[],Iw(e,t=(!o&&r||e).__k=Dge(Di,null,[t]),n||np,np,e.namespaceURI,!o&&r?[r]:n?null:e.firstChild?Xx.call(e.childNodes):null,i,!o&&r?r:n?n.__e:e.firstChild,o,s),l8(i,t,s)}Xx=n8.slice,Re={__e:function(t,e,r,o){for(var n,i,s;e=e.__;)if((n=e.__c)&&!n.__)try{if((i=n.constructor)&&i.getDerivedStateFromError!=null&&(n.setState(i.getDerivedStateFromError(t)),s=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(t,o||{}),s=n.__d),s)return n.__E=n}catch(a){t=a}throw t}},r8=0,Oge=function(t){return t!=null&&t.constructor==null},Gx.prototype.setState=function(t,e){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Ni({},this.state),typeof t=="function"&&(t=t(Ni({},r),this.props)),t&&Ni(r,t),t!=null&&this.__v&&(e&&this._sb.push(e),QH(this))},Gx.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),QH(this))},Gx.prototype.render=Di,na=[],o8=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Cw=function(t,e){return t.__v.__b-e.__v.__b},$x.__r=0,Mw=0,Ew=t8(!1),ww=t8(!0),Fge=0;var Hge=0,Mlt=Array.isArray;function I(t,e,r,o,n,i){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?s=e[a]:c[a]=e[a];var l={type:t,props:c,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--Hge,__i:-1,__u:0,__source:n,__self:i};if(typeof t=="function"&&(s=t.defaultProps))for(a in s)c[a]===void 0&&(c[a]=s[a]);return Re.vnode&&Re.vnode(l),l}var Yx=t=>{let{children:e,orientation:r="horizontal"}=t;return I("div",{className:`deck-widget-button-group ${r}`,children:e})};var Bl,Xe,Bw,f8,ip=0,y8=[],et=Re,u8=et.__b,d8=et.__r,h8=et.diffed,p8=et.__c,m8=et.unmount,g8=et.__;function qx(t,e){et.__h&&et.__h(Xe,t,ip||e),ip=0;var r=Xe.__H||(Xe.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({}),r.__[t]}function Ui(t){return ip=1,jge(x8,t)}function jge(t,e,r){var o=qx(Bl++,2);if(o.t=t,!o.__c&&(o.__=[r?r(e):x8(void 0,e),function(a){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,a);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=Xe,!Xe.u)){var n=function(a,c,l){if(!o.__c.__H)return!0;var f=o.__c.__H.__.filter(function(d){return!!d.__c});if(f.every(function(d){return!d.__N}))return!i||i.call(this,a,c,l);var u=!1;return f.forEach(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(u=!0)}}),!(!u&&o.__c.props===a)&&(!i||i.call(this,a,c,l))};Xe.u=!0;var i=Xe.shouldComponentUpdate,s=Xe.componentWillUpdate;Xe.componentWillUpdate=function(a,c,l){if(this.__e){var f=i;i=void 0,n(a,c,l),i=f}s&&s.call(this,a,c,l)},Xe.shouldComponentUpdate=n}return o.__N||o.__}function Hr(t,e){var r=qx(Bl++,3);!et.__s&&Nw(r.__H,e)&&(r.__=t,r.i=e,Xe.__H.__h.push(r))}function Fw(t,e){var r=qx(Bl++,4);!et.__s&&Nw(r.__H,e)&&(r.__=t,r.i=e,Xe.__h.push(r))}function Bt(t){return ip=5,On(function(){return{current:t}},[])}function On(t,e){var r=qx(Bl++,7);return Nw(r.__H,e)&&(r.__=t(),r.__H=e,r.__h=t),r.__}function Fn(t,e){return ip=8,On(function(){return t},e)}function Wge(){for(var t;t=y8.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Kx),t.__H.__h.forEach(Ow),t.__H.__h=[]}catch(e){t.__H.__h=[],et.__e(e,t.__v)}}et.__b=function(t){Xe=null,u8&&u8(t)},et.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),g8&&g8(t,e)},et.__r=function(t){d8&&d8(t),Bl=0;var e=(Xe=t.__c).__H;e&&(Bw===Xe?(e.__h=[],Xe.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(e.__h.forEach(Kx),e.__h.forEach(Ow),e.__h=[],Bl=0)),Bw=Xe},et.diffed=function(t){h8&&h8(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(y8.push(e)!==1&&f8===et.requestAnimationFrame||((f8=et.requestAnimationFrame)||Gge)(Wge)),e.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),Bw=Xe=null},et.__c=function(t,e){e.some(function(r){try{r.__h.forEach(Kx),r.__h=r.__h.filter(function(o){return!o.__||Ow(o)})}catch(o){e.some(function(n){n.__h&&(n.__h=[])}),e=[],et.__e(o,r.__v)}}),p8&&p8(t,e)},et.unmount=function(t){m8&&m8(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Kx(o)}catch(n){e=n}}),r.__H=void 0,e&&et.__e(e,r.__v))};var _8=typeof requestAnimationFrame=="function";function Gge(t){var e,r=function(){clearTimeout(o),_8&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(r,100);_8&&(e=requestAnimationFrame(r))}function Kx(t){var e=Xe,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),Xe=e}function Ow(t){var e=Xe;t.__c=t.__(),Xe=e}function Nw(t,e){return!t||t.length!==e.length||e.some(function(r,o){return r!==t[o]})}function x8(t,e){return typeof e=="function"?e(t):e}function Zx(t){if(!t)return;let e=`url("${t.replace(/"/g,"'")}")`;return{maskImage:e,WebkitMaskImage:e}}var Me=t=>{let{className:e="",style:r,color:o,icon:n,label:i,onClick:s,children:a}=t,c=On(()=>{let l=Zx(n);return o?{...l,backgroundColor:o}:l},[o,n]);return I("div",{className:"deck-widget-button",style:r,children:I("button",{className:`deck-widget-icon-button ${e}`,type:"button",onClick:s,title:i,children:a||I("div",{className:"deck-widget-icon",style:c})})})};var sp=class extends ${constructor(e={}){super(e),this.className="deck-widget-zoom",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=I(Yx,{orientation:this.props.orientation,children:[I(Me,{onClick:()=>this.handleZoomIn(),label:this.props.zoomInLabel,className:"deck-widget-zoom-in"}),I(Me,{onClick:()=>this.handleZoomOut(),label:this.props.zoomOutLabel,className:"deck-widget-zoom-out"})]});te(r,e)}isOrthographicView(e){let r=this.deck;return(r?.isInitialized&&r.getView(e))instanceof D_}handleZoom(e,r){let o=this.getViewState(e),n={};if(this.isOrthographicView(e)){let{zoomAxis:s}=this.props,{zoomX:a,minZoomX:c,maxZoomX:l,zoomY:f,minZoomY:u,maxZoomY:d}=$ge(o),h,p;if(s==="X")h=Jx(a+r,c,l),p=f;else if(s==="Y")h=a,p=Jx(f+r,u,d);else{let m=Jx(r,Math.max(c-a,u-f),Math.min(l-a,d-f));h=a+m,p=f+m}n.zoom=[h,p],n.zoomX=h,n.zoomY=p,this.props.onZoom?.({viewId:e,delta:r,zoom:s==="Y"?p:h,zoomX:h,zoomY:p})}else{let{zoom:s=0,minZoom:a,maxZoom:c}=o,l=Jx(s+r,a,c);n.zoom=l,this.props.onZoom?.({viewId:e,delta:r,zoom:l})}let i={...o,...n};this.props.transitionDuration>0&&(i.transitionDuration=this.props.transitionDuration,i.transitionInterpolator="latitude"in i?new so:new Ue({transitionProps:"zoomX"in n?["zoomX","zoomY"]:["zoom"]})),this.setViewState(e,i)}handleZoomIn(){for(let e of this.viewIds)this.handleZoom(e,1)}handleZoomOut(){for(let e of this.viewIds)this.handleZoom(e,-1)}};sp.defaultProps={...$.defaultProps,id:"zoom",placement:"top-left",orientation:"vertical",transitionDuration:200,zoomInLabel:"Zoom In",zoomOutLabel:"Zoom Out",zoomAxis:"all",viewId:null,onZoom:()=>{}};function Jx(t,e,r){return t<e?e:t>r?r:t}function $ge({zoom:t=0,zoomX:e,zoomY:r,minZoom:o=-1/0,maxZoom:n=1/0,minZoomX:i=o,maxZoomX:s=n,minZoomY:a=o,maxZoomY:c=n}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r,minZoomX:i,minZoomY:a,maxZoomX:s,maxZoomY:c}}var ap=class extends ${constructor(e={}){super(e),this.className="deck-widget-reset-view",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){te(I(Me,{className:"deck-widget-reset-focus",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}handleClick(){let e=this.props.initialViewState||this.deck?.props.initialViewState;this.resetViewState(e)}resetViewState(e){for(let r of this.viewIds){let o={...e?.[r]??e};this.props.onReset?.({viewId:r,viewState:o}),this.setViewState(r,o)}}};ap.defaultProps={...$.defaultProps,id:"reset-view",placement:"top-left",label:"Reset View",initialViewState:void 0,viewId:null,onReset:()=>{}};var cp=class extends ${constructor(e={}){super(e),this.className="deck-widget-gimbal",this.placement="top-left",this.viewports={},this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=this.viewId||Object.values(this.viewports)[0]?.id||"default-view",o=this.viewports[r],{rotationOrbit:n,rotationX:i}=this.getNormalizedRotation(o),s=I("div",{className:"deck-widget-button",style:{perspective:100,pointerEvents:"auto"},children:I("button",{type:"button",onClick:()=>{for(let a of Object.values(this.viewports))this.resetOrbitView(a)},title:this.props.label,style:{position:"relative",width:26,height:26},children:[I("svg",{className:"gimbal-outer-ring",width:"100%",height:"100%",viewBox:"0 0 26 26",style:{position:"absolute",top:0,left:0,transform:`rotateY(${n}deg)`},children:I("circle",{cx:"13",cy:"13",r:"10",stroke:"var(--icon-gimbal-outer-color, rgb(68, 92, 204))",strokeWidth:this.props.strokeWidth,fill:"none"})}),I("svg",{className:"gimbal-inner-ring",width:"100%",height:"100%",viewBox:"0 0 26 26",style:{position:"absolute",top:0,left:0,transform:`rotateX(${i}deg)`},children:I("circle",{cx:"13",cy:"13",r:"7",stroke:"var(--icon-gimbal-inner-color, rgb(240, 92, 68))",strokeWidth:this.props.strokeWidth,fill:"none"})})]})});te(s,e)}onViewportChange(e){this.viewports[e.id]=e,this.updateHTML()}resetOrbitView(e){let r=this.viewId||e?.id||"OrbitView",o=this.getViewState(r);if("rotationOrbit"in o||"rotationX"in o){this.props.onReset?.({viewId:r,rotationOrbit:0,rotationX:0});let n={...o,rotationOrbit:0,rotationX:0,transitionDuration:this.props.transitionDuration,transitionInterpolator:new Ue({transitionProps:["rotationOrbit","rotationX"]})};this.setViewState(r,n)}}getNormalizedRotation(e){let r=this.viewId||e?.id||"OrbitView",o=this.getViewState(r),[n,i]=this.getRotation(o),s=b8(n),a=b8(i);return{rotationOrbit:s,rotationX:a}}getRotation(e){return e&&("rotationOrbit"in e||"rotationX"in e)?[-(e.rotationOrbit||0),e.rotationX||0]:[0,0]}};cp.defaultProps={...$.defaultProps,id:"gimbal",placement:"top-left",viewId:null,label:"Gimbal",strokeWidth:1.5,transitionDuration:200,onReset:()=>{}};function b8(t){let e=((t+180)%360+360)%360-180,r=10,o=e-90;return Math.abs(o)<r&&(o<r?e=90+r:o>-r&&(e=90-r)),e}var lp=class extends ${constructor(e={}){super(e),this.className="deck-widget-compass",this.placement="top-left",this.viewports={},this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=this.viewId||Object.values(this.viewports)[0]?.id,o=this.viewports[r],[n,i]=this.getRotation(o),s=I("div",{className:"deck-widget-button",style:{perspective:100},children:I("button",{type:"button",onClick:()=>{for(let a of Object.values(this.viewports))this.handleCompassReset(a)},title:this.props.label,style:{transform:`rotateX(${i}deg)`},children:I("svg",{fill:"none",width:"100%",height:"100%",viewBox:"0 0 26 26",children:I("g",{transform:`rotate(${n},13,13)`,children:[I("path",{d:"M10 13.0001L12.9999 5L15.9997 13.0001H10Z",fill:"var(--icon-compass-north-color, rgb(240, 92, 68))"}),I("path",{d:"M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",fill:"var(--icon-compass-south-color, rgb(204, 204, 204))"})]})})})});te(s,e)}onViewportChange(e){e.equals(this.viewports[e.id])||(this.viewports[e.id]=e,this.updateHTML())}getRotation(e){return e instanceof Mt?[-e.bearing,e.pitch]:e instanceof Oo?[0,Math.max(-80,Math.min(80,e.latitude))]:[0,0]}handleCompassReset(e){let r=this.viewId||e.id;if(e instanceof Mt){let o=this.getViewState(r),n=this.getRotation(e)[0]===0,i=0,s=n?0:e.pitch;this.props.onReset?.({viewId:r,bearing:i,pitch:s});let a={...o,bearing:i,...n?{pitch:s}:{},transitionDuration:this.props.transitionDuration,transitionInterpolator:new so};this.setViewState(r,a)}}};lp.defaultProps={...$.defaultProps,id:"compass",placement:"top-left",viewId:null,label:"Reset Compass",transitionDuration:200,onReset:()=>{}};var fp=class extends ${constructor(e={}){super(e),this.className="deck-widget-scale",this.placement="bottom-left",this.scaleWidth=10,this.scaleValue=0,this.scaleText="",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let o=50+this.scaleWidth,n=10;te(I("svg",{className:"deck-widget-scale",width:o,height:30,style:{overflow:"visible",background:"transparent"},onClick:this.handleClick.bind(this),children:[I("text",{x:50+5,y:"10",textAnchor:"end",alignmentBaseline:"middle",style:{fontSize:"16px",fill:"black",fontWeight:"bold",fontFamily:"sans-serif"},children:this.scaleText}),I("line",{x1:50,y1:"15",x2:50+this.scaleWidth,y2:"15",stroke:"black",strokeWidth:"6"}),I("line",{x1:50,y1:"15",x2:50,y2:15-n,stroke:"black",strokeWidth:"6"}),I("line",{x1:50+this.scaleWidth,y1:"15",x2:50+this.scaleWidth,y2:15-n,stroke:"black",strokeWidth:"6"})]}),e)}onViewportChange(e){if(!("latitude"in e))return;let{latitude:r,zoom:o}=e,n=Xge(r,o),{candidate:i,candidatePixels:s}=Yge(n);this.scaleValue=i,this.scaleWidth=s,i>=1e3?this.scaleText=`${(i/1e3).toFixed(1)} km`:this.scaleText=`${i} m`,this.updateHTML()}handleClick(){}};fp.defaultProps={...$.defaultProps,id:"scale",placement:"bottom-left",label:"Scale",viewId:null};function Xge(t,e){return 40075016686e-3*Math.cos(t*Math.PI/180)/Math.pow(2,e+8)}function Yge(t){let n=150*t,i=Math.floor(Math.log10(n)),s=Math.pow(10,i),a=[1,2,5],c=a[0]*s,l=c/t;for(let f=0;f<a.length;f++){let u=a[f]*s,d=u/t;if(d>=100&&d<=200){c=u,l=d;break}if(d>200){c=f>0?a[f-1]*s:u,l=c/t;break}f===a.length-1&&d<100&&(c=a[0]*s*10,l=c/t)}return{candidate:c,candidatePixels:l}}function Kge(t){return typeof t=="string"?t:t.value}function qge(t){return typeof t=="string"?t:t.label}function Zge(t){return typeof t=="string"?void 0:t.icon}var Qx=t=>{let[e,r]=Ui(!1);return I(sa,{...t,style:{...t.style,position:"absolute"},isOpen:e,onClose:()=>r(!1),trigger:I("button",{className:"deck-widget-dropdown-button",onClick:()=>r(!e),children:I("span",{className:`deck-widget-dropdown-icon ${e?"open":""}`})})})},sa=t=>{let e=Bt(null);Hr(()=>{let o=n=>{e.current&&!e.current.contains(n.target)&&t.onClose()};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]);let r=(o,n)=>{o&&(typeof n=="object"&&n.onSelect?.(),t.onSelect?.(o),t.onClose())};return t.menuItems.length===0?null:I("div",{className:"deck-widget-dropdown-container",ref:e,children:[t.trigger,t.isOpen&&I("ul",{className:"deck-widget-dropdown-menu",style:t.style,children:t.menuItems.map((o,n)=>{let i=Kge(o),s=Zge(o);return I("li",{className:`deck-widget-dropdown-item ${i?"":"disabled"}`,onClick:()=>r(i,o),children:[s&&I("span",{className:"deck-widget-dropdown-item-icon",style:Zx(s)}),qge(o)]},n)})})]})};var Jge="current",A8="deck-geocoder-history",eb=class{constructor(e){this.addressText="",this.errorText="",this.addressHistory=[],this.props={maxEntries:5,...e},this.addressHistory=this.loadPreviousAddresses()}async geocode(e,r,o){this.errorText="",this.addressText=r;try{let n=await e.geocode(r,o);if(n)return this.storeAddress(this.addressText),n;this.errorText="Invalid address"}catch(n){this.errorText=`${n.message}`}return null}loadPreviousAddresses(){try{let e=window.localStorage.getItem(A8),r=e&&JSON.parse(e);return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{}return[]}storeAddress(e){let r=e.trim();if(!r||r===Jge)return;let o=[r,...this.addressHistory.filter(n=>n!==r)];this.addressHistory=o.slice(0,this.props.maxEntries);try{window.localStorage.setItem(A8,JSON.stringify(this.addressHistory))}catch{}}};var Qge="https://maps.googleapis.com/maps/api/geocode/json",e_e="https://api.mapbox.com/geocoding/v5/mapbox.places",t_e="https://api.opencagedata.com/geocode/v1/json",tb={name:"google",requiresApiKey:!0,async geocode(t,e){let r=encodeURIComponent(t),o=await Dw(`${Qge}?address=${r}&key=${e}`);switch(o.status){case"OK":let n=o.results.length>0&&o.results[0].geometry.location;return n?{longitude:n.lng,latitude:n.lat}:null;default:throw new Error(`Google Geocoder failed: ${o.status}`)}}},rb={name:"google",requiresApiKey:!0,async geocode(t,e){let r=encodeURIComponent(t),o=await Dw(`${e_e}/${r}.json?access_token=${e}`);if(Array.isArray(o.features)&&o.features.length>0){let n=o.features[0].center;if(Array.isArray(n)&&n.length>=2)return{longitude:n[0],latitude:n[1]}}return null}},ob={name:"opencage",requiresApiKey:!0,async geocode(t,e){let r=encodeURIComponent(t),o=await Dw(`${t_e}?q=${r}&key=${e}`);if(Array.isArray(o.results)&&o.results.length>0){let n=o.results[0].geometry;return{longitude:n.lng,latitude:n.lat}}return null}},nb={name:"current",requiresApiKey:!1,async geocode(){if(!navigator.geolocation)throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.geolocation.getCurrentPosition(r=>{let{longitude:o,latitude:n}=r.coords;t({longitude:o,latitude:n})},r=>e(new Error(r.message)))})}};async function Dw(t){let e;try{e=await fetch(t)}catch(o){throw new Error(`CORS error? ${o}. ${t}: `)}if(!e.ok)throw new Error(`${e.statusText}. ${t}: `);let r=await e.json();if(!r)throw new Error(`No data returned. ${t}`);return r}var Ol={name:"coordinates",requiresApiKey:!1,placeholderLocation:"-122.45, 37.8 or 37\xB048'N, 122\xB027'W",async geocode(t){return r_e(t)||null}};function r_e(t){t=t.trim();let e=t.split(/[,;]/).map(n=>n.trim());if(e.length<2)return null;let r=T8(e[0]),o=T8(e[1]);return r===null||o===null||Math.abs(r)>90&&Math.abs(o)>90?null:Math.abs(r)>90?{longitude:r,latitude:o}:Math.abs(o)>90?{longitude:o,latitude:r}:{latitude:r,longitude:o}}function T8(t){if(t=t.trim(),t.includes("\xB0")||t.includes("'")||t.includes('"')){let o=o_e(t);return isNaN(o)?null:o}let e=1;/[SW]/i.test(t)&&(e=-1),t=t.replace(/[NSEW]/gi,"");let r=parseFloat(t);return isNaN(r)?null:e*r}function o_e(t){let e=/(-?\d+)[°d]\s*(\d+)?['′m]?\s*(\d+(?:\.\d+)?)?[\"″s]?\s*([NSEW])?/i,r=t.match(e);if(!r)return NaN;let o=parseFloat(r[1])||0,n=parseFloat(r[2])||0,i=parseFloat(r[3])||0,s=r[4]||"",a=o<0?-1:1,c=Math.abs(o)+n/60+i/3600;return/[SW]/i.test(s)?c=-c:c=a*c,c}var v8="current",n_e="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-480q33 0 56.5-23.5T560-560q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 33 23.5 56.5T480-480Zm0 294q122-112 181-203.5T720-552q0-109-69.5-178.5T480-800q-101 0-170.5 69.5T240-552q0 71 59 162.5T480-186Zm0 106Q319-217 239.5-334.5T160-552q0-150 96.5-239T480-880q127 0 223.5 89T800-552q0 100-79.5 217.5T480-80Z'/%3E%3C/svg%3E",i_e={label:"Current location",value:v8,icon:n_e},up=class extends ${constructor(e={}){super(e),this.className="deck-widget-geocoder",this.placement="top-left",this.geocodeHistory=new eb({}),this.addressText="",this.geocoder=Ol,this.isGettingLocation=!1,this.setInput=r=>{this.addressText=r},this.handleKeyPress=r=>{r.key==="Enter"&&this.handleSubmit()},this.handleSelect=r=>{r===v8?this.getCurrentLocation():(this.setInput(r),this.handleSubmit())},this.handleSubmit=()=>{this.geocode(this.addressText)},this.getCurrentLocation=async()=>{this.isGettingLocation=!0,this.rootElement&&this.updateHTML();try{let r=await nb.geocode();r&&this.flyTo(r)}catch(r){this.geocodeHistory.errorText=r instanceof Error?r.message:"Location error"}finally{this.isGettingLocation=!1,this.rootElement&&this.updateHTML()}},this.geocode=async r=>{let o=await this.geocodeHistory.geocode(this.geocoder,this.addressText,this.props.apiKey);this.rootElement&&this.updateHTML(),o&&this.flyTo(o)},this.setProps(this.props)}setProps(e){if(this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,this.geocoder=s_e(this.props),this.geocoder.requiresApiKey&&!this.props.apiKey)throw new Error(`API key is required for the ${this.geocoder.name} geocoder`);super.setProps(e)}onRenderHTML(e){let r=this.props._geolocation?[i_e,...this.geocodeHistory.addressHistory]:[...this.geocodeHistory.addressHistory];te(I("div",{className:"deck-widget-geocoder",children:[I("input",{className:"deck-widget-geocoder-input",type:"text",placeholder:this.isGettingLocation?"Finding your location...":this.geocoder.placeholderLocation??"Enter address or location",value:this.geocodeHistory.addressText,onInput:o=>this.setInput(o.target?.value||""),onKeyPress:this.handleKeyPress}),I(Qx,{menuItems:r,onSelect:this.handleSelect}),this.geocodeHistory.errorText&&I("div",{className:"deck-widget-geocoder-error",children:this.geocodeHistory.errorText})]}),e)}flyTo(e){for(let r of this.viewIds){"longitude"in e&&"latitude"in e&&this.props.onGeocode?.({viewId:r,coordinates:{longitude:e.longitude,latitude:e.latitude,zoom:e.zoom}});let n={...this.getViewState(r),...e};this.props.transitionDuration>0&&(n.transitionDuration=this.props.transitionDuration,n.transitionInterpolator="latitude"in n?new so:new Ue),this.setViewState(r,n)}}};up.defaultProps={...$.defaultProps,id:"geocoder",viewId:null,placement:"top-left",label:"Geocoder",transitionDuration:200,geocoder:"coordinates",customGeocoder:Ol,apiKey:"",_geolocation:!1,onGeocode:()=>{}};function s_e(t){switch(t.geocoder){case"google":return tb;case"mapbox":return rb;case"opencage":return ob;case"coordinates":return Ol;case"custom":if(!t.customGeocoder)throw new Error("Custom geocoder is not defined");return t.customGeocoder;default:throw new Error(`Unknown geocoder: ${t.geocoder}`)}}var dp=class extends ${constructor(e={}){super(e),this.className="deck-widget-fullscreen",this.placement="top-left",this.fullscreen=!1,this.setProps(this.props)}onAdd(){document.addEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}onRemove(){document.removeEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}onRenderHTML(e){let r=this.getFullscreen();te(I(Me,{onClick:()=>{this.handleClick().catch(o=>N.error(o)())},label:r?this.props.exitLabel:this.props.enterLabel,className:r?"deck-widget-fullscreen-exit":"deck-widget-fullscreen-enter"}),e)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}getContainer(){return this.props.container||this.deck?.props.parent||this.deck?.getCanvas()?.parentElement}getFullscreen(){return this.fullscreen}onFullscreenChange(){let e=document.fullscreenElement===this.getContainer();e!==this.fullscreen&&(this.fullscreen=e,this.props.onFullscreenChange?.(e),this.updateHTML())}async handleClick(){this.getFullscreen()?await this.exitFullscreen():await this.requestFullscreen()}async requestFullscreen(){let e=this.getContainer();e?.requestFullscreen?await e.requestFullscreen({navigationUI:"hide"}):this.togglePseudoFullscreen()}async exitFullscreen(){document.exitFullscreen?await document.exitFullscreen():this.togglePseudoFullscreen()}togglePseudoFullscreen(){this.getContainer()?.classList.toggle("deck-pseudo-fullscreen"),this.fullscreen=!this.fullscreen,this.props.onFullscreenChange?.(this.fullscreen),this.updateHTML()}};dp.defaultProps={...$.defaultProps,id:"fullscreen",placement:"top-left",viewId:null,enterLabel:"Enter Fullscreen",exitLabel:"Exit Fullscreen",container:void 0,onFullscreenChange:()=>{}};function S8(t){let e=[],r=n=>"views"in n;function o(n){let i=e.length,s=n.minSplit??.05,a=n.maxSplit??.95,c=Math.min(Math.max(n.initialSplit??.5,s),a),l={id:i,orientation:n.orientation,views:n.views,split:c,editable:n.editable??!0,minSplit:s,maxSplit:a,x:0,y:0,width:0,height:0};return e.push(l),l.views=[r(n.views[0])?o(n.views[0]):n.views[0],r(n.views[1])?o(n.views[1]):n.views[1]],l}return o(t),e}function C8(t){let e=[];function r(o,n,i,s,a){o.x=n,o.y=i,o.width=s,o.height=a;let c=n,l=i,f=s,u=a,d=n,h=i,p=s,m=a;o.orientation==="horizontal"?(f=s*o.split,d=n+f,p=s-f):(u=a*o.split,h=i+u,m=a-u);let[g,_]=o.views;"views"in g?r(g,c,l,f,u):e.push(g.clone({x:`${c}%`,y:`${l}%`,width:`${f}%`,height:`${u}%`})),"views"in _?r(_,d,h,p,m):e.push(_.clone({x:`${d}%`,y:`${h}%`,width:`${p}%`,height:`${m}%`}))}return r(t,0,0,100,100),e}var hp=class extends ${constructor(e){super(e),this.className="deck-widget-splitter",this.placement="fill",this.needsUpdate=!0,this.viewLayouts=S8(this.props.viewLayout)}setProps(e){e.viewLayout&&!ie(e.viewLayout,this.props.viewLayout,-1)&&(this.viewLayouts=S8(e.viewLayout),this.views=void 0),super.setProps(e)}onRedraw(){super.updateHTML()}updateHTML(){this.views||(this.views=C8(this.viewLayouts[0]),this.props.onChange(this.views.slice())),requestAnimationFrame(()=>{this.doUpdate()})}doUpdate(){if(this.deck){let e=this.deck.props.views;!(e&&e!==this.lastViews)&&this.lastViews!==this.views&&(this.lastViews=this.views,this.deck.setProps({views:this.views}))}}onChange(e,r){r.split=e,this.views=C8(this.viewLayouts[0]),this.props.onChange(this.views.slice()),this.doUpdate()}onRenderHTML(e){te(I(Di,{children:this.viewLayouts.map(r=>r.editable&&I(a_e,{...r,onChange:o=>this.onChange(o,r),onDragStart:()=>this.props.onDragStart(),onDragEnd:()=>this.props.onDragStart()}))}),e)}};hp.defaultProps={...$.defaultProps,id:"splitter-widget",viewLayout:void 0,onChange:()=>{},onDragStart:()=>{},onDragEnd:()=>{}};function a_e({orientation:t,x:e,y:r,width:o,height:n,split:i,minSplit:s,maxSplit:a,onChange:c,onDragStart:l,onDragEnd:f}){let[u,d]=Ui(!1),h=Bt(null);Hr(()=>{if(!u)return;let _=y=>{if(!h.current)return;let b=h.current.getBoundingClientRect(),T;t==="horizontal"?T=(y.clientX-b.left)/b.width:T=(y.clientY-b.top)/b.height,T=Math.min(Math.max(T,s),a),c?.(T)},x=()=>{f?.(),d(!1)};return document.addEventListener("pointermove",_),document.addEventListener("pointerup",x),document.addEventListener("pointerleave",x),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",x),document.removeEventListener("pointerleave",x)}},[u]);let p=_=>{d(!0),l?.(),_.preventDefault()},m=t==="horizontal"?{left:`${i*100}%`}:{top:`${i*100}%`},g={position:"absolute",top:`${r}%`,left:`${e}%`,width:`${o}%`,height:`${n}%`};return I("div",{ref:h,style:g,children:I("div",{className:`deck-widget-splitter-handle deck-widget-splitter-handle--${t} ${u?"active":""}`,style:m,onPointerDown:p})})}var ki=Math.min,Nn=Math.max,mp=Math.round,gp=Math.floor,po=t=>({x:t,y:t}),c_e={left:"right",right:"left",bottom:"top",top:"bottom"};function sb(t,e,r){return Nn(t,ki(e,r))}function Fl(t,e){return typeof t=="function"?t(e):t}function Vi(t){return t.split("-")[0]}function Nl(t){return t.split("-")[1]}function Uw(t){return t==="x"?"y":"x"}function ab(t){return t==="y"?"height":"width"}function Dn(t){let e=t[0];return e==="t"||e==="b"?"y":"x"}function cb(t){return Uw(Dn(t))}function P8(t,e,r){r===void 0&&(r=!1);let o=Nl(t),n=cb(t),i=ab(n),s=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=pp(s)),[s,pp(s)]}function M8(t){let e=pp(t);return[ib(t),e,ib(e)]}function ib(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}var E8=["left","right"],w8=["right","left"],l_e=["top","bottom"],f_e=["bottom","top"];function u_e(t,e,r){switch(t){case"top":case"bottom":return r?e?w8:E8:e?E8:w8;case"left":case"right":return e?l_e:f_e;default:return[]}}function R8(t,e,r,o){let n=Nl(t),i=u_e(Vi(t),r==="start",o);return n&&(i=i.map(s=>s+"-"+n),e&&(i=i.concat(i.map(ib)))),i}function pp(t){let e=Vi(t);return c_e[e]+t.slice(e.length)}function d_e(t){return{top:0,right:0,bottom:0,left:0,...t}}function kw(t){return typeof t!="number"?d_e(t):{top:t,right:t,bottom:t,left:t}}function aa(t){let{x:e,y:r,width:o,height:n}=t;return{width:o,height:n,top:r,left:e,right:e+o,bottom:r+n,x:e,y:r}}function I8(t,e,r){let{reference:o,floating:n}=t,i=Dn(e),s=cb(e),a=ab(s),c=Vi(e),l=i==="y",f=o.x+o.width/2-n.width/2,u=o.y+o.height/2-n.height/2,d=o[a]/2-n[a]/2,h;switch(c){case"top":h={x:f,y:o.y-n.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-n.width,y:u};break;default:h={x:o.x,y:o.y}}switch(Nl(e)){case"start":h[s]-=d*(r&&l?-1:1);break;case"end":h[s]+=d*(r&&l?-1:1);break}return h}async function L8(t,e){var r;e===void 0&&(e={});let{x:o,y:n,platform:i,rects:s,elements:a,strategy:c}=t,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:d=!1,padding:h=0}=Fl(e,t),p=kw(h),g=a[d?u==="floating"?"reference":"floating":u],_=aa(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(g)))==null||r?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:c})),x=u==="floating"?{x:o,y:n,width:s.floating.width,height:s.floating.height}:s.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),b=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},T=aa(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:y,strategy:c}):x);return{top:(_.top-T.top+p.top)/b.y,bottom:(T.bottom-_.bottom+p.bottom)/b.y,left:(_.left-T.left+p.left)/b.x,right:(T.right-_.right+p.right)/b.x}}var h_e=50,B8=async(t,e,r)=>{let{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:s}=r,a=s.detectOverflow?s:{...s,detectOverflow:L8},c=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:t,floating:e,strategy:n}),{x:f,y:u}=I8(l,o,c),d=o,h=0,p={};for(let m=0;m<i.length;m++){let g=i[m];if(!g)continue;let{name:_,fn:x}=g,{x:y,y:b,data:T,reset:v}=await x({x:f,y:u,initialPlacement:o,placement:d,strategy:n,middlewareData:p,rects:l,platform:a,elements:{reference:t,floating:e}});f=y??f,u=b??u,p[_]={...p[_],...T},v&&h<h_e&&(h++,typeof v=="object"&&(v.placement&&(d=v.placement),v.rects&&(l=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:n}):v.rects),{x:f,y:u}=I8(l,d,c)),m=-1)}return{x:f,y:u,placement:d,strategy:n,middlewareData:p}},O8=t=>({name:"arrow",options:t,async fn(e){let{x:r,y:o,placement:n,rects:i,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:f=0}=Fl(t,e)||{};if(l==null)return{};let u=kw(f),d={x:r,y:o},h=cb(n),p=ab(h),m=await s.getDimensions(l),g=h==="y",_=g?"top":"left",x=g?"bottom":"right",y=g?"clientHeight":"clientWidth",b=i.reference[p]+i.reference[h]-d[h]-i.floating[p],T=d[h]-i.reference[h],v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),w=v?v[y]:0;(!w||!await(s.isElement==null?void 0:s.isElement(v)))&&(w=a.floating[y]||i.floating[p]);let C=b/2-T/2,S=w/2-m[p]/2-1,A=ki(u[_],S),M=ki(u[x],S),B=A,O=w-m[p]-M,F=w/2-m[p]/2+C,X=sb(B,F,O),G=!c.arrow&&Nl(n)!=null&&F!==X&&i.reference[p]/2-(F<B?A:M)-m[p]/2<0,j=G?F<B?F-B:F-O:0;return{[h]:d[h]+j,data:{[h]:X,centerOffset:F-X-j,...G&&{alignmentOffset:j}},reset:G}}});var F8=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r,o;let{placement:n,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Fl(t,e);if((r=i.arrow)!=null&&r.alignmentOffset)return{};let _=Vi(n),x=Dn(a),y=Vi(a)===a,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),T=d||(y||!m?[pp(a)]:M8(a)),v=p!=="none";!d&&v&&T.push(...R8(a,m,p,b));let w=[a,...T],C=await c.detectOverflow(e,g),S=[],A=((o=i.flip)==null?void 0:o.overflows)||[];if(f&&S.push(C[_]),u){let F=P8(n,s,b);S.push(C[F[0]],C[F[1]])}if(A=[...A,{placement:n,overflows:S}],!S.every(F=>F<=0)){var M,B;let F=(((M=i.flip)==null?void 0:M.index)||0)+1,X=w[F];if(X&&(!(u==="alignment"?x!==Dn(X):!1)||A.every(se=>Dn(se.placement)===x?se.overflows[0]>0:!0)))return{data:{index:F,overflows:A},reset:{placement:X}};let G=(B=A.filter(j=>j.overflows[0]<=0).sort((j,se)=>j.overflows[1]-se.overflows[1])[0])==null?void 0:B.placement;if(!G)switch(h){case"bestFit":{var O;let j=(O=A.filter(se=>{if(v){let ne=Dn(se.placement);return ne===x||ne==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(ne=>ne>0).reduce((ne,pe)=>ne+pe,0)]).sort((se,ne)=>se[1]-ne[1])[0])==null?void 0:O[0];j&&(G=j);break}case"initialPlacement":G=a;break}if(n!==G)return{reset:{placement:G}}}return{}}}};var p_e=new Set(["left","top"]);async function m_e(t,e){let{placement:r,platform:o,elements:n}=t,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),s=Vi(r),a=Nl(r),c=Dn(r)==="y",l=p_e.has(s)?-1:1,f=i&&c?-1:1,u=Fl(e,t),{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),c?{x:h*f,y:d*l}:{x:d*l,y:h*f}}var N8=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,o;let{x:n,y:i,placement:s,middlewareData:a}=e,c=await m_e(e,t);return s===((r=a.offset)==null?void 0:r.placement)&&(o=a.arrow)!=null&&o.alignmentOffset?{}:{x:n+c.x,y:i+c.y,data:{...c,placement:s}}}}},D8=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:r,y:o,placement:n,platform:i}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:_=>{let{x,y}=_;return{x,y}}},...l}=Fl(t,e),f={x:r,y:o},u=await i.detectOverflow(e,l),d=Dn(Vi(n)),h=Uw(d),p=f[h],m=f[d];if(s){let _=h==="y"?"top":"left",x=h==="y"?"bottom":"right",y=p+u[_],b=p-u[x];p=sb(y,p,b)}if(a){let _=d==="y"?"top":"left",x=d==="y"?"bottom":"right",y=m+u[_],b=m-u[x];m=sb(y,m,b)}let g=c.fn({...e,[h]:p,[d]:m});return{...g,data:{x:g.x-r,y:g.y-o,enabled:{[h]:s,[d]:a}}}}}};function lb(){return typeof window<"u"}function la(t){return k8(t)?(t.nodeName||"").toLowerCase():"#document"}function or(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function mo(t){var e;return(e=(k8(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function k8(t){return lb()?t instanceof Node||t instanceof or(t).Node:!1}function jr(t){return lb()?t instanceof Element||t instanceof or(t).Element:!1}function Jo(t){return lb()?t instanceof HTMLElement||t instanceof or(t).HTMLElement:!1}function U8(t){return!lb()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof or(t).ShadowRoot}function Ul(t){let{overflow:e,overflowX:r,overflowY:o,display:n}=Wr(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+r)&&n!=="inline"&&n!=="contents"}function V8(t){return/^(table|td|th)$/.test(la(t))}function _p(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}var g_e=/transform|translate|scale|rotate|perspective|filter/,__e=/paint|layout|strict|content/,ca=t=>!!t&&t!=="none",Vw;function fb(t){let e=jr(t)?Wr(t):t;return ca(e.transform)||ca(e.translate)||ca(e.scale)||ca(e.rotate)||ca(e.perspective)||!ub()&&(ca(e.backdropFilter)||ca(e.filter))||g_e.test(e.willChange||"")||__e.test(e.contain||"")}function z8(t){let e=Un(t);for(;Jo(e)&&!fa(e);){if(fb(e))return e;if(_p(e))return null;e=Un(e)}return null}function ub(){return Vw==null&&(Vw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Vw}function fa(t){return/^(html|body|#document)$/.test(la(t))}function Wr(t){return or(t).getComputedStyle(t)}function yp(t){return jr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Un(t){if(la(t)==="html")return t;let e=t.assignedSlot||t.parentNode||U8(t)&&t.host||mo(t);return U8(e)?e.host:e}function H8(t){let e=Un(t);return fa(e)?t.ownerDocument?t.ownerDocument.body:t.body:Jo(e)&&Ul(e)?e:H8(e)}function Dl(t,e,r){var o;e===void 0&&(e=[]),r===void 0&&(r=!0);let n=H8(t),i=n===((o=t.ownerDocument)==null?void 0:o.body),s=or(n);if(i){let a=db(s);return e.concat(s,s.visualViewport||[],Ul(n)?n:[],a&&r?Dl(a):[])}else return e.concat(n,Dl(n,[],r))}function db(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function $8(t){let e=Wr(t),r=parseFloat(e.width)||0,o=parseFloat(e.height)||0,n=Jo(t),i=n?t.offsetWidth:r,s=n?t.offsetHeight:o,a=mp(r)!==i||mp(o)!==s;return a&&(r=i,o=s),{width:r,height:o,$:a}}function Hw(t){return jr(t)?t:t.contextElement}function kl(t){let e=Hw(t);if(!Jo(e))return po(1);let r=e.getBoundingClientRect(),{width:o,height:n,$:i}=$8(e),s=(i?mp(r.width):r.width)/o,a=(i?mp(r.height):r.height)/n;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var y_e=po(0);function X8(t){let e=or(t);return!ub()||!e.visualViewport?y_e:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function x_e(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==or(t)?!1:e}function ua(t,e,r,o){e===void 0&&(e=!1),r===void 0&&(r=!1);let n=t.getBoundingClientRect(),i=Hw(t),s=po(1);e&&(o?jr(o)&&(s=kl(o)):s=kl(t));let a=x_e(i,r,o)?X8(i):po(0),c=(n.left+a.x)/s.x,l=(n.top+a.y)/s.y,f=n.width/s.x,u=n.height/s.y;if(i){let d=or(i),h=o&&jr(o)?or(o):o,p=d,m=db(p);for(;m&&o&&h!==p;){let g=kl(m),_=m.getBoundingClientRect(),x=Wr(m),y=_.left+(m.clientLeft+parseFloat(x.paddingLeft))*g.x,b=_.top+(m.clientTop+parseFloat(x.paddingTop))*g.y;c*=g.x,l*=g.y,f*=g.x,u*=g.y,c+=y,l+=b,p=or(m),m=db(p)}}return aa({width:f,height:u,x:c,y:l})}function hb(t,e){let r=yp(t).scrollLeft;return e?e.left+r:ua(mo(t)).left+r}function Y8(t,e){let r=t.getBoundingClientRect(),o=r.left+e.scrollLeft-hb(t,r),n=r.top+e.scrollTop;return{x:o,y:n}}function b_e(t){let{elements:e,rect:r,offsetParent:o,strategy:n}=t,i=n==="fixed",s=mo(o),a=e?_p(e.floating):!1;if(o===s||a&&i)return r;let c={scrollLeft:0,scrollTop:0},l=po(1),f=po(0),u=Jo(o);if((u||!u&&!i)&&((la(o)!=="body"||Ul(s))&&(c=yp(o)),u)){let h=ua(o);l=kl(o),f.x=h.x+o.clientLeft,f.y=h.y+o.clientTop}let d=s&&!u&&!i?Y8(s,c):po(0);return{width:r.width*l.x,height:r.height*l.y,x:r.x*l.x-c.scrollLeft*l.x+f.x+d.x,y:r.y*l.y-c.scrollTop*l.y+f.y+d.y}}function A_e(t){return Array.from(t.getClientRects())}function T_e(t){let e=mo(t),r=yp(t),o=t.ownerDocument.body,n=Nn(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=Nn(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-r.scrollLeft+hb(t),a=-r.scrollTop;return Wr(o).direction==="rtl"&&(s+=Nn(e.clientWidth,o.clientWidth)-n),{width:n,height:i,x:s,y:a}}var j8=25;function v_e(t,e){let r=or(t),o=mo(t),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,a=0,c=0;if(n){i=n.width,s=n.height;let f=ub();(!f||f&&e==="fixed")&&(a=n.offsetLeft,c=n.offsetTop)}let l=hb(o);if(l<=0){let f=o.ownerDocument,u=f.body,d=getComputedStyle(u),h=f.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,p=Math.abs(o.clientWidth-u.clientWidth-h);p<=j8&&(i-=p)}else l<=j8&&(i+=l);return{width:i,height:s,x:a,y:c}}function S_e(t,e){let r=ua(t,!0,e==="fixed"),o=r.top+t.clientTop,n=r.left+t.clientLeft,i=Jo(t)?kl(t):po(1),s=t.clientWidth*i.x,a=t.clientHeight*i.y,c=n*i.x,l=o*i.y;return{width:s,height:a,x:c,y:l}}function W8(t,e,r){let o;if(e==="viewport")o=v_e(t,r);else if(e==="document")o=T_e(mo(t));else if(jr(e))o=S_e(e,r);else{let n=X8(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return aa(o)}function K8(t,e){let r=Un(t);return r===e||!jr(r)||fa(r)?!1:Wr(r).position==="fixed"||K8(r,e)}function C_e(t,e){let r=e.get(t);if(r)return r;let o=Dl(t,[],!1).filter(a=>jr(a)&&la(a)!=="body"),n=null,i=Wr(t).position==="fixed",s=i?Un(t):t;for(;jr(s)&&!fa(s);){let a=Wr(s),c=fb(s);!c&&a.position==="fixed"&&(n=null),(i?!c&&!n:!c&&a.position==="static"&&!!n&&(n.position==="absolute"||n.position==="fixed")||Ul(s)&&!c&&K8(t,s))?o=o.filter(f=>f!==s):n=a,s=Un(s)}return e.set(t,o),o}function E_e(t){let{element:e,boundary:r,rootBoundary:o,strategy:n}=t,s=[...r==="clippingAncestors"?_p(e)?[]:C_e(e,this._c):[].concat(r),o],a=W8(e,s[0],n),c=a.top,l=a.right,f=a.bottom,u=a.left;for(let d=1;d<s.length;d++){let h=W8(e,s[d],n);c=Nn(h.top,c),l=ki(h.right,l),f=ki(h.bottom,f),u=Nn(h.left,u)}return{width:l-u,height:f-c,x:u,y:c}}function w_e(t){let{width:e,height:r}=$8(t);return{width:e,height:r}}function P_e(t,e,r){let o=Jo(e),n=mo(e),i=r==="fixed",s=ua(t,!0,i,e),a={scrollLeft:0,scrollTop:0},c=po(0);function l(){c.x=hb(n)}if(o||!o&&!i)if((la(e)!=="body"||Ul(n))&&(a=yp(e)),o){let h=ua(e,!0,i,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop}else n&&l();i&&!o&&n&&l();let f=n&&!o&&!i?Y8(n,a):po(0),u=s.left+a.scrollLeft-c.x-f.x,d=s.top+a.scrollTop-c.y-f.y;return{x:u,y:d,width:s.width,height:s.height}}function zw(t){return Wr(t).position==="static"}function G8(t,e){if(!Jo(t)||Wr(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return mo(t)===r&&(r=r.ownerDocument.body),r}function q8(t,e){let r=or(t);if(_p(t))return r;if(!Jo(t)){let n=Un(t);for(;n&&!fa(n);){if(jr(n)&&!zw(n))return n;n=Un(n)}return r}let o=G8(t,e);for(;o&&V8(o)&&zw(o);)o=G8(o,e);return o&&fa(o)&&zw(o)&&!fb(o)?r:o||z8(t)||r}var M_e=async function(t){let e=this.getOffsetParent||q8,r=this.getDimensions,o=await r(t.floating);return{reference:P_e(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function R_e(t){return Wr(t).direction==="rtl"}var I_e={convertOffsetParentRelativeRectToViewportRelativeRect:b_e,getDocumentElement:mo,getClippingRect:E_e,getOffsetParent:q8,getElementRects:M_e,getClientRects:A_e,getDimensions:w_e,getScale:kl,isElement:jr,isRTL:R_e};function Z8(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function L_e(t,e){let r=null,o,n=mo(t);function i(){var a;clearTimeout(o),(a=r)==null||a.disconnect(),r=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();let l=t.getBoundingClientRect(),{left:f,top:u,width:d,height:h}=l;if(a||e(),!d||!h)return;let p=gp(u),m=gp(n.clientWidth-(f+d)),g=gp(n.clientHeight-(u+h)),_=gp(f),y={rootMargin:-p+"px "+-m+"px "+-g+"px "+-_+"px",threshold:Nn(0,ki(1,c))||1},b=!0;function T(v){let w=v[0].intersectionRatio;if(w!==c){if(!b)return s();w?s(!1,w):o=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!Z8(l,t.getBoundingClientRect())&&s(),b=!1}try{r=new IntersectionObserver(T,{...y,root:n.ownerDocument})}catch{r=new IntersectionObserver(T,y)}r.observe(t)}return s(!0),i}function J8(t,e,r,o){o===void 0&&(o={});let{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=Hw(t),f=n||i?[...l?Dl(l):[],...e?Dl(e):[]]:[];f.forEach(_=>{n&&_.addEventListener("scroll",r,{passive:!0}),i&&_.addEventListener("resize",r)});let u=l&&a?L_e(l,r):null,d=-1,h=null;s&&(h=new ResizeObserver(_=>{let[x]=_;x&&x.target===l&&h&&e&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(e)})),r()}),l&&!c&&h.observe(l),e&&h.observe(e));let p,m=c?ua(t):null;c&&g();function g(){let _=ua(t);m&&!Z8(m,_)&&r(),m=_,p=requestAnimationFrame(g)}return r(),()=>{var _;f.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),u?.(),(_=h)==null||_.disconnect(),h=null,c&&cancelAnimationFrame(p)}}var jw=N8;var Ww=D8,Gw=F8;var Q8=O8;var e5=(t,e,r)=>{let o=new Map,n={platform:I_e,...r},i={...n.platform,_c:o};return B8(t,e,{...n,platform:i})};var zi=({x:t,y:e,placement:r="right",offset:o=0,arrow:n=!1,arrowColor:i="white",children:s})=>{let a=Bt(null),c=Bt(null),l=Bt(null),f=Bt();return f.current=()=>{if(!a.current||!c.current)return;let u=Array.isArray(n)?n[0]:n||0,d=Array.isArray(n)?n[1]:n||0,h=o+Math.max(d,u),p=r.includes("-")?[jw(h),Gw(),Ww()]:[jw(h),Ww(),Gw()];l.current&&p.push(Q8({element:l.current})),e5(a.current,c.current,{placement:r,strategy:"fixed",middleware:p}).then(m=>{c.current&&Object.assign(c.current.style,{left:`${m.x}px`,top:`${m.y}px`});let g=m.middlewareData.arrow;if(g&&l.current){let _=B_e(u,d,i,m.placement);_.transform=`translate(${g.x||0}px, ${g.y||0}px)`,Object.assign(l.current.style,_)}})},On(()=>{f.current?.()},[t,e,r,n,o]),Hr(()=>{let u=a.current,d=c.current;if(!u||!d)return;d.style.visibility="visible";let h=J8(u,d,()=>f.current?.());return()=>{h()}},[]),I("div",{style:{position:"absolute",left:t,top:e},ref:a,children:I("div",{className:"deck-widget deck-widget-popover",style:{position:"fixed",visibility:"hidden",pointerEvents:"none"},ref:c,children:[Boolean(n)&&I("div",{className:"deck-widget-popover-arrow",style:{position:"absolute"},ref:l}),s]})})};function B_e(t,e,r,o){let n={width:0,height:0,top:"",bottom:"",left:"",right:""};return o.startsWith("bottom")?(n.borderLeft=`${t/2}px solid transparent`,n.borderRight=`${t/2}px solid transparent`,n.borderBottom=`${e}px solid ${r}`,n.borderTop="",n.top=`${-e}px`):o.startsWith("top")?(n.borderLeft=`${t/2}px solid transparent`,n.borderRight=`${t/2}px solid transparent`,n.borderTop=`${e}px solid ${r}`,n.borderBottom="",n.bottom=`${-e}px`):o.startsWith("right")?(n.borderTop=`${t/2}px solid transparent`,n.borderBottom=`${t/2}px solid transparent`,n.borderRight=`${e}px solid ${r}`,n.borderLeft="",n.left=`${-e}px`):o.startsWith("left")&&(n.borderTop=`${t/2}px solid transparent`,n.borderBottom=`${t/2}px solid transparent`,n.borderLeft=`${e}px solid ${r}`,n.borderRight="",n.right=`${-e}px`),n}var xp=({text:t,html:e,element:r,...o})=>{let n=Bt(null);return Hr(()=>(n.current&&r&&n.current.append(r),()=>{r?.remove()}),[r]),I("div",{ref:n,...o,dangerouslySetInnerHTML:e?{__html:e}:void 0,children:t})};var bp=class extends ${constructor(e){super(e),this.className="deck-widget-info",this.placement="fill",this.tooltip=null,this.setProps(this.props)}setProps(e){this.viewId=e.viewId??this.viewId,super.setProps(e)}onAdd({deck:e}){this.deck=e}onRemove(){this.rootElement&&te(null,this.rootElement)}onViewportChange(e){this.viewport=e,this.updateHTML()}onHover(e){this.props.mode==="hover"&&(this.tooltip=this._getTooltip(e),this.updateHTML())}onClick(e){this.props.mode==="click"&&(this.tooltip=this._getTooltip(e),this.updateHTML())}_getTooltip(e){if(!this.props.getTooltip)return null;let r=this.props.getTooltip(e,this)??null;if(r===null)return null;let o=typeof r=="string"?{text:r}:r,n=o.position||e.coordinate;return n?{position:n,text:"",html:"",element:null,className:"",style:{},...o}:null}onRenderHTML(e){if(!this.viewport||this.tooltip===null){te(null,e);return}let r={...this.props.style,...this.tooltip.style},[o,n]=this.viewport.project(this.tooltip.position),i=I(zi,{x:o,y:n,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:I(xp,{className:`deck-widget-popup-content ${this.tooltip.className} ${this.props.className}`,style:r,html:this.tooltip.html,text:this.tooltip.text,element:this.tooltip.element})});te(i,e)}};bp.defaultProps={...$.defaultProps,id:"info",viewId:null,mode:"hover",getTooltip:void 0,placement:"right",offset:10,arrow:10};var Ap=class extends ${constructor(e){super(e),this.className="deck-widget-popup",this.placement="fill",this.setProps(this.props),this.isOpen=this.props.defaultIsOpen}setProps(e){this.viewId=e.viewId??this.viewId,super.setProps(e)}onAdd({deck:e}){this.deck=e}onRemove(){this.rootElement&&te(null,this.rootElement)}onViewportChange(e){this.viewport=e,this.updateHTML()}onClick(){this.props.closeOnClickOutside&&this._setIsOpen(!1)}_setIsOpen(e){this.isOpen!==e&&(this.isOpen=e,this.props.onOpenChange?.(e),this.updateHTML())}onRenderHTML(e){if(!this.viewport){te(null,e);return}let{marker:r,content:o,style:n}=this.props,[i,s]=this.viewport.project(this.props.position),a=I("div",{children:[r&&I("div",{className:"deck-widget-popup-marker",style:{left:i,top:s},children:I(xp,{...r,onClick:()=>this._setIsOpen(!0)})}),this.isOpen&&I(zi,{x:i,y:s,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:I("div",{className:`deck-widget-popup-content ${this.props.className}`,style:n,children:[this.props.closeButton&&I("div",{className:"deck-widget-popup-controls",style:{width:"100%",display:"flex",justifyContent:"end"},children:I(Me,{className:"deck-widget-popup-close-button",onClick:()=>this._setIsOpen(!1)})}),I(xp,{...typeof o=="string"?{text:o}:o})]})})]});te(a,e)}};Ap.defaultProps={...$.defaultProps,id:"info",viewId:null,position:[0,0],marker:null,defaultIsOpen:!0,content:"",placement:"right",offset:10,arrow:10,closeButton:!0,closeOnClickOutside:!1,onOpenChange:()=>{}};var Tp=class extends ${constructor(e){super(e),this.className="deck-widget-context-menu",this.placement="fill",this.menu=null,this.setProps(this.props)}onAdd({deck:e}){e.getCanvas()?.addEventListener("contextmenu",r=>this.handleContextMenu(r))}handleContextMenu(e){let r=e.target.getBoundingClientRect(),o=e.clientX-r.x,n=e.clientY-r.y,i=this.deck?.pickObject({x:o,y:n})||{x:o,y:n,picked:!1,layer:null,color:null,index:-1,pixelRatio:1},s=this.props.getMenuItems?.(i,this)||this.props.menuItems;this.menu=s.length>0?{items:s,pickInfo:i}:null,e.preventDefault(),this.updateHTML()}onRenderHTML(e){if(!this.menu){te(null,e);return}let{items:r,pickInfo:o}=this.menu,n={pointerEvents:"auto",position:"static",...this.props.style},i=I(zi,{x:o.x,y:o.y,placement:this.props.placement,arrow:this.props.arrow,arrowColor:"var(--menu-background, #fff)",offset:this.props.offset,children:I(sa,{menuItems:r,onSelect:s=>this.props.onMenuItemSelected(s,o),style:n,isOpen:!0,onClose:()=>this.hide()})});te(i,e)}hide(){this.menu=null,this.updateHTML()}};Tp.defaultProps={...$.defaultProps,id:"context",viewId:null,menuItems:[],getMenuItems:void 0,onMenuItemSelected:()=>{},placement:"bottom-start",offset:10,arrow:!1};var t5={passive:!1},vp=(t,e,r)=>t<e?e:t>r?r:t,pb=(t,e)=>{if(!t||!t.firstElementChild)return[0,0];let r=t.firstElementChild.getBoundingClientRect();return e?[r.top,r.height]:e?[r.top,r.height]:[r.left,r.width]},Sp=(t,e)=>typeof t=="number"&&!Number.isNaN(t)&&t>0?t:Math.max(1,e/10||1),$w=(t,e)=>typeof t=="number"&&!Number.isNaN(t)&&t>0?t:Math.max(1,e||1);function Vl(t){let{className:e="",min:r,max:o,step:n,value:i,orientation:s,pageSize:a,stepButtons:c=!1,startButtonAriaLabel:l,endButtonAriaLabel:f,eventTarget:u,decorations:d=[],onChange:h}=t,p=s!=="horizontal",m=Bt(null),g=Bt(null),_=Bt(null),x=Bt(null),[y,b]=Ui(0),T=o-r,v=Math.max(0,i[1]-i[0]),w=Math.max(0,T-v),C=vp(i[0],r,r+w),{thumbLength:S,thumbOffset:A}=On(()=>{if(y<=0||T<=0)return{thumbLength:0,thumbOffset:0};if(T<=v)return{thumbLength:1,thumbOffset:0};let U=v/T,re=Math.max(0,1-U),go=w<=0?0:vp((C-r)/w,0,1);return{thumbLength:Math.max(0,Math.min(U,1)),thumbOffset:re*go}},[y,T,v,w,C,r]),M=Fn(U=>{if(!h)return;let re=vp(U,r,r+w);h([re,re+v])},[h,r,w,v]),B=Fn(U=>{U.stopPropagation(),M(C-Sp(n,T))},[M,C,n,T]),O=Fn(U=>{U.stopPropagation(),M(C+Sp(n,T))},[M,C,n,T]),F=Fn(U=>{if(U.button!==0||U.target?.dataset.scrollbarThumb==="true")return;let go=g.current;if(!go)return;U.preventDefault(),U.stopPropagation();let[ha]=pb(go,p),zl=p?U.clientY-ha:U.clientX-ha,pa=Math.max(1,1-S)*y,ma=S/2*y,ga=pa<=0?0:vp((zl-ma)/pa,0,1);M(r+ga*w)},[p,y,S,M,r,w]),X=U=>{U.button!==0||!g.current||(x.current={pointerId:U.pointerId,startCoord:p?U.clientY:U.clientX,startRatio:A,min:r,max:o,maxStart:w},U.currentTarget.setPointerCapture(U.pointerId),U.preventDefault(),U.stopPropagation())},G=Fn(U=>{let re=x.current;if(!re||re.pointerId!==U.pointerId)return;let[go,ha]=pb(g.current,p),pa=(p?U.clientY:U.clientX)-re.startCoord,ma=re.startRatio+pa/ha,ga=vp(ma*(re.max-re.min),0,re.maxStart)+re.min;M(ga),U.preventDefault()},[M,p]),j=Fn(U=>{let re=x.current;re&&re.pointerId===U.pointerId&&(x.current=null,_.current?.releasePointerCapture(U.pointerId),U.preventDefault())},[]),se=Fn(U=>{switch(U.key){case"ArrowUp":case"ArrowLeft":(p&&U.key==="ArrowUp"||!p&&U.key==="ArrowLeft")&&(M(C-Sp(n,T)),U.preventDefault());break;case"ArrowDown":case"ArrowRight":(p&&U.key==="ArrowDown"||!p&&U.key==="ArrowRight")&&(M(C+Sp(n,T)),U.preventDefault());break;case"PageUp":M(C-$w(a,v)),U.preventDefault();break;case"PageDown":M(C+$w(a,v)),U.preventDefault();break;case"Home":M(r),U.preventDefault();break;case"End":M(r+w),U.preventDefault();break;default:break}},[p,M,C,n,T,a,v,r,w]),ne=Fn(U=>{if(U.preventDefault(),U.stopPropagation(),w===0)return;let re=p?U.deltaY:U.deltaX;!p&&re===0&&(re=U.deltaY),U.deltaMode===WheelEvent.DOM_DELTA_LINE?re*=Sp(n,T):U.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(re*=$w(a,v)),re!==0&&M(C+re)},[M,C,w,p,n,T,a,v]);Fw(()=>{b(pb(g.current,p)[1])},[p]),Fw(()=>{let U=g.current;if(!U)return;let re=()=>{b(pb(U,p)[1])};if(re(),typeof ResizeObserver<"u"){let go=new ResizeObserver(re);return go.observe(U),()=>go.disconnect()}if(typeof window<"u")return window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[p]),Hr(()=>{let U=u??m.current;if(U)return U.addEventListener("keydown",se),U.addEventListener("wheel",ne,t5),()=>{U.removeEventListener("keydown",se),U.removeEventListener("wheel",ne,t5)}},[u,se,ne]);let pe=On(()=>!d.length||T<=0?[]:d.map((U,re)=>{let[go,ha]=U.position,zl=(go-r)/T,pa=(ha-r)/T,ma=Math.round(zl*1e3)/10,ga=Math.max(0,Math.round((pa-zl)*1e3)/10),a5=p?{left:"0",width:"100%",top:`${ma}%`,height:`${ga}%`}:{top:"0",height:"100%",left:`${ma}%`,width:`${ga}%`};return I("div",{className:"deck-widget-range__decoration",style:a5,children:U.element},`decoration-${re}`)}),[d,T,r,p]);return I("div",{ref:m,tabIndex:0,role:"scrollbar","aria-valuemin":r,"aria-valuemax":r+w,"aria-valuenow":C,"aria-orientation":s,className:`${e} deck-widget-range deck-widget-range--${s} ${w===0?"deck-widget-range--disabled":""}`,children:[c&&I("button",{type:"button",className:"deck-widget-range__button deck-widget-range__button--start","aria-label":l,disabled:C<=r,onClick:B,children:I("span",{className:"deck-widget-icon"})}),I("div",{className:"deck-widget-range__track",ref:g,onClick:F,children:[I("div",{className:"deck-widget-range__decorations",children:pe}),I("div",{className:"deck-widget-range__thumb","data-scrollbar-thumb":"true",ref:_,style:p?{height:`${S*100}%`,top:`${A*100}%`}:{width:`${S*100}%`,left:`${A*100}%`},onPointerDown:X,onPointerMove:G,onPointerUp:j,onPointerCancel:j})]}),c&&I("button",{type:"button",className:"deck-widget-range__button deck-widget-range__button--end","aria-label":f,disabled:C>=r+w,onClick:O,children:I("span",{className:"deck-widget-icon"})})]})}var r5=(t,e,r)=>t<e?e:t>r?r:t,da=class extends ${constructor(e){let r={...da.defaultProps,...e};super(r),this.className="deck-widget-scrollbar",this.placement="fill",this.contentSize=0,this.viewportSize=0,this.scrollOffset=0,this.handleRangeChange=o=>{this.emitScroll(o[0])},this.viewId=r.viewId??null}onViewportChange(e){this.viewport=e,this.onRenderHTML()}onRenderHTML(){let e=this.rootElement;if(!e)return;e.dataset.placement=this.props.placement;let r=this.viewport;this.updateViewport(r);let o=this.getClampedOffset(),n=this.getWheelEventTarget(this.props.captureWheel?"global":"local"),i=this.getDecorations(r),s=this.isVertical(),a=this.props.startButtonAriaLabel??(s?"Scroll up":"Scroll left"),c=this.props.endButtonAriaLabel??(s?"Scroll down":"Scroll right"),l=I(Vl,{min:0,max:Math.max(0,this.contentSize),step:this.getEffectiveStep(),pageSize:this.getEffectivePage(),value:[o,o+this.viewportSize],orientation:this.props.orientation,stepButtons:!0,startButtonAriaLabel:a,endButtonAriaLabel:c,eventTarget:n,decorations:i,onChange:this.handleRangeChange});te(l,e)}onRemove(){this.rootElement&&te(null,this.rootElement),super.onRemove()}getContentBounds(e){return this.props.contentBounds??this.deck?.getView(e)?.controller?.maxBounds??null}updateViewport(e){if(!e){this.contentSize=0,this.scrollOffset=0,this.viewportSize=0;return}let r=this.getContentBounds(e.id),o=this.isVertical(),n=r?Xw(r,e,o):[0,0];this.contentSize=n[1]-n[0],this.scrollOffset=-n[0],this.viewportSize=o?e.height:e.width}getDecorations(e){let{decorations:r=[]}=this.props;if(!e||r.length===0)return[];let o=this.getContentBounds(e.id);if(!o)return[];let n=this.isVertical(),[i]=Xw(o,e,n);return r.map(s=>{let[a,c]=Xw(s.contentBounds,e,n),l=s.onClick?f=>{s.onClick?.(f)&&(f.stopPropagation(),f.preventDefault())}:void 0;return{position:[a-i,c-i],element:I("div",{style:{pointerEvents:l?"all":"none",width:"100%",height:"100%",backgroundColor:s.color},title:s.title,onClick:l})}})}getWheelEventTarget(e){return e===null?null:e==="local"?this.rootElement:this.deck?.props.parent||this.deck?.getCanvas()?.parentElement||this.rootElement}getMaxScroll(){return Math.max(0,this.contentSize-this.viewportSize)}getClampedOffset(){let e=this.getMaxScroll();return r5(this.scrollOffset,0,e)}isVertical(){return this.props.orientation!=="horizontal"}getEffectiveStep(){return typeof this.props.stepSize=="number"&&!Number.isNaN(this.props.stepSize)?this.props.stepSize:Math.max(1,this.viewportSize/10||1)}getEffectivePage(){return typeof this.props.pageSize=="number"&&!Number.isNaN(this.props.pageSize)?this.props.pageSize:this.viewportSize}emitScroll(e){let r=this.getMaxScroll(),o=r5(Math.round(e),0,r),n=this.viewport;if(n&&o!==this.getClampedOffset()){let i=n.project(n.position);this.isVertical()?i[1]-=o-this.scrollOffset:i[0]-=o-this.scrollOffset;let{target:s}=n.panByPosition(n.position,i);this.deck._onViewStateChange({viewId:n.id,viewState:{...this.getViewState(n.id),target:s},interactionState:{}})}}};da.defaultProps={...$.defaultProps,contentBounds:null,placement:"top-right",viewId:null,orientation:"vertical",stepSize:null,pageSize:null,startButtonAriaLabel:"",endButtonAriaLabel:"",captureWheel:!1,decorations:[]};function Xw(t,e,r){return t.map(([o,n])=>e.project([o,n,0])).reduce((o,[n,i])=>{let s=r?i:n;return o[0]=Math.min(o[0],s),o[1]=Math.max(o[1],s),o},[1/0,-1/0])}var Cp=class extends ${constructor(e){super(e),this.className="",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId,super.setProps(e)}onRenderHTML(e){let{className:r,style:o,icon:n,color:i,label:s,onClick:a}=this.props;te(I(Me,{className:r,style:o,color:i,icon:n,label:s,onClick:a}),e)}};Cp.defaultProps={...$.defaultProps,id:"icon",placement:"top-left",viewId:null,icon:"",label:"",color:"",onClick:void 0};var Ep=class extends ${constructor(e){super(e),this.className="deck-widget-toggle",this.placement="top-left",this._toggle=()=>{this.checked=!this.checked,this.props.onChange?.(this.checked),this.updateHTML()},this.checked=this.props.initialChecked,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId,super.setProps(e)}onRenderHTML(e){let{className:r,style:o,icon:n,label:i,color:s,onIcon:a=n,onLabel:c=i,onColor:l=s}=this.props,f=this.checked;e.dataset.checked=String(f),te(I(Me,{className:r,style:o,icon:f?a:n,label:f?c:i,color:f?l:s,onClick:this._toggle}),e)}};Ep.defaultProps={...$.defaultProps,id:"icon",placement:"top-left",viewId:null,initialChecked:!1,icon:"",onIcon:void 0,label:"",onLabel:void 0,color:"",onColor:void 0,onChange:void 0};var wp=class extends ${constructor(e){super(e),this.className="deck-widget-selector",this.placement="top-left",this.isOpen=!1,this._toggleMenu=()=>{this.isOpen?this.isOpen=!1:this.rootElement&&(this.isOpen={x:this.rootElement.offsetLeft,y:this.rootElement.offsetTop,placement:this.props.placement.includes("right")?"left-start":"right-start"}),this.updateHTML()},this._handleSelectMode=r=>{this.value=r,this.props.onChange(r),this.updateHTML()},this.value=this.props.initialValue,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let r=this.props.options.find(o=>o.value===this.value)??this.props.options[0];te(I("div",{children:[I(Me,{icon:r.icon,label:r.label,onClick:this._toggleMenu}),this.isOpen&&I(zi,{...this.isOpen,children:I(sa,{isOpen:!0,style:{pointerEvents:"auto",position:"static"},menuItems:this.props.options,onSelect:this._handleSelectMode,onClose:this._toggleMenu})})]}),e)}};wp.defaultProps={...$.defaultProps,id:"view-selector",placement:"top-left",viewId:null,initialValue:"",options:[],onChange:()=>{}};var Pp=class extends ${getTime(){return this.props.time??this.currentTime}getPlaying(){return this.props.playing??this._playing}constructor(e={}){super(e),this.id="timeline",this.className="deck-widget-timeline",this.placement="fill",this._playing=!1,this.timerId=null,this.handlePlayPause=()=>{let n=!this.getPlaying();this.props.onPlayingChange?.(n),this.props.playing===void 0&&(n?this.play():this.stop())},this.handleTimeChange=([o])=>{this.props.onTimeChange(o),this.props.time===void 0&&(this.currentTime=o,this.props.timeline?.setTime(o),this.updateHTML())},this.tick=()=>{let{timeRange:[o,n],step:i,loop:s}=this.props;if(i>0){let a=this.getTime(),c=Math.round(a/i)*i+i;c>n&&(a<n?c=n:s?c=o:(c=n,this._playing=!1,this.props.onPlayingChange?.(!1))),this.props.onTimeChange(c),this.props.time===void 0&&(this.currentTime=c,this.props.timeline?.setTime(c)),this.updateHTML()}this._playing?this.timerId=window.setTimeout(this.tick,this.props.playInterval):this.timerId=null},this.currentTime=this.props.initialTime??this.props.timeRange[0];let r=this.props.time??this.currentTime;this.props.timeline?.setTime(r),this.setProps(this.props)}setProps(e){let{playing:r,time:o}=this.props;this.viewId=e.viewId??this.viewId,super.setProps(e),e.time!==void 0&&e.time!==o&&this.props.timeline?.setTime(e.time),e.playing!==void 0&&e.playing!==r&&(e.playing&&!this._playing?this._startTimer():!e.playing&&this._playing&&this._stopTimer())}onAdd(){this._playing=!1,this.timerId=null,this.props.autoPlay&&(this.props.playing!==void 0?this.props.onPlayingChange?.(!0):this.play())}onRemove(){this.stop()}onRenderHTML(e){let{timeRange:r,step:o,formatLabel:n}=this.props,i=this.getPlaying(),s=this.getTime();e.dataset.placement=this.props.placement,te(I("div",{className:"deck-widget-button-group",children:[i?I(Me,{label:"Pause",className:"deck-widget-timeline-pause",onClick:this.handlePlayPause}):I(Me,{label:"Play",className:"deck-widget-timeline-play",onClick:this.handlePlayPause}),I(Vl,{min:r[0],max:r[1],orientation:"horizontal",step:o,value:[s,s],onChange:this.handleTimeChange,decorations:[{position:[s,s+o],element:I("div",{className:"deck-widget-timeline-label deck-widget-timeline-label--current",children:n(s)})}]})]}),e)}play(){this._playing=!0;let{timeRange:[e,r]}=this.props;this.props.time===void 0&&this.getTime()>=r&&(this.currentTime=e,this.props.onTimeChange(e),this.props.timeline?.setTime(e)),this.updateHTML(),this.tick()}stop(){this._stopTimer(),this.updateHTML()}_startTimer(){this._playing=!0,this.tick()}_stopTimer(){this._playing=!1,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null)}};Pp.defaultProps={...$.defaultProps,id:"timeline",placement:"bottom-left",viewId:null,timeline:null,timeRange:[0,100],step:1,initialTime:void 0,time:void 0,onTimeChange:()=>{},autoPlay:!1,loop:!1,playInterval:1e3,playing:void 0,onPlayingChange:()=>{},formatLabel:String};var Mp=class extends ${constructor(e={}){super(e),this.className="deck-widget-screenshot",this.placement="top-left",this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){te(I(Me,{className:"deck-widget-camera",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}handleClick(){if(this.props.onCapture){this.props.onCapture(this);return}let e=this.captureScreenToDataURL(this.props.imageFormat);e&&this.downloadDataURL(e,this.props.filename)}captureScreenToDataURL(e){return this.deck?.getCanvas()?.toDataURL(e)}downloadDataURL(e,r){let o=document.createElement("a");o.href=e,o.download=r,o.click()}};Mp.defaultProps={...$.defaultProps,id:"screenshot",placement:"top-left",viewId:null,label:"Screenshot",filename:"screenshot.png",imageFormat:"image/png",onCapture:void 0};var o5={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"#fff","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"unset","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--button-backdrop-filter":"unset","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--button-text":"rgb(24, 24, 26, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(204, 204, 204)","--menu-gap":"4px","--menu-background":"#fff","--menu-backdrop-filter":"unset","--menu-border":"unset","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--menu-text":"rgb(24, 24, 26, 1)","--menu-item-hover":"rgba(0, 0, 0, 0.08)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"#d8d8e5","--range-thumb-color":"#616166","--range-decoration-active-color":"#f8dd50"},n5={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(18, 18, 20, 1)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"unset","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--button-backdrop-filter":"unset","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--button-text":"rgb(215, 214, 229, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(200, 199, 209)","--menu-gap":"4px","--menu-background":"rgba(18, 18, 20, 1)","--menu-backdrop-filter":"unset","--menu-border":"unset","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--menu-text":"rgb(215, 214, 229, 1)","--menu-item-hover":"rgba(255, 255, 255, 0.1)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"#2c2c30","--range-thumb-color":"#9e9da8","--range-decoration-active-color":"#dd7d2c"},mb={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(255, 255, 255, 0.6)","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"1px solid rgba(255, 255, 255, 0.6)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--button-text":"rgb(24, 24, 26, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(204, 204, 204)","--menu-gap":"4px","--menu-background":"rgba(255, 255, 255, 0.6)","--menu-backdrop-filter":"blur(4px)","--menu-border":"1px solid rgba(255, 255, 255, 0.6)","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--menu-text":"rgb(24, 24, 26, 1)","--menu-item-hover":"rgba(0, 0, 0, 0.08)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"rgba(215, 214, 229, 0.3)","--range-thumb-color":"rgba(97, 97, 102, 1)","--range-decoration-active-color":"rgba(255, 215, 0, 0.6)"},gb={"--widget-margin":"12px","--button-size":"28px","--button-corner-radius":"8px","--button-background":"rgba(18, 18, 20, 0.75)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"1px solid rgba(18, 18, 20, 0.75)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--button-text":"rgb(215, 214, 229, 1)","--icon-compass-north-color":"rgb(240, 92, 68)","--icon-compass-south-color":"rgb(200, 199, 209)","--menu-gap":"4px","--menu-background":"rgba(18, 18, 20, 0.75)","--menu-backdrop-filter":"blur(4px)","--menu-border":"1px solid rgba(18, 18, 20, 0.75)","--menu-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--menu-text":"rgb(215, 214, 229, 1)","--menu-item-hover":"rgba(255, 255, 255, 0.1)","--range-step-button-size":"24px","--range-track-size":"16px","--range-thumb-size":"10px","--range-track-color":"rgba(24, 24, 26, 0.3)","--range-thumb-color":"rgba(158, 157, 168, 1)","--range-decoration-active-color":"rgba(255, 145, 0, 0.6)"};var Rp=class extends ${constructor(e={}){super(e),this.className="deck-widget-theme",this.placement="top-left",this.themeMode="dark",this.appliedTheme={},this.themeMode=this._getInitialThemeMode(),this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){let{lightModeLabel:r,darkModeLabel:o}=this.props,n=this.getThemeMode();this._applyTheme(n,e),te(I(Me,{onClick:this._handleClick.bind(this),label:n==="dark"?o:r,className:n==="dark"?"deck-widget-moon":"deck-widget-sun"}),e)}getThemeMode(){return this.props.themeMode??this.themeMode}_handleClick(){let r=this.getThemeMode()==="dark"?"light":"dark";this.props.onThemeModeChange?.(r),this.props.themeMode===void 0&&(this.themeMode=r,this.updateHTML())}_applyTheme(e,r){let o=e==="dark"?this.props.darkModeTheme:this.props.lightModeTheme;if(ie(o,this.appliedTheme,1))return;let n=r.closest(".deck-widget-container");if(!n)return;xs(n,o),this.appliedTheme=o;let i=e==="dark"?this.props.darkModeLabel:this.props.lightModeLabel;N.log(1,`Switched theme to ${i}`,o)()}_getInitialThemeMode(){let{initialThemeMode:e}=this.props;return e!=="auto"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}};Rp.defaultProps={...$.defaultProps,id:"theme",placement:"top-left",viewId:null,lightModeLabel:"Light Mode",lightModeTheme:mb,darkModeLabel:"Dark Mode",darkModeTheme:gb,initialThemeMode:"auto",themeMode:void 0,onThemeModeChange:()=>{}};var Ip=class extends ${constructor(e={}){super(e),this.className="deck-widget-loading",this.placement="top-left",this.loading=!0,this.setProps(this.props)}setProps(e){this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,super.setProps(e)}onRenderHTML(e){te(this.loading&&I(Me,{className:"deck-widget-spinner",label:this.props.label,onClick:this.handleClick.bind(this)}),e)}onRedraw({layers:e}){let r=e.some(o=>!o.isLoaded);r!==this.loading&&(this.loading=r,this.props.onLoadingChange?.(r),this.updateHTML())}handleClick(){}};Ip.defaultProps={...$.defaultProps,id:"loading",placement:"top-left",viewId:null,label:"Loading layer data",onLoadingChange:()=>{}};q();var Yw=t=>`${t.name}: ${t.count}`;function Kw(t){return t<1e3?`${t.toFixed(2)}ms`:`${(t/1e3).toFixed(2)}s`}function s5(t){return`${(t/1e6).toFixed(1)} MB`}var i5={count:Yw,averageTime:t=>`${t.name}: ${Kw(t.getAverageTime())}`,totalTime:t=>`${t.name}: ${Kw(t.time)}`,fps:t=>`${t.name}: ${Math.round(t.getHz())}fps`,memory:t=>`${t.name}: ${s5(t.count)}`},Lp=class extends ${getExpanded(){return this.props.expanded??this._expanded}constructor(e={}){super(e),this.className="deck-widget-stats",this.placement="top-left",this._counter=0,this._expanded=!1,this._toggleExpanded=()=>{let r=!this.getExpanded();this.props.onExpandedChange?.(r),this.props.expanded===void 0&&(this._expanded=r,this.updateHTML())},this._getFps=()=>Math.round(this.deck?.metrics.fps??0),this._formatters={...i5},this._resetOnUpdate={...this.props.resetOnUpdate},this._expanded=Boolean(e.initialExpanded),this.setProps(e)}setProps(e){if(this.placement=e.placement??this.placement,this.viewId=e.viewId??this.viewId,e.formatters)for(let r in e.formatters){let o=e.formatters[r];this._formatters[r]=typeof o=="string"?i5[o]||Yw:o}e.resetOnUpdate&&(this._resetOnUpdate={...e.resetOnUpdate}),super.setProps(e)}onRemove(){this.rootElement&&te(null,this.rootElement)}onRenderHTML(e){if(!this.getExpanded()){te(I(O_e,{getFps:this._getFps,onClick:this._toggleExpanded}),e);return}let o=this._getStats(),n=this.props.title||("id"in o?o.id:null)||"Stats",i=this._getDeviceLabel(),s=[];o&&o.forEach(a=>{let c=this._getLines(a).split(`
`);this._resetOnUpdate&&this._resetOnUpdate[a.name]&&a.reset(),c.forEach((l,f)=>{s.push(I("div",{style:{whiteSpace:"pre"},children:l},`${a.name}-${f}`))})}),te(I("div",{className:"deck-widget-stats-container",style:{cursor:"default"},children:[I("div",{className:"deck-widget-stats-header",style:{cursor:"pointer",pointerEvents:"auto"},onClick:this._toggleExpanded,children:[I("b",{children:n}),i&&I("span",{className:"deck-widget-stats-device",children:i}),I("button",{className:"deck-widget-dropdown-button",children:I("span",{className:"deck-widget-dropdown-icon open"})})]}),I("div",{className:"deck-widget-stats-content",children:s})]}),e)}onRedraw(){if(this.getExpanded()){let e=Math.max(1,this.props.framesPerUpdate||1);this._counter++%e===0&&this.updateHTML()}}_getStats(){switch(this.props.type){case"deck":let e=this.deck?.metrics??{};return Object.entries(e);case"luma":return Array.from(Co.stats.stats.values())[0];case"device":let o=this.deck?.device?.statsManager.stats.values();return o?Array.from(o)[0]:[];case"custom":return this.props.stats;default:throw new Error(`Unknown stats type: ${this.props.type}`)}}_getDeviceLabel(){let e=this.deck?.device?.type;if(!e)return null;switch(e){case"webgpu":return"WebGPU";case"webgl":return"WebGL";default:return String(e)}}_getLines(e){if("count"in e)return(this._formatters[e.name]||this._formatters[e.type||""]||Yw)(e);let[r,o]=e,n=r.endsWith("Memory")?s5(o):r.includes("Time")?Kw(o):`${o.toFixed(2)}`;return`${r}: ${n}`}};Lp.defaultProps={...$.defaultProps,type:"deck",placement:"top-left",viewId:null,initialExpanded:!1,stats:void 0,title:"Stats",framesPerUpdate:1,formatters:{},resetOnUpdate:{},id:"stats",expanded:void 0,onExpandedChange:()=>{}};function O_e({getFps:t,onClick:e}){let[r,o]=Ui(t());return Hr(()=>{let n=()=>{o(t()),i=requestAnimationFrame(n)},i=requestAnimationFrame(n);return()=>{cancelAnimationFrame(i)}},[t]),I(Me,{onClick:e,children:I("div",{className:"text",children:["FPS",I("br",{}),r]})})}var Bp=kn(kd(),1);$c._checkH3Lib=()=>{let t='include the <script src="https://unpkg.com/h3-js@^4.0.0"><\/script> tag before the deck.gl script tag. https://deck.gl/docs/api-reference/geo-layers/h3-hexagon-layer';if(Bp){if(Bp.polyfill&&!Bp.polygonToCells)throw new Error(`Incompatible h3-js version. ${t}`)}else throw new Error(`To use H3 functionality, ${t}`)};return p5(F_e);})();
/*! Bundled license information:
long/dist/long.js:
(**
* @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
* Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/long.js for details
*)
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
long/index.js:
(**
* @license
* Copyright 2009 The Closure Library Authors
* Copyright 2020 Daniel Wirtz / The long.js Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*)
*/
return __exports__;
});