@gis_victory/gismap 2.0.64 → 2.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{R as e,S as t,a as n,g as i,r,b as o,n as s,T as a,c as A,d as l,W as c}from"./webgl-device-Ck4EhfeB.js";import{P as u,i as f,a as h,V as d,b as p,c as g,S as m,m as b,r as y,d as v,e as _,f as C,g as x,h as w,t as B,v as M,j as S,k as T,l as E,n as P,o as I,p as L,q as R,A as F,M as O,s as D,u as N,w as U,x as k,y as G,z,B as V,C as H,D as j,E as Q,F as J,G as K,H as W,I as q,J as Y,K as X,L as Z,N as $,O as ee,R as te,Q as ne,T as ie,U as re,W as oe,X as se,Y as ae,Z as Ae,_ as le,$ as ce,a0 as ue,a1 as fe,a2 as he,a3 as de,a4 as pe,a5 as ge,a6 as me,a7 as be,a8 as ye,a9 as ve,aa as _e,ab as Ce,ac as xe,ad as we,ae as Be,af as Me,ag as Se,ah as Te,ai as Ee,aj as Pe,ak as Ie,al as Le,am as Re,an as Fe,ao as Oe,ap as De,aq as Ne,ar as Ue,as as ke,at as Ge,au as ze,av as Ve,aw as He,ax as je,ay as Qe,az as Je,aA as Ke,aB as We,aC as qe,aD as Ye,aE as Xe,aF as Ze,aG as $e,aH as et,aI as tt,aJ as nt,aK as it,aL as rt,aM as ot,aN as st,aO as at,aP as At}from"./webgl-developer-tools-XiIH8Rtv.js";import{g as lt}from"./index-D-1yhK6a.js";async function ct(e,t,n,i){return i._parse(e,t,n,i)}globalThis.probe={};const ut=new u({id:"@probe.gl/log"});const ft={};function ht(e={}){const t=e.useLocalLibraries??e.core?.useLocalLibraries,n=e.CDN??e.core?.CDN,i=e.modules;return{...void 0!==t?{useLocalLibraries:t}:{},...void 0!==n?{CDN:n}:{},...void 0!==i?{modules:i}:{}}}async function dt(e,t=null,n={},i=null){return t&&(e=function(e,t,n={},i=null){if(n?.core)throw new Error("loadLibrary: options.core must be pre-normalized");if(!n.useLocalLibraries&&e.startsWith("http"))return e;i=i||e;const r=n.modules||{};if(r[i])return r[i];if(!f)return`modules/${t}/dist/libs/${i}`;if(n.CDN)return h(n.CDN.startsWith("http")),`${n.CDN}/${t}@${d}/dist/libs/${i}`;if(p)return`../src/libs/${i}`;return`modules/${t}/src/libs/${i}`}(e,t,n,i)),ft[e]=ft[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(f||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}try{return await t(e)}catch{if(e.includes("/dist/libs/"))return await t(e.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load ArrayBuffer from ${e}`)}}(e);if(!f){const{requireFromFile:t}=globalThis.loaders||{};try{const n=await(t?.(e));return n||!e.includes("/dist/libs/")?n:await(t?.(e.replace("/dist/libs/","/src/libs/")))}catch(n){if(e.includes("/dist/libs/"))try{return await(t?.(e.replace("/dist/libs/","/src/libs/")))}catch{}return null}}if(p)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(f||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}try{return await t(e)}catch{if(e.includes("/dist/libs/"))return await t(e.replace("/dist/libs/","/src/libs/"));throw new Error(`Failed to load text from ${e}`)}}(e);return function(e,t){if(!f){const{requireFromString:n}=globalThis.loaders||{};return n?.(e,t)}if(p)return eval.call(globalThis,e),null;const n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch(i){n.text=e}return document.body.appendChild(n),null}(t,e)}(e),await ft[e]}function pt(e,t,n){if(e.byteLength<=t+n)return"";const i=new DataView(e);let r="";for(let o=0;o<n;o++)r+=String.fromCharCode(i.getUint8(t+o));return r}function gt(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return pt(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return pt(e,0,t);return""}(e)}"`)}}function mt(e,t){return g(e>=0),g(t>0),e+(t-1)&-4}function bt(e,t,n){let i;if(e instanceof ArrayBuffer)i=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;i=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(i,n),n+mt(i.byteLength,4)}const yt={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class vt{props;stats;activeRequestCount=0;requestQueue=[];requestMap=/* @__PURE__ */new Map;updateTimer=null;constructor(e={}){this.props={...yt,...e},this.stats=new m({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}setProps(e){void 0!==e.throttleRequests&&(this.props.throttleRequests=e.throttleRequests),void 0!==e.maxRequests&&(this.props.maxRequests=e.maxRequests),void 0!==e.debounceTime&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,t=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const n={handle:e,priority:0,getPriority:t},i=new Promise(e=>(n.resolve=e,n));return this.requestQueue.push(n),this.requestMap.set(e,i),this._issueNewRequests(),i}_issueRequest(e){const{handle:t,resolve:n}=e;let i=!1;const r=()=>{i||(i=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:r}):Promise.resolve({done:r})}_issueNewRequests(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const n=e[t];this._updateRequest(n)||(e.splice(t,1),this.requestMap.delete(n.handle),t--)}e.sort((e,t)=>e.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}class _t{static defaultOptions={core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}};optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(e,t,n){this.options=n?b({...n,core:_t.defaultOptions},t):{...t},this.data=e,this.url="string"==typeof e?y(e):"",this.loadOptions=function(e){const t={...e};e?.core&&(t.core={...e.core});const n="string"==typeof t.baseUri?t.baseUri:void 0,i="string"==typeof t.baseUrl?t.baseUrl:void 0;void 0===n&&void 0===i||(t.core||={},void 0===t.core.baseUrl&&(t.core.baseUrl=i??n),delete t.baseUri,delete t.baseUrl);return t}(this.options.core?.loadOptions),this.fetch=function(e){const t=e?.core?.fetch;if(t&&"function"==typeof t)return(e,n)=>t(e,n);const n=e?.fetch;if(n&&"function"!=typeof n)return e=>fetch(e,n);return e=>fetch(e)}(this.loadOptions)}setProps(e){this.options=Object.assign(this.options,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){const t=this._needsRefresh;return e&&(this._needsRefresh=!1),t}}class Ct{static type="template";static testURL=e=>!1}function xt(e){return function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}(e)||function(e){return!!Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}(e)}function wt(e,t,n){const i=function(e){switch(e.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"}}(t.value),r=n||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:i}]},nullable:!1,metadata:r}}const Bt={};function Mt(e){if(void 0===Bt[e]){const t=v?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.imageFormatsNode||t,i=globalThis.loaders?.parseImageNode;return Boolean(i)&&n.includes(e)}(e);Bt[e]=t}return Bt[e]}function St(e){const{input:t,inputChannels:n,output:i}={};if(!t)return"#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";if(!n)throw new Error("inputChannels");return`#version 300 es\nin ${function(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${e}`)}}(n)} ${t};\nout vec4 ${i};\nvoid main() {\n ${i} = ${function(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw new Error(`invalid channels: ${t}`)}}(t,n)};\n}`}class Tt extends _{constructor(e=0,t=0){super(2),C(e)&&1===arguments.length?this.copy(e):(x.debug&&(w(e),w(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return x.debug&&(w(e.x),w(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 B(this,this,e),this.check()}transformAsVector(e){return M(this,this,e),this.check()}transformByMatrix3(e){return S(this,this,e),this.check()}transformByMatrix2x3(e){return T(this,this,e),this.check()}transformByMatrix2(e){return E(this,this,e),this.check()}}let Et;class Pt extends _{static get ZERO(){return Et||(Et=new Pt(0,0,0,0),Object.freeze(Et)),Et}constructor(e=0,t=0,n=0,i=0){super(-0,-0,-0,-0),C(e)&&1===arguments.length?this.copy(e):(x.debug&&(w(e),w(t),w(n),w(i)),this[0]=e,this[1]=t,this[2]=n,this[3]=i)}set(e,t,n,i){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,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 x.debug&&(w(e.x),w(e.y),w(e.z),w(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]=w(e)}get w(){return this[3]}set w(e){this[3]=w(e)}transform(e){return P(this,this,e),this.check()}transformByMatrix3(e){return I(this,this,e),this.check()}transformByMatrix2(e){return L(this,this,e),this.check()}transformByQuaternion(e){return R(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function It(e,t,n){const i=t[0],r=t[1],o=t[2],s=t[3],a=t[4],A=t[5],l=t[6],c=t[7],u=t[8],f=n[0],h=n[1],d=n[2],p=n[3],g=n[4],m=n[5],b=n[6],y=n[7],v=n[8];return e[0]=f*i+h*s+d*l,e[1]=f*r+h*a+d*c,e[2]=f*o+h*A+d*u,e[3]=p*i+g*s+m*l,e[4]=p*r+g*a+m*c,e[5]=p*o+g*A+m*u,e[6]=b*i+y*s+v*l,e[7]=b*r+y*a+v*c,e[8]=b*o+y*A+v*u,e}function Lt(e,t,n){const i=n[0],r=n[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=r*t[3],e[4]=r*t[4],e[5]=r*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}var Rt,Ft;(Ft=Rt||(Rt={}))[Ft.COL0ROW0=0]="COL0ROW0",Ft[Ft.COL0ROW1=1]="COL0ROW1",Ft[Ft.COL0ROW2=2]="COL0ROW2",Ft[Ft.COL1ROW0=3]="COL1ROW0",Ft[Ft.COL1ROW1=4]="COL1ROW1",Ft[Ft.COL1ROW2=5]="COL1ROW2",Ft[Ft.COL2ROW0=6]="COL2ROW0",Ft[Ft.COL2ROW1=7]="COL2ROW1",Ft[Ft.COL2ROW2=8]="COL2ROW2";const Ot=Object.freeze([1,0,0,0,1,0,0,0,1]);class Dt extends O{static get IDENTITY(){return function(){Ut||(Ut=new Dt,Object.freeze(Ut));return Ut}()}static get ZERO(){return function(){Nt||(Nt=new Dt([0,0,0,0,0,0,0,0,0]),Object.freeze(Nt));return Nt}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Rt}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):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(Ot)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const n=t[0],i=t[1],r=t[2],o=t[3],s=n+n,a=i+i,A=r+r,l=n*s,c=i*s,u=i*a,f=r*s,h=r*a,d=r*A,p=o*s,g=o*a,m=o*A;e[0]=1-u-d,e[3]=c-m,e[6]=f+g,e[1]=c+m,e[4]=1-l-d,e[7]=h-p,e[2]=f-g,e[5]=h+p,e[8]=1-l-u}(this,e),this.check()}set(e,t,n,i,r,o,s,a,A){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=A,this.check()}setRowMajor(e,t,n,i,r,o,s,a,A){return this[0]=e,this[1]=i,this[2]=s,this[3]=t,this[4]=r,this[5]=a,this[6]=n,this[7]=o,this[8]=A,this.check()}determinant(){return function(e){const t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],s=e[5],a=e[6],A=e[7],l=e[8];return t*(l*o-s*A)+n*(-l*r+s*a)+i*(A*r-o*a)}(this)}transpose(){return function(e,t){if(e===t){const n=t[1],i=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=i,e[7]=r}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]}(this,this),this.check()}invert(){return function(e,t){const n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],a=t[5],A=t[6],l=t[7],c=t[8],u=c*s-a*l,f=-c*o+a*A,h=l*o-s*A;let d=n*u+i*f+r*h;d&&(d=1/d,e[0]=u*d,e[1]=(-c*i+r*l)*d,e[2]=(a*i-r*s)*d,e[3]=f*d,e[4]=(c*n-r*A)*d,e[5]=(-a*n+r*o)*d,e[6]=h*d,e[7]=(-l*n+i*A)*d,e[8]=(s*n-i*o)*d)}(this,this),this.check()}multiplyLeft(e){return It(this,e,this),this.check()}multiplyRight(e){return It(this,this,e),this.check()}rotate(e){return function(e,t,n){const i=t[0],r=t[1],o=t[2],s=t[3],a=t[4],A=t[5],l=t[6],c=t[7],u=t[8],f=Math.sin(n),h=Math.cos(n);e[0]=h*i+f*s,e[1]=h*r+f*a,e[2]=h*o+f*A,e[3]=h*s-f*i,e[4]=h*a-f*r,e[5]=h*A-f*o,e[6]=l,e[7]=c,e[8]=u}(this,this,e),this.check()}scale(e){return Array.isArray(e)?Lt(this,this,e):Lt(this,this,[e,e]),this.check()}translate(e){return function(e,t,n){const i=t[0],r=t[1],o=t[2],s=t[3],a=t[4],A=t[5],l=t[6],c=t[7],u=t[8],f=n[0],h=n[1];e[0]=i,e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=A,e[6]=f*i+h*s+l,e[7]=f*r+h*a+c,e[8]=f*o+h*A+u}(this,this,e),this.check()}transform(e,t){let n;switch(e.length){case 2:n=S(t||[-0,-0],e,this);break;case 3:n=D(t||[-0,-0,-0],e,this);break;case 4:n=I(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return N(n,e.length),n}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let Nt,Ut=null;function kt(){const e=new F(4);return F!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Gt(e,t,n){n*=.5;const i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function zt(e,t,n){const i=t[0],r=t[1],o=t[2],s=t[3],a=n[0],A=n[1],l=n[2],c=n[3];return e[0]=i*c+s*a+r*l-o*A,e[1]=r*c+s*A+o*a-i*l,e[2]=o*c+s*l+i*A-r*a,e[3]=s*c-i*a-r*A-o*l,e}function Vt(e,t,n,i){const r=t[0],o=t[1],s=t[2],a=t[3];let A,l,c,u,f,h=n[0],d=n[1],p=n[2],g=n[3];return A=r*h+o*d+s*p+a*g,A<0&&(A=-A,h=-h,d=-d,p=-p,g=-g),1-A>X?(l=Math.acos(A),f=Math.sin(l),c=Math.sin((1-i)*l)/f,u=Math.sin(i*l)/f):(c=1-i,u=i),e[0]=c*r+u*h,e[1]=c*o+u*d,e[2]=c*s+u*p,e[3]=c*a+u*g,e}function Ht(e,t){const n=t[0]+t[4]+t[8];let i;if(n>0)i=Math.sqrt(n+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);const r=(n+1)%3,o=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*r+r]-t[3*o+o]+1),e[n]=.5*i,i=.5/i,e[3]=(t[3*r+o]-t[3*o+r])*i,e[r]=(t[3*r+n]+t[3*n+r])*i,e[o]=(t[3*o+n]+t[3*n+o])*i}return e}const jt=K,Qt=q,Jt=G,Kt=W,Wt=U,qt=k,Yt=Y,Xt=function(){const e=z(),t=V(1,0,0),n=V(0,1,0);return function(i,r,o){const s=H(r,o);return s<-.999999?(j(e,t,r),Q(e)<1e-6&&j(e,n,r),J(e,e),Gt(i,e,Math.PI),i):s>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(j(e,r,o),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+s,Yt(i,i))}}();!function(){const e=kt(),t=kt()}(),function(){const e=function(){const e=new F(9);return F!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}()}();const Zt=[0,0,0,1];class $t extends Z{constructor(e=0,t=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,n,i)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,n,i){return this[0]=e,this[1]=t,this[2]=n,this[3]=i,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 Ht(this,e),this.check()}fromAxisRotation(e,t){return Gt(this,e,t),this.check()}identity(){var e;return(e=this)[0]=0,e[1]=0,e[2]=0,e[3]=1,this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=w(e)}get y(){return this[1]}set y(e){this[1]=w(e)}get z(){return this[2]}set z(e){this[2]=w(e)}get w(){return this[3]}set w(e){this[3]=w(e)}len(){return Wt(this)}lengthSquared(){return qt(this)}dot(e){return Jt(this,e)}rotationTo(e,t){return Xt(this,e,t),this.check()}add(e){return jt(this,this,e),this.check()}calculateW(){return function(e,t){const n=t[0],i=t[1],r=t[2];e[0]=n,e[1]=i,e[2]=r,e[3]=Math.sqrt(Math.abs(1-n*n-i*i-r*r))}(this,this),this.check()}conjugate(){var e,t;return t=this,(e=this)[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],this.check()}invert(){return function(e,t){const n=t[0],i=t[1],r=t[2],o=t[3],s=n*n+i*i+r*r+o*o,a=s?1/s:0;e[0]=-n*a,e[1]=-i*a,e[2]=-r*a,e[3]=o*a}(this,this),this.check()}lerp(e,t,n){return void 0===n?this.lerp(this,e,t):(Kt(this,e,t,n),this.check())}multiplyRight(e){return zt(this,this,e),this.check()}multiplyLeft(e){return zt(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,n){n*=.5;const i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);e[0]=i*A+s*a,e[1]=r*A+o*a,e[2]=o*A-r*a,e[3]=s*A-i*a}(this,this,e),this.check()}rotateY(e){return function(e,t,n){n*=.5;const i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);e[0]=i*A-o*a,e[1]=r*A+s*a,e[2]=o*A+i*a,e[3]=s*A-r*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,n){n*=.5;const i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);e[0]=i*A+r*a,e[1]=r*A-i*a,e[2]=o*A+s*a,e[3]=s*A-o*a}(this,this,e),this.check()}scale(e){return Qt(this,this,e),this.check()}slerp(e,t,n){let i,r,o;switch(arguments.length){case 1:({start:i=Zt,target:r,ratio:o}=e);break;case 2:i=this,r=e,o=t;break;default:i=e,r=t,o=n}return Vt(this,i,r,o),this.check()}transformVector4(e,t=new Pt){return $(t,e,this),N(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}function en(e,t=[],n=0){const i=Math.fround(e),r=e-i;return t[n]=i,t[n+1]=r,t}function tn(e,t=!0){return e??t}function nn(e=[0,0,0],t=!0){return t?e.map(e=>e/255):[...e]}const rn="\nlayout(std140) uniform fp64arithmeticUniforms {\n uniform float ONE;\n uniform float SPLIT;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThese helpers implement Dekker/Veltkamp-style error tracking. If the compiler\nfolds constants or reassociates the arithmetic, the high/low split can stop\ntracking the rounding error correctly. That failure mode tends to look fine in\nsimple coordinate setup, but then breaks down inside iterative arithmetic such\nas fp64 Mandelbrot loops.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\nfloat prevent_fp64_optimization(float value) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n return value + fp64.ONE * 0.0;\n#else\n return value;\n#endif\n}\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker\n // split into a constant expression and reassociate the recovery steps.\n float split = prevent_fp64_optimization(fp64.SPLIT);\n float t = prevent_fp64_optimization(a * split);\n float temp = t - a;\n float a_hi = t - temp;\n float a_lo = a - a_hi;\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend\n // on the split terms and cross terms staying in the original evaluation\n // order. If the compiler folds or reassociates them, the low part tends to\n // collapse to zero or NaN on some drivers.\n float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);\n float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);\n float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);\n float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err1 = (highProduct - prod) * fp64.ONE;\n float err2 = crossProduct1 * fp64.ONE * fp64.ONE;\n float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;\n float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err1 = highProduct - prod;\n float err2 = crossProduct1;\n float err3 = crossProduct2;\n float err4 = lowProduct;\n#endif\n float err = ((err1 + err2) + err3) + err4;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",on={name:"fp64arithmetic",source:"struct Fp64ArithmeticUniforms {\n ONE: f32,\n SPLIT: f32,\n};\n\n@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;\n\nfn fp64_nan(seed: f32) -> f32 {\n let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);\n return bitcast<f32>(nanBits);\n}\n\nfn fp64_runtime_zero() -> f32 {\n return fp64arithmetic.ONE * 0.0;\n}\n\nfn prevent_fp64_optimization(value: f32) -> f32 {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n return value + fp64_runtime_zero();\n#else\n return value;\n#endif\n}\n\nfn split(a: f32) -> vec2f {\n let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());\n let t = prevent_fp64_optimization(a * splitValue);\n let temp = prevent_fp64_optimization(t - a);\n let aHi = prevent_fp64_optimization(t - temp);\n let aLo = prevent_fp64_optimization(a - aHi);\n return vec2f(aHi, aLo);\n}\n\nfn split2(a: vec2f) -> vec2f {\n var b = split(a.x);\n b.y = b.y + a.y;\n return b;\n}\n\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);\n let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);\n#else\n let sum = prevent_fp64_optimization(a + b);\n let err = prevent_fp64_optimization(b - (sum - a));\n#endif\n return vec2f(sum, err);\n}\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a + b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) +\n prevent_fp64_optimization(b - v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a - b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) -\n prevent_fp64_optimization(b + v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSqr(a: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * a);\n let aFp64 = split(a);\n let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);\n let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);\n let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err =\n (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +\n crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +\n lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n#else\n let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);\n#endif\n return vec2f(prod, err);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * b);\n let aFp64 = split(a);\n let bFp64 = split(b);\n let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);\n let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);\n let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);\n let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err1 = (highProduct - prod) * fp64arithmetic.ONE;\n let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err4 =\n lowProduct *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE;\n#else\n let err1 = highProduct - prod;\n let err2 = crossProduct1;\n let err3 = crossProduct2;\n let err4 = lowProduct;\n#endif\n let err12InputA = prevent_fp64_optimization(err1);\n let err12InputB = prevent_fp64_optimization(err2);\n let err12 = prevent_fp64_optimization(err12InputA + err12InputB);\n let err123InputA = prevent_fp64_optimization(err12);\n let err123InputB = prevent_fp64_optimization(err3);\n let err123 = prevent_fp64_optimization(err123InputA + err123InputB);\n let err1234InputA = prevent_fp64_optimization(err123);\n let err1234InputB = prevent_fp64_optimization(err4);\n let err = prevent_fp64_optimization(err1234InputA + err1234InputB);\n return vec2f(prod, err);\n}\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSum(a.x, b.x);\n let t = twoSum(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSub(a.x, b.x);\n let t = twoSub(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n var prod = twoProd(a.x, b.x);\n let crossProduct1 = prevent_fp64_optimization(a.x * b.y);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct1);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n let crossProduct2 = prevent_fp64_optimization(a.y * b.x);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct2);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let xn = prevent_fp64_optimization(1.0 / b.x);\n let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));\n let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);\n let prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2f(0.0, 0.0);\n }\n if (a.x < 0.0) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n let x = prevent_fp64_optimization(1.0 / sqrt(a.x));\n let yn = prevent_fp64_optimization(a.x * x);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;\n#else\n let ynSqr = twoSqr(yn);\n#endif\n let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);\n let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2f(yn, 0.0), prod);\n#endif\n}\n",fs:rn,vs:rn,defaultUniforms:{ONE:1,SPLIT:4097},uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:en,fp64LowPart:function(e){return e-Math.fround(e)},fp64ifyMatrix4:function(e){const t=new Float32Array(32);for(let n=0;n<4;++n)for(let i=0;i<4;++i){const r=4*n+i;en(e[4*i+n],t,2*r)}return t}},sn="layout(std140) uniform floatColorsUniforms {\n float useByteColors;\n} floatColors;\n\nvec3 floatColors_normalize(vec3 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_normalize(vec4 inputColor) {\n return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor;\n}\n\nvec4 floatColors_premultiplyAlpha(vec4 inputColor) {\n return vec4(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nvec4 floatColors_unpremultiplyAlpha(vec4 inputColor) {\n return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0);\n}\n\nvec4 floatColors_premultiply_alpha(vec4 inputColor) {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nvec4 floatColors_unpremultiply_alpha(vec4 inputColor) {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",an={name:"floatColors",props:{},uniforms:{},vs:sn,fs:sn,source:"struct floatColorsUniforms {\n useByteColors: f32\n};\n\n@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms;\n\nfn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> {\n return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5);\n}\n\nfn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a);\n}\n\nfn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> {\n return select(\n vec4<f32>(0.0),\n vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a),\n inputColor.a > 0.0\n );\n}\n\nfn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_premultiplyAlpha(inputColor);\n}\n\nfn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {\n return floatColors_unpremultiplyAlpha(inputColor);\n}\n",uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}},An={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:[0,1,1,1]},vs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useByteColors > 0.5 ? color / 255.0 : color;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n",fs:"layout(std140) uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useByteColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n",getUniforms:function(e={},t){const n={},i=tn(e.useByteColors,!0);if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)n.isHighlightActive=!1;else{n.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);n.highlightedObjectColor=t}e.highlightColor&&(n.highlightColor=function(e,t=!0){const n=nn(e.slice(0,3),t),i=Number.isFinite(e[3]),r=i?e[3]:1;return[n[0],n[1],n[2],t&&i?r/255:r]}(e.highlightColor,i));void 0!==e.isActive&&(n.isActive=Boolean(e.isActive),n.isAttribute=Boolean(e.isAttribute));void 0!==e.useByteColors&&(n.useByteColors=Boolean(e.useByteColors));return n}};const ln={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:"\nstruct skinUniforms {\n jointMatrix: array<mat4x4<f32>, 20>,\n};\n\n@group(0) @binding(auto) var<uniform> skin: skinUniforms;\n\nfn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {\n return (weights.x * skin.jointMatrix[joints.x])\n + (weights.y * skin.jointMatrix[joints.y])\n + (weights.z * skin.jointMatrix[joints.z])\n + (weights.w * skin.jointMatrix[joints.w]);\n}\n",vs:"\nlayout(std140) uniform skinUniforms {\n mat4 jointMatrix[SKIN_MAX_JOINTS];\n} skin;\n\nmat4 getSkinMatrix(vec4 weights, uvec4 joints) {\n return (weights.x * skin.jointMatrix[joints.x])\n + (weights.y * skin.jointMatrix[joints.y])\n + (weights.z * skin.jointMatrix[joints.z])\n + (weights.w * skin.jointMatrix[joints.w]);\n}\n\n",fs:"",defines:{SKIN_MAX_JOINTS:20},getUniforms:(e={},t)=>{const{scenegraphsFromGLTF:n}=e;if(!n?.gltf?.skins?.[0])return{jointMatrix:[]};const{inverseBindMatrices:i,joints:r,skeleton:o}=n.gltf.skins[0],s=[],a=i.value.length/16;for(let u=0;u<a;u++){const e=i.value.subarray(16*u,16*u+16);s.push(new ee(Array.from(e)))}const A=n.gltfNodeIndexToNodeMap.get(o),l={};A.preorderTraversal((e,{worldMatrix:t})=>{l[e.id]=t});const c=new Float32Array(320);for(let u=0;u<20;++u){const e=r[u];if(void 0===e)break;const t=l[n.gltfNodeIndexToNodeMap.get(e).id],i=s[u],o=(new ee).copy(t).multiplyRight(i),a=16*u;for(let n=0;n<16;n++)c[a+n]=o[n]}return{jointMatrix:c}},uniformTypes:{jointMatrix:["mat4x4<f32>",20]}};class cn extends te{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,cn.defaultProps),this.shaderLayout=t.shaderLayout}static defaultProps={...te.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0}}class un{static defaultProps={...e.defaultProps};static getDefaultPipelineFactory(e){const t=e.getModuleData("@luma.gl/core");return t.defaultPipelineFactory||=new un(e),t.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(t){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(t);const n={...e.defaultProps,...t},i=this._renderPipelineCache,r=this._hashRenderPipeline(n);let o=i[r]?.resource;if(o)i[r].useCount++,this.device.props.debugFactories&&ie.log(3,`${this}: ${i[r].resource} reused, count=${i[r].useCount}, (id=${t.id})`)();else{const e="webgl"===this.device.type&&this.device.props._sharePipelines?this.createSharedRenderPipeline(n):void 0;o=this.device.createRenderPipeline({...n,id:n.id?`${n.id}-cached`:ne("unnamed-cached"),_sharedRenderPipeline:e}),o.hash=r,i[r]={resource:o,useCount:1},this.device.props.debugFactories&&ie.log(3,`${this}: ${o} created, count=${i[r].useCount}`)()}return o}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);const t={...cn.defaultProps,...e},n=this._computePipelineCache,i=this._hashComputePipeline(t);let r=n[i]?.resource;return r?(n[i].useCount++,this.device.props.debugFactories&&ie.log(3,`${this}: ${n[i].resource} reused, count=${n[i].useCount}, (id=${e.id})`)()):(r=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),r.hash=i,n[i]={resource:r,useCount:1},this.device.props.debugFactories&&ie.log(3,`${this}: ${r} created, count=${n[i].useCount}`)()),r}release(e){if(!this.device.props._cachePipelines)return void e.destroy();const t=this._getCache(e),n=e.hash;t[n].useCount--,0===t[n].useCount?(this._destroyPipeline(e),this.device.props.debugFactories&&ie.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(ie.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.device.props.debugFactories&&ie.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}createSharedRenderPipeline(e){const t=this._hashSharedRenderPipeline(e);let n=this._sharedRenderPipelineCache[t];if(!n){n={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[t]=n}return n.useCount++,n.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;const t=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[t];n&&(n.useCount--,0===n.useCount&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[t]))}_destroyPipeline(t){const n=this._getCache(t);return!!this.device.props._destroyPipelines&&(delete n[t.hash],t.destroy(),t instanceof e&&this.releaseSharedRenderPipeline(t),!0)}_getCache(t){let n;if(t instanceof cn&&(n=this._computePipelineCache),t instanceof e&&(n=this._renderPipelineCache),!n)throw new Error(`${this}`);if(!n[t.hash])throw new Error(`${this}: ${t} matched incorrect entry`);return n}_hashComputePipeline(e){const{type:t}=this.device;return`${t}/C/${this._getHash(e.shader.source)}SL${this._getHash(JSON.stringify(e.shaderLayout))}`}_hashRenderPipeline(e){const t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,i=this._getWebGLVaryingHash(e),r=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e.bufferLayout)),{type:s}=this.device;if("webgl"===s){const a=this._getHash(JSON.stringify(e.parameters));return`${s}/R/${t}/${n}V${i}T${e.topology}P${a}SL${r}BL${o}`}{const a=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),A=this._getHash(JSON.stringify(e.parameters)),l=this._getWebGPUAttachmentHash(e);return`${s}/R/${t}/${n}V${i}T${e.topology}EP${a}P${A}SL${r}BL${o}A${l}`}}_hashSharedRenderPipeline(e){return`webgl/S/${e.vs?this._getHash(e.vs.source):0}/${e.fs?this._getHash(e.fs.source):0}V${this._getWebGLVaryingHash(e)}`}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){const{varyings:t=[],bufferMode:n=null}=e;return this._getHash(JSON.stringify({varyings:t,bufferMode:n}))}_getWebGPUAttachmentHash(e){const t=e.colorAttachmentFormats??[this.device.preferredColorFormat],n=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:t,depthStencilAttachmentFormat:n}))}}class fn{static defaultProps={...t.defaultProps};static getDefaultShaderFactory(e){const t=e.getModuleData("@luma.gl/core");return t.defaultShaderFactory||=new fn(e),t.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);const t=this._hashShader(e);let n=this._cache[t];if(n)n.useCount++,this.device.props.debugFactories&&ie.log(3,`${this}: Reusing shader ${n.resource.id} count=${n.useCount}`)();else{const i=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={resource:i,useCount:1},this.device.props.debugFactories&&ie.log(3,`${this}: Created new shader ${i.id}`)()}return n.resource}release(e){if(!this.device.props._cacheShaders)return void e.destroy();const t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,0===n.useCount)this.device.props._destroyShaders&&(delete this._cache[t],n.resource.destroy(),this.device.props.debugFactories&&ie.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&ie.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}}function hn(e,t={}){const i={...e},r=t.layout??"std140",o={};let s=0;for(const[n,a]of Object.entries(i))s=gn(o,n,a,s,r);return s=n(s,bn(i,r)),{layout:r,byteLength:4*s,uniformTypes:i,fields:o}}function dn(e,t){const o=r(e),s=i(o),a=/^mat(\d)x(\d)<.+>$/.exec(o);if(a){const e=Number(a[1]),i=Number(a[2]),r=yn(i,o,s.type),A=function(e,t,i){return"std140"===i?4:n(e,t)}(r.size,r.alignment,t);return{alignment:r.alignment,size:e*A,components:e*i,columns:e,rows:i,columnStride:A,shaderType:o,type:s.type}}const A=/^vec(\d)<.+>$/.exec(o);return A?yn(Number(A[1]),o,s.type):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:o,type:s.type}}function pn(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function gn(e,t,i,r,o){if("string"==typeof i){const s=dn(i,o),a=n(r,s.alignment);return e[t]={offset:a,...s},a+s.size}if(Array.isArray(i)){if(Array.isArray(i[0]))throw new Error(`Nested arrays are not supported for ${t}`);const s=i[0],a=i[1],A=vn(s,o),l=n(r,bn(i,o));for(let n=0;n<a;n++)gn(e,`${t}[${n}]`,s,l+n*A,o);return l+A*a}if(pn(i)){const s=bn(i,o);let a=n(r,s);for(const[n,r]of Object.entries(i))a=gn(e,`${t}.${n}`,r,a,o);return n(a,s)}throw new Error(`Unsupported CompositeShaderType for ${t}`)}function mn(e,t){if("string"==typeof e)return dn(e,t).size;if(Array.isArray(e)){const n=e[0],i=e[1];if(Array.isArray(n))throw new Error("Nested arrays are not supported");return vn(n,t)*i}let i=0;for(const r of Object.values(e)){const e=r;i=n(i,bn(e,t)),i+=mn(e,t)}return n(i,bn(e,t))}function bn(e,t){if("string"==typeof e)return dn(e,t).alignment;if(Array.isArray(e)){const n=bn(e[0],t);return _n(t)?Math.max(n,4):n}let n=1;for(const i of Object.values(e)){const e=bn(i,t);n=Math.max(n,e)}return function(e){return"std140"===e||"wgsl-uniform"===e}(t)?Math.max(n,4):n}function yn(e,t,n,i){return{alignment:2===e?2:4,size:3===e?3:e,components:e,columns:1,rows:e,columnStride:3===e?3:e,shaderType:t,type:n}}function vn(e,t){return function(e,t,i){return n(e,_n(i)?4:t)}(mn(e,t),bn(e,t),t)}function _n(e){return"std140"===e||"wgsl-uniform"===e}function Cn(e){return Array.isArray(e)?0===e.length||"number"==typeof e[0]:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}(e)}class xn{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){const t=this.layout.fields[e];return t?{offset:t.offset,size:t.size}:void 0}getFlatUniformValues(e){const t={};for(const[n,i]of Object.entries(e)){const e=this.layout.uniformTypes[n];e?this._flattenCompositeValue(t,n,e,i):this.layout.fields[n]&&(t[n]=i)}return t}getData(e){const t=o(this.layout.byteLength);new Uint8Array(t,0,this.layout.byteLength).fill(0);const n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)},i=this.getFlatUniformValues(e);for(const[r,o]of Object.entries(i))this._writeLeafValue(n,r,o);return new Uint8Array(t,0,this.layout.byteLength)}_flattenCompositeValue(e,t,n,i){if(void 0!==i)if("string"==typeof n||this.layout.fields[t])e[t]=i;else{if(Array.isArray(n)){const r=n[0],o=n[1];if(Array.isArray(r))throw new Error(`Nested arrays are not supported for ${t}`);if("string"==typeof r&&Cn(i))return void this._flattenPackedArray(e,t,r,o,i);if(!Array.isArray(i))return void ie.warn(`Unsupported uniform array value for ${t}:`,i)();for(let n=0;n<Math.min(i.length,o);n++){const o=i[n];void 0!==o&&this._flattenCompositeValue(e,`${t}[${n}]`,r,o)}return}if(pn(n)&&function(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}(i))for(const[r,o]of Object.entries(i)){if(void 0===o)continue;const i=`${t}.${r}`;this._flattenCompositeValue(e,i,n[r],o)}else ie.warn(`Unsupported uniform value for ${t}:`,i)()}}_flattenPackedArray(e,t,n,i,r){const o=r,s=dn(n,this.layout.layout).components;for(let a=0;a<i;a++){const n=a*s;if(n>=o.length)break;e[`${t}[${a}]`]=1===s?Number(o[n]):wn(r,n,n+s)}}_writeLeafValue(e,t,n){const i=this.layout.fields[t];if(!i)return void ie.warn(`Uniform ${t} not found in layout`)();const{type:r,components:o,columns:s,rows:a,offset:A,columnStride:l}=i,c=e[r];if(1===o)return void(c[A]=Number(n));const u=n;if(1===s){for(let e=0;e<o;e++)c[A+e]=Number(u[e]??0);return}let f=0;for(let h=0;h<s;h++){const e=A+h*l;for(let t=0;t<a;t++)c[e+t]=Number(u[f++]??0)}}}function wn(e,t,n){return Array.prototype.slice.call(e,t,n)}class Bn{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){const t=e?.shaderLayout.bindings?.find(t=>"uniform"===t.type&&t.name===e?.name);if(!t)throw new Error(e?.name);const n=t;for(const e of n.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){var n;(function(e,t,n=16){if(e===t)return!0;const i=e,r=t;if(!Cn(i)||!Cn(r))return!1;if(i.length!==r.length)return!1;const o=Math.min(n,128);if(i.length>o)return!1;for(let s=0;s<i.length;++s)if(r[s]!==i[s])return!1;return!0})(this.uniforms[e],t)||(this.uniforms[e]=Cn(n=t)?n.slice():n,this.modifiedUniforms[e]=!0,this.modified=!0)}}class Mn{device;uniformBlocks=/* @__PURE__ */new Map;shaderBlockLayouts=/* @__PURE__ */new Map;shaderBlockWriters=/* @__PURE__ */new Map;uniformBuffers=/* @__PURE__ */new Map;constructor(e,t){this.device=e;for(const[n,i]of Object.entries(t)){const t=n,r=hn(i.uniformTypes??{},{layout:i.layout??Sn(e)}),o=new xn(r);this.shaderBlockLayouts.set(t,r),this.shaderBlockWriters.set(t,o);const s=new Bn({name:n});s.setUniforms(o.getFlatUniformValues(i.defaultUniforms||{})),this.uniformBlocks.set(t,s)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(const[t,n]of Object.entries(e)){const e=t,i=this.shaderBlockWriters.get(e),r=i?.getFlatUniformValues(n||{});this.uniformBlocks.get(e)?.setUniforms(r||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){const t=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(t,1024)}getUniformBufferData(e){const t=this.uniformBlocks.get(e)?.getAllUniforms()||{},n=this.shaderBlockWriters.get(e);return n?.getData(t)||new Uint8Array(0)}createUniformBuffer(e,t){t&&this.setUniforms(t);const n=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:re.UNIFORM|re.COPY_DST,byteLength:n}),r=this.getUniformBufferData(e);return i.write(r),i}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){const t=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:re.UNIFORM|re.COPY_DST,byteLength:t});this.uniformBuffers.set(e,n)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||=n}return e&&ie.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){const t=this.uniformBlocks.get(e);let n=this.uniformBuffers.get(e),i=!1;if(n&&t?.needsRedraw){i||=t.needsRedraw;const r=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(r);const o=this.uniformBlocks.get(e)?.getAllUniforms();ie.log(4,`Writing to uniform buffer ${String(e)}`,r,o)()}return i}}function Sn(e){return"webgpu"===e.type?"wgsl-uniform":"std140"}const Tn="precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n",En={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[{color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},5]},defaultUniforms:Rn(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:"// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nconst MAX_LIGHTS: i32 = 5;\n\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct UniformLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n directionalLightCount: i32,\n pointLightCount: i32,\n spotLightCount: i32,\n ambientColor: vec3<f32>,\n lights: array<UniformLight, 5>,\n};\n\n@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n let light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nfn lighting_getSpotLight(index: i32) -> SpotLight {\n let light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {\n let lightDirection = normalize(positionWorldspace - spotLight.position);\n let coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), lightDirection)\n );\n let distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n",vs:Tn,fs:Tn,getUniforms:function(e,t={}){if(!(e=e?{...e}:e))return Rn();e.lights&&(e={...e,...In(e.lights),lights:void 0});const{useByteColors:n,ambientLight:i,pointLights:r,spotLights:o,directionalLights:s}=e||{};if(!(i||r&&r.length>0||o&&o.length>0||s&&s.length>0))return{...Rn(),enabled:0};const a={...Rn(),...Pn({useByteColors:n,ambientLight:i,pointLights:r,spotLights:o,directionalLights:s})};void 0!==e.enabled&&(a.enabled=e.enabled?1:0);return a}};function Pn({useByteColors:e,ambientLight:t,pointLights:n=[],spotLights:i=[],directionalLights:r=[]}){const o=Fn();let s=0,a=0,A=0,l=0;for(const c of n){if(s>=5)break;o[s]={...o[s],color:Ln(c,e),position:c.position,attenuation:c.attenuation||[1,0,0]},s++,a++}for(const c of i){if(s>=5)break;o[s]={...o[s],color:Ln(c,e),position:c.position,direction:c.direction,attenuation:c.attenuation||[1,0,0],coneCos:On(c)},s++,A++}for(const c of r){if(s>=5)break;o[s]={...o[s],color:Ln(c,e),direction:c.direction},s++,l++}return n.length+i.length+r.length>5&&ie.warn("MAX_LIGHTS exceeded, truncating to 5")(),{ambientColor:Ln(t,e),directionalLightCount:l,pointLightCount:a,spotLightCount:A,lights:o}}function In(e){const t={pointLights:[],spotLights:[],directionalLights:[]};for(const n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":t.directionalLights?.push(n);break;case"point":t.pointLights?.push(n);break;case"spot":t.spotLights?.push(n)}return t}function Ln(e={},t){const{color:n=[0,0,0],intensity:i=1}=e;return nn(n,tn(t,!0)).map(e=>e*i)}function Rn(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Fn()}}function Fn(){return Array.from({length:5},()=>({color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}))}function On(e){const t=e.innerConeAngle??0,n=e.outerConeAngle??Math.PI/4;return[Math.cos(t),Math.cos(n)]}const Dn="#ifdef USE_IBL\nuniform samplerCube pbr_diffuseEnvSampler;\nuniform samplerCube pbr_specularEnvSampler;\nuniform sampler2D pbr_brdfLUT;\n#endif\n",Nn={name:"ibl",firstBindingSlot:32,bindingLayout:[{name:"pbr_diffuseEnvSampler",group:2},{name:"pbr_specularEnvSampler",group:2},{name:"pbr_brdfLUT",group:2}],source:"#ifdef USE_IBL\n@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;\n@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;\n@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;\n@group(2) @binding(auto) var pbr_specularEnvSamplerSampler: sampler;\n@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;\n@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;\n#endif\n",vs:Dn,fs:Dn},Un="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n",kn="layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n",Gn="struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (\n lambertian * phongMaterial.diffuse * surfaceColor +\n specular * floatColors_normalize(phongMaterial.specularColor)\n ) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n",zn={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:kn.replace("phongMaterial","gouraudMaterial"),fs:Un.replace("phongMaterial","gouraudMaterial"),source:Gn.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[En,an],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[38.25,38.25,38.25]},getUniforms:e=>({...zn.defaultUniforms,...e})},Vn={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[En,an],source:Gn,vs:Un,fs:kn,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:[38.25,38.25,38.25]},getUniforms:e=>({...Vn.defaultUniforms,...e})},Hn="layout(std140) uniform pbrProjectionUniforms {\n mat4 modelViewProjectionMatrix;\n mat4 modelMatrix;\n mat4 normalMatrix;\n vec3 camera;\n} pbrProjection;\n",jn={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:[En,Nn,{name:"pbrProjection",bindingLayout:[{name:"pbrProjection",group:0}],source:"struct pbrProjectionUniforms {\n modelViewProjectionMatrix: mat4x4<f32>,\n modelMatrix: mat4x4<f32>,\n normalMatrix: mat4x4<f32>,\n camera: vec3<f32>\n};\n\n@group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;\n",vs:Hn,fs:Hn,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<f32>"}}],source:"struct PBRFragmentInputs {\n pbr_vPosition: vec3f,\n pbr_vUV0: vec2f,\n pbr_vUV1: vec2f,\n pbr_vTBN: mat3x3f,\n pbr_vNormal: vec3f\n};\n\nvar<private> fragmentInputs: PBRFragmentInputs;\n\nfn pbr_setPositionNormalTangentUV(\n position: vec4f,\n normal: vec4f,\n tangent: vec4f,\n uv0: vec2f,\n uv1: vec2f\n)\n{\n var pos: vec4f = pbrProjection.modelMatrix * position;\n fragmentInputs.pbr_vPosition = pos.xyz / pos.w;\n fragmentInputs.pbr_vNormal = vec3f(0.0, 0.0, 1.0);\n fragmentInputs.pbr_vTBN = mat3x3f(\n vec3f(1.0, 0.0, 0.0),\n vec3f(0.0, 1.0, 0.0),\n vec3f(0.0, 0.0, 1.0)\n );\n fragmentInputs.pbr_vUV0 = vec2f(0.0, 0.0);\n fragmentInputs.pbr_vUV1 = uv1;\n\n#ifdef HAS_NORMALS\n let normalW: vec3f = normalize((pbrProjection.normalMatrix * vec4f(normal.xyz, 0.0)).xyz);\n fragmentInputs.pbr_vNormal = normalW;\n#ifdef HAS_TANGENTS\n let tangentW: vec3f = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);\n let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;\n fragmentInputs.pbr_vTBN = mat3x3f(tangentW, bitangentW, normalW);\n#endif\n#endif\n\n#ifdef HAS_UV\n fragmentInputs.pbr_vUV0 = uv0;\n#endif\n}\n\nstruct pbrMaterialUniforms {\n // Material is unlit\n unlit: u32,\n\n // Base color map\n baseColorMapEnabled: u32,\n baseColorFactor: vec4f,\n\n normalMapEnabled : u32,\n normalScale: f32, // #ifdef HAS_NORMALMAP\n\n emissiveMapEnabled: u32,\n emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP\n\n metallicRoughnessValues: vec2f,\n metallicRoughnessMapEnabled: u32,\n\n occlusionMapEnabled: i32,\n occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP\n \n alphaCutoffEnabled: i32,\n alphaCutoff: f32, // #ifdef ALPHA_CUTOFF\n\n specularColorFactor: vec3f,\n specularIntensityFactor: f32,\n specularColorMapEnabled: i32,\n specularIntensityMapEnabled: i32,\n\n ior: f32,\n\n transmissionFactor: f32,\n transmissionMapEnabled: i32,\n\n thicknessFactor: f32,\n attenuationDistance: f32,\n attenuationColor: vec3f,\n\n clearcoatFactor: f32,\n clearcoatRoughnessFactor: f32,\n clearcoatMapEnabled: i32,\n clearcoatRoughnessMapEnabled: i32,\n\n sheenColorFactor: vec3f,\n sheenRoughnessFactor: f32,\n sheenColorMapEnabled: i32,\n sheenRoughnessMapEnabled: i32,\n\n iridescenceFactor: f32,\n iridescenceIor: f32,\n iridescenceThicknessRange: vec2f,\n iridescenceMapEnabled: i32,\n\n anisotropyStrength: f32,\n anisotropyRotation: f32,\n anisotropyDirection: vec2f,\n anisotropyMapEnabled: i32,\n\n emissiveStrength: f32,\n \n // IBL\n IBLenabled: i32,\n scaleIBLAmbient: vec2f, // #ifdef USE_IBL\n \n // debugging flags used for shader output of intermediate PBR variables\n // #ifdef PBR_DEBUG\n scaleDiffBaseMR: vec4f,\n scaleFGDSpec: vec4f,\n // #endif\n\n baseColorUVSet: i32,\n baseColorUVTransform: mat3x3f,\n metallicRoughnessUVSet: i32,\n metallicRoughnessUVTransform: mat3x3f,\n normalUVSet: i32,\n normalUVTransform: mat3x3f,\n occlusionUVSet: i32,\n occlusionUVTransform: mat3x3f,\n emissiveUVSet: i32,\n emissiveUVTransform: mat3x3f,\n specularColorUVSet: i32,\n specularColorUVTransform: mat3x3f,\n specularIntensityUVSet: i32,\n specularIntensityUVTransform: mat3x3f,\n transmissionUVSet: i32,\n transmissionUVTransform: mat3x3f,\n thicknessUVSet: i32,\n thicknessUVTransform: mat3x3f,\n clearcoatUVSet: i32,\n clearcoatUVTransform: mat3x3f,\n clearcoatRoughnessUVSet: i32,\n clearcoatRoughnessUVTransform: mat3x3f,\n clearcoatNormalUVSet: i32,\n clearcoatNormalUVTransform: mat3x3f,\n sheenColorUVSet: i32,\n sheenColorUVTransform: mat3x3f,\n sheenRoughnessUVSet: i32,\n sheenRoughnessUVTransform: mat3x3f,\n iridescenceUVSet: i32,\n iridescenceUVTransform: mat3x3f,\n iridescenceThicknessUVSet: i32,\n iridescenceThicknessUVTransform: mat3x3f,\n anisotropyUVSet: i32,\n anisotropyUVTransform: mat3x3f,\n}\n\n@group(3) @binding(auto) var<uniform> pbrMaterial : pbrMaterialUniforms;\n\n// Samplers\n#ifdef HAS_BASECOLORMAP\n@group(3) @binding(auto) var pbr_baseColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_baseColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_NORMALMAP\n@group(3) @binding(auto) var pbr_normalSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_normalSamplerSampler: sampler;\n#endif\n#ifdef HAS_EMISSIVEMAP\n@group(3) @binding(auto) var pbr_emissiveSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_emissiveSamplerSampler: sampler;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\n@group(3) @binding(auto) var pbr_metallicRoughnessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_metallicRoughnessSamplerSampler: sampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\n@group(3) @binding(auto) var pbr_occlusionSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_occlusionSamplerSampler: sampler;\n#endif\n#ifdef HAS_SPECULARCOLORMAP\n@group(3) @binding(auto) var pbr_specularColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_specularColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_SPECULARINTENSITYMAP\n@group(3) @binding(auto) var pbr_specularIntensitySampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_specularIntensitySamplerSampler: sampler;\n#endif\n#ifdef HAS_TRANSMISSIONMAP\n@group(3) @binding(auto) var pbr_transmissionSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_transmissionSamplerSampler: sampler;\n#endif\n#ifdef HAS_THICKNESSMAP\n@group(3) @binding(auto) var pbr_thicknessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_thicknessSamplerSampler: sampler;\n#endif\n#ifdef HAS_CLEARCOATMAP\n@group(3) @binding(auto) var pbr_clearcoatSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_clearcoatSamplerSampler: sampler;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\n@group(3) @binding(auto) var pbr_clearcoatRoughnessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_clearcoatRoughnessSamplerSampler: sampler;\n#endif\n#ifdef HAS_CLEARCOATNORMALMAP\n@group(3) @binding(auto) var pbr_clearcoatNormalSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_clearcoatNormalSamplerSampler: sampler;\n#endif\n#ifdef HAS_SHEENCOLORMAP\n@group(3) @binding(auto) var pbr_sheenColorSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_sheenColorSamplerSampler: sampler;\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\n@group(3) @binding(auto) var pbr_sheenRoughnessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_sheenRoughnessSamplerSampler: sampler;\n#endif\n#ifdef HAS_IRIDESCENCEMAP\n@group(3) @binding(auto) var pbr_iridescenceSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_iridescenceSamplerSampler: sampler;\n#endif\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\n@group(3) @binding(auto) var pbr_iridescenceThicknessSampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_iridescenceThicknessSamplerSampler: sampler;\n#endif\n#ifdef HAS_ANISOTROPYMAP\n@group(3) @binding(auto) var pbr_anisotropySampler: texture_2d<f32>;\n@group(3) @binding(auto) var pbr_anisotropySamplerSampler: sampler;\n#endif\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo {\n NdotL: f32, // cos angle between normal and light direction\n NdotV: f32, // cos angle between normal and view direction\n NdotH: f32, // cos angle between normal and half vector\n LdotH: f32, // cos angle between light direction and half vector\n VdotH: f32, // cos angle between view direction and half vector\n perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader)\n metalness: f32, // metallic value at the surface\n reflectance0: vec3f, // full reflectance color (normal incidence angle)\n reflectance90: vec3f, // reflectance color at grazing angle\n alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2])\n diffuseColor: vec3f, // color contribution from diffuse lighting\n specularColor: vec3f, // color contribution from specular lighting\n n: vec3f, // normal at surface point\n v: vec3f, // vector from surface point to camera\n};\n\nconst M_PI = 3.141592653589793;\nconst c_MinRoughness = 0.04;\n\nfn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f\n{\n var linOut: vec3f = srgbIn.xyz;\n#ifdef MANUAL_SRGB\n let bLess: vec3f = step(vec3f(0.04045), srgbIn.xyz);\n linOut = mix(\n srgbIn.xyz / vec3f(12.92),\n pow((srgbIn.xyz + vec3f(0.055)) / vec3f(1.055), vec3f(2.4)),\n bLess\n );\n#ifdef SRGB_FAST_APPROXIMATION\n linOut = pow(srgbIn.xyz, vec3f(2.2));\n#endif\n#endif\n return vec4f(linOut, srgbIn.w);\n}\n\nfn getMaterialUV(uvSet: i32, uvTransform: mat3x3f) -> vec2f\n{\n var baseUV = fragmentInputs.pbr_vUV0;\n if (uvSet == 1) {\n baseUV = fragmentInputs.pbr_vUV1;\n }\n return (uvTransform * vec3f(baseUV, 1.0)).xy;\n}\n\n// Build the tangent basis from interpolated attributes or screen-space derivatives.\nfn getTBN(uv: vec2f) -> mat3x3f\n{\n let pos_dx: vec3f = dpdx(fragmentInputs.pbr_vPosition);\n let pos_dy: vec3f = dpdy(fragmentInputs.pbr_vPosition);\n let tex_dx: vec3f = dpdx(vec3f(uv, 0.0));\n let tex_dy: vec3f = dpdy(vec3f(uv, 0.0));\n 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);\n\n var ng: vec3f = cross(pos_dx, pos_dy);\n#ifdef HAS_NORMALS\n ng = normalize(fragmentInputs.pbr_vNormal);\n#endif\n t = normalize(t - ng * dot(ng, t));\n var b: vec3f = normalize(cross(ng, t));\n var tbn: mat3x3f = mat3x3f(t, b, ng);\n#ifdef HAS_TANGENTS\n tbn = fragmentInputs.pbr_vTBN;\n#endif\n\n return tbn;\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nfn getMappedNormal(\n normalSampler: texture_2d<f32>,\n normalSamplerBinding: sampler,\n tbn: mat3x3f,\n normalScale: f32,\n uv: vec2f\n) -> vec3f\n{\n let n = textureSample(normalSampler, normalSamplerBinding, uv).rgb;\n return normalize(tbn * ((2.0 * n - 1.0) * vec3f(normalScale, normalScale, 1.0)));\n}\n\nfn getNormal(tbn: mat3x3f, uv: vec2f) -> vec3f\n{\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n var n: vec3f = normalize(tbn[2].xyz);\n#ifdef HAS_NORMALMAP\n n = getMappedNormal(\n pbr_normalSampler,\n pbr_normalSamplerSampler,\n tbn,\n pbrMaterial.normalScale,\n uv\n );\n#endif\n\n return n;\n}\n\nfn getClearcoatNormal(tbn: mat3x3f, baseNormal: vec3f, uv: vec2f) -> vec3f\n{\n#ifdef HAS_CLEARCOATNORMALMAP\n return getMappedNormal(\n pbr_clearcoatNormalSampler,\n pbr_clearcoatNormalSamplerSampler,\n tbn,\n 1.0,\n uv\n );\n#else\n return baseNormal;\n#endif\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nfn getIBLContribution(pbrInfo: PBRInfo, n: vec3f, reflection: vec3f) -> vec3f\n{\n let mipCount: f32 = 9.0; // resolution of 512x512\n let lod: f32 = pbrInfo.perceptualRoughness * mipCount;\n // retrieve a scale and bias to F0. See [1], Figure 3\n let brdf = SRGBtoLINEAR(\n textureSampleLevel(\n pbr_brdfLUT,\n pbr_brdfLUTSampler,\n vec2f(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness),\n 0.0\n )\n ).rgb;\n let diffuseLight =\n SRGBtoLINEAR(\n textureSampleLevel(pbr_diffuseEnvSampler, pbr_diffuseEnvSamplerSampler, n, 0.0)\n ).rgb;\n var specularLight = SRGBtoLINEAR(\n textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n reflection,\n 0.0\n )\n ).rgb;\n#ifdef USE_TEX_LOD\n specularLight = SRGBtoLINEAR(\n textureSampleLevel(\n pbr_specularEnvSampler,\n pbr_specularEnvSamplerSampler,\n reflection,\n lod\n )\n ).rgb;\n#endif\n\n let diffuse = diffuseLight * pbrInfo.diffuseColor * pbrMaterial.scaleIBLAmbient.x;\n let specular =\n specularLight * (pbrInfo.specularColor * brdf.x + brdf.y) * pbrMaterial.scaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nfn diffuse(pbrInfo: PBRInfo) -> vec3<f32> {\n return pbrInfo.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nfn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> {\n return pbrInfo.reflectance0 +\n (pbrInfo.reflectance90 - pbrInfo.reflectance0) *\n pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {\n let NdotL: f32 = pbrInfo.NdotL;\n let NdotV: f32 = pbrInfo.NdotV;\n let r: f32 = pbrInfo.alphaRoughness;\n\n let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {\n let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;\n let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nfn maxComponent(value: vec3f) -> f32 {\n return max(max(value.r, value.g), value.b);\n}\n\nfn getDielectricF0(ior: f32) -> f32 {\n let clampedIor = max(ior, 1.0);\n let ratio = (clampedIor - 1.0) / (clampedIor + 1.0);\n return ratio * ratio;\n}\n\nfn normalizeDirection(direction: vec2f) -> vec2f {\n let directionLength = length(direction);\n if (directionLength > 0.0001) {\n return direction / directionLength;\n }\n\n return vec2f(1.0, 0.0);\n}\n\nfn rotateDirection(direction: vec2f, rotation: f32) -> vec2f {\n let s = sin(rotation);\n let c = cos(rotation);\n return vec2f(direction.x * c - direction.y * s, direction.x * s + direction.y * c);\n}\n\nfn getIridescenceTint(iridescence: f32, thickness: f32, NdotV: f32) -> vec3f {\n if (iridescence <= 0.0) {\n return vec3f(1.0);\n }\n\n let phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;\n let thinFilmTint =\n 0.5 +\n 0.5 *\n cos(vec3f(phase, phase + 2.0943951, phase + 4.1887902));\n return mix(vec3f(1.0), thinFilmTint, iridescence);\n}\n\nfn getVolumeAttenuation(thickness: f32) -> vec3f {\n if (thickness <= 0.0) {\n return vec3f(1.0);\n }\n\n let attenuationCoefficient =\n -log(max(pbrMaterial.attenuationColor, vec3f(0.0001))) /\n max(pbrMaterial.attenuationDistance, 0.0001);\n return exp(-attenuationCoefficient * thickness);\n}\n\nfn createClearcoatPBRInfo(\n basePBRInfo: PBRInfo,\n clearcoatNormal: vec3f,\n clearcoatRoughness: f32\n) -> PBRInfo {\n let perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n let alphaRoughness = perceptualRoughness * perceptualRoughness;\n let NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);\n\n return PBRInfo(\n basePBRInfo.NdotL,\n NdotV,\n basePBRInfo.NdotH,\n basePBRInfo.LdotH,\n basePBRInfo.VdotH,\n perceptualRoughness,\n 0.0,\n vec3f(0.04),\n vec3f(1.0),\n alphaRoughness,\n vec3f(0.0),\n vec3f(0.04),\n clearcoatNormal,\n basePBRInfo.v\n );\n}\n\nfn calculateClearcoatContribution(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n clearcoatNormal: vec3f,\n clearcoatFactor: f32,\n clearcoatRoughness: f32\n) -> vec3f {\n if (clearcoatFactor <= 0.0) {\n return vec3f(0.0);\n }\n\n let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;\n}\n\n#ifdef USE_IBL\nfn calculateClearcoatIBLContribution(\n pbrInfo: PBRInfo,\n clearcoatNormal: vec3f,\n reflection: vec3f,\n clearcoatFactor: f32,\n clearcoatRoughness: f32\n) -> vec3f {\n if (clearcoatFactor <= 0.0) {\n return vec3f(0.0);\n }\n\n let clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;\n}\n#endif\n\nfn calculateSheenContribution(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n sheenColor: vec3f,\n sheenRoughness: f32\n) -> vec3f {\n if (maxComponent(sheenColor) <= 0.0) {\n return vec3f(0.0);\n }\n\n let sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n let sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);\n return pbrInfo.NdotL *\n lightColor *\n sheenColor *\n (0.25 + 0.75 * sheenFresnel) *\n sheenVisibility *\n (1.0 - pbrInfo.metalness);\n}\n\nfn calculateAnisotropyBoost(\n pbrInfo: PBRInfo,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> f32 {\n if (anisotropyStrength <= 0.0) {\n return 1.0;\n }\n\n let anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n let bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));\n return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);\n}\n\nfn calculateMaterialLightColor(\n pbrInfo: PBRInfo,\n lightColor: vec3f,\n clearcoatNormal: vec3f,\n clearcoatFactor: f32,\n clearcoatRoughness: f32,\n sheenColor: vec3f,\n sheenRoughness: f32,\n anisotropyTangent: vec3f,\n anisotropyStrength: f32\n) -> vec3f {\n let anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n var color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;\n color += calculateClearcoatContribution(\n pbrInfo,\n lightColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);\n return color;\n}\n\nfn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {\n (*pbrInfo).NdotL = 1.0;\n (*pbrInfo).NdotH = 0.0;\n (*pbrInfo).LdotH = 0.0;\n (*pbrInfo).VdotH = 1.0;\n}\n\nfn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {\n let n = (*pbrInfo).n;\n let v = (*pbrInfo).v;\n let l = normalize(lightDirection); // Vector from surface point to light\n let h = normalize(l + v); // Half vector between both l and v\n\n (*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0);\n (*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);\n (*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);\n (*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nfn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {\n let light_direction = normalize(pointLight.position - fragmentInputs.pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nfn PBRInfo_setSpotLight(pbrInfo: ptr<function, PBRInfo>, spotLight: SpotLight) {\n let light_direction = normalize(spotLight.position - fragmentInputs.pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nfn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {\n // Calculate the shading terms for the microfacet specular shading model\n let F = specularReflection(pbrInfo);\n let G = geometricOcclusion(pbrInfo);\n let D = microfacetDistribution(pbrInfo);\n\n // Calculation of analytical lighting contribution\n let diffuseContrib = (1.0 - F) * diffuse(pbrInfo);\n let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nfn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {\n let baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);\n let metallicRoughnessUV = getMaterialUV(\n pbrMaterial.metallicRoughnessUVSet,\n pbrMaterial.metallicRoughnessUVTransform\n );\n let normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);\n let occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);\n let emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);\n let specularColorUV = getMaterialUV(\n pbrMaterial.specularColorUVSet,\n pbrMaterial.specularColorUVTransform\n );\n let specularIntensityUV = getMaterialUV(\n pbrMaterial.specularIntensityUVSet,\n pbrMaterial.specularIntensityUVTransform\n );\n let transmissionUV = getMaterialUV(\n pbrMaterial.transmissionUVSet,\n pbrMaterial.transmissionUVTransform\n );\n let thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);\n let clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);\n let clearcoatRoughnessUV = getMaterialUV(\n pbrMaterial.clearcoatRoughnessUVSet,\n pbrMaterial.clearcoatRoughnessUVTransform\n );\n let clearcoatNormalUV = getMaterialUV(\n pbrMaterial.clearcoatNormalUVSet,\n pbrMaterial.clearcoatNormalUVTransform\n );\n let sheenColorUV = getMaterialUV(\n pbrMaterial.sheenColorUVSet,\n pbrMaterial.sheenColorUVTransform\n );\n let sheenRoughnessUV = getMaterialUV(\n pbrMaterial.sheenRoughnessUVSet,\n pbrMaterial.sheenRoughnessUVTransform\n );\n let iridescenceUV = getMaterialUV(\n pbrMaterial.iridescenceUVSet,\n pbrMaterial.iridescenceUVTransform\n );\n let iridescenceThicknessUV = getMaterialUV(\n pbrMaterial.iridescenceThicknessUVSet,\n pbrMaterial.iridescenceThicknessUVTransform\n );\n let anisotropyUV = getMaterialUV(\n pbrMaterial.anisotropyUVSet,\n pbrMaterial.anisotropyUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n var baseColor: vec4<f32> = pbrMaterial.baseColorFactor;\n #ifdef HAS_BASECOLORMAP\n baseColor = SRGBtoLINEAR(\n textureSample(pbr_baseColorSampler, pbr_baseColorSamplerSampler, baseColorUV)\n ) * pbrMaterial.baseColorFactor;\n #endif\n\n #ifdef ALPHA_CUTOFF\n if (baseColor.a < pbrMaterial.alphaCutoff) {\n discard;\n }\n #endif\n\n var color = vec3<f32>(0.0, 0.0, 0.0);\n var transmission = 0.0;\n\n if (pbrMaterial.unlit != 0u) {\n color = baseColor.rgb;\n } else {\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;\n var metallic = pbrMaterial.metallicRoughnessValues.x;\n #ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n let mrSample = textureSample(\n pbr_metallicRoughnessSampler,\n pbr_metallicRoughnessSamplerSampler,\n metallicRoughnessUV\n );\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n #endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n let tbn = getTBN(normalUV);\n let n = getNormal(tbn, normalUV); // normal at surface point\n let v = normalize(pbrProjection.camera - fragmentInputs.pbr_vPosition); // Vector from surface point to camera\n let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n var useExtendedPBR = false;\n #ifdef USE_MATERIAL_EXTENSIONS\n useExtendedPBR =\n pbrMaterial.specularColorMapEnabled != 0 ||\n pbrMaterial.specularIntensityMapEnabled != 0 ||\n abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||\n maxComponent(abs(pbrMaterial.specularColorFactor - vec3f(1.0))) > 0.0001 ||\n abs(pbrMaterial.ior - 1.5) > 0.0001 ||\n pbrMaterial.transmissionMapEnabled != 0 ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.clearcoatMapEnabled != 0 ||\n pbrMaterial.clearcoatRoughnessMapEnabled != 0 ||\n pbrMaterial.clearcoatFactor > 0.0001 ||\n pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||\n pbrMaterial.sheenColorMapEnabled != 0 ||\n pbrMaterial.sheenRoughnessMapEnabled != 0 ||\n maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||\n pbrMaterial.sheenRoughnessFactor > 0.0001 ||\n pbrMaterial.iridescenceMapEnabled != 0 ||\n pbrMaterial.iridescenceFactor > 0.0001 ||\n abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||\n pbrMaterial.anisotropyMapEnabled != 0 ||\n pbrMaterial.anisotropyStrength > 0.0001 ||\n abs(pbrMaterial.anisotropyRotation) > 0.0001 ||\n length(pbrMaterial.anisotropyDirection - vec2f(1.0, 0.0)) > 0.0001;\n #endif\n\n if (!useExtendedPBR) {\n let alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n let f0 = vec3<f32>(0.04);\n var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n let specularColor = mix(f0, baseColor.rgb, metallic);\n\n let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n let specularEnvironmentR0 = specularColor;\n let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;\n let reflection = -normalize(reflect(v, n));\n\n var pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n #ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(&pbrInfo);\n color += calculateFinalColor(pbrInfo, lighting.ambientColor);\n\n for (var i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);\n }\n }\n\n for (var i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));\n let attenuation = getPointLightAttenuation(\n lighting_getPointLight(i),\n distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)\n );\n color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);\n }\n }\n\n for (var i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));\n let attenuation = getSpotLightAttenuation(\n lighting_getSpotLight(i),\n fragmentInputs.pbr_vPosition\n );\n color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);\n }\n }\n #endif\n\n #ifdef USE_IBL\n if (pbrMaterial.IBLenabled != 0) {\n color += getIBLContribution(pbrInfo, n, reflection);\n }\n #endif\n\n #ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled != 0) {\n let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n #endif\n\n var emissive = pbrMaterial.emissiveFactor;\n #ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled != 0u) {\n emissive *= SRGBtoLINEAR(\n textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV)\n ).rgb;\n }\n #endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n #ifdef PBR_DEBUG\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n #endif\n\n return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);\n }\n\n var specularIntensity = pbrMaterial.specularIntensityFactor;\n #ifdef HAS_SPECULARINTENSITYMAP\n if (pbrMaterial.specularIntensityMapEnabled != 0) {\n specularIntensity *= textureSample(\n pbr_specularIntensitySampler,\n pbr_specularIntensitySamplerSampler,\n specularIntensityUV\n ).a;\n }\n #endif\n\n var specularFactor = pbrMaterial.specularColorFactor;\n #ifdef HAS_SPECULARCOLORMAP\n if (pbrMaterial.specularColorMapEnabled != 0) {\n specularFactor *= SRGBtoLINEAR(\n textureSample(\n pbr_specularColorSampler,\n pbr_specularColorSamplerSampler,\n specularColorUV\n )\n ).rgb;\n }\n #endif\n\n transmission = pbrMaterial.transmissionFactor;\n #ifdef HAS_TRANSMISSIONMAP\n if (pbrMaterial.transmissionMapEnabled != 0) {\n transmission *= textureSample(\n pbr_transmissionSampler,\n pbr_transmissionSamplerSampler,\n transmissionUV\n ).r;\n }\n #endif\n transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);\n var thickness = max(pbrMaterial.thicknessFactor, 0.0);\n #ifdef HAS_THICKNESSMAP\n thickness *= textureSample(\n pbr_thicknessSampler,\n pbr_thicknessSamplerSampler,\n thicknessUV\n ).g;\n #endif\n\n var clearcoatFactor = pbrMaterial.clearcoatFactor;\n var clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;\n #ifdef HAS_CLEARCOATMAP\n if (pbrMaterial.clearcoatMapEnabled != 0) {\n clearcoatFactor *= textureSample(\n pbr_clearcoatSampler,\n pbr_clearcoatSamplerSampler,\n clearcoatUV\n ).r;\n }\n #endif\n #ifdef HAS_CLEARCOATROUGHNESSMAP\n if (pbrMaterial.clearcoatRoughnessMapEnabled != 0) {\n clearcoatRoughness *= textureSample(\n pbr_clearcoatRoughnessSampler,\n pbr_clearcoatRoughnessSamplerSampler,\n clearcoatRoughnessUV\n ).g;\n }\n #endif\n clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);\n clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n let clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);\n\n var sheenColor = pbrMaterial.sheenColorFactor;\n var sheenRoughness = pbrMaterial.sheenRoughnessFactor;\n #ifdef HAS_SHEENCOLORMAP\n if (pbrMaterial.sheenColorMapEnabled != 0) {\n sheenColor *= SRGBtoLINEAR(\n textureSample(\n pbr_sheenColorSampler,\n pbr_sheenColorSamplerSampler,\n sheenColorUV\n )\n ).rgb;\n }\n #endif\n #ifdef HAS_SHEENROUGHNESSMAP\n if (pbrMaterial.sheenRoughnessMapEnabled != 0) {\n sheenRoughness *= textureSample(\n pbr_sheenRoughnessSampler,\n pbr_sheenRoughnessSamplerSampler,\n sheenRoughnessUV\n ).a;\n }\n #endif\n sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);\n\n var iridescence = pbrMaterial.iridescenceFactor;\n #ifdef HAS_IRIDESCENCEMAP\n if (pbrMaterial.iridescenceMapEnabled != 0) {\n iridescence *= textureSample(\n pbr_iridescenceSampler,\n pbr_iridescenceSamplerSampler,\n iridescenceUV\n ).r;\n }\n #endif\n iridescence = clamp(iridescence, 0.0, 1.0);\n var iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n 0.5\n );\n #ifdef HAS_IRIDESCENCETHICKNESSMAP\n iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n textureSample(\n pbr_iridescenceThicknessSampler,\n pbr_iridescenceThicknessSamplerSampler,\n iridescenceThicknessUV\n ).g\n );\n #endif\n\n var anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);\n var anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);\n #ifdef HAS_ANISOTROPYMAP\n if (pbrMaterial.anisotropyMapEnabled != 0) {\n let anisotropySample = textureSample(\n pbr_anisotropySampler,\n pbr_anisotropySamplerSampler,\n anisotropyUV\n ).rgb;\n anisotropyStrength *= anisotropySample.b;\n let mappedDirection = anisotropySample.rg * 2.0 - 1.0;\n if (length(mappedDirection) > 0.0001) {\n anisotropyDirection = normalize(mappedDirection);\n }\n }\n #endif\n anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);\n var anisotropyTangent =\n normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);\n if (length(anisotropyTangent) < 0.0001) {\n anisotropyTangent = normalize(tbn[0]);\n }\n let anisotropyViewAlignment = abs(dot(v, anisotropyTangent));\n perceptualRoughness = mix(\n perceptualRoughness,\n clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),\n anisotropyStrength\n );\n\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n let alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n let dielectricF0 = getDielectricF0(pbrMaterial.ior);\n var dielectricSpecularF0 = min(\n vec3f(dielectricF0) * specularFactor * specularIntensity,\n vec3f(1.0)\n );\n let iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);\n dielectricSpecularF0 = mix(\n dielectricSpecularF0,\n dielectricSpecularF0 * iridescenceTint,\n iridescence\n );\n var diffuseColor = baseColor.rgb * (vec3f(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission);\n var specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n let baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;\n diffuseColor *= baseLayerEnergy;\n specularColor *= baseLayerEnergy;\n\n // Compute reflectance.\n let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflectance to 0%.\n let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n let specularEnvironmentR0 = specularColor;\n let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;\n let reflection = -normalize(reflect(v, n));\n\n var pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n #ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(&pbrInfo);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting.ambientColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n\n // Apply directional light\n for (var i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n // Apply point light\n for (var i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));\n let attenuation = getPointLightAttenuation(\n lighting_getPointLight(i),\n distance(lighting_getPointLight(i).position, fragmentInputs.pbr_vPosition)\n );\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n for (var i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(&pbrInfo, lighting_getSpotLight(i));\n let attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), fragmentInputs.pbr_vPosition);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n #endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n #ifdef USE_IBL\n if (pbrMaterial.IBLenabled != 0) {\n color += getIBLContribution(pbrInfo, n, reflection) *\n calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;\n }\n #endif\n\n // Apply optional PBR terms for additional (optional) shading\n #ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled != 0) {\n let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSamplerSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n #endif\n\n var emissive = pbrMaterial.emissiveFactor;\n #ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled != 0u) {\n emissive *= SRGBtoLINEAR(\n textureSample(pbr_emissiveSampler, pbr_emissiveSamplerSampler, emissiveUV)\n ).rgb;\n }\n #endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n if (transmission > 0.0) {\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n }\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n #ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, pbr_scaleFGDSpec.x);\n // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);\n // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);\n // color = mix(color, specContrib, pbr_scaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n #endif\n }\n\n let alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), alpha);\n}\n",vs:"out vec3 pbr_vPosition;\nout vec2 pbr_vUV0;\nout vec2 pbr_vUV1;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(\n vec4 position,\n vec4 normal,\n vec4 tangent,\n vec2 uv0,\n vec2 uv1\n)\n{\n vec4 pos = pbrProjection.modelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV0 = uv0;\n#else\n pbr_vUV0 = vec2(0.,0.);\n#endif\n\n pbr_vUV1 = uv1;\n}\n",fs:"precision highp float;\n\nlayout(std140) uniform pbrMaterialUniforms {\n // Material is unlit\n bool unlit;\n\n // Base color map\n bool baseColorMapEnabled;\n vec4 baseColorFactor;\n\n bool normalMapEnabled; \n float normalScale; // #ifdef HAS_NORMALMAP\n\n bool emissiveMapEnabled;\n vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP\n\n vec2 metallicRoughnessValues;\n bool metallicRoughnessMapEnabled;\n\n bool occlusionMapEnabled;\n float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP\n \n bool alphaCutoffEnabled;\n float alphaCutoff; // #ifdef ALPHA_CUTOFF\n\n vec3 specularColorFactor;\n float specularIntensityFactor;\n bool specularColorMapEnabled;\n bool specularIntensityMapEnabled;\n\n float ior;\n\n float transmissionFactor;\n bool transmissionMapEnabled;\n\n float thicknessFactor;\n float attenuationDistance;\n vec3 attenuationColor;\n\n float clearcoatFactor;\n float clearcoatRoughnessFactor;\n bool clearcoatMapEnabled;\n bool clearcoatRoughnessMapEnabled;\n\n vec3 sheenColorFactor;\n float sheenRoughnessFactor;\n bool sheenColorMapEnabled;\n bool sheenRoughnessMapEnabled;\n\n float iridescenceFactor;\n float iridescenceIor;\n vec2 iridescenceThicknessRange;\n bool iridescenceMapEnabled;\n\n float anisotropyStrength;\n float anisotropyRotation;\n vec2 anisotropyDirection;\n bool anisotropyMapEnabled;\n\n float emissiveStrength;\n \n // IBL\n bool IBLenabled;\n vec2 scaleIBLAmbient; // #ifdef USE_IBL\n \n // debugging flags used for shader output of intermediate PBR variables\n // #ifdef PBR_DEBUG\n vec4 scaleDiffBaseMR;\n vec4 scaleFGDSpec;\n // #endif\n\n int baseColorUVSet;\n mat3 baseColorUVTransform;\n int metallicRoughnessUVSet;\n mat3 metallicRoughnessUVTransform;\n int normalUVSet;\n mat3 normalUVTransform;\n int occlusionUVSet;\n mat3 occlusionUVTransform;\n int emissiveUVSet;\n mat3 emissiveUVTransform;\n int specularColorUVSet;\n mat3 specularColorUVTransform;\n int specularIntensityUVSet;\n mat3 specularIntensityUVTransform;\n int transmissionUVSet;\n mat3 transmissionUVTransform;\n int thicknessUVSet;\n mat3 thicknessUVTransform;\n int clearcoatUVSet;\n mat3 clearcoatUVTransform;\n int clearcoatRoughnessUVSet;\n mat3 clearcoatRoughnessUVTransform;\n int clearcoatNormalUVSet;\n mat3 clearcoatNormalUVTransform;\n int sheenColorUVSet;\n mat3 sheenColorUVTransform;\n int sheenRoughnessUVSet;\n mat3 sheenRoughnessUVTransform;\n int iridescenceUVSet;\n mat3 iridescenceUVTransform;\n int iridescenceThicknessUVSet;\n mat3 iridescenceThicknessUVTransform;\n int anisotropyUVSet;\n mat3 anisotropyUVTransform;\n} pbrMaterial;\n\n// Samplers\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D pbr_baseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D pbr_normalSampler;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D pbr_emissiveSampler;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D pbr_metallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D pbr_occlusionSampler;\n#endif\n#ifdef HAS_SPECULARCOLORMAP\nuniform sampler2D pbr_specularColorSampler;\n#endif\n#ifdef HAS_SPECULARINTENSITYMAP\nuniform sampler2D pbr_specularIntensitySampler;\n#endif\n#ifdef HAS_TRANSMISSIONMAP\nuniform sampler2D pbr_transmissionSampler;\n#endif\n#ifdef HAS_THICKNESSMAP\nuniform sampler2D pbr_thicknessSampler;\n#endif\n#ifdef HAS_CLEARCOATMAP\nuniform sampler2D pbr_clearcoatSampler;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\nuniform sampler2D pbr_clearcoatRoughnessSampler;\n#endif\n#ifdef HAS_CLEARCOATNORMALMAP\nuniform sampler2D pbr_clearcoatNormalSampler;\n#endif\n#ifdef HAS_SHEENCOLORMAP\nuniform sampler2D pbr_sheenColorSampler;\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\nuniform sampler2D pbr_sheenRoughnessSampler;\n#endif\n#ifdef HAS_IRIDESCENCEMAP\nuniform sampler2D pbr_iridescenceSampler;\n#endif\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\nuniform sampler2D pbr_iridescenceThicknessSampler;\n#endif\n#ifdef HAS_ANISOTROPYMAP\nuniform sampler2D pbr_anisotropySampler;\n#endif\n// Inputs from vertex shader\n\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV0;\nin vec2 pbr_vUV1;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\n\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo {\n float NdotL; // cos angle between normal and light direction\n float NdotV; // cos angle between normal and view direction\n float NdotH; // cos angle between normal and half vector\n float LdotH; // cos angle between light direction and half vector\n float VdotH; // cos angle between view direction and half vector\n float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)\n float metalness; // metallic value at the surface\n vec3 reflectance0; // full reflectance color (normal incidence angle)\n vec3 reflectance90; // reflectance color at grazing angle\n float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])\n vec3 diffuseColor; // color contribution from diffuse lighting\n vec3 specularColor; // color contribution from specular lighting\n vec3 n; // normal at surface point\n vec3 v; // vector from surface point to camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor);\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else // SRGB_FAST_APPROXIMATION\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif //SRGB_FAST_APPROXIMATION\n return vec4(linOut,srgbIn.w);;\n#else //MANUAL_SRGB\n return srgbIn;\n#endif //MANUAL_SRGB\n}\n\nvec2 getMaterialUV(int uvSet, mat3 uvTransform)\n{\n vec2 baseUV = uvSet == 1 ? pbr_vUV1 : pbr_vUV0;\n return (uvTransform * vec3(baseUV, 1.0)).xy;\n}\n\n// Build the tangent basis from interpolated attributes or screen-space derivatives.\nmat3 getTBN(vec2 uv)\n{\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(uv, 0.0));\n vec3 tex_dy = dFdy(vec3(uv, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else // HAS_TANGENTS\n mat3 tbn = pbr_vTBN;\n#endif\n\n return tbn;\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nvec3 getMappedNormal(sampler2D normalSampler, mat3 tbn, float normalScale, vec2 uv)\n{\n vec3 n = texture(normalSampler, uv).rgb;\n return normalize(tbn * ((2.0 * n - 1.0) * vec3(normalScale, normalScale, 1.0)));\n}\n\nvec3 getNormal(mat3 tbn, vec2 uv)\n{\n#ifdef HAS_NORMALMAP\n vec3 n = getMappedNormal(pbr_normalSampler, tbn, pbrMaterial.normalScale, uv);\n#else\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\nvec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal, vec2 uv)\n{\n#ifdef HAS_CLEARCOATNORMALMAP\n return getMappedNormal(pbr_clearcoatNormalSampler, tbn, 1.0, uv);\n#else\n return baseNormal;\n#endif\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0; // resolution of 512x512\n float lod = (pbrInfo.perceptualRoughness * mipCount);\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,\n vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;\n vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= pbrMaterial.scaleIBLAmbient.x;\n specular *= pbrMaterial.scaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nvec3 diffuse(PBRInfo pbrInfo)\n{\n return pbrInfo.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nvec3 specularReflection(PBRInfo pbrInfo)\n{\n return pbrInfo.reflectance0 +\n (pbrInfo.reflectance90 - pbrInfo.reflectance0) *\n pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfloat geometricOcclusion(PBRInfo pbrInfo)\n{\n float NdotL = pbrInfo.NdotL;\n float NdotV = pbrInfo.NdotV;\n float r = pbrInfo.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfloat microfacetDistribution(PBRInfo pbrInfo)\n{\n float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;\n float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nfloat maxComponent(vec3 value)\n{\n return max(max(value.r, value.g), value.b);\n}\n\nfloat getDielectricF0(float ior)\n{\n float clampedIor = max(ior, 1.0);\n float ratio = (clampedIor - 1.0) / (clampedIor + 1.0);\n return ratio * ratio;\n}\n\nvec2 normalizeDirection(vec2 direction)\n{\n float directionLength = length(direction);\n return directionLength > 0.0001 ? direction / directionLength : vec2(1.0, 0.0);\n}\n\nvec2 rotateDirection(vec2 direction, float rotation)\n{\n float s = sin(rotation);\n float c = cos(rotation);\n return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c);\n}\n\nvec3 getIridescenceTint(float iridescence, float thickness, float NdotV)\n{\n if (iridescence <= 0.0) {\n return vec3(1.0);\n }\n\n float phase = 0.015 * thickness * pbrMaterial.iridescenceIor + (1.0 - NdotV) * 6.0;\n vec3 thinFilmTint =\n 0.5 + 0.5 * cos(vec3(phase, phase + 2.0943951, phase + 4.1887902));\n return mix(vec3(1.0), thinFilmTint, iridescence);\n}\n\nvec3 getVolumeAttenuation(float thickness)\n{\n if (thickness <= 0.0) {\n return vec3(1.0);\n }\n\n vec3 attenuationCoefficient =\n -log(max(pbrMaterial.attenuationColor, vec3(0.0001))) /\n max(pbrMaterial.attenuationDistance, 0.0001);\n return exp(-attenuationCoefficient * thickness);\n}\n\nPBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness)\n{\n float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n float NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);\n\n return PBRInfo(\n basePBRInfo.NdotL,\n NdotV,\n basePBRInfo.NdotH,\n basePBRInfo.LdotH,\n basePBRInfo.VdotH,\n perceptualRoughness,\n 0.0,\n vec3(0.04),\n vec3(1.0),\n alphaRoughness,\n vec3(0.0),\n vec3(0.04),\n clearcoatNormal,\n basePBRInfo.v\n );\n}\n\nvec3 calculateClearcoatContribution(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 clearcoatNormal,\n float clearcoatFactor,\n float clearcoatRoughness\n) {\n if (clearcoatFactor <= 0.0) {\n return vec3(0.0);\n }\n\n PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;\n}\n\n#ifdef USE_IBL\nvec3 calculateClearcoatIBLContribution(\n PBRInfo pbrInfo,\n vec3 clearcoatNormal,\n vec3 reflection,\n float clearcoatFactor,\n float clearcoatRoughness\n) {\n if (clearcoatFactor <= 0.0) {\n return vec3(0.0);\n }\n\n PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;\n}\n#endif\n\nvec3 calculateSheenContribution(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 sheenColor,\n float sheenRoughness\n) {\n if (maxComponent(sheenColor) <= 0.0) {\n return vec3(0.0);\n }\n\n float sheenFresnel = pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n float sheenVisibility = mix(1.0, pbrInfo.NdotL * pbrInfo.NdotV, sheenRoughness);\n return pbrInfo.NdotL *\n lightColor *\n sheenColor *\n (0.25 + 0.75 * sheenFresnel) *\n sheenVisibility *\n (1.0 - pbrInfo.metalness);\n}\n\nfloat calculateAnisotropyBoost(\n PBRInfo pbrInfo,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n if (anisotropyStrength <= 0.0) {\n return 1.0;\n }\n\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n float bitangentViewAlignment = abs(dot(pbrInfo.v, anisotropyBitangent));\n return mix(1.0, 0.65 + 0.7 * bitangentViewAlignment, anisotropyStrength);\n}\n\nvec3 calculateMaterialLightColor(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 clearcoatNormal,\n float clearcoatFactor,\n float clearcoatRoughness,\n vec3 sheenColor,\n float sheenRoughness,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n float anisotropyBoost = calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n vec3 color = calculateFinalColor(pbrInfo, lightColor) * anisotropyBoost;\n color += calculateClearcoatContribution(\n pbrInfo,\n lightColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);\n return color;\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {\n pbrInfo.NdotL = 1.0;\n pbrInfo.NdotH = 0.0;\n pbrInfo.LdotH = 0.0;\n pbrInfo.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {\n vec3 n = pbrInfo.n;\n vec3 v = pbrInfo.v;\n vec3 l = normalize(lightDirection); // Vector from surface point to light\n vec3 h = normalize(l+v); // Half vector between both l and v\n\n pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nvoid PBRInfo_setSpotLight(inout PBRInfo pbrInfo, SpotLight spotLight) {\n vec3 light_direction = normalize(spotLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInfo);\n float G = geometricOcclusion(pbrInfo);\n float D = microfacetDistribution(pbrInfo);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);\n vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);\n vec2 metallicRoughnessUV = getMaterialUV(\n pbrMaterial.metallicRoughnessUVSet,\n pbrMaterial.metallicRoughnessUVTransform\n );\n vec2 normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);\n vec2 occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);\n vec2 emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);\n vec2 specularColorUV = getMaterialUV(\n pbrMaterial.specularColorUVSet,\n pbrMaterial.specularColorUVTransform\n );\n vec2 specularIntensityUV = getMaterialUV(\n pbrMaterial.specularIntensityUVSet,\n pbrMaterial.specularIntensityUVTransform\n );\n vec2 transmissionUV = getMaterialUV(\n pbrMaterial.transmissionUVSet,\n pbrMaterial.transmissionUVTransform\n );\n vec2 thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);\n vec2 clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);\n vec2 clearcoatRoughnessUV = getMaterialUV(\n pbrMaterial.clearcoatRoughnessUVSet,\n pbrMaterial.clearcoatRoughnessUVTransform\n );\n vec2 clearcoatNormalUV = getMaterialUV(\n pbrMaterial.clearcoatNormalUVSet,\n pbrMaterial.clearcoatNormalUVTransform\n );\n vec2 sheenColorUV = getMaterialUV(\n pbrMaterial.sheenColorUVSet,\n pbrMaterial.sheenColorUVTransform\n );\n vec2 sheenRoughnessUV = getMaterialUV(\n pbrMaterial.sheenRoughnessUVSet,\n pbrMaterial.sheenRoughnessUVTransform\n );\n vec2 iridescenceUV = getMaterialUV(\n pbrMaterial.iridescenceUVSet,\n pbrMaterial.iridescenceUVTransform\n );\n vec2 iridescenceThicknessUV = getMaterialUV(\n pbrMaterial.iridescenceThicknessUVSet,\n pbrMaterial.iridescenceThicknessUVTransform\n );\n vec2 anisotropyUV = getMaterialUV(\n pbrMaterial.anisotropyUVSet,\n pbrMaterial.anisotropyUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor =\n SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) * pbrMaterial.baseColorFactor;\n#else\n vec4 baseColor = pbrMaterial.baseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < pbrMaterial.alphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n float transmission = 0.0;\n\n if(pbrMaterial.unlit){\n color.rgb = baseColor.rgb;\n }\n else{\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;\n float metallic = pbrMaterial.metallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n vec4 mrSample = texture(pbr_metallicRoughnessSampler, metallicRoughnessUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n mat3 tbn = getTBN(normalUV);\n vec3 n = getNormal(tbn, normalUV); // normal at surface point\n vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n#ifdef USE_MATERIAL_EXTENSIONS\n bool useExtendedPBR =\n pbrMaterial.specularColorMapEnabled ||\n pbrMaterial.specularIntensityMapEnabled ||\n abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||\n maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 ||\n abs(pbrMaterial.ior - 1.5) > 0.0001 ||\n pbrMaterial.transmissionMapEnabled ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.clearcoatMapEnabled ||\n pbrMaterial.clearcoatRoughnessMapEnabled ||\n pbrMaterial.clearcoatFactor > 0.0001 ||\n pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||\n pbrMaterial.sheenColorMapEnabled ||\n pbrMaterial.sheenRoughnessMapEnabled ||\n maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||\n pbrMaterial.sheenRoughnessFactor > 0.0001 ||\n pbrMaterial.iridescenceMapEnabled ||\n pbrMaterial.iridescenceFactor > 0.0001 ||\n abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||\n pbrMaterial.anisotropyMapEnabled ||\n pbrMaterial.anisotropyStrength > 0.0001 ||\n abs(pbrMaterial.anisotropyRotation) > 0.0001 ||\n length(pbrMaterial.anisotropyDirection - vec2(1.0, 0.0)) > 0.0001;\n#else\n bool useExtendedPBR = false;\n#endif\n\n if (!useExtendedPBR) {\n // Keep the baseline metallic-roughness implementation byte-for-byte equivalent in behavior.\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(pbrInfo);\n color += calculateFinalColor(pbrInfo, lighting.ambientColor);\n\n for(int i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);\n }\n }\n\n for(int i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));\n float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));\n color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);\n }\n }\n\n for(int i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));\n float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);\n color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);\n }\n }\n#endif\n\n#ifdef USE_IBL\n if (pbrMaterial.IBLenabled) {\n color += getIBLContribution(pbrInfo, n, reflection);\n }\n#endif\n\n#ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled) {\n float ao = texture(pbr_occlusionSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n#endif\n\n vec3 emissive = pbrMaterial.emissiveFactor;\n#ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled) {\n emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;\n }\n#endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n#ifdef PBR_DEBUG\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n#endif\n\n return vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a);\n }\n\n float specularIntensity = pbrMaterial.specularIntensityFactor;\n#ifdef HAS_SPECULARINTENSITYMAP\n if (pbrMaterial.specularIntensityMapEnabled) {\n specularIntensity *= texture(pbr_specularIntensitySampler, specularIntensityUV).a;\n }\n#endif\n\n vec3 specularFactor = pbrMaterial.specularColorFactor;\n#ifdef HAS_SPECULARCOLORMAP\n if (pbrMaterial.specularColorMapEnabled) {\n specularFactor *= SRGBtoLINEAR(texture(pbr_specularColorSampler, specularColorUV)).rgb;\n }\n#endif\n\n transmission = pbrMaterial.transmissionFactor;\n#ifdef HAS_TRANSMISSIONMAP\n if (pbrMaterial.transmissionMapEnabled) {\n transmission *= texture(pbr_transmissionSampler, transmissionUV).r;\n }\n#endif\n transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);\n float thickness = max(pbrMaterial.thicknessFactor, 0.0);\n#ifdef HAS_THICKNESSMAP\n thickness *= texture(pbr_thicknessSampler, thicknessUV).g;\n#endif\n\n float clearcoatFactor = pbrMaterial.clearcoatFactor;\n float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;\n#ifdef HAS_CLEARCOATMAP\n if (pbrMaterial.clearcoatMapEnabled) {\n clearcoatFactor *= texture(pbr_clearcoatSampler, clearcoatUV).r;\n }\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\n if (pbrMaterial.clearcoatRoughnessMapEnabled) {\n clearcoatRoughness *= texture(pbr_clearcoatRoughnessSampler, clearcoatRoughnessUV).g;\n }\n#endif\n clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);\n clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n vec3 clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);\n\n vec3 sheenColor = pbrMaterial.sheenColorFactor;\n float sheenRoughness = pbrMaterial.sheenRoughnessFactor;\n#ifdef HAS_SHEENCOLORMAP\n if (pbrMaterial.sheenColorMapEnabled) {\n sheenColor *= SRGBtoLINEAR(texture(pbr_sheenColorSampler, sheenColorUV)).rgb;\n }\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\n if (pbrMaterial.sheenRoughnessMapEnabled) {\n sheenRoughness *= texture(pbr_sheenRoughnessSampler, sheenRoughnessUV).a;\n }\n#endif\n sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);\n\n float iridescence = pbrMaterial.iridescenceFactor;\n#ifdef HAS_IRIDESCENCEMAP\n if (pbrMaterial.iridescenceMapEnabled) {\n iridescence *= texture(pbr_iridescenceSampler, iridescenceUV).r;\n }\n#endif\n iridescence = clamp(iridescence, 0.0, 1.0);\n float iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n 0.5\n );\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\n iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n texture(pbr_iridescenceThicknessSampler, iridescenceThicknessUV).g\n );\n#endif\n\n float anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);\n vec2 anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);\n#ifdef HAS_ANISOTROPYMAP\n if (pbrMaterial.anisotropyMapEnabled) {\n vec3 anisotropySample = texture(pbr_anisotropySampler, anisotropyUV).rgb;\n anisotropyStrength *= anisotropySample.b;\n vec2 mappedDirection = anisotropySample.rg * 2.0 - 1.0;\n if (length(mappedDirection) > 0.0001) {\n anisotropyDirection = normalize(mappedDirection);\n }\n }\n#endif\n anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);\n vec3 anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);\n if (length(anisotropyTangent) < 0.0001) {\n anisotropyTangent = normalize(tbn[0]);\n }\n float anisotropyViewAlignment = abs(dot(v, anisotropyTangent));\n perceptualRoughness = mix(\n perceptualRoughness,\n clamp(perceptualRoughness * (1.0 - 0.6 * anisotropyViewAlignment), c_MinRoughness, 1.0),\n anisotropyStrength\n );\n\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n float dielectricF0 = getDielectricF0(pbrMaterial.ior);\n vec3 dielectricSpecularF0 = min(\n vec3(dielectricF0) * specularFactor * specularIntensity,\n vec3(1.0)\n );\n vec3 iridescenceTint = getIridescenceTint(iridescence, iridescenceThickness, NdotV);\n dielectricSpecularF0 = mix(\n dielectricSpecularF0,\n dielectricSpecularF0 * iridescenceTint,\n iridescence\n );\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission);\n vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n float baseLayerEnergy = 1.0 - clearcoatFactor * 0.25;\n diffuseColor *= baseLayerEnergy;\n specularColor *= baseLayerEnergy;\n\n // Compute reflectance.\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflecance to 0%.\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n\n#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInfo);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting.ambientColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n\n // Apply directional light\n for(int i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n // Apply point light\n for(int i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));\n float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n\n for(int i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));\n float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n if (pbrMaterial.IBLenabled) {\n color += getIBLContribution(pbrInfo, n, reflection) *\n calculateAnisotropyBoost(pbrInfo, anisotropyTangent, anisotropyStrength);\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;\n }\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled) {\n float ao = texture(pbr_occlusionSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n#endif\n\n vec3 emissive = pbrMaterial.emissiveFactor;\n#ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled) {\n emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;\n }\n#endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n if (transmission > 0.0) {\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n }\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n#ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, pbr_scaleFGDSpec.x);\n // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);\n // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);\n // color = mix(color, specContrib, pbr_scaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n#endif\n\n }\n\n float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n return vec4(pow(color,vec3(1.0/2.2)), alpha);\n}\n",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:e=>e,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>"}},Qn={name:"color",dependencies:[],source:"\n\n@must_use\nfn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {\n return vec4(fragColor.rgb * fragColor.a, fragColor.a); \n};\n",getUniforms:e=>({})},Jn={name:"project32",dependencies:[oe],source:"// Define a structure to hold both the clip-space position and the common position.\nstruct ProjectResult {\n clipPosition: vec4<f32>,\n commonPosition: vec4<f32>,\n};\n\n// This function mimics the GLSL version with the 'out' parameter by returning both values.\nfn project_position_to_clipspace_and_commonspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> ProjectResult {\n // Compute the projected position.\n let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low);\n\n // Start with the provided offset.\n var finalOffset: vec3<f32> = offset;\n\n // Get whether a rotation is needed and the rotation matrix.\n let rotationResult = project_needs_rotation(projectedPosition);\n\n // If rotation is needed, update the offset.\n if (rotationResult.needsRotation) {\n finalOffset = rotationResult.transform * offset;\n }\n\n // Compute the common position.\n let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0);\n\n // Convert to clip-space.\n let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition);\n\n return ProjectResult(clipPosition, commonPosition);\n}\n\n// A convenience overload that returns only the clip-space position.\nfn project_position_to_clipspace(\n position: vec3<f32>,\n position64Low: vec3<f32>,\n offset: vec3<f32>\n) -> vec4<f32> {\n return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;\n}\n",vs:"vec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"},Kn={...An,source:"struct pickingUniforms {\n isActive: f32,\n isAttribute: f32,\n isHighlightActive: f32,\n useByteColors: f32,\n highlightedObjectColor: vec3<f32>,\n highlightColor: vec4<f32>,\n};\n\n@group(0) @binding(auto) var<uniform> picking: pickingUniforms;\n\nfn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {\n return select(color, color / 255.0, picking.useByteColors > 0.5);\n}\n\nfn picking_isColorZero(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) < 0.00001;\n}\n\nfn picking_isColorValid(color: vec3<f32>) -> bool {\n return dot(color, vec3<f32>(1.0)) > 0.00001;\n}\n",defaultUniforms:{...An.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ","vs:DECKGL_FILTER_COLOR":"\n picking_setPickingColor(geometry.pickingColor);\n ","fs:DECKGL_FILTER_COLOR":{order:99,injection:"\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "}}},Wn=[0,0,0];function qn(e,t,n=!1){const i=t.projectPosition(e);if(n&&t instanceof ce){const[n,r,o=0]=e,s=t.getDistanceScales([n,r]);i[2]=o*s.unitsPerMeter[2]}return i}function Yn(e,{viewport:t,modelMatrix:n,coordinateSystem:i,coordinateOrigin:r,offsetMode:o}){let[s,a,A=0]=e;switch(n&&([s,a,A]=se([],[s,a,A,1],n)),i){case"default":return Yn(e,{viewport:t,modelMatrix:n,coordinateSystem:t.isGeospatial?"lnglat":"cartesian",coordinateOrigin:r,offsetMode:o});case"lnglat":return qn([s,a,A],t,o);case"lnglat-offsets":return qn([s+r[0],a+r[1],A+(r[2]||0)],t,o);case"meter-offsets":return qn(ae(r,[s,a,A]),t,o);case"cartesian":return t.isGeospatial?[s+r[0],a+r[1],A+r[2]]:t.projectPosition([s,a,A]);default:throw new Error(`Invalid coordinateSystem: ${i}`)}}const Xn={};function Zn(e="id"){Xn[e]=Xn[e]||1;return`${e}-${Xn[e]++}`}class $n{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Zn("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&re.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(const 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 ei(e,t){if(t instanceof $n)return t;const n=function(e,t){if(!t.indices)return;const n=t.indices.value;return e.createBuffer({usage:re.INDEX,data:n})}(e,t),{attributes:i,bufferLayout:r}=function(e,t){const n=[],i={};for(const[o,s]of Object.entries(t.attributes)){let t=o;switch(o){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"TEXCOORD_1":t="texCoords1";break;case"COLOR_0":t="colors"}if(s){i[t]=e.createBuffer({data:s.value,id:`${o}-buffer`});const{value:r,size:a,normalized:A}=s;if(void 0===a)throw new Error(`Attribute ${o} is missing a size`);n.push({name:t,format:ue.getVertexFormatFromAttribute(r,a,A)})}}const r=t._calculateVertexCount(t.attributes,t.indices);return{attributes:i,bufferLayout:n,vertexCount:r}}(e,t);return new $n({topology:t.topology||"triangle-list",bufferLayout:r,vertexCount:t.vertexCount,indices:n,attributes:i})}const ti="__debugFramebufferState";function ni(e,t,n){if("webgl"!==e.device.type)return;const i=(r=e.device,r.userData[ti]||={flushing:!1,queuedFramebuffers:[]},r.userData[ti]);var r;i.flushing||(!function(e){const t=e.props.framebuffer;return!t||null===t.handle}(e)?t&&"colorAttachments"in t&&null!==t.handle&&(i.queuedFramebuffers.includes(t)||i.queuedFramebuffers.push(t)):function(e,t,n){if(0===n.queuedFramebuffers.length)return;const i=e.device,{gl:r}=i,o=r.getParameter(36010),s=r.getParameter(36006),[a,A]=e.device.getDefaultCanvasContext().getDrawingBufferSize();let l=ri(t.top,8);const c=ri(t.left,8);n.flushing=!0;try{for(const e of n.queuedFramebuffers){const[n,i,o,s,u]=ii({framebuffer:e,targetWidth:a,targetHeight:A,topPx:l,leftPx:c,minimap:t.minimap});r.bindFramebuffer(36008,e.handle),r.bindFramebuffer(36009,null),r.blitFramebuffer(0,0,e.width,e.height,n,i,o,s,16384,9728),l+=u+8}}finally{r.bindFramebuffer(36008,o),r.bindFramebuffer(36009,s),n.flushing=!1}}(e,n,i))}function ii(e){const{framebuffer:t,targetWidth:n,targetHeight:i,topPx:r,leftPx:o}=e,s=Math.max(Math.floor(n/4),1),a=Math.max(Math.floor(i/4),1),A=Math.min(s/t.width,a/t.height),l=Math.max(Math.floor(t.width*A),1),c=Math.max(Math.floor(t.height*A),1),u=o,f=Math.max(i-r-c,0);return[u,f,u+l,f+c,c]}function ri(e,t){if(!e)return t;const n=Number.parseInt(e,10);return Number.isFinite(n)?n:t}function oi(e,t,n){if(e===t)return!0;if(!n||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!oi(e[i],t[i],n-1))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(const o of i){if(!t.hasOwnProperty(o))return!1;if(!oi(e[o],t[o],n-1))return!1}return!0}return!1}class si{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}mergeBufferLayouts(e,t){const n=[...e];for(const i of t){const e=n.findIndex(e=>e.name===i.name);e<0?n.push(i):n[e]=i}return n}getBufferIndex(e){const t=this.bufferLayouts.findIndex(t=>t.name===e);return-1===t&&ie.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}}function ai(e,t){let n=1/0;for(const i of e){const e=t[i];void 0!==e&&(n=Math.min(n,e))}return n}function Ai(e,t){if(!e||!t.some(e=>e.bindingLayout?.length))return e;const n={...e,bindings:e.bindings.map(e=>({...e}))};"attributes"in(e||{})&&(n.attributes=e?.attributes||[]);for(const i of t)for(const e of i.bindingLayout||[])for(const t of ci(e.name)){const i=n.bindings.find(e=>e.name===t);0===i?.group&&(i.group=e.group)}return n}function li(e){return Boolean(e.uniformTypes&&!function(e){for(const t in e)return!1;return!0}(e.uniformTypes))}function ci(e){const t=/* @__PURE__ */new Set([e,`${e}Uniforms`]);return e.endsWith("Uniforms")||t.add(`${e}Sampler`),[...t]}function ui(e,t={}){const n={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const r=e[i];var o;Object.prototype.hasOwnProperty.call(t,i)||(xt(o=r)||"number"==typeof o||"boolean"==typeof o)?n.uniforms[i]=r:n.bindings[i]=r}),n}class fi{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,t){Object.assign(this.options,t);const n=fe(Object.values(e).filter(bi));for(const i of n)e[i.name]=i;ie.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[i,r]of Object.entries(e))r&&(this._addModule(r),r.name&&i!==r.name&&!this.options.disableWarnings&&ie.warn(`Module name: ${i} vs ${r.name}`)())}destroy(){}setProps(e){for(const t of Object.keys(e)){const n=t,i=e[n]||{},r=this.modules[n];if(r){const e=this.moduleUniforms[n],t=this.moduleBindings[n],o=r.getUniforms?.(i,e)||i,{uniforms:s,bindings:a}=ui(o,r.uniformTypes);this.moduleUniforms[n]=hi(e,s,r.uniformTypes),this.moduleBindings[n]={...t,...a}}else this.options.disableWarnings||ie.warn(`Module ${t} not found`)()}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){const e={};for(const[t,n]of Object.entries(this.moduleUniforms))for(const[i,r]of Object.entries(n))e[`${t}.${i}`]={type:this.modules[t].uniformTypes?.[i],value:String(r)};return e}_addModule(e){const t=e.name;this.moduleUniforms[t]=hi({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[t]={}}}function hi(e={},t={},n={}){const i={...e};for(const[r,o]of Object.entries(t))void 0!==o&&(i[r]=di(e[r],o,n[r]));return i}function di(e,t,n){if(!n||"string"==typeof n)return pi(t);if(Array.isArray(n)){if(gi(t)||!Array.isArray(t))return pi(t);const i=Array.isArray(e)&&!gi(e)?[...e]:[],r=i.slice();for(let e=0;e<t.length;e++){const o=t[e];void 0!==o&&(r[e]=di(i[e],o,n[0]))}return r}if(!mi(t))return pi(t);const i=n,r=mi(e)?e:{},o={...r};for(const[s,a]of Object.entries(t))void 0!==a&&(o[s]=di(r[s],a,i[s]));return o}function pi(e){if(ArrayBuffer.isView(e))return Array.prototype.slice.call(e);if(Array.isArray(e)){if(gi(e))return e.slice();return e.map(e=>void 0===e?void 0:pi(e))}return mi(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,void 0===t?void 0:pi(t)])):e}function gi(e){return ArrayBuffer.isView(e)||Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function mi(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}function bi(e){return Boolean(e?.dependencies)}const yi={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function vi(e){return e?Array.isArray(e)?e[0]??null:e:null}function _i(e){if(he(e))return de(e);if("object"==typeof e&&"width"in e&&"height"in e)return{width:e.width,height:e.height};throw new Error("Unsupported mip-level data")}function Ci(e){return"object"==typeof e&&null!==e&&"data"in e&&"width"in e&&"height"in e}function xi(e){return ArrayBuffer.isView(e)}function wi(e){const{textureFormat:t,format:n}=e;if(t&&n&&t!==n)throw new Error(`Conflicting texture formats "${t}" and "${n}" provided for the same mip level`);return t??n}function Bi(e){const t=yi[e];if(void 0===t)throw new Error(`Invalid cube face: ${e}`);return t}function Mi(e,t){return 6*e+Bi(t)}function Si(e){throw new Error("setTexture1DData not supported in WebGL.")}function Ti(e,t,n,i){const r=(o=t,Array.isArray(o)?o:[o]);var o;const s=e,a=[];for(let A=0;A<r.length;A++){const e=r[A];if(he(e))a.push({type:"external-image",image:e,z:s,mipLevel:A});else if(Ci(e))a.push({type:"texture-data",data:e,textureFormat:wi(e),z:s,mipLevel:A});else{if(!xi(e)||!n)throw new Error("Unsupported 2D mip-level payload");a.push({type:"texture-data",data:{data:e,width:Math.max(1,n.width>>A),height:Math.max(1,n.height>>A),...i?{format:i}:{}},textureFormat:i,z:s,mipLevel:A})}}return a}function Ei(e){const t=[];for(let n=0;n<e.length;n++)t.push(...Ti(n,e[n]));return t}function Pi(e){const t=[];for(let n=0;n<e.length;n++)t.push(...Ti(n,e[n]));return t}function Ii(e){const t=[];for(const[n,i]of Object.entries(e)){const e=Bi(n);t.push(...Ti(e,i))}return t}function Li(e){const t=[];return e.forEach((e,n)=>{for(const[i,r]of Object.entries(e)){const e=Mi(n,i);t.push(...Ti(e,r))}}),t}class Ri{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(){const e=this._texture?.width??this.props.width??"?",t=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${t}px:(${this.isReady?"ready":"loading..."})`}constructor(e,t){this.device=e;const n=Zn("dynamic-texture"),i=t;this.props={...Ri.defaultProps,id:n,...t,data:null},this.id=this.props.id,this.ready=new Promise((e,t)=>{this.resolveReady=e,this.rejectReady=t}),this.initAsync(i)}async initAsync(e){try{const t=await this._loadAllData(e);this._checkNotDestroyed();const n=t.data?function(e){if(!e.data)return[];const t=e.width&&e.height?{width:e.width,height:e.height}:void 0,n="format"in e?e.format:void 0;switch(e.dimension){case"1d":return Si();case"2d":return Ti(0,e.data,t,n);case"3d":return Ei(e.data);case"2d-array":return Pi(e.data);case"cube":return Ii(e.data);case"cube-array":return Li(e.data);default:throw new Error(`Unhandled dimension ${e.dimension}`)}}({...t,width:e.width,height:e.height,format:e.format}):[],i="format"in e&&void 0!==e.format,r="usage"in e&&void 0!==e.usage,o=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};const e=function(e){const{dimension:t,data:n}=e;if(!n)return null;switch(t){case"1d":{const e=vi(n);if(!e)return null;const{width:t}=_i(e);return{width:t,height:1}}case"2d":{const e=vi(n);return e?_i(e):null}case"3d":case"2d-array":{if(!Array.isArray(n)||0===n.length)return null;const e=vi(n[0]);return e?_i(e):null}case"cube":{const e=Object.keys(n)[0]??null;if(!e)return null;const t=vi(n[e]);return t?_i(t):null}case"cube-array":{if(!Array.isArray(n)||0===n.length)return null;const e=n[0],t=Object.keys(e)[0]??null;if(!t)return null;const i=vi(e[t]);return i?_i(i):null}default:return null}}(t);return e||{width:this.props.width||1,height:this.props.height||1}})();if(!o||o.width<=0||o.height<=0)throw new Error(`${this} size could not be determined or was zero`);const s=function(e,t,n,i){if(0===t.length)return{subresources:t,mipLevels:1,format:i.format,hasExplicitMipChain:!1};const r=/* @__PURE__ */new Map;for(const c of t){const e=r.get(c.z)??[];e.push(c),r.set(c.z,e)}const o=t.some(e=>e.mipLevel>0);let s=i.format,a=Number.POSITIVE_INFINITY;const A=[];for(const[c,u]of r){const t=[...u].sort((e,t)=>e.mipLevel-t.mipLevel),i=t[0];if(!i||0!==i.mipLevel)throw new Error(`DynamicTexture: slice ${c} is missing mip level 0`);const r=Oi(e,i);if(r.width!==n.width||r.height!==n.height)throw new Error(`DynamicTexture: slice ${c} base level dimensions ${r.width}x${r.height} do not match expected ${n.width}x${n.height}`);const o=Fi(i);if(o){if(s&&s!==o)throw new Error(`DynamicTexture: slice ${c} base level format "${o}" does not match texture format "${s}"`);s=o}const l=s&&e.isTextureFormatCompressed(s)?Di(e,r.width,r.height,s):e.getMipLevelCount(r.width,r.height);let f=0;for(let n=0;n<t.length;n++){const i=t[n];if(!i||i.mipLevel!==n)break;if(n>=l)break;const o=Oi(e,i),a=Math.max(1,r.width>>n),c=Math.max(1,r.height>>n);if(o.width!==a||o.height!==c)break;const u=Fi(i);if(u&&(s||(s=u),u!==s))break;f++,A.push(i)}a=Math.min(a,f)}const l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:A.filter(e=>e.mipLevel<l),mipLevels:l,format:s,hasExplicitMipChain:o}}(this.device,n,o,{format:i?e.format:void 0}),a=s.format??this.props.format,A={...this.props,...o,format:a,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(a)&&!r&&(A.usage=pe.SAMPLE|pe.COPY_DST);const l=this.props.mipmaps&&!s.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(a);if("webgpu"===this.device.type&&l){const e="3d"===this.props.dimension?pe.SAMPLE|pe.STORAGE|pe.COPY_DST|pe.COPY_SRC:pe.SAMPLE|pe.RENDER|pe.COPY_DST|pe.COPY_SRC;A.usage|=e}const c=this.device.getMipLevelCount(A.width,A.height),u=s.hasExplicitMipChain?s.mipLevels:"auto"===this.props.mipLevels?c:Math.max(1,Math.min(c,this.props.mipLevels??1)),f={...A,mipLevels:u};this._texture=this.device.createTexture(f),this._sampler=this.texture.sampler,this._view=this.texture.view,s.subresources.length&&this._setTextureSubresources(s.subresources),!this.props.mipmaps||s.hasExplicitMipChain||l||ie.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),l&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),ie.info(0,`${this} created`)()}catch(t){const e=t instanceof Error?t:new Error(String(t));this.rejectReady(e)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){"webgl"===this.device.type?this.texture.generateMipmapsWebGL():"webgpu"===this.device.type?this.device.generateMipmapsWebGPU(this.texture):ie.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();const t=e instanceof ge?e:this.device.createSampler(e);this.texture.setSampler(t),this._sampler=t}async readBuffer(e={}){this.isReady||await this.ready;const t=e.width??this.texture.width,n=e.height??this.texture.height,i=e.depthOrArrayLayers??this.texture.depth,r=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:i}),o=this.device.createBuffer({byteLength:r.byteLength,usage:re.COPY_DST|re.MAP_READ});this.texture.readBuffer({...e,width:t,height:n,depthOrArrayLayers:i},o);const s=this.device.createFence();return await s.signaled,s.destroy(),o}async readAsync(e={}){this.isReady||await this.ready;const t=e.width??this.texture.width,n=e.height??this.texture.height,i=e.depthOrArrayLayers??this.texture.depth,r=this.texture.computeMemoryLayout({width:t,height:n,depthOrArrayLayers:i}),o=await this.readBuffer(e),s=await o.readAsync(0,r.byteLength);return o.destroy(),s.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;const t=this.texture;return this._texture=t.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,t.destroy(),ie.info(`${this} resized`),!0}getCubeFaceIndex(e){const t=yi[e];if(void 0===t)throw new Error(`Invalid cube face: ${e}`);return t}getCubeArrayFaceIndex(e,t){return 6*e+this.getCubeFaceIndex(t)}setTexture1DData(e){if(this._checkReady(),"1d"!==this.texture.props.dimension)throw new Error(`${this} is not 1d`);const t=Si();this._setTextureSubresources(t)}setTexture2DData(e,t=0){if(this._checkReady(),"2d"!==this.texture.props.dimension)throw new Error(`${this} is not 2d`);const n=Ti(t,e);this._setTextureSubresources(n)}setTexture3DData(e){if("3d"!==this.texture.props.dimension)throw new Error(`${this} is not 3d`);const t=Ei(e);this._setTextureSubresources(t)}setTextureArrayData(e){if("2d-array"!==this.texture.props.dimension)throw new Error(`${this} is not 2d-array`);const t=Pi(e);this._setTextureSubresources(t)}setTextureCubeData(e){if("cube"!==this.texture.props.dimension)throw new Error(`${this} is not cube`);const t=Ii(e);this._setTextureSubresources(t)}setTextureCubeArrayData(e){if("cube-array"!==this.texture.props.dimension)throw new Error(`${this} is not cube-array`);const t=Li(e);this._setTextureSubresources(t)}_setTextureSubresources(e){for(const t of e){const{z:e,mipLevel:n}=t;switch(t.type){case"external-image":const{image:i,flipY:r}=t;this.texture.copyExternalImage({image:i,z:e,mipLevel:n,flipY:r});break;case"texture-data":const{data:o,textureFormat:s}=t;if(s&&s!==this.texture.format)throw new Error(`${this} mip level ${n} uses format "${s}" but texture format is "${this.texture.format}"`);this.texture.writeData(o.data,{x:0,y:0,z:e,width:o.width,height:o.height,depthOrArrayLayers:1,mipLevel:n});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){const t=await Ni(e.data);return{dimension:e.dimension??"2d",data:t??null}}_checkNotDestroyed(){this.destroyed&&ie.warn(`${this} already destroyed`)}_checkReady(){this.isReady||ie.warn(`${this} Cannot perform this operation before ready`)}static defaultProps={...pe.defaultProps,dimension:"2d",data:null,mipmaps:!1}}function Fi(e){if("texture-data"===e.type)return e.textureFormat??wi(e.data)}function Oi(e,t){switch(t.type){case"external-image":return e.getExternalImageSize(t.image);case"texture-data":return{width:t.data.width,height:t.data.height};default:throw new Error("Unsupported texture subresource")}}function Di(e,t,n,i){const{blockWidth:r=1,blockHeight:o=1}=e.getTextureFormatInfo(i);let s=1;for(let a=1;;a++){const e=Math.max(1,t>>a),i=Math.max(1,n>>a);if(e<r||i<o)break;s++}return s}async function Ni(e){if(e=await e,Array.isArray(e))return await Promise.all(e.map(Ni));if(e&&"object"==typeof e&&e.constructor===Object){const t=e,n=await Promise.all(Object.values(t).map(Ni)),i=Object.keys(t),r={};for(let e=0;e<i.length;e++)r[i[e]]=n[e];return r}return e}const Ui="render pipeline initialization failed";class ki{static defaultProps={...e.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:me.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};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,t){this.props={...ki.defaultProps,...t},t=this.props,this.id=t.id||Zn("model"),this.device=e,Object.assign(this.userData,t.userData),this.material=t.material||null;const n=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]),i=t.shaderInputs||new fi(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);const r=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(e),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];this.props.shaderLayout=Ai(this.props.shaderLayout,o)||null;if("webgpu"===this.device.type&&this.props.source){const{source:t,getUniforms:n,bindingTable:i}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:r,...this.props,modules:o});this.source=t,this._getModuleUniforms=n,this._bindingTable=i;const s=e.getShaderLayout?.(this.source);this.props.shaderLayout=Ai(this.props.shaderLayout||s||null,o)||null}else{const{vs:e,fs:t,getUniforms:n}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:r,...this.props,modules:o});this.vs=e,this.fs=t,this._getModuleUniforms=n,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,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||un.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||fn.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 t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.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");const 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){const t=this._areBindingsLoading();if(t)return ie.info(2,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n,i=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),i=this.pipeline.isErrored,i)ie.info(2,`>>> DRAWING ABORTED ${this.id}: ${Ui}`)(),n=!1;else{const t=this._getBindings(),i=this._getBindGroups(),{indexBuffer:r}=this.vertexArray,o=r?r.byteLength/("uint32"===r.indexType?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,bindings:t,bindGroups:i,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw=i?Ui:"waiting for resource initialization",n}setGeometry(e){this._gpuGeometry?.destroy();const t=e&&ei(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");const e=new si(this.bufferLayout);this.bufferLayout=e.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const t=new si(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.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){oi(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Mn(this.device,this.shaderInputs.modules);for(const[t,n]of Object.entries(this.shaderInputs.modules))if(li(n)&&!this.material?.ownsModule(t)){const e=this._uniformStore.getManagedUniformBuffer(t);this.bindings[`${t}Uniforms`]=e}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,t){const n=t?.disableWarnings??this.props.disableWarnings;e.indices&&ie.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=function(e,t){const n=Object.fromEntries(e.attributes.map(e=>[e.name,e.location])),i=t.slice();return i.sort((e,t)=>{const i=e.attributes?e.attributes.map(e=>e.attribute):[e.name],r=t.attributes?t.attributes.map(e=>e.attribute):[t.name];return ai(i,n)-ai(r,n)}),i}(this.pipeline.shaderLayout,this.bufferLayout);const i=new si(this.bufferLayout);for(const[r,o]of Object.entries(e)){const e=i.getBufferLayout(r);if(!e){n||ie.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const t=i.getAttributeNamesForBuffer(e);let s=!1;for(const n of t){const e=this._attributeInfos[n];if(e){const t="webgpu"===this.device.type?i.getBufferIndex(e.bufferName):e.location;this.vertexArray.setBuffer(t,o),s=!0}}s||n||ie.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[n,i]of Object.entries(e)){const e=this._attributeInfos[n];e?this.vertexArray.setConstantWebGL(e.location,i):(t?.disableWarnings??this.props.disableWarnings)||ie.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(const e of Object.values(this.bindings))if(e instanceof Ri&&!e.isReady)return e.id;for(const e of Object.values(this.material?.bindings||{}))if(e instanceof Ri&&!e.isReady)return e.id;return!1}_getBindings(){const e={};for(const[t,n]of Object.entries(this.bindings))n instanceof Ri?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindGroups(){const e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},t=e.bindings.length?s(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return t;for(const[n,i]of Object.entries(this.material.getBindingsByGroup())){const e=Number(n);t[e]={...t[e]||{},...i}}return t}_getBindGroupCacheKeys(){const e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof a?e=Math.max(e,t.texture.updateTimestamp):t instanceof re||t instanceof pe?e=Math.max(e,t.updateTimestamp):t instanceof Ri?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof ge||(e=Math.max(e,t.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){const t={...e.attributes};for(const[n]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(e=>e.name===n)||"positions"===n||delete t[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(ie.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let i=null;this.source?i=n:this.fs&&(i=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:n,fs:i}),this._attributeInfos=A(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&t!==e&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=ie.level>3?0:1e4;ie.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,ie.group(2,`>>> DRAWING MODEL ${this.id}`,{collapsed:ie.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){const t={},n="Values";if(0===e.attributes.length&&!e.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(const i of e.attributes)i&&(t[`in ${i.location} ${i.name}: ${i.type}`]={[n]:i.stepMode||"vertex"});for(const i of e.varyings||[])t[`out ${i.location} ${i.name}`]={[n]:JSON.stringify(i)};return t}(this.pipeline.shaderLayout,this.id);ie.table(2,e)();const t=this.shaderInputs.getDebugTable();ie.table(2,t)();const n=this._getAttributeDebugTable();ie.table(2,this._attributeInfos)(),ie.table(2,n)(),ie.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;const n=e.props.framebuffer;ni(e,n,{id:n?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[t,n]of Object.entries(this._attributeInfos)){const i=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:t}=this.vertexArray,n="uint32"===t.indexType?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){const n=be.getTypedArrayConstructor(t);return(e instanceof re?new n(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;const t={};for(const[n,i]of Object.entries(e))this.material.ownsBinding(n)||(t[n]=i);return t}}const Gi=3;class zi{device;modules;_materialBindingNames;_materialModuleNames;constructor(e,t={}){this.device=e,this.modules=t.modules||[];const n=new fi(Object.fromEntries(this.modules.map(e=>[e.name,e])));this._materialBindingNames=function(e){const t=/* @__PURE__ */new Set;for(const n of Object.values(e.modules))for(const e of n.bindingLayout||[])3===e.group&&t.add(e.name);return t}(n),this._materialModuleNames=function(e){const t=/* @__PURE__ */new Set;for(const n of Object.values(e.modules))n.name&&n.bindingLayout?.some(e=>3===e.group&&e.name===n.name)&&t.add(n.name);return t}(n)}createMaterial(e={}){return new Hi(this.device,{...e,factory:this})}getBindingNames(){return Array.from(this._materialBindingNames)}ownsBinding(e){if(this._materialBindingNames.has(e))return!0;const t=Vi(e);return!!t&&this._materialModuleNames.has(t)}ownsModule(e){return this._materialModuleNames.has(e)}getBindingsByGroup(e){return Object.keys(e).length>0?{[Gi]:e}:{}}}function Vi(e){return e.endsWith("Uniforms")?e.slice(0,-8):null}class Hi{id;device;factory;shaderInputs;bindings={};_uniformStore;_bindGroupCacheToken={};constructor(e,t={}){this.id=t.id||Zn("material"),this.device=e,this.factory=t.factory||new zi(e,{modules:t.modules||t.shaderInputs?.getModules()||[]});const n=Object.fromEntries((t.shaderInputs?.getModules()||this.factory.modules).map(e=>[e.name,e]));this.shaderInputs=t.shaderInputs||new fi(n),this._uniformStore=new Mn(this.device,this.shaderInputs.modules);for(const[i,r]of Object.entries(this.shaderInputs.modules))if(this.ownsModule(i)&&li(r)){const e=this._uniformStore.getManagedUniformBuffer(i);this.bindings[`${i}Uniforms`]=e}this.updateShaderInputs(),t.bindings&&this._replaceOwnedBindings(t.bindings)}destroy(){this._uniformStore.destroy()}clone(e={}){const t=this.factory.createMaterial({id:e.id,shaderInputs:e.shaderInputs,bindings:{...this.getResourceBindings(),...e.bindings}});return e.shaderInputs||t.setProps(this.shaderInputs.getUniformValues()),e.moduleProps&&t.setProps(e.moduleProps),t}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(){const e={};for(const[t,n]of Object.entries(this.bindings))Vi(t)||(e[t]=n);return e}getBindings(){const e={},t=e;for(const[n,i]of Object.entries(this.bindings))i instanceof Ri?i.isReady&&(t[n]=i.texture):t[n]=i;return e}getBindingsByGroup(){return this.factory.getBindingsByGroup(this.getBindings())}getBindGroupCacheKey(e){return 3===e?this._bindGroupCacheToken:null}getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof a?e=Math.max(e,t.texture.updateTimestamp):t instanceof re||t instanceof pe?e=Math.max(e,t.updateTimestamp):t instanceof Ri?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof ge||(e=Math.max(e,t.buffer.updateTimestamp));return e}_replaceOwnedBindings(e){this._setOwnedBindings(e)&&(this._bindGroupCacheToken={})}_setOwnedBindings(e){let t=!1;for(const[n,i]of Object.entries(e))void 0!==i&&this.ownsBinding(n)&&this.bindings[n]!==i&&(this.bindings[n]=i,t=!0);return t}}class ji{device;model;transformFeedback;static defaultProps={...ki.defaultProps,outputs:void 0,feedbackBuffers:void 0};static isSupported(e){return"webgl"===e?.info?.type}constructor(e,t=ji.defaultProps){if(!ji.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new ki(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||St(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.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);const t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof re)return t.readAsync();const{buffer:n,byteOffset:i=0,byteLength:r=n.byteLength}=t;return n.readAsync(i,r)}}class Qi{id;topology;vertexCount;indices;attributes;userData={};constructor(e){const{attributes:t={},indices:n=null,vertexCount:i=null}=e;this.id=e.id||Zn("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(const[r,o]of Object.entries(t)){const e=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(e.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if("POSITION"!==r&&"positions"!==r||e.size||(e.size=3),"indices"===r){if(this.indices)throw new Error("Multiple indices detected");this.indices=e}else this.attributes[r]=e}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||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,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(const i of Object.values(e)){const{value:e,size:t,constant:r}=i;!r&&e&&void 0!==t&&t>=1&&(n=Math.min(n,e.length/t))}return n}}function Ji(e,t){if(!e)throw new Error(t)}class Ki{id;matrix=new ee;display=!0;position=new ye;rotation=new ye;scale=new ye(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||Zn(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 Ji(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return Ji(3===e.length||4===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return Ji(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:t,rotation:n,scale:i,update:r=!0}=e;return t&&this.setPosition(t),n&&this.setRotation(n),i&&this.setScale(i),r&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),4===this.rotation.length){const e=(new ee).fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:t,scale:n}={}){return e&&this.setPosition(e),t&&this.setRotation(t),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,t){t=t||this.matrix;const n=new ee(e).multiplyRight(t),i=n.invert(),r=i.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:n,worldInverseMatrix:i,worldInverseTransposeMatrix:r}}_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)}}class Wi extends Ki{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;ie.assert(t.every(e=>e instanceof Ki),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:n})=>{const i=t.getBounds();if(!i)return;const[r,o]=i,s=new ye(r).add(o).divide([2,2,2]);n.transformAsPoint(s,s);const a=new ye(o).subtract(r).divide([2,2,2]);n.transformAsVector(a,a);for(let A=0;A<8;A++){const t=new ye(1&A?-1:1,2&A?-1:1,4&A?-1:1).multiply(a).add(s);for(let n=0;n<3;n++)e[0][n]=Math.min(e[0][n],t[n]),e[1][n]=Math.max(e[1][n],t[n])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){const t=this.children,n=t.indexOf(e);return n>-1&&t.splice(n,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new ee}={}){const n=new ee(t).multiplyRight(this.matrix);for(const i of this.children)i instanceof Wi?i.traverse(e,{worldMatrix:n}):e(i,{worldMatrix:n})}preorderTraversal(e,{worldMatrix:t=new ee}={}){const n=new ee(t).multiplyRight(this.matrix);e(this,{worldMatrix:n});for(const i of this.children)i instanceof Wi?i.preorderTraversal(e,{worldMatrix:n}):e(i,{worldMatrix:n})}}class qi extends Ki{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)}}const Yi=be.getDataType.bind(be);function Xi(e,t,n){if(t.size>4)return null;const i="webgpu"===n&&"uint8"===t.type?"unorm8":t.type;return{attribute:e,format:t.size>1?`${i}x${t.size}`:t.type,byteOffset:t.offset||0}}function Zi(e){return e.stride||e.size*e.bytesPerElement}function $i(e,t){t.offset&&Ce.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const n=Zi(e),i=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*n+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:i,stride:n}}class er{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;const i=t.logicalType||t.type,r="float64"===i;let o,{defaultValue:s}=t;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0),o=r?"float32":!i&&t.isIndexed?"uint32":i||"float32";let a=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return l(e)}}(i||o);this.doublePrecision=r,r&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:s,logicalType:i,type:o,normalized:o.includes("norm"),size:this.size,bytesPerElement:a.BYTES_PER_ELEMENT},this.state={...n,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(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Zi(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),ve.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){const n={};if(this.state.constant){const i=this.value;if(t){const r=$i(this.getAccessor(),t),o=r.offset/i.BYTES_PER_ELEMENT,s=r.size||this.size;n[e]=i.subarray(o,o+s)}else n[e]=i}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){const n=this.getAccessor(),i=[],r={name:this.id,byteStride:Zi(n)};if(this.doublePrecision){const r=function(e,t){const n=$i(e,t);return{high:n,low:{...n,offset:n.offset+4*e.size}}}(n,t||{});i.push(Xi(e,{...n,...r.high},this.device.type),Xi(`${e}64Low`,{...n,...r.low},this.device.type))}else if(t){const r=$i(n,t);i.push(Xi(e,{...n,...r},this.device.type))}else i.push(Xi(e,n,this.device.type));return r.attributes=i.filter(Boolean),r}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){const t=Array.from(this.value);e=[t,t]}else{const{value:t,numInstances:n,size:i}=this,r=n*i;if(t&&r&&t.length>=r){const n=new Array(i).fill(1/0),o=new Array(i).fill(-1/0);for(let e=0;e<r;)for(let r=0;r<i;r++){const i=t[e++];i<n[r]&&(n[r]=i),i>o[r]&&(o[r]=i)}e=[n,o]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let n;n=ArrayBuffer.isView(e)?{value:e}:e instanceof re?{buffer:e}:e;const i={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type){if(this.doublePrecision&&n.value instanceof Float64Array)i.type="float32";else{const e=Yi(n.value);i.type=i.normalized?e.replace("int","norm"):e}}i.bytesPerElement=n.value.BYTES_PER_ELEMENT,i.stride=Zi(i)}if(t.bounds=null,n.constant){let e=n.value;e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e));if(!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(n.buffer){const e=n.buffer;t.externalBuffer=e,t.constant=!1,this.value=n.value||null}else if(n.value){this._checkExternalBuffer(n);let e=n.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:r}=this;const o=Zi(i),s=(i.vertexOffset||0)*o;if(this.doublePrecision&&e instanceof Float64Array&&(e=_e(e,i)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const a=e.byteLength+s+2*o;(!r||r.byteLength<a)&&(r=this._createBuffer(a)),r.write(e,s)}return this.setAccessor(i),!0}updateSubBuffer(e={}){this.state.bounds=null;const t=this.value,{startOffset:n=0,endOffset:i}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?_e(t,{size:this.size,startIndex:n,endIndex:i}):t.subarray(n,i),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){const{state:n}=this,i=n.allocatedValue,r=ve.allocate(i,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=r;const{byteOffset:o}=this;let{buffer:s}=this;return(!s||s.byteLength<r.byteLength+o)&&(s=this._createBuffer(r.byteLength+o),t&&i&&s.write(i instanceof Float64Array?_e(i,this):i,o)),n.allocatedValue=r,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){const{value:t}=e;if(!ArrayBuffer.isView(t))throw new Error(`Attribute ${this.id} value is not TypedArray`);const n=this.settings.defaultType;let i=!1;if(this.doublePrecision&&(i=t.BYTES_PER_ELEMENT<4),i)throw new Error(`Attribute ${this.id} does not support ${t.constructor.name}`);t instanceof n||!this.settings.normalized||"normalized"in e||Ce.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(e=>(e+128)/255*2-1);case"snorm16":return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(e=>e/255);case"unorm16":return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,n){const{defaultValue:i,size:r}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let e=r;for(;--e>=0;)t[n+e]=i[e];return t}switch(r){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:i[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:i[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:i[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:i[0];break;default:let o=r;for(;--o>=0;)t[n+o]=Number.isFinite(e[o])?e[o]:i[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:n}=this;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();const{isIndexed:t,type:n}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?re.INDEX:re.VERTEX)|re.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}}const tr=[],nr=[];function ir(e,t=0,n=1/0){let i=tr;const r={index:-1,data:e,target:[]};return e?"function"==typeof e[Symbol.iterator]?i=e:e.length>0&&(nr.length=e.length,i=nr):i=tr,(t>0||Number.isFinite(n))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(t,n),r.index=t-1),{iterable:i,objectInfo:r}}function rr(e){return e&&e[Symbol.asyncIterator]}function or(e,t){const{size:n,stride:i,offset:r,startIndices:o,nested:s}=t,a=e.BYTES_PER_ELEMENT,A=i?i/a:n,l=r?r/a:0,c=Math.floor((e.length-l)/A);return(t,{index:i,target:r})=>{if(!o){const t=i*A+l;for(let i=0;i<n;i++)r[i]=e[t+i];return r}const a=o[i],u=o[i+1]||c;let f;if(s){f=new Array(u-a);for(let t=a;t<u;t++){const i=t*A+l;r=new Array(n);for(let t=0;t<n;t++)r[t]=e[i+t];f[t-a]=r}}else if(A===n)f=e.subarray(a*n+l,u*n+l);else{f=new e.constructor((u-a)*n);let t=0;for(let i=a;i<u;i++){const r=i*A+l;for(let i=0;i<n;i++)f[t++]=e[r+i]}}return f}}const sr=[],ar=[[0,1/0]];const Ar={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function lr(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const n=e.type||"interpolation";return{...Ar[n],...t,...e,type:n}}class cr extends er{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:ar}),this.constant=!1,this.settings.update=t.update||(t.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}={}){const t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t,n,i;(t=this.state).layoutChanged||(t.layoutChanged=(n=e,i=this.getAccessor(),!(n.type===i.type&&n.size===i.size&&Zi(n)===Zi(i)&&(n.offset||0)===(i.offset||0)))),super.setAccessor(e)}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat("function"!=typeof e&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:t}=this.settings,n=this.settings.transition;return lr(Array.isArray(t)?e[t.find(t=>e[t])]:e[t],n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){const{startRow:e=0,endRow:n=1/0}=t;this.state.updateRanges=function(e,t){if(e===ar)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const n=[],i=e.length;let r=0;for(let o=0;o<i;o++){const i=e[o];i[1]<t[0]?(n.push(i),r=o+1):i[0]>t[1]?n.push(i):t=[Math.min(i[0],t[0]),Math.max(i[1],t[1])]}return n.splice(r,0,t),n}(this.state.updateRanges,[e,n])}else this.state.updateRanges=ar}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=sr}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:n}=this;return!n.noAlloc&&(!!n.update&&(super.allocate(e,t.updateRanges!==ar),!0))}updateBuffer({numInstances:e,data:t,props:n,context:i}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:o,noAlloc:s}}=this;let a=!0;if(o){for(const[s,a]of r)o.call(i,this,{data:t,startRow:s,endRow:a,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(i,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(const[t,n]of r){const i=Number.isFinite(t)?this.getVertexOffset(t):0,r=Number.isFinite(n)?this.getVertexOffset(n):s||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:i,endOffset:r})}else;this._checkAttributeArray()}else a=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),a}setConstantValue(e,t){if(void 0===t||"function"==typeof t)return!1;const n=this.settings.transform&&e?this.settings.transform.call(e,t):t;if("webgpu"===this.device.type)return this.setConstantBufferValue(n,this.numInstances);return this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setConstantBufferValue(e,t){const n=this.settings.defaultType,i=this._normalizeValue(e,new n(this.size),0);if(this._hasConstantBufferValue(i,t))return this.constant=!1,this.clearNeedsUpdate(),!1;const r=new n(Math.max(t,1)*this.size);for(let s=0;s<r.length;s+=this.size)r.set(i,s);const o=this.setData({value:r});return this.constant=!1,this.clearNeedsUpdate(),o&&this.setNeedsRedraw(),o}_hasConstantBufferValue(e,t){const n=this.value,i=Math.max(t,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==i||n.length%this.size!==0)return!1;for(let r=0;r<n.length;r+=this.size)for(let t=0;t<this.size;t++)if(n[r+t]!==e[t])return!1;return!0}setExternalBuffer(e){const{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e||(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){const{state:n,settings:i}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(i.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;n.binaryValue=e,this.setNeedsRedraw();if(i.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const r=e;xe(ArrayBuffer.isView(r.value),`invalid ${i.accessor}`);const o=Boolean(r.size)&&r.size!==this.size;return n.binaryAccessor=or(r.value,{size:r.size||this.size,stride:r.stride,offset:r.offset,startIndices:t,nested:o}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){const{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){const e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(const n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;const t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:i}=this.settings;if(n.stepMode="dynamic"===i?e?e.isInstanced?"instance":"vertex":"instance":i??"vertex",!t)return n;for(const r in t){const e=super._getBufferLayout(r,t[r]);n.attributes.push(...e.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:i,props:r,numInstances:o}){const{settings:s,state:a,value:A,size:l,startIndices:c}=e,{accessor:u,transform:f}=s,h=a.binaryAccessor||("function"==typeof u?u:r[u]);xe("function"==typeof h,`accessor "${u}" is not a function`);let d=e.getVertexOffset(n);const{iterable:p,objectInfo:g}=ir(t,n,i);for(const m of p){g.index++;let t=h(m,g);if(f&&(t=f.call(this,t)),c){const n=(g.index<c.length-1?c[g.index+1]:o)-c[g.index];if(t&&Array.isArray(t[0])){let n=d;for(const i of t)e._normalizeValue(i,A,n),n+=l}else t&&t.length>l?A.set(t,d):(e._normalizeValue(t,g.target,0),we({target:A,source:g.target,start:d,count:n}));d+=n*l}else e._normalizeValue(t,A,d),d+=l}}_validateAttributeUpdaters(){const{settings:e}=this;if(!(e.noAlloc||"function"==typeof e.update))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n=n&&Number.isFinite(e[3]);case 3:n=n&&Number.isFinite(e[2]);case 2:n=n&&Number.isFinite(e[1]);case 1:n=n&&Number.isFinite(e[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function ur(e){const{source:t,target:n,start:i=0,size:r,getData:o}=e,s=e.end||n.length,a=t.length,A=s-i;if(a>A)return void n.set(t.subarray(0,A),i);if(n.set(t,i),!o)return;let l=a;for(;l<A;){const e=o(l,t);for(let t=0;t<r;t++)n[i+l]=e[t]||0,l++}}function fr(e){switch(e){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 "${e}"`)}}function hr(e){switch(e){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function dr(e){e.push(e.shift())}function pr({device:e,source:t,target:n}){return(!n||n.byteLength<t.byteLength)&&(n?.destroy(),n=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),n}function gr({device:e,buffer:t,attribute:n,fromLength:i,toLength:r,fromStartIndices:o,getData:s=e=>e}){const a=n.doublePrecision&&n.value instanceof Float64Array?2:1,A=n.size*a,l=n.byteOffset,c=n.settings.bytesPerElement<4?l/n.settings.bytesPerElement*4:l,u=n.startIndices,f=o&&u,h=n.isConstant;if(!f&&t&&i>=r)return t;const d=n.value instanceof Float64Array?Float32Array:n.value.constructor,p=h?n.value:new d(n.getBuffer().readSyncWebGL(l,r*d.BYTES_PER_ELEMENT).buffer);if(n.settings.normalized&&!h){const e=s;s=(t,i)=>n.normalizeConstant(e(t,i))}const g=h?(e,t)=>s(p,t):(e,t)=>s(p.subarray(e+l,e+l+A),t),m=t?new Float32Array(t.readSyncWebGL(c,4*i).buffer):new Float32Array(0),b=new Float32Array(r);return function({source:e,target:t,size:n,getData:i,sourceStartIndices:r,targetStartIndices:o}){if(!r||!o)return ur({source:e,target:t,size:n,getData:i}),t;let s=0,a=0;const A=i&&((e,t)=>i(e+a,t)),l=Math.min(r.length,o.length);for(let c=1;c<l;c++){const i=r[c]*n,l=o[c]*n;ur({source:e.subarray(s,i),target:t,start:a,end:l,size:n,getData:A}),s=i,a=l}a<t.length&&ur({source:[],target:t,start:a,size:n,getData:A})}({source:m,target:b,sourceStartIndices:o,targetStartIndices:u,size:A,getData:g}),(!t||t.byteLength<b.byteLength+c)&&(t?.destroy(),t=e.createBuffer({byteLength:b.byteLength+c,usage:35050})),t.write(b,c),t}class mr{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new Be(n),this.attribute=t,this.attributeInTransition=function(e){const{device:t,settings:n,value:i}=e,r=new cr(t,n);return r.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:n.normalized}),r}(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=function(e,t){const{doublePrecision:n,settings:i,value:r,size:o}=e,s=n&&r instanceof Float64Array?2:1;let a=0;const{shaderAttributes:A}=e.settings;if(A)for(const l of Object.values(A))a=Math.max(a,l.vertexOffset??0);return(i.noAlloc?r.length:(t+a)*o)*s}(this.attribute,t),this.transition.start({...e,duration:n})}update(){const 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(const e of this.buffers)e.destroy();this.buffers.length=0}}const br={name:"interpolation",vs:"layout(std140) uniform interpolationUniforms {\n float time;\n} interpolation;\n",uniformTypes:{time:"f32"}},yr="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, interpolation.time);\n gl_Position = vec4(0.0);\n}\n",vr="#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aFrom64Low;\nin ATTRIBUTE_TYPE aTo;\nin ATTRIBUTE_TYPE aTo64Low;\nout ATTRIBUTE_TYPE vCurrent;\nout ATTRIBUTE_TYPE vCurrent64Low;\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid main(void) {\n for (int i=0; i<ATTRIBUTE_SIZE; i++) {\n vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time);\n vCurrent[i] = value.x;\n vCurrent64Low[i] = value.y;\n }\n gl_Position = vec4(0.0);\n}\n";function _r(e){return e.doublePrecision&&e.value instanceof Float64Array}const Cr={name:"spring",vs:"layout(std140) uniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n",uniformTypes:{damping:"f32",stiffness:"f32"}},xr="#version 300 es\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nin ATTRIBUTE_TYPE aPrev;\nin ATTRIBUTE_TYPE aCur;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vNext;\nout float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE force = delta * spring.stiffness;\n ATTRIBUTE_TYPE resistance = velocity * spring.damping;\n return force - resistance + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n",wr="#version 300 es\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nin float vIsTransitioningFlag;\n\nout vec4 fragColor;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n fragColor = vec4(1.0);\n}";const Br={interpolation:class extends mr{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="interpolation",this.transform=function(e,t){const n=t.size,i=fr(n),r=hr(n),o=t.getBufferLayout();if(_r(t))return new ji(e,{vs:vr,bufferLayout:[{name:"aFrom",byteStride:8*n,attributes:[{attribute:"aFrom",format:r,byteOffset:0},{attribute:"aFrom64Low",format:r,byteOffset:4*n}]},{name:"aTo",byteStride:8*n,attributes:[{attribute:"aTo",format:r,byteOffset:0},{attribute:"aTo64Low",format:r,byteOffset:4*n}]}],modules:[on,br],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:n},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0});return new ji(e,{vs:yr,bufferLayout:[{name:"aFrom",format:r},{name:"aTo",format:o.attributes[0].format}],modules:[br],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}(e,t)}start(e,t){const n=this.currentLength,i=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0)return void this.transition.cancel();const{buffers:r,attribute:o}=this;dr(r),r[0]=gr({device:this.device,buffer:r[0],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:e.enter}),r[1]=pr({device:this.device,source:r[0],target:r[1]}),this.setBuffer(r[1]);const{transform:s}=this,a=s.model;let A=Math.floor(this.currentLength/o.size);_r(o)&&(A/=2),a.setVertexCount(A),o.isConstant?(a.setAttributes({aFrom:r[0]}),a.setConstantAttributes({aTo:o.value})):a.setAttributes({aFrom:r[0],aTo:o.getBuffer()}),s.transformFeedback.setBuffers({vCurrent:r[1]})}onUpdate(){const{duration:e,easing:t}=this.settings,{time:n}=this.transition;let i=n/e;t&&(i=t(i));const{model:r}=this.transform,o={time:i};r.shaderInputs.setProps({interpolation:o}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},spring:class extends mr{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="spring",this.texture=function(e){return e.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}(e),this.framebuffer=function(e,t){return e.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[t]})}(e,this.texture),this.transform=function(e,t){const n=fr(t.size),i=hr(t.size);return new ji(e,{vs:xr,fs:wr,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:t.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[Cr],defines:{ATTRIBUTE_TYPE:n},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}(e,t)}start(e,t){const n=this.currentLength,i=this.currentStartIndices;super.start(e,t);const{buffers:r,attribute:o}=this;for(let a=0;a<2;a++)r[a]=gr({device:this.device,buffer:r[a],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:i,getData:e.enter});r[2]=pr({device:this.device,source:r[0],target:r[2]}),this.setBuffer(r[1]);const{model:s}=this.transform;s.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?s.setConstantAttributes({aTo:o.value}):s.setAttributes({aTo:o.getBuffer()})}onUpdate(){const{buffers:e,transform:t,framebuffer:n,transition:i}=this,r=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});const o={stiffness:r.stiffness,damping:r.damping};t.model.shaderInputs.setProps({spring:o}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),dr(e),this.setBuffer(e[1]);this.device.readPixelsToArrayWebGL(n)[0]>0||i.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class Mr{constructor(e,{id:t,timeline:n}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(const i in e){const n=e[i],r=n.getTransitionSetting(t);r&&this._updateAttribute(i,n,r)}for(const i in this.transitions){const n=e[i];n&&n.getTransitionSetting(t)||this._removeTransition(i)}}hasAttribute(e){const t=this.transitions[e];return t&&t.inProgress}getAttributes(){const e={};for(const t in this.transitions){const n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(0===this.numInstances)return!1;for(const t in this.transitions){this.transitions[t].update()&&(this.needsRedraw=!0)}const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){const i=this.transitions[e];let r=!i||i.type!==n.type;if(r){i&&this._removeTransition(e);const o=Br[n.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):(Ce.error(`unsupported transition type '${n.type}'`)(),r=!1)}(r||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}const Sr="attributeManager.invalidate";class Tr{constructor(e,{id:t="attribute-manager",stats:n,timeline:i}={}){this.mergeBoundsMemoized=Me(Se),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new Mr(e,{id:`${t}-transitions`,timeline:i}),Object.seal(this)}finalize(){for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(const t of e)void 0!==this.attributes[t]&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){const n=this._invalidateTrigger(e,t);Te(Sr,this,e,n)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);Te(Sr,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:i,props:r={},buffers:o={},context:s={}}){let a=!1;Te("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const A in this.attributes){const i=this.attributes[A],l=i.settings.accessor;i.startIndices=n,i.numInstances=t,r[A]&&Ce.removed(`props.${A}`,`data.attributes.${A}`)(),i.setExternalBuffer(o[A])||i.setBinaryValue("string"==typeof l?o[l]:void 0,e.startIndices)||"string"==typeof l&&!o[l]&&i.setConstantValue(s,r[l])||i.needsUpdate()&&(a=!0,this._updateAttribute({attribute:i,numInstances:t,data:e,props:r,context:s})),this.needsRedraw=this.needsRedraw||i.needsRedraw()}a&&Te("attributeManager.updateEnd",this,t),this.stats&&(this.stats.get("Update Attributes").timeEnd(),a&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:i})}updateTransition(){const{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){const t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:t,attributeTransitionManager:n}=this,i={...n.getAttributes()};for(const r in t){const o=t[r];o.needsRedraw(e)&&!n.hasAttribute(r)&&(i[r]=o)}return i}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(const n in e){const i=e[n],r={...i,id:n,size:(i.isIndexed?1:i.size)||1,...t};this.attributes[n]=new cr(this.device,r)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const e={};for(const t in this.attributes){this.attributes[t].getUpdateTriggers().forEach(n=>{e[n]||(e[n]=[]),e[n].push(t)})}this.updateTriggers=e}_invalidateTrigger(e,t){const{attributes:n,updateTriggers:i}=this,r=i[e];return r&&r.forEach(e=>{const i=n[e];i&&i.setNeedsUpdate(i.id,t)}),r}_updateAttribute(e){const{attribute:t,numInstances:n}=e;if(Te("attribute.updateStart",t),t.constant)return void t.setConstantValue(e.context,t.value);t.allocate(n)&&Te("attribute.allocate",t,n);t.updateBuffer(e)&&(this.needsRedraw=!0,Te("attribute.updateEnd",t,n))}}const Er=1e-5;function Pr(e,t,n,i,r){const o=t-e;return(n-t)*r+-o*i+o+t}function Ir(e,t){if(Array.isArray(e)){let n=0;for(let i=0;i<e.length;i++){const r=e[i]-t[i];n+=r*r}return Math.sqrt(n)}return Math.abs(e-t)}const Lr={interpolation:class extends Be{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:t,toValue:n,duration:i,easing:r}}=this,o=r(e/i);this._value=Ee(t,n,o)}},spring:class extends Be{get value(){return this._currValue}_onUpdate(){const{fromValue:e,toValue:t,damping:n,stiffness:i}=this.settings,{_prevValue:r=e,_currValue:o=e}=this;let s=function(e,t,n,i,r){if(Array.isArray(n)){const o=[];for(let s=0;s<n.length;s++)o[s]=Pr(e[s],t[s],n[s],i,r);return o}return Pr(e,t,n,i,r)}(r,o,t,n,i);const a=Ir(s,t),A=Ir(s,o);a<Er&&A<Er&&(s=t,this.end()),this._prevValue=o,this._currValue=s}}};class Rr{constructor(e){this.transitions=/* @__PURE__ */new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,i){const{transitions:r}=this;if(r.has(e)){const n=r.get(e),{value:i=n.settings.fromValue}=n;t=i,this.remove(e)}if(!(i=lr(i)))return;const o=Lr[i.type];if(!o)return void Ce.error(`unsupported transition type '${i.type}'`)();const s=new o(this.timeline);s.start({...i,fromValue:t,toValue:n}),r.set(e,s)}remove(e){const{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){const e={};for(const[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}function Fr(e,t){const n=Dr({newProps:e,oldProps:t,propTypes:e[Pe],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=function(e,t){if(null===t)return"oldProps is null, initial diff";let n=!1;const{dataComparator:i,_dataDiff:r}=e;i?i(e.data,t.data)||(n="Data comparator detected a change"):e.data!==t.data&&(n="A new data container was supplied");n&&r&&(n=r(e.data,t.data)||n);return n}(e,t);let r=!1;return i||(r=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers){if(kr(e,t,"all"))return{all:!0}}const n={};let i=!1;for(const r in e.updateTriggers)if("all"!==r){kr(e,t,r)&&(n[r]=!0,i=!0)}return!!i&&n}(e,t)),{dataChanged:i,propsChanged:n,updateTriggersChanged:r,extensionsChanged:Ur(e,t),transitionsChanged:Or(e,t)}}function Or(e,t){if(!e.transitions)return!1;const n={},i=e[Pe];let r=!1;for(const o in e.transitions){const s=i[o],a=s&&s.type;("number"===a||"color"===a||"array"===a)&&Nr(e[o],t[o],s)&&(n[o]=!0,r=!0)}return!!r&&n}function Dr({newProps:e,oldProps:t,ignoreProps:n={},propTypes:i={},triggerName:r="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return`${r} changed shallowly`;if("object"!=typeof t||null===t)return`${r} changed shallowly`;for(const o of Object.keys(e))if(!(o in n)){if(!(o in t))return`${r}.${o} added`;const n=Nr(e[o],t[o],i[o]);if(n)return`${r}.${o} ${n}`}for(const o of Object.keys(t))if(!(o in n)){if(!(o in e))return`${r}.${o} dropped`;if(!Object.hasOwnProperty.call(e,o)){const n=Nr(e[o],t[o],i[o]);if(n)return`${r}.${o} ${n}`}}return!1}function Nr(e,t,n){let i=n&&n.equal;return i&&!i(e,t,n)?"changed deeply":i||(i=e&&t&&e.equals,!i||i.call(e,t))?i||t===e?null:"changed shallowly":"changed deeply"}function Ur(e,t){if(null===t)return!0;const n=t.extensions,{extensions:i}=e;if(i===n)return!1;if(!n||!i)return!0;if(i.length!==n.length)return!0;for(let r=0;r<i.length;r++)if(!i[r].equals(n[r]))return!0;return!1}function kr(e,t,n){let i=e.updateTriggers[n];i=null==i?{}:i;let r=t.updateTriggers[n];r=null==r?{}:r;return Dr({oldProps:r,newProps:i,triggerName:n})}function Gr(e){if(null===(t=e)||"object"!=typeof t)throw new Error("count(): argument not an object");var t;if("function"==typeof e.count)return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(function(e){return null!==e&&"object"==typeof e&&e.constructor===Object}(e))return Object.keys(e).length;throw new Error("count(): argument not a container")}function zr(e,t){if(!t)return e;const n={...e,...t};if("defines"in t&&(n.defines={...e.defines,...t.defines}),"modules"in t&&(n.modules=(e.modules||[]).concat(t.modules),t.modules.some(e=>"project64"===e.name))){const e=n.modules.findIndex(e=>"project32"===e.name);e>=0&&n.modules.splice(e,1)}if("inject"in t)if(e.inject){const i={...e.inject};for(const e in t.inject)i[e]=(i[e]||"")+t.inject[e];n.inject=i}else n.inject=t.inject;return n}const Vr={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Hr={};const jr={boolean:{validate:(e,t)=>!0,equal:(e,t,n)=>Boolean(e)===Boolean(t)},number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},color:{validate:(e,t)=>t.optional&&!e||Kr(e)&&(3===e.length||4===e.length),equal:(e,t,n)=>Ie(e,t,1)},accessor:{validate(e,t){const n=Wr(e);return"function"===n||n===Wr(t.value)},equal:(e,t,n)=>"function"==typeof t||Ie(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||Kr(e),equal(e,t,n){const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?Ie(e,t,r):e===t}},object:{equal(e,t,n){if(n.ignore)return!0;const{compare:i}=n,r=Number.isInteger(i)?i:i?1:0;return i?Ie(e,t,r):e===t}},function:{validate:(e,t)=>t.optional&&!e||"function"==typeof e,equal:(e,t,n)=>!n.compare&&!1!==n.ignore||e===t},data:{transform:(e,t,n)=>{if(!e)return e;const{dataTransform:i}=n.props;return i?i(e):"string"==typeof e.shape&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,n)=>{const i=n.context;return i&&i.device?function(e,t,n,i){if(n instanceof pe)return n;n.constructor&&"Object"!==n.constructor.name&&(n={data:n});let r=null;n.compressed&&(r={minFilter:"linear",mipmapFilter:n.data.length>1?"nearest":"linear"});const{width:o,height:s}=n.data,a=t.createTexture({...n,sampler:{...Vr,...r,...i},mipLevels:t.getMipLevelCount(o,s)});return"webgl"===t.type?a.generateMipmapsWebGL():"webgpu"===t.type&&t.generateMipmapsWebGPU(a),Hr[a.id]=e,a}(n.id,i.device,e,{...t.parameters,...n.props.textureParameters}):null},release:(e,t,n)=>{var i,r;i=n.id,(r=e)&&r instanceof pe&&Hr[r.id]===i&&(r.delete(),delete Hr[r.id])}}};function Qr(e,t){switch(Wr(t)){case"object":return Jr(e,t);case"array":return Jr(e,{type:"array",value:t,compare:!1});case"boolean":return Jr(e,{type:"boolean",value:t});case"number":return Jr(e,{type:"number",value:t});case"function":return Jr(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function Jr(e,t){return"type"in t?{name:e,...jr[t.type],...t}:"value"in t?{name:e,type:Wr(t.value),...t}:{name:e,type:"object",value:t}}function Kr(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function Wr(e){return Kr(e)?"array":null===e?"null":typeof e}const qr="_mergedDefaultProps";function Yr(e,t){if(!(e instanceof to.constructor))return{};let n=qr;if(t)for(const r of t){const e=r.constructor;e&&(n+=`:${e.extensionName||e.name}`)}const i=$r(e,n);return i||(e[n]=function(e,t){const n=e.prototype;if(!n)return null;const i=Object.getPrototypeOf(e),r=Yr(i),o=$r(e,"defaultProps")||{},s=function(e){const t={},n={},i={};for(const[r,o]of Object.entries(e)){const e=o?.deprecatedFor;if(e)i[r]=Array.isArray(e)?e:[e];else{const e=Qr(r,o);t[r]=e,n[r]=e.value}}return{propTypes:t,defaultProps:n,deprecatedProps:i}}(o),a=Object.assign(/* @__PURE__ */Object.create(null),r,s.defaultProps),A=Object.assign(/* @__PURE__ */Object.create(null),r?.[Pe],s.propTypes),l=Object.assign(/* @__PURE__ */Object.create(null),r?.[Oe],s.deprecatedProps);for(const c of t){const e=Yr(c.constructor);e&&(Object.assign(a,e),Object.assign(A,e[Pe]),Object.assign(l,e[Oe]))}(function(e,t){const n=function(e){const t=e.componentName;t||Ce.warn(`${e.name}.componentName not specified`)();return t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:n}})})(a,e),function(e,t){const n={},i={};for(const r in t){const e=t[r],{name:o,value:s}=e;e.async&&(n[o]=s,i[o]=Xr(o))}e[De]=n,e[Re]={},Object.defineProperties(e,i)}(a,A),function(e,t){for(const n in t)Object.defineProperty(e,n,{enumerable:!1,set(e){const i=`${this.id}: ${n}`;for(const r of t[n])Zr(this,r)||(this[r]=e);Ce.deprecated(i,t[n].join("/"))()}})}(a,l),a[Pe]=A,a[Oe]=l,0!==t.length||Zr(e,"_propTypes")||(e._propTypes=A);return a}(e,t||[]))}function Xr(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||rr(t)?this[Re][e]=t:this[Fe][e]=t},get(){if(this[Fe]){if(e in this[Fe]){return this[Fe][e]||this[De][e]}if(e in this[Re]){const t=this[Le]&&this[Le].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[De][e]}}return this[De][e]}}}function Zr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $r(e,t){return Zr(e,t)&&e[t]}let eo=0;class to{constructor(...e){this.props=function(e,t){let n;for(let o=t.length-1;o>=0;o--){const e=t[o];"extensions"in e&&(n=e.extensions)}const i=Yr(e.constructor,n),r=Object.create(i);r[Le]=e,r[Re]={},r[Fe]={};for(let o=0;o<t.length;++o){const e=t[o];for(const t in e)r[t]=e[t]}return Object.freeze(r),r}(this,e),this.id=this.props.id,this.count=eo++}clone(e){const{props:t}=this,n={};for(const i in t[De])i in t[Fe]?n[i]=t[Fe][i]:i in t[Re]&&(n[i]=t[Re][i]);return new this.constructor({...t,...n,...e})}}to.componentName="Component",to.defaultProps={};const no=Object.freeze({});class io{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||no}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){const t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(const t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[Le]||this.component;const t=e[Fe]||{},n=e[Re]||e,i=e[De]||{};for(const r in t){const e=t[r];this._createAsyncPropData(r,i[r]),this._updateAsyncProp(r,e),t[r]=this.getAsyncProp(r)}for(const r in n){const e=n[r];this._createAsyncPropData(r,i[r]),this._updateAsyncProp(r,e)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){this._didAsyncInputValueChange(e,t)&&("string"==typeof t&&(t=this._fetch(e,t)),t instanceof Promise?this._watchPromise(e,t):rr(t)?this._resolveAsyncIterable(e,t):this._setPropValue(e,t))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){const n=this.asyncProps[e];return t!==n.resolvedValue&&t!==n.lastValue&&(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();const n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){const i=this.asyncProps[e];i&&n>=i.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),i.resolvedValue=t,i.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const n=this.asyncProps[e];if(n){n.pendingLoadCount++;const i=n.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(n,t),this._setAsyncPropValue(e,t,i),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if("data"!==e)return void this._setPropValue(e,t);const n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;const i=n.pendingLoadCount;let r=[],o=0;for await(const s of t){if(!this.component)return;const{dataTransform:t}=this.component.props;r=t?t(s,r):r.concat(s),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:o,endRow:r.length}]}),o=r.length,this._setAsyncPropValue(e,r,i)}this._onResolve(e,r)}_postProcessValue(e,t){const n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){const n=this.component&&this.component.props[Pe];this.asyncProps[e]={type:n&&n[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class ro extends io{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){const n=this.layer,i=n?.props.fetch;return i?i(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){const n=this.layer;if(n){const i=n.props.onDataLoad;"data"===e&&i&&i(t,{propName:e,layer:n})}}_onError(e,t){const n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}}const oo=2**24-1,so=Object.freeze([]),ao=Me(({oldViewport:e,viewport:t})=>e.equals(t));let Ao=new Uint8ClampedArray(0);const lo={data:{type:"data",value:so,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__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:(e,{propName:t,layer:n,loaders:i,loadOptions:r,signal:o})=>{const{resourceManager:s}=n.context;r=r||n.getLoadOptions(),i=i||n.props.loaders,o&&(r={...r,core:{...r?.core,fetch:{...r?.core?.fetch,signal:o}}});let a=s.contains(e);return a||r||(s.add({resourceId:e,data:ke(e,i),persistent:!1}),a=!0),a?s.subscribe({resourceId:e,onChange:e=>n.internalState?.reloadAsyncProp(t,e),consumerId:n.id,requestId:t}):ke(e,i,r)}},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:e})=>[0,100*-e]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class co extends to{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Ne.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){xe(this.internalState);const t=this.internalState.viewport||this.context.viewport,n=Yn(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[i,r,o]=Ue(n,t.pixelProjectionMatrix);return 2===e.length?[i,r]:[i,r,o]}unproject(e){xe(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){xe(this.internalState);return function(e,t){const{viewport:n,coordinateSystem:i,coordinateOrigin:r,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:n,coordinateOrigin:i}=e;let{coordinateSystem:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}=e;return"default"===r&&(r=t.isGeospatial?"lnglat":"cartesian"),void 0===o?o=r:"default"===o&&(o=t.isGeospatial?"lnglat":"cartesian"),void 0===s&&(s=i),{viewport:t,coordinateSystem:r,coordinateOrigin:i,modelMatrix:n,fromCoordinateSystem:o,fromCoordinateOrigin:s}}(t),{autoOffset:A=!0}=t,{geospatialOrigin:l=Wn,shaderCoordinateOrigin:c=Wn,offsetMode:u=!1}=A?Ae(n,i,r):{},f=Yn(e,{viewport:n,modelMatrix:o,coordinateSystem:s,coordinateOrigin:a,offsetMode:u});if(u){const e=n.projectPosition(l||c);le(f,f,e)}return f}(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}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()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(const t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return"default"===e||"lnglat"===e||"cartesian"===e}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){xe(e instanceof Uint8Array);const[t,n,i]=e;return t+256*n+65536*i-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:Gr(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=zr(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=zr(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(const i of n)t.invalidateAll(i);else t.invalidateAll();if(t){const{props:n}=e,i=this.internalState.hasPickingBuffer,r=Number.isInteger(n.highlightedObjectIndex)||Boolean(n.pickable)||n.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(i!==r){this.internalState.hasPickingBuffer=r;const{pickingColors:e,instancePickingColors:n}=t.attributes,i=e||n;i&&(r&&i.constant&&(i.constant=!1,t.invalidate(i.id)),i.value||r||(i.constant=!0,i.value=[0,0,0]))}}}finalizeState(e){for(const n of this.getModels())n.destroy();const t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){const{index:i}=e;return i>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[i]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${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()))}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;const t=this.internalState.viewport;this.internalState.viewport=e,t&&ao({oldViewport:t,viewport:e})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const t=this.getAttributeManager();t&&("all"===e?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(const n in e)e[n].layoutChanged()&&(t=!0);for(const n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const t=this.props,n=this.getNumInstances(),i=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:i,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const r=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const t=e.update(),n=Object.create(this.props);for(const e in t)Object.defineProperty(n,e,{value:t[e]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;const n=Math.floor(Ao.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>oo&&Ce.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Ao=ve.allocate(Ao,t,{size:4,copy:!0,maxCount:Math.max(t,oo)});const e=Math.floor(Ao.length/4),i=[0,0,0];for(let t=n;t<e;t++)this.encodePickingColor(t,i),Ao[4*t+0]=i[0],Ao[4*t+1]=i[1],Ao[4*t+2]=i[2],Ao[4*t+3]=0}e.value=Ao.subarray(0,4*t)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){const n=this.getAttributeManager();e.setBufferLayout(n.getBufferLayouts(e)),t=n.getAttributes()}const i=e.userData?.excludeAttributes||{},r={},o={};for(const s in t){if(i[s])continue;const n=t[s].getValue();for(const i in n){const a=n[i];a instanceof re?t[s].settings.isIndexed?e.setIndexBuffer(a):r[i]=a:a&&(o[i]=a)}}e.setAttributes(r),e.setConstantAttributes(o)}disablePickingIndex(e){const t=this.props.data;if(!("attributes"in t))return void this._disablePickingIndex(e);const{pickingColors:n,instancePickingColors:i}=this.getAttributeManager().attributes,r=n||i,o=r&&t.attributes&&t.attributes[r.id];if(o&&o.value){const n=o.value,i=this.encodePickingColor(e);for(let e=0;e<t.length;e++){const t=r.getVertexOffset(e);n[t]===i[0]&&n[t+1]===i[1]&&n[t+2]===i[2]&&this._disablePickingIndex(e)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){const{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,i=t||n;if(!i)return;const r=i.getVertexOffset(e),o=i.getVertexOffset(e+1);i.buffer.write(new Uint8Array(o-r),r)}restorePickingColors(){const{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==Ao.buffer&&(n.value=Ao.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){xe(!this.internalState),Te("layer.initialize",this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new ro({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(Ce.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Rr(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Te("layer.matched",this,this===e);const{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(Te("layer.update",this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();const t=this.props,n=this.context,i=this.internalState,r=n.viewport,o=this._updateUniformTransition();i.propsInTransition=o,n.viewport=i.viewport||r,this.props=o;try{const e=this._getUpdateParams(),t=this.getModels();if(n.device)this.updateState(e);else try{this.updateState(e)}catch(s){}for(const n of this.props.extensions)n.updateState.call(this,e,n);this.setNeedsRedraw(),this._updateAttributes();const i=this.getModels()[0]!==t[0];this._postUpdate(e,i)}finally{n.viewport=r,this.props=t,this._clearChangeFlags(),i.needsUpdate=!1,i.resetOldProps()}}_finalize(){Te("layer.finalize",this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:i={}}){this._updateAttributeTransition();const r=this.props,o=this.context;this.props=this.internalState.propsInTransition||r;try{t&&this.setShaderModuleProps(t);const{getPolygonOffset:r}=this.props,s=r&&r(n)||[0,0];o.device instanceof c&&o.device.setParametersWebGL({polygonOffset:s});const a=o.device instanceof c?null:function(e){const{blendConstant:t,...n}=e;return t?{pipelineParameters:n,renderPassParameters:{blendConstant:t}}:{pipelineParameters:n}}(i);if(function(e,t,n,i){for(const r of e)"webgpu"===r.device.type?(uo(r,t),r.setParameters({...r.parameters,...i?.pipelineParameters})):r.setParameters(n)}(this.getModels(),e,i,a),o.device instanceof c)o.device.withParametersWebGL(i,()=>{const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:i,context:o};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)});else{a?.renderPassParameters&&e.setParameters(a.renderPassParameters);const r={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:i,context:o};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)}}finally{this.props=r}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:t}=this.internalState;for(const i in e)if(e[i]){let n=!1;if("dataChanged"===i){const r=e[i],o=t[i];r&&Array.isArray(o)&&(t.dataChanged=Array.isArray(r)?o.concat(r):r,n=!0)}t[i]||(t[i]=e[i],n=!0),n&&Te("layer.changeFlag",this,i,e)}const n=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){const n=Fr(e,t);if(n.updateTriggersChanged)for(const i in n.updateTriggersChanged)n.updateTriggersChanged[i]&&this.invalidateAttribute(i);if(n.transitionsChanged)for(const i in n.transitionsChanged)this.internalState.uniformTransitions.add(i,t[i],e[i],e.transitions?.[i]);return this.setChangeFlags(n)}validateProps(){!function(e){const t=e[Pe];for(const n in t){const i=t[n],{validate:r}=i;if(r&&!r(e[n],i))throw new Error(`Invalid prop ${n}: ${e[n]}`)}}(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&"function"==typeof n&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new Tr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:n,oldProps:i}=e,r=this.state.model;r?.isInstanced&&r.setInstanceCount(this.getNumInstances());const{autoHighlight:o,highlightedObjectIndex:s,highlightColor:a}=n;if(t||i.autoHighlight!==o||i.highlightedObjectIndex!==s||i.highlightColor!==a){const e={};Array.isArray(a)&&(e.highlightColor=a),(t||i.autoHighlight!==o||s!==i.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(s)&&s>=0?this.encodePickingColor(s):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),i=!!n&&n.getNeedsRedraw(e);if(t=t||i,t)for(const r of this.props.extensions)r.onNeedsRedraw.call(this,r);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}function uo(e,t){const n=t.props.framebuffer||(t.framebuffer??null);if(!n)return;const i=n.colorAttachments.map(e=>e?.texture?.format??null),r=n.depthStencilAttachment?.texture?.format,o=e;(function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0})(o.props.colorAttachmentFormats,i)&&o.props.depthStencilAttachmentFormat===r||(o.props.colorAttachmentFormats=i,o.props.depthStencilAttachmentFormat=r,o._setPipelineNeedsUpdate("attachment formats"))}co.defaultProps=lo,co.layerName="Layer";class fo extends co{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}){const{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){const{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if("function"==typeof e){const t={index:-1,data:this.props.data,target:[]};return(n,i)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,i)}return e}getSubLayerProps(e={}){const{opacity:t,pickable:n,visible:i,parameters:r,getPolygonOffset:o,highlightedObjectIndex:s,autoHighlight:a,highlightColor:A,coordinateSystem:l,coordinateOrigin:c,wrapLongitude:u,positionFormat:f,modelMatrix:h,extensions:d,fetch:p,operation:g,_subLayerProps:m}=this.props,b={id:"",updateTriggers:{},opacity:t,pickable:n,visible:i,parameters:r,getPolygonOffset:o,highlightedObjectIndex:s,autoHighlight:a,highlightColor:A,coordinateSystem:l,coordinateOrigin:c,wrapLongitude:u,positionFormat:f,modelMatrix:h,extensions:d,fetch:p,operation:g},y=m&&e.id&&m[e.id],v=y&&y.updateTriggers,_=e.id||"sublayer";if(y){const t=this.props[Pe],n=e.type?e.type._propTypes:{};for(const e in y){const i=n[e]||t[e];i&&"accessor"===i.type&&(y[e]=this.getSubLayerAccessor(y[e]))}}Object.assign(b,e,y),b.id=`${this.props.id}-${_}`,b.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...v};for(const C of d){const e=C.getSubLayerProps.call(this,C);e&&Object.assign(b,e,{updateTriggers:Object.assign(b.updateTriggers,e.updateTriggers)})}return b}_updateAutoHighlight(e){for(const t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers;const i=!n||this.needsUpdate();if(i){const e=this.renderLayers();n=Ge(e,Boolean),this.internalState.subLayers=n}Te("compositeLayer.renderLayers",this,i,n);for(const r of n)r.parent=this}}fo.layerName="CompositeLayer";class ho{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e||this.constructor===e.constructor&&Ie(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){const{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(const i in t)if(i in this.props){const e=t[i],r=this.props[i];n[i]=r,e&&"accessor"===e.type&&(n.updateTriggers[i]=this.props.updateTriggers[i],"function"==typeof r&&(n[i]=this.getSubLayerAccessor(r)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}}ho.defaultProps={},ho.extensionName="LayerExtension";class po{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:t={}}=e;this.typedArrayManager=ve,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:t,buffers:n={},getGeometry:i,geometryBuffer:r,positionFormat:o,dataChanged:s,normalize:a=!0}=this.opts;if(this.data=t,this.getGeometry=i,this.positionSize=r&&r.size||("XY"===o?2:3),this.buffers=n,this.normalize=a,r&&(xe(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),a||(n.vertexPositions=r)),this.geometryBuffer=n.vertexPositions,Array.isArray(s))for(const A of s)this._rebuildGeometry(A);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){const t=e.value||e;return ArrayBuffer.isView(t)?or(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){const{attributes:n,buffers:i,_attributeDefs:r,typedArrayManager:o}=this;for(const s in r)if(s in i)o.release(n[s]),n[s]=null;else{const i=r[s];i.copy=t,n[s]=o.allocate(n[s],e,i)}}_forEachGeometry(e,t,n){const{data:i,getGeometry:r}=this,{iterable:o,objectInfo:s}=ir(i,t,n);for(const a of o){s.index++;e(r?r(a,s):null,s.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:i}=this;const{data:r,geometryBuffer:o}=this,{startRow:s=0,endRow:a=1/0}=e||{},A={};if(e||(t=[0],n=[0]),this.normalize||!o)this._forEachGeometry((e,t)=>{const i=e&&this.normalizeGeometry(e);A[t]=i,n[t+1]=n[t]+(i?this.getGeometrySize(i):0)},s,a),i=n[n.length-1];else if(n=r.startIndices,i=n[r.length]||0,ArrayBuffer.isView(o))i=i||o.length/this.positionSize;else if(o instanceof re){const e=4*this.positionSize;i=i||o.byteLength/e}else if(o.buffer){const e=o.stride||4*this.positionSize;i=i||o.buffer.byteLength/e}else if(o.value){const e=o.value,t=o.stride/e.BYTES_PER_ELEMENT||this.positionSize;i=i||e.length/t}this._allocate(i,Boolean(e)),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=i;const l={};this._forEachGeometry((e,r)=>{const o=A[r]||e;l.vertexStart=n[r],l.indexStart=t[r];const s=r<n.length-1?n[r+1]:i;l.geometrySize=s-n[r],l.geometryIndex=r,this.updateGeometryAttributes(o,l)},s,a),this.vertexCount=t[t.length-1]}}const go="layout(std140) uniform arcUniforms {\n bool greatCircle;\n bool useShortestPath;\n float numSegments;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int widthUnits;\n} arc;\n",mo={name:"arc",vs:go,fs:go,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}},bo=[0,0,0,255],yo={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getSourceColor:{type:"accessor",value:bo},getTargetColor:{type:"accessor",value:bo},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}};class vo extends co{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME arc-layer-vertex-shader\nin vec4 instanceSourceColors;\nin vec4 instanceTargetColors;\nin vec3 instanceSourcePositions;\nin vec3 instanceSourcePositions64Low;\nin vec3 instanceTargetPositions;\nin vec3 instanceTargetPositions64Low;\nin vec3 instancePickingColors;\nin float instanceWidths;\nin float instanceHeights;\nin float instanceTilts;\nout vec4 vColor;\nout vec2 uv;\nout float isValid;\nfloat paraboloid(float distance, float sourceZ, float targetZ, float ratio) {\nfloat deltaZ = targetZ - sourceZ;\nfloat dh = distance * instanceHeights;\nif (dh == 0.0) {\nreturn sourceZ + deltaZ * ratio;\n}\nfloat unitZ = deltaZ / dh;\nfloat p2 = unitZ * unitZ + 1.0;\nfloat dir = step(deltaZ, 0.0);\nfloat z0 = mix(sourceZ, targetZ, dir);\nfloat r = mix(ratio, 1.0 - ratio, dir);\nreturn sqrt(r * (p2 - r)) * dh + z0;\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\nvec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);\ndir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\nreturn dir_screenspace * offset_direction * width / 2.0;\n}\nfloat getSegmentRatio(float index) {\nreturn smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0));\n}\nvec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {\nfloat distance = length(source.xy - target.xy);\nfloat z = paraboloid(distance, source.z, target.z, segmentRatio);\nfloat tiltAngle = radians(instanceTilts);\nvec2 tiltDirection = normalize(target.xy - source.xy);\nvec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);\nreturn vec3(\nmix(source.xy, target.xy, segmentRatio) + tilt,\nz * cos(tiltAngle)\n);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\nvec2 sourceRadians = radians(source);\nvec2 targetRadians = radians(target);\nvec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);\nvec2 shd_sq = sin_half_delta * sin_half_delta;\nfloat a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;\nreturn 2.0 * asin(sqrt(a));\n}\nvec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {\nvec2 lngLat;\nif(abs(angularDist - PI) < 0.001) {\nlngLat = (1.0 - t) * source.xy + t * target.xy;\n} else {\nfloat a = sin((1.0 - t) * angularDist);\nfloat b = sin(t * angularDist);\nvec3 p = source3D.yxz * a + target3D.yxz * b;\nlngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));\n}\nfloat z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);\nreturn vec3(lngLat, z);\n}\nvoid main(void) {\ngeometry.worldPosition = instanceSourcePositions;\ngeometry.worldPositionAlt = instanceTargetPositions;\nfloat segmentIndex = float(gl_VertexID / 2);\nfloat segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.;\nfloat segmentRatio = getSegmentRatio(segmentIndex);\nfloat prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));\nfloat nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0));\nfloat indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\nisValid = 1.0;\nuv = vec2(segmentRatio, segmentSide);\ngeometry.uv = uv;\ngeometry.pickingColor = instancePickingColors;\nvec4 curr;\nvec4 next;\nvec3 source;\nvec3 target;\nif ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nsource = project_globe_(vec3(instanceSourcePositions.xy, 0.0));\ntarget = project_globe_(vec3(instanceTargetPositions.xy, 0.0));\nfloat angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);\nvec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);\nvec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);\nvec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);\nif (abs(currPos.x - prevPos.x) > 180.0) {\nindexDir = -1.0;\nisValid = 0.0;\n} else if (abs(currPos.x - nextPos.x) > 180.0) {\nindexDir = 1.0;\nisValid = 0.0;\n}\nnextPos = indexDir < 0.0 ? prevPos : nextPos;\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nif (isValid == 0.0) {\nnextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;\nfloat t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);\ncurrPos = mix(currPos, nextPos, t);\nsegmentRatio = mix(segmentRatio, nextSegmentRatio, t);\n}\nvec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);\nvec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);\ncurr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);\nnext = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n} else {\nvec3 source_world = instanceSourcePositions;\nvec3 target_world = instanceTargetPositions;\nif (arc.useShortestPath) {\nsource_world.x = mod(source_world.x + 180., 360.0) - 180.;\ntarget_world.x = mod(target_world.x + 180., 360.0) - 180.;\nfloat deltaLng = target_world.x - source_world.x;\nif (deltaLng > 180.) target_world.x -= 360.;\nif (deltaLng < -180.) source_world.x -= 360.;\n}\nsource = project_position(source_world, instanceSourcePositions64Low);\ntarget = project_position(target_world, instanceTargetPositions64Low);\nfloat antiMeridianX = 0.0;\nif (arc.useShortestPath) {\nif (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nantiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE;\n}\nfloat thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);\nif (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {\nisValid = 0.0;\nindexDir = sign(segmentRatio - thresholdRatio);\nsegmentRatio = thresholdRatio;\n}\n}\nnextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;\nvec3 currPos = interpolateFlat(source, target, segmentRatio);\nvec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);\nif (arc.useShortestPath) {\nif (nextPos.x < antiMeridianX) {\ncurrPos.x += TILE_SIZE;\nnextPos.x += TILE_SIZE;\n}\n}\ncurr = project_common_position_to_clipspace(vec4(currPos, 1.0));\nnext = project_common_position_to_clipspace(vec4(nextPos, 1.0));\ngeometry.position = vec4(currPos, 1.0);\n}\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits),\narc.widthMinPixels, arc.widthMaxPixels\n);\nvec3 offset = vec3(\ngetExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels),\n0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\nDECKGL_FILTER_GL_POSITION(curr, geometry);\ngl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\nvec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);\nvColor = vec4(color.rgb, color.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME arc-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 uv;\nin float isValid;\nout vec4 fragColor;\nvoid main(void) {\nif (isValid == 0.0) {\ndiscard;\n}\nfragColor = vColor;\ngeometry.uv = uv;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Jn,Kn,mo]})}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:bo},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:bo},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}){const{widthUnits:t,widthScale:n,widthMinPixels:i,widthMaxPixels:r,greatCircle:o,wrapLongitude:s,numSegments:a}=this.props,A={numSegments:a,widthUnits:ze[t],widthScale:n,widthMinPixels:i,widthMaxPixels:r,greatCircle:o,useShortestPath:s},l=this.state.model;l.shaderInputs.setProps({arc:A}),l.setVertexCount(2*a),l.draw(this.context.renderPass)}_getModel(){return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}}vo.layerName="ArcLayer",vo.defaultProps=yo;const _o=new Uint32Array([0,2,1,0,3,2]),Co=new Float32Array([0,1,0,0,1,0,1,1]);function xo(e,t){if(!t)return function(e){const t=new Float64Array(12);for(let n=0;n<e.length;n++)t[3*n+0]=e[n][0],t[3*n+1]=e[n][1],t[3*n+2]=e[n][2]||0;return{vertexCount:6,positions:t,indices:_o,texCoords:Co}}(e);const n=Math.max(Math.abs(e[0][0]-e[3][0]),Math.abs(e[1][0]-e[2][0])),i=Math.max(Math.abs(e[1][1]-e[0][1]),Math.abs(e[2][1]-e[3][1])),r=Math.ceil(n/t)+1,o=Math.ceil(i/t)+1,s=(r-1)*(o-1)*6,a=new Uint32Array(s),A=new Float32Array(r*o*2),l=new Float64Array(r*o*3);let c=0,u=0;for(let f=0;f<r;f++){const t=f/(r-1);for(let n=0;n<o;n++){const i=n/(o-1),r=wo(e,t,i);l[3*c+0]=r[0],l[3*c+1]=r[1],l[3*c+2]=r[2]||0,A[2*c+0]=t,A[2*c+1]=1-i,f>0&&n>0&&(a[u++]=c-o,a[u++]=c-o-1,a[u++]=c-1,a[u++]=c-o,a[u++]=c-1,a[u++]=c),c++}}return{vertexCount:s,positions:l,indices:a,texCoords:A}}function wo(e,t,n){return Ee(Ee(e[0],e[1],n),Ee(e[3],e[2],n),t)}const Bo="layout(std140) uniform bitmapUniforms {\n vec4 bounds;\n float coordinateConversion;\n float desaturate;\n vec3 tintColor;\n vec4 transparentColor;\n} bitmap;\n",Mo={name:"bitmap",vs:Bo,fs:Bo,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}};class So extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME bitmap-layer-vertex-shader\n\nin vec2 texCoords;\nin vec3 positions;\nin vec3 positions64Low;\n\nout vec2 vTexCoord;\nout vec2 vTexPos;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n if (bitmap.coordinateConversion < -0.5) {\n vTexPos = geometry.position.xy + project.commonOrigin.xy;\n } else if (bitmap.coordinateConversion > 0.5) {\n vTexPos = geometry.worldPosition.xy;\n }\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nin vec2 vTexCoord;\nin vec2 vTexPos;\n\nout vec4 fragColor;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), bitmap.desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * bitmap.tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n if (bitmap.transparentColor.a == 0.0) {\n return vec4(color, alpha);\n }\n float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);\n float highLightRatio = alpha / blendedAlpha;\n vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),\n (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])\n );\n}\n\n\nvec3 packUVsIntoRGB(vec2 uv) {\n // Extract the top 8 bits. We want values to be truncated down so we can add a fraction\n vec2 uv8bit = floor(uv * 256.);\n\n // Calculate the normalized remainders of u and v parts that do not fit into 8 bits\n // Scale and clamp to 0-1 range\n vec2 uvFraction = fract(uv * 256.);\n vec2 uvFraction4bit = floor(uvFraction * 16.);\n\n // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates\n float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;\n\n return vec3(uv8bit, fractions) / 255.;\n}\n\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (bitmap.coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (bitmap.coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture(bitmapTexture, uv);\n\n fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(fragColor, geometry);\n\n if (bool(picking.isActive) && !bool(picking.isAttribute)) {\n // Since instance information is not used, we can use picking color for pixel index\n fragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n",modules:[Jn,Kn,Mo]})}initializeState(){const e=this.getAttributeManager();e.remove(["instancePickingColors"]);const t=!0;e.add({indices:{size:1,isIndexed:!0,update:e=>e.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:e=>e.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:e=>e.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:n}){const i=this.getAttributeManager();if(n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll()),e.bounds!==t.bounds){const e=this.state.mesh,t=this._createMesh();this.state.model.setVertexCount(t.vertexCount);for(const n in t)e&&e[n]!==t[n]&&i.invalidate(n);this.setState({mesh:t,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){const{image:t}=this.props,n=e.info;if(!n.color||!t)return n.bitmap=null,n;const{width:i,height:r}=t;n.index=0;const o=function(e){const[t,n,i]=e;return[(t+(15&i)/16)/256,(n+(240&i)/256)/256]}(n.color);return n.bitmap={size:{width:i,height:r},uv:o,pixel:[Math.floor(o[0]*i),Math.floor(o[1]*r)]},n}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){const{bounds:e}=this.props;let t=e;return To(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),xo(t,this.context.viewport.resolution)}_getModel(){return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){const{shaderModuleProps:t}=e,{model:n,coordinateConversion:i,bounds:r,disablePicking:o}=this.state,{image:s,desaturate:a,transparentColor:A,tintColor:l}=this.props;if((!t.picking.isActive||!o)&&s&&n){const e={bitmapTexture:s,bounds:r,coordinateConversion:i,desaturate:a,tintColor:l.slice(0,3).map(e=>e/255),transparentColor:A.map(e=>e/255)};n.shaderInputs.setProps({bitmap:e}),n.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if("default"!==e){const{bounds:t}=this.props;if(!To(t))throw new Error("_imageCoordinateSystem only supports rectangular bounds");const n=this.context.viewport.resolution?"lnglat":"cartesian";if(e="lnglat"===e?"lnglat":"cartesian","lnglat"===e&&"cartesian"===n)return{coordinateConversion:-1,bounds:t};if("cartesian"===e&&"lnglat"===n){const e=Ve([t[0],t[1]]),n=Ve([t[2],t[3]]);return{coordinateConversion:1,bounds:[e[0],e[1],n[0],n[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}function To(e){return Number.isFinite(e[0])}So.layerName="BitmapLayer",So.defaultProps={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}};const Eo="layout(std140) uniform iconUniforms {\n float sizeScale;\n vec2 iconsTextureDim;\n float sizeBasis;\n float sizeMinPixels;\n float sizeMaxPixels;\n bool billboard;\n highp int sizeUnits;\n float alphaCutoff;\n} icon;\n",Po={name:"icon",vs:Eo,fs:Eo,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},Io=()=>{},Lo={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Ro={x:0,y:0,width:0,height:0};function Fo(e,t,n,i){const r=Math.min(n/t.width,i/t.height),o=Math.floor(t.width*r),s=Math.floor(t.height*r);return 1===r?{image:t,width:o,height:s}:(e.canvas.height=s,e.canvas.width=o,e.clearRect(0,0,o,s),e.drawImage(t,0,0,t.width,t.height,0,0,o,s),{image:e.canvas,width:o,height:s})}function Oo(e){return e&&(e.id||e.url)}function Do(e){const{device:t}=e;"webgl"===t.type?e.generateMipmapsWebGL():"webgpu"===t.type&&t.generateMipmapsWebGPU(e)}function No(e,t,n){for(let i=0;i<t.length;i++){const{icon:r,xOffset:o}=t[i];e[Oo(r)]={...r,x:o,y:n}}}class Uo{constructor(e,{onUpdate:t=Io,onError:n=Io}){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=4,this._canvasWidth=1024,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=t,this.onError=n}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){const t=this._autoPacking?Oo(e):e;return this._mapping[t]||Ro}setProps({loadOptions:e,autoPacking:t,iconAtlas:n,iconMapping:i,textureParameters:r}){e&&(this._loadOptions=e),void 0!==t&&(this._autoPacking=t),i&&(this._mapping=i),n&&(this._texture?.delete(),this._texture=null,this._externalTexture=n),r&&(this._samplerParameters=r)}get isLoaded(){return 0===this._pendingCount}packIcons(e,t){if(!this._autoPacking||"undefined"==typeof document)return;const n=Object.values(function(e,t,n){if(!e||!t)return null;n=n||{};const i={},{iterable:r,objectInfo:o}=ir(e);for(const s of r){o.index++;const e=t(s,o),r=Oo(e);if(!e)throw new Error("Icon is missing.");if(!e.url)throw new Error("Icon url is missing.");i[r]||n[r]&&e.url===n[r].url||(i[r]={...e,source:s,sourceIndex:o.index})}return i}(e,t,this._mapping)||{});if(n.length>0){const{mapping:e,xOffset:t,yOffset:i,rowHeight:r,canvasHeight:o}=function({icons:e,buffer:t,mapping:n={},xOffset:i=0,yOffset:r=0,rowHeight:o=0,canvasWidth:s}){let a=[];for(let l=0;l<e.length;l++){const A=e[l];if(!n[Oo(A)]){const{height:e,width:l}=A;i+l+t>s&&(No(n,a,r),i=0,r=o+r+t,o=0,a=[]),a.push({icon:A,xOffset:i}),i=i+l+t,o=Math.max(o,e)}}return a.length>0&&No(n,a,r),{mapping:n,rowHeight:o,xOffset:i,yOffset:r,canvasWidth:s,canvasHeight:(A=o+r+t,Math.pow(2,Math.ceil(Math.log2(A))))};var A}({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=r,this._mapping=e,this._xOffset=t,this._yOffset=i,this._canvasHeight=o,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||Lo,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=function(e,t,n,i){const{width:r,height:o,device:s}=e,a=s.createTexture({format:"rgba8unorm",width:t,height:n,sampler:i,mipLevels:s.getMipLevelCount(t,n)}),A=s.createCommandEncoder();A.copyTextureToTexture({sourceTexture:e,destinationTexture:a,width:r,height:o});const l=A.finish();return s.submit(l),Do(a),e.destroy(),a}(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||Lo)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(n)}}_loadIcons(e){const t=this._canvas.getContext("2d",{willReadFrequently:!0});for(const n of e)this._pendingCount++,ke(n.url,this._loadOptions).then(e=>{const i=Oo(n),r=this._mapping[i],{x:o,y:s,width:a,height:A}=r,{image:l,width:c,height:u}=Fo(t,e,a,A),f=o+(a-c)/2,h=s+(A-u)/2;this._texture?.copyExternalImage({image:l,x:f,y:h,width:c,height:u}),r.x=f,r.y=h,r.width=c,r.height=u,this._texture&&Do(this._texture),this.onUpdate(c!==a||u!==A)}).catch(e=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}}const ko=[0,0,0,255],Go={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:e=>e.position},getIcon:{type:"accessor",value:e=>e.icon},getColor:{type:"accessor",value:ko},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}};class zo extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;\nfloat instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin float vColorMode;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nvec4 texColor = texture(iconsTexture, vTextureCoords);\nvec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);\nfloat a = texColor.a * layer.opacity * vColor.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color, a);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:'struct IconUniforms {\n sizeScale: f32,\n iconsTextureDim: vec2<f32>,\n sizeBasis: f32,\n sizeMinPixels: f32,\n sizeMaxPixels: f32,\n billboard: i32,\n sizeUnits: i32,\n alphaCutoff: f32\n};\n\n@group(0) @binding(auto) var<uniform> icon: IconUniforms;\n@group(0) @binding(auto) var iconsTexture : texture_2d<f32>;\n@group(0) @binding(auto) var iconsTextureSampler : sampler;\n\nfn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> {\n let angle_radian = angle_deg * PI / 180.0;\n let c = cos(angle_radian);\n let s = sin(angle_radian);\n let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c));\n return rotation * vertex;\n}\n\nstruct Attributes {\n @location(0) positions: vec2<f32>,\n\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceSizes: f32,\n @location(4) instanceAngles: f32,\n @location(5) instanceColors: vec4<f32>,\n @location(6) instancePickingColors: vec3<f32>,\n @location(7) instanceIconFrames: vec4<f32>,\n @location(8) instanceColorModes: f32,\n @location(9) instanceOffsets: vec2<f32>,\n @location(10) instancePixelOffset: vec2<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n\n @location(0) vColorMode: f32,\n @location(1) vColor: vec4<f32>,\n @location(2) vTextureCoords: vec2<f32>,\n @location(3) uv: vec2<f32>,\n @location(4) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(inp: Attributes) -> Varyings {\n // write geometry fields used by filters + FS\n geometry.worldPosition = inp.instancePositions;\n geometry.uv = inp.positions;\n geometry.pickingColor = inp.instancePickingColors;\n\n var outp: Varyings;\n outp.uv = inp.positions;\n\n let iconSize = inp.instanceIconFrames.zw;\n\n // convert size in meters to pixels, then clamp\n let sizePixels = clamp(\n project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),\n icon.sizeMinPixels, icon.sizeMaxPixels\n );\n\n // scale icon height to match instanceSize\n let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0);\n let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0);\n\n // scale and rotate vertex in "pixel" units; then add per-instance pixel offset\n var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets;\n pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale;\n pixelOffset = pixelOffset + inp.instancePixelOffset;\n pixelOffset.y = pixelOffset.y * -1.0;\n\n if (icon.billboard != 0) {\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n\n var offset = vec3<f32>(pixelOffset, 0.0);\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipOffset = project_pixel_size_to_clipspace(offset.xy);\n pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w);\n outp.position = pos;\n } else {\n var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);\n // DECKGL_FILTER_SIZE(offset_common, geometry);\n var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position);\n // DECKGL_FILTER_GL_POSITION(pos, geometry);\n outp.position = pos;\n }\n\n let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5;\n outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim;\n\n outp.vColor = inp.instanceColors;\n // DECKGL_FILTER_COLOR(outp.vColor, geometry);\n\n outp.vColorMode = inp.instanceColorModes;\n outp.pickingColor = inp.instancePickingColors;\n\n return outp;\n}\n\n@fragment\nfn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> {\n // expose to deck.gl filter hooks\n geometry.uv = inp.uv;\n\n let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords);\n\n // if colorMode == 0, use pixel color from the texture\n // if colorMode == 1 (or picking), use texture as transparency mask\n let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode);\n let a = texColor.a * layer.opacity * inp.vColor.a;\n\n if (a < icon.alphaCutoff) {\n discard;\n }\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(inp.pickingColor)) {\n discard;\n }\n return vec4<f32>(inp.pickingColor, 1.0);\n }\n\n var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a));\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n return fragColor;\n}\n',modules:[Jn,Qn,Kn,Po]})}initializeState(){this.state={iconManager:new Uo(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:ko},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.getAttributeManager(),{iconAtlas:o,iconMapping:s,data:a,getIcon:A,textureParameters:l}=t,{iconManager:c}=this.state;if("string"==typeof o)return;const u=o||this.internalState.isAsyncPropLoading("iconAtlas");c.setProps({loadOptions:t.loadOptions,autoPacking:!u,iconAtlas:o,iconMapping:u?s:null,textureParameters:l}),u?n.iconMapping!==t.iconMapping&&r.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&c.packIcons(a,A),i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){const{sizeScale:t,sizeBasis:n,sizeMinPixels:i,sizeMaxPixels:r,sizeUnits:o,billboard:s,alphaCutoff:a}=this.props,{iconManager:A}=this.state,l=A.getTexture();if(l){const e=this.state.model,A={iconsTexture:l,iconsTextureDim:[l.width,l.height],sizeUnits:ze[o],sizeScale:t,sizeBasis:"height"===n?1:0,sizeMinPixels:i,sizeMaxPixels:r,billboard:s,alphaCutoff:a};e.shaderInputs.setProps({icon:A}),e.draw(this.context.renderPass)}}_getModel(){return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Qi({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([-1,-1,1,-1,-1,1,1,1])}}}),isInstanced:!0})}_onUpdate(e){e?(this.getAttributeManager()?.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){const t=this.getCurrentLayer()?.props.onIconError;t?t(e):Ce.error(e.error.message)()}getInstanceIconDef(e){const{x:t,y:n,width:i,height:r,mask:o,anchorX:s=i/2,anchorY:a=r/2}=this.state.iconManager.getIconMapping(e);return[i/2-s,r/2-a,t,n,i,r,o?1:0]}}zo.defaultProps=Go,zo.layerName="IconLayer";const Vo="layout(std140) uniform pointCloudUniforms {\n float radiusPixels;\n highp int sizeUnits;\n} pointCloud;\n",Ho={name:"pointCloud",source:"",vs:Vo,fs:Vo,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}},jo=[0,0,0,255],Qo=[0,0,1],Jo={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:e=>e.position},getNormal:{type:"accessor",value:Qo},getColor:{type:"accessor",value:jo},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class Ko extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceNormals;\nin vec4 instanceColors;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec3 instancePickingColors;\nout vec4 vColor;\nout vec2 unitPosition;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.normal = project_normal(instanceNormals);\nunitPosition = positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\nvec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\nvec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, instanceColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 unitPosition;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition.xy;\nfloat distToCenter = length(unitPosition);\nif (distToCenter > 1.0) {\ndiscard;\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"struct PointCloudUniforms {\n radiusPixels: f32,\n sizeUnits: i32,\n};\n\n@group(0) @binding(0)\nvar<uniform> pointCloudUniforms: PointCloudUniforms;\n\nstruct ConstantAttributes {\n instanceNormals: vec3<f32>,\n instanceColors: vec4<f32>,\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instancePickingColors: vec3<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(1.0, 0.0, 0.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n vec3<f32>(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceNormals: vec3<f32>,\n @location(4) instanceColors: vec4<f32>,\n @location(5) instancePickingColors: vec3<f32>\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vColor: vec4<f32>,\n @location(1) unitPosition: vec2<f32>,\n @location(2) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n geometry.worldPosition = attributes.instancePositions;\n\n let centerResult = project_position_to_clipspace_and_commonspace(\n attributes.instancePositions,\n attributes.instancePositions64Low,\n vec3<f32>(0.0)\n );\n geometry.position = centerResult.commonPosition;\n geometry.normal = project_normal(attributes.instanceNormals);\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n // Find the center of the point and add the current vertex\n let offset = vec3<f32>(\n attributes.positions.xy *\n project_unit_size_to_pixel(pointCloudUniforms.radiusPixels, pointCloudUniforms.sizeUnits),\n 0.0\n );\n // DECKGL_FILTER_SIZE(offset, geometry);\n\n varyings.position = centerResult.clipPosition;\n // DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position.x += clipPixels.x;\n varyings.position.y += clipPixels.y;\n\n // Apply lighting\n let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vColor = vec4(lightColor, attributes.instanceColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(vColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition.xy;\n\n let distToCenter = length(varyings.unitPosition);\n if (distToCenter > 1.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n fragColor = varyings.vColor;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n}\n",modules:[Jn,Qn,zn,Kn,Ho]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:Qo},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:jo}})}updateState(e){const{changeFlags:t,props:n}=e;super.updateState(e),t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),t.dataChanged&&function(e){const{header:t,attributes:n}=e;if(t&&n&&(e.length=t.vertexCount,n.POSITION&&(n.instancePositions=n.POSITION),n.NORMAL&&(n.instanceNormals=n.NORMAL),n.COLOR_0)){const{size:e,value:t}=n.COLOR_0;n.instanceColors={size:e,type:"unorm8",value:t}}}(n.data)}draw({uniforms:e}){const{pointSize:t,sizeUnits:n}=this.props,i=this.state.model,r={sizeUnits:ze[n],radiusPixels:t};i.shaderInputs.setProps({pointCloud:r}),i.draw(this.context.renderPass)}_getModel(){const e=[];for(let t=0;t<3;t++){const n=t/3*Math.PI*2;e.push(2*Math.cos(n),2*Math.sin(n),0)}return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Qi({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}}Ko.layerName="PointCloudLayer",Ko.defaultProps=Jo;const Wo="layout(std140) uniform scatterplotUniforms {\n float radiusScale;\n float radiusMinPixels;\n float radiusMaxPixels;\n float lineWidthScale;\n float lineWidthMinPixels;\n float lineWidthMaxPixels;\n float stroked;\n float filled;\n bool antialiasing;\n bool billboard;\n highp int radiusUnits;\n highp int lineWidthUnits;\n} scatterplot;\n",qo={name:"scatterplot",vs:Wo,fs:Wo,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"}},Yo=[0,0,0,255],Xo={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:e=>e.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:Yo},getLineColor:{type:"accessor",value:Yo},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class Zo extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-vertex-shader\nin vec3 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceRadius;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout vec2 unitPosition;\nout float innerUnitRadius;\nout float outerRadiusPixels;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nouterRadiusPixels = clamp(\nproject_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),\nscatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n);\nfloat lineWidthPixels = clamp(\nproject_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),\nscatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n);\nouterRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\nfloat edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\nunitPosition = edgePadding * positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\ninnerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;\nif (scatterplot.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = edgePadding * positions * outerRadiusPixels;\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin vec2 unitPosition;\nin float innerUnitRadius;\nin float outerRadiusPixels;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition) * outerRadiusPixels;\nfloat inCircle = scatterplot.antialiasing ?\nsmoothedge(distToCenter, outerRadiusPixels) :\nstep(distToCenter, outerRadiusPixels);\nif (inCircle == 0.0) {\ndiscard;\n}\nif (scatterplot.stroked > 0.5) {\nfloat isLine = scatterplot.antialiasing ?\nsmoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\nstep(innerUnitRadius * outerRadiusPixels, distToCenter);\nif (scatterplot.filled > 0.5) {\nfragColor = mix(vFillColor, vLineColor, isLine);\n} else {\nif (isLine == 0.0) {\ndiscard;\n}\nfragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n}\n} else if (scatterplot.filled < 0.5) {\ndiscard;\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= inCircle;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",source:"// Main shaders\n\nstruct ScatterplotUniforms {\n radiusScale: f32,\n radiusMinPixels: f32,\n radiusMaxPixels: f32,\n lineWidthScale: f32,\n lineWidthMinPixels: f32,\n lineWidthMaxPixels: f32,\n stroked: f32,\n filled: i32,\n antialiasing: i32,\n billboard: i32,\n radiusUnits: i32,\n lineWidthUnits: i32,\n};\n\nstruct ConstantAttributeUniforms {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>,\n\n instancePositionsConstant: i32,\n instancePositions64LowConstant: i32,\n instanceRadiusConstant: i32,\n instanceLineWidthsConstant: i32,\n instanceFillColorsConstant: i32,\n instanceLineColorsConstant: i32,\n instancePickingColorsConstant: i32\n};\n\n@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms;\n\nstruct ConstantAttributes {\n instancePositions: vec3<f32>,\n instancePositions64Low: vec3<f32>,\n instanceRadius: f32,\n instanceLineWidths: f32,\n instanceFillColors: vec4<f32>,\n instanceLineColors: vec4<f32>,\n instancePickingColors: vec3<f32>\n};\n\nconst constants = ConstantAttributes(\n vec3<f32>(0.0),\n vec3<f32>(0.0),\n 0.0,\n 0.0,\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0),\n vec3<f32>(0.0)\n);\n\nstruct Attributes {\n @builtin(instance_index) instanceIndex : u32,\n @builtin(vertex_index) vertexIndex : u32,\n @location(0) positions: vec3<f32>,\n @location(1) instancePositions: vec3<f32>,\n @location(2) instancePositions64Low: vec3<f32>,\n @location(3) instanceRadius: f32,\n @location(4) instanceLineWidths: f32,\n @location(5) instanceFillColors: vec4<f32>,\n @location(6) instanceLineColors: vec4<f32>,\n @location(7) instancePickingColors: vec3<f32>,\n};\n\nstruct Varyings {\n @builtin(position) position: vec4<f32>,\n @location(0) vFillColor: vec4<f32>,\n @location(1) vLineColor: vec4<f32>,\n @location(2) unitPosition: vec2<f32>,\n @location(3) innerUnitRadius: f32,\n @location(4) outerRadiusPixels: f32,\n @location(5) pickingColor: vec3<f32>,\n};\n\n@vertex\nfn vertexMain(attributes: Attributes) -> Varyings {\n var varyings: Varyings;\n\n // Draw an inline geometry constant array clip space triangle to verify that rendering works.\n // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));\n // if (attributes.instanceIndex == 0) {\n // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);\n // return varyings;\n // }\n\n geometry.worldPosition = attributes.instancePositions;\n\n // Multiply out radius and clamp to limits\n varyings.outerRadiusPixels = clamp(\n project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),\n scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels\n );\n\n // Multiply out line width and clamp to limits\n let lineWidthPixels = clamp(\n project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),\n scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels\n );\n\n // outer radius needs to offset by half stroke width\n varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;\n // Expand geometry to accommodate edge smoothing\n let edgePadding = select(\n (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,\n 1.0,\n scatterplot.antialiasing != 0\n );\n\n // position on the containing square in [-1, 1] space\n varyings.unitPosition = edgePadding * attributes.positions.xy;\n geometry.uv = varyings.unitPosition;\n geometry.pickingColor = attributes.instancePickingColors;\n\n varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;\n\n if (scatterplot.billboard != 0) {\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n let offset = attributes.positions; // * edgePadding * varyings.outerRadiusPixels;\n // DECKGL_FILTER_SIZE(offset, geometry);\n let clipPixels = project_pixel_size_to_clipspace(offset.xy);\n varyings.position.x = clipPixels.x;\n varyings.position.y = clipPixels.y;\n } else {\n let offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);\n // DECKGL_FILTER_SIZE(offset, geometry);\n varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);\n // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);\n }\n\n // Apply opacity to instance color, or return instance picking color\n varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);\n varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity);\n // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);\n varyings.pickingColor = attributes.instancePickingColors;\n\n return varyings;\n}\n\n@fragment\nfn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {\n // var geometry: Geometry;\n // geometry.uv = unitPosition;\n\n let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;\n let inCircle = select(\n smoothedge(distToCenter, varyings.outerRadiusPixels),\n step(distToCenter, varyings.outerRadiusPixels),\n scatterplot.antialiasing != 0\n );\n\n if (inCircle == 0.0) {\n discard;\n }\n\n var fragColor: vec4<f32>;\n\n if (scatterplot.stroked != 0) {\n let isLine = select(\n smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),\n scatterplot.antialiasing != 0\n );\n\n if (scatterplot.filled != 0) {\n fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);\n } else {\n if (isLine == 0.0) {\n discard;\n }\n fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);\n }\n } else if (scatterplot.filled == 0) {\n discard;\n } else {\n fragColor = varyings.vFillColor;\n }\n\n fragColor.a *= inCircle;\n\n if (picking.isActive > 0.5) {\n if (!picking_isColorValid(varyings.pickingColor)) {\n discard;\n }\n return vec4<f32>(varyings.pickingColor, 1.0);\n }\n\n if (picking.isHighlightActive > 0.5) {\n let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {\n let highLightAlpha = picking.highlightColor.a;\n let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha);\n if (blendedAlpha > 0.0) {\n let highLightRatio = highLightAlpha / blendedAlpha;\n fragColor = vec4<f32>(\n mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio),\n blendedAlpha\n );\n } else {\n fragColor = vec4<f32>(fragColor.rgb, 0.0);\n }\n }\n }\n\n // Apply premultiplied alpha as required by transparent canvas\n fragColor = deckgl_premultiplied_alpha(fragColor);\n\n return fragColor;\n // return vec4<f32>(0, 0, 1, 1);\n}\n",modules:[Jn,Qn,Kn,qo]})}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}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:t,radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,stroked:o,filled:s,billboard:a,antialiasing:A,lineWidthUnits:l,lineWidthScale:c,lineWidthMinPixels:u,lineWidthMaxPixels:f}=this.props,h={stroked:o,filled:s,billboard:a,antialiasing:A,radiusUnits:ze[t],radiusScale:n,radiusMinPixels:i,radiusMaxPixels:r,lineWidthUnits:ze[l],lineWidthScale:c,lineWidthMinPixels:u,lineWidthMaxPixels:f},d=this.state.model;d.shaderInputs.setProps({scatterplot:h}),d.draw(this.context.renderPass)}_getModel(){return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Qi({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0])}}}),isInstanced:!0})}}Zo.defaultProps=Xo,Zo.layerName="ScatterplotLayer";const $o=1,es=-1;function ts(e,t,n={}){const i=function(e,t={}){return Math.sign(function(e,t={}){const{start:n=0,end:i=e.length,plane:r="xy"}=t,o=t.size||2;let s=0;const a=ns[r[0]],A=ns[r[1]];for(let l=n,c=i-o;l<i;l+=o)s+=(e[l+a]-e[c+a])*(e[l+A]+e[c+A]),c=l;return s/2}(e,t))}(e,n);return i!==t&&(function(e,t){const{start:n=0,end:i=e.length,size:r=2}=t,o=(i-n)/r,s=Math.floor(o/2);for(let a=0;a<s;++a){const t=n+a*r,i=n+(o-1-a)*r;for(let n=0;n<r;++n){const r=e[t+n];e[t+n]=e[i+n],e[i+n]=r}}}(e,n),!0)}const ns={x:0,y:1,z:2};function is(e,t){const n=t.length,i=e.length;if(i>0){let r=!0;for(let o=0;o<n;o++)if(e[i-n+o]!==t[o]){r=!1;break}if(r)return!1}for(let r=0;r<n;r++)e[i+r]=t[r];return!0}function rs(e,t){const n=t.length;for(let i=0;i<n;i++)e[i]=t[i]}function os(e,t,n,i,r=[]){const o=i+t*n;for(let s=0;s<n;s++)r[s]=e[o+s];return r}function ss(e,t,n,i,r=[]){let o,s;if(8&n)o=(i[3]-e[1])/(t[1]-e[1]),s=3;else if(4&n)o=(i[1]-e[1])/(t[1]-e[1]),s=1;else if(2&n)o=(i[2]-e[0])/(t[0]-e[0]),s=2;else{if(!(1&n))return null;o=(i[0]-e[0])/(t[0]-e[0]),s=0}for(let a=0;a<e.length;a++)r[a]=(1&s)===a?i[s]:o*(t[a]-e[a])+e[a];return r}function as(e,t){let n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}function As(e,t){const{size:n=2,broken:i=!1,gridResolution:r=10,gridOffset:o=[0,0],startIndex:s=0,endIndex:a=e.length}=t||{},A=(a-s)/n;let l=[];const c=[l],u=os(e,0,n,s);let f,h;const d=us(u,r,o,[]),p=[];is(l,u);for(let g=1;g<A;g++){for(f=os(e,g,n,s,f),h=as(f,d);h;){ss(u,f,h,d,p);const e=as(p,d);e&&(ss(u,p,e,d,p),h=e),is(l,p),rs(u,p),fs(d,r,h),i&&l.length>n&&(l=[],c.push(l),is(l,u)),h=as(f,d)}is(l,f),rs(u,f)}return i?c:c[0]}function ls(e,t=null,n){if(!e.length)return[];const{size:i=2,gridResolution:r=10,gridOffset:o=[0,0],edgeTypes:s=!1}=n||{},a=[],A=[{pos:e,types:s?new Array(e.length/i).fill(1):null,holes:t||[]}],l=[[],[]];let c=[];for(;A.length;){const{pos:e,types:t,holes:n}=A.shift();hs(e,i,n[0]||e.length,l),c=us(l[0],r,o,c);const u=as(l[1],c);if(u){let r=cs(e,t,i,0,n[0]||e.length,c,u);const o={pos:r[0].pos,types:r[0].types,holes:[]},a={pos:r[1].pos,types:r[1].types,holes:[]};A.push(o,a);for(let A=0;A<n.length;A++)r=cs(e,t,i,n[A],n[A+1]||e.length,c,u),r[0]&&(o.holes.push(o.pos.length),o.pos=ds(o.pos,r[0].pos),s&&(o.types=ds(o.types,r[0].types))),r[1]&&(a.holes.push(a.pos.length),a.pos=ds(a.pos,r[1].pos),s&&(a.types=ds(a.types,r[1].types)))}else{const i={positions:e};s&&(i.edgeTypes=t),n.length&&(i.holeIndices=n),a.push(i)}}return a}function cs(e,t,n,i,r,o,s){const a=(r-i)/n,A=[],l=[],c=[],u=[],f=[];let h,d,p;const g=os(e,a-1,n,i);let m=Math.sign(8&s?g[1]-o[3]:g[0]-o[2]),b=t&&t[a-1],y=0,v=0;for(let _=0;_<a;_++)h=os(e,_,n,i,h),d=Math.sign(8&s?h[1]-o[3]:h[0]-o[2]),p=t&&t[i/n+_],d&&m&&m!==d&&(ss(g,h,s,o,f),is(A,f)&&c.push(b),is(l,f)&&u.push(b)),d<=0?(is(A,h)&&c.push(p),y-=d):c.length&&(c[c.length-1]=0),d>=0?(is(l,h)&&u.push(p),v+=d):u.length&&(u[u.length-1]=0),rs(g,h),m=d,b=p;return[y?{pos:A,types:t&&c}:null,v?{pos:l,types:t&&u}:null]}function us(e,t,n,i){const r=Math.floor((e[0]-n[0])/t)*t+n[0],o=Math.floor((e[1]-n[1])/t)*t+n[1];return i[0]=r,i[1]=o,i[2]=r+t,i[3]=o+t,i}function fs(e,t,n){8&n?(e[1]+=t,e[3]+=t):4&n?(e[1]-=t,e[3]-=t):2&n?(e[0]+=t,e[2]+=t):1&n&&(e[0]-=t,e[2]-=t)}function hs(e,t,n,i){let r=1/0,o=-1/0,s=1/0,a=-1/0;for(let A=0;A<n;A+=t){const t=e[A],n=e[A+1];r=t<r?t:r,o=t>o?t:o,s=n<s?n:s,a=n>a?n:a}return i[0][0]=r,i[0][1]=s,i[1][0]=o,i[1][1]=a,i}function ds(e,t){for(let n=0;n<t.length;n++)e.push(t[n]);return e}function ps(e,t,n,i){let r=-1,o=-1;for(let s=n+1;s<i;s+=t){const t=Math.abs(e[s]);t>r&&(r=t,o=s-1)}return o}function gs(e,t,n,i,r=85.051129){const o=e[n],s=e[i-t];if(Math.abs(o-s)>180){const i=os(e,0,t,n);i[0]+=360*Math.round((s-o)/360),is(e,i),i[1]=Math.sign(i[1])*r,is(e,i),i[0]=o,is(e,i)}}function ms(e,t,n,i){let r,o=e[0];for(let s=n;s<i;s+=t){r=e[s];const t=r-o;(t>180||t<-180)&&(r-=360*Math.round(t/360)),e[s]=o=r}}function bs(e,t){let n;const i=e.length/t;for(let o=0;o<i&&(n=e[o*t],(n+180)%360==0);o++);const r=360*-Math.round(n/360);if(0!==r)for(let o=0;o<i;o++)e[o*t]+=r}class ys extends Qi{constructor(e){const{indices:t,attributes:n}=function(e){const{radius:t,height:n=1,nradial:i=10}=e;let{vertices:r}=e;r&&(Ce.assert(r.length>=i),r=r.flatMap(e=>[e[0],e[1]]),ts(r,es));const o=n>0,s=i+1,a=o?3*s+1:i,A=2*Math.PI/i,l=new Uint16Array(o?3*i*2:0),c=new Float32Array(3*a),u=new Float32Array(3*a);let f=0;if(o){for(let e=0;e<s;e++){const o=e*A,s=e%i,a=Math.sin(o),l=Math.cos(o);for(let e=0;e<2;e++)c[f+0]=r?r[2*s]:l*t,c[f+1]=r?r[2*s+1]:a*t,c[f+2]=(.5-e)*n,u[f+0]=r?r[2*s]:l,u[f+1]=r?r[2*s+1]:a,f+=3}c[f+0]=c[f-3],c[f+1]=c[f-2],c[f+2]=c[f-1],f+=3}for(let h=o?0:1;h<s;h++){const e=Math.floor(h/2)*Math.sign(.5-h%2),o=e*A,s=(e+i)%i,a=Math.sin(o),l=Math.cos(o);c[f+0]=r?r[2*s]:l*t,c[f+1]=r?r[2*s+1]:a*t,c[f+2]=n/2,u[f+2]=1,f+=3}if(o){let e=0;for(let t=0;t<i;t++)l[e++]=2*t+0,l[e++]=2*t+2,l[e++]=2*t+0,l[e++]=2*t+1,l[e++]=2*t+1,l[e++]=2*t+3}return{indices:l,attributes:{POSITION:{size:3,value:c},NORMAL:{size:3,value:u}}}}(e);super({...e,indices:t,attributes:n})}}const vs="layout(std140) uniform columnUniforms {\n float radius;\n float angle;\n vec2 offset;\n bool extruded;\n bool stroked;\n bool isStroke;\n float coverage;\n float elevationScale;\n float edgeDistance;\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n highp int radiusUnits;\n highp int widthUnits;\n} column;\n",_s={name:"column",vs:vs,fs:vs,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"}},Cs=[0,0,0,255],xs={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:e=>e.position},getFillColor:{type:"accessor",value:Cs},getLineColor:{type:"accessor",value:Cs},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class ws extends co{getShaders(){const e={},{flatShading:t}=this.props;return t&&(e.FLAT_SHADING=1),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME column-layer-vertex-shader\nin vec3 positions;\nin vec3 normals;\nin vec3 instancePositions;\nin float instanceElevations;\nin vec3 instancePositions64Low;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin float instanceStrokeWidths;\nin vec3 instancePickingColors;\nout vec4 vColor;\n#ifdef FLAT_SHADING\nout vec3 cameraPosition;\nout vec4 position_commonspace;\n#endif\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nvec4 color = column.isStroke ? instanceLineColors : instanceFillColors;\nmat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle));\nfloat elevation = 0.0;\nfloat strokeOffsetRatio = 1.0;\nif (column.extruded) {\nelevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale;\n} else if (column.stroked) {\nfloat widthPixels = clamp(\nproject_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits),\ncolumn.widthMinPixels, column.widthMaxPixels) / 2.0;\nfloat halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius);\nif (column.isStroke) {\nstrokeOffsetRatio -= sign(positions.z) * halfOffset;\n} else {\nstrokeOffsetRatio -= halfOffset;\n}\n}\nfloat shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);\nfloat dotRadius = column.radius * column.coverage * shouldRender;\ngeometry.pickingColor = instancePickingColors;\nvec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);\nvec3 centroidPosition64Low = instancePositions64Low;\nvec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius;\nif (column.radiusUnits == UNIT_METERS) {\noffset = project_size(offset);\n} else if (column.radiusUnits == UNIT_PIXELS) {\noffset = project_pixel_size(offset);\n}\nvec3 pos = vec3(offset, 0.);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);\ngeometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (column.extruded && !column.isStroke) {\n#ifdef FLAT_SHADING\ncameraPosition = project.cameraPosition;\nposition_commonspace = geometry.position;\nvColor = vec4(color.rgb, color.a * layer.opacity);\n#else\nvec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, color.a * layer.opacity);\n#endif\n} else {\nvColor = vec4(color.rgb, color.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME column-layer-fragment-shader\nprecision highp float;\nout vec4 fragColor;\nin vec4 vColor;\n#ifdef FLAT_SHADING\nin vec3 cameraPosition;\nin vec4 position_commonspace;\n#endif\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\n#ifdef FLAT_SHADING\nif (column.extruded && !column.isStroke && !bool(picking.isActive)) {\nvec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\nfragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);\n}\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:e,modules:[Jn,t?Vn:zn,Kn,_s]})}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:Cs},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:Cs},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,r=i.extensionsChanged||t.flatShading!==n.flatShading;r&&(this.state.models?.forEach(e=>e.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());const o=this.getNumInstances();this.state.fillModel.setInstanceCount(o),this.state.wireframeModel.setInstanceCount(o),(r||t.diskResolution!==n.diskResolution||t.vertices!==n.vertices||(t.extruded||t.stroked)!==(n.extruded||n.stroked))&&this._updateGeometry(t)}getGeometry(e,t,n){const i=new ys({radius:1,height:n?2:0,vertices:t,nradial:e});let r=0;if(t)for(let o=0;o<e;o++){const n=t[o];r+=Math.sqrt(n[0]*n[0]+n[1]*n[1])/e}else r=1;return this.setState({edgeDistance:Math.cos(Math.PI/e)*r}),i}_getModels(){const e=this.getShaders(),t=this.getAttributeManager().getBufferLayouts(),n=new ki(this.context.device,{...e,id:`${this.props.id}-fill`,bufferLayout:t,isInstanced:!0}),i=new ki(this.context.device,{...e,id:`${this.props.id}-wireframe`,bufferLayout:t,isInstanced:!0});return{fillModel:n,wireframeModel:i,models:[i,n]}}_updateGeometry({diskResolution:e,vertices:t,extruded:n,stroked:i}){const r=this.getGeometry(e,t,n||i);this.setState({fillVertexCount:r.attributes.POSITION.value.length/3});const o=this.state.fillModel,s=this.state.wireframeModel;o.setGeometry(r),o.setTopology("triangle-strip"),o.setIndexBuffer(null),s.setGeometry(r),s.setTopology("line-list")}draw({uniforms:e}){const{lineWidthUnits:t,lineWidthScale:n,lineWidthMinPixels:i,lineWidthMaxPixels:r,radiusUnits:o,elevationScale:s,extruded:a,filled:A,stroked:l,wireframe:c,offset:u,coverage:f,radius:h,angle:d}=this.props,p=this.state.fillModel,g=this.state.wireframeModel,{fillVertexCount:m,edgeDistance:b}=this.state,y={radius:h,angle:d/180*Math.PI,offset:u,extruded:a,stroked:l,coverage:f,elevationScale:s,edgeDistance:b,radiusUnits:ze[o],widthUnits:ze[t],widthScale:n,widthMinPixels:i,widthMaxPixels:r};a&&c&&(g.shaderInputs.setProps({column:{...y,isStroke:!0}}),g.draw(this.context.renderPass)),A&&(p.setVertexCount(m),p.shaderInputs.setProps({column:{...y,isStroke:!1}}),p.draw(this.context.renderPass)),!a&&l&&(p.setVertexCount(2*m/3),p.shaderInputs.setProps({column:{...y,isStroke:!0}}),p.draw(this.context.renderPass))}}function Bs(e,t,n,i){let r;if(Array.isArray(e[0])){const n=e.length*t;r=new Array(n);for(let i=0;i<e.length;i++)for(let n=0;n<t;n++)r[i*t+n]=e[i][n]||0}else r=e;return n?As(r,{size:t,gridResolution:n}):i?function(e,t){const{size:n=2,startIndex:i=0,endIndex:r=e.length,normalize:o=!0}=t||{},s=e.slice(i,r);ms(s,n,0,r-i);const a=As(s,{size:n,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(o)for(const A of a)bs(A,n);return a}(r,{size:t}):r}ws.layerName="ColumnLayer",ws.defaultProps=xs;class Ms extends po{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?Bs(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(Ss(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}const t=this.getPathLength(e);return t<2?0:this.isClosed(e)?t<3?0:t+2:t}updateGeometryAttributes(e,t){if(0!==t.geometrySize)if(e&&Ss(e))for(const n of e){const e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e}else this._updateSegmentTypes(e,t),this._updatePositions(e,t)}_updateSegmentTypes(e,t){const n=this.attributes.segmentTypes,i=!!e&&this.isClosed(e),{vertexStart:r,geometrySize:o}=t;n.fill(0,r,r+o),i?(n[r]=4,n[r+o-2]=4):(n[r]+=1,n[r+o-2]+=2),n[r+o-1]=4}_updatePositions(e,t){const{positions:n}=this.attributes;if(!n||!e)return;const{vertexStart:i,geometrySize:r}=t,o=new Array(3);for(let s=i,a=0;a<r;s++,a++)this.getPointOnPath(e,a,o),n[3*s]=o[0],n[3*s+1]=o[1],n[3*s+2]=o[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,t,n=[]){const{positionSize:i}=this;t*i>=e.length&&(t+=1-e.length/i);const r=t*i;return n[0]=e[r],n[1]=e[r+1],n[2]=3===i&&e[r+2]||0,n}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:t}=this,n=e.length-t;return e[0]===e[n]&&e[1]===e[n+1]&&(2===t||e[2]===e[n+2])}}function Ss(e){return Array.isArray(e[0])}const Ts="layout(std140) uniform pathUniforms {\n float widthScale;\n float widthMinPixels;\n float widthMaxPixels;\n float jointType;\n float capType;\n float miterLimit;\n bool billboard;\n highp int widthUnits;\n} path;\n",Es={name:"path",vs:Ts,fs:Ts,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},Ps=[0,0,0,255],Is={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:e=>e.path},getColor:{type:"accessor",value:Ps},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Ls={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class Rs extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME path-layer-vertex-shader\nin vec2 positions;\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\nfloat flipIfTrue(bool flag) {\nreturn -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\nvec3 prevPoint, vec3 currPoint, vec3 nextPoint,\nvec2 width\n) {\nbool isEnd = positions.x > 0.0;\nfloat sideOfPath = positions.y;\nfloat isJoint = float(sideOfPath == 0.0);\nvec3 deltaA3 = (currPoint - prevPoint);\nvec3 deltaB3 = (nextPoint - currPoint);\nmat3 rotationMatrix;\nbool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);\nif (needsRotation) {\ndeltaA3 = deltaA3 * rotationMatrix;\ndeltaB3 = deltaB3 * rotationMatrix;\n}\nvec2 deltaA = deltaA3.xy / width;\nvec2 deltaB = deltaB3.xy / width;\nfloat lenA = length(deltaA);\nfloat lenB = length(deltaB);\nvec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\nvec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\nvec2 perpA = vec2(-dirA.y, dirA.x);\nvec2 perpB = vec2(-dirB.y, dirB.x);\nvec2 tangent = dirA + dirB;\ntangent = length(tangent) > 0. ? normalize(tangent) : perpA;\nvec2 miterVec = vec2(-tangent.y, tangent.x);\nvec2 dir = isEnd ? dirA : dirB;\nvec2 perp = isEnd ? perpA : perpB;\nfloat L = isEnd ? lenA : lenB;\nfloat sinHalfA = abs(dot(miterVec, perp));\nfloat cosHalfA = abs(dot(dirA, miterVec));\nfloat turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\nfloat cornerPosition = sideOfPath * turnDirection;\nfloat miterSize = 1.0 / max(sinHalfA, EPSILON);\nmiterSize = mix(\nmin(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\nmiterSize,\nstep(0.0, cornerPosition)\n);\nvec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n* (sideOfPath + isJoint * turnDirection);\nbool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\nbool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\nbool isCap = isStartCap || isEndCap;\nif (isCap) {\noffsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);\nvJointType = path.capType;\n} else {\nvJointType = path.jointType;\n}\nvPathLength = L;\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\ndot(offsetFromStartOfPath, dir)\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\nif (needsRotation) {\noffset = rotationMatrix * offset;\n}\nreturn offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\nif (position.w < EPSILON) {\nfloat r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\nposition = refPosition + (position - refPosition) * r;\n}\n}\nvoid main() {\ngeometry.pickingColor = instancePickingColors;\nvColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\nfloat isEnd = positions.x;\nvec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\nvec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\nvec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\nvec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\nvec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\nvec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\ngeometry.worldPosition = currPosition;\nvec2 widthPixels = vec2(clamp(\nproject_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),\npath.widthMinPixels, path.widthMaxPixels) / 2.0);\nvec3 width;\nif (path.billboard) {\nvec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\nvec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n);\nDECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\ngl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n} else {\nprevPosition = project_position(prevPosition, prevPosition64Low);\ncurrPosition = project_position(currPosition, currPosition64Low);\nnextPosition = project_position(nextPosition, nextPosition64Low);\nwidth = vec3(project_pixel_size(widthPixels), 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\ngeometry.position = vec4(currPosition + offset, 1.0);\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME path-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 vCornerOffset;\nin float vMiterLength;\nin vec2 vPathPosition;\nin float vPathLength;\nin float vJointType;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Jn,Kn,Es]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const e=!0;this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Ls,accessor:"getPath",update:this.calculatePositions,noAlloc:e,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:e},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Ls,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Ls,defaultValue:Ps},instancePickingColors:{size:4,type:"uint8",accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}}),this.setState({pathTesselator:new Ms({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);const{props:t,changeFlags:n}=e,i=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){const{pathTesselator:e}=this.state,r=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:r.getPath,buffers:r,normalize:!t._pathType,loop:"loop"===t._pathType,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),n.dataChanged||i.invalidateAll()}n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,i=this.props.data;return i[0]&&i[0].__source&&(t.object=i.find(e=>e.__source.index===n)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{jointRounded:t,capRounded:n,billboard:i,miterLimit:r,widthUnits:o,widthScale:s,widthMinPixels:a,widthMaxPixels:A}=this.props,l=this.state.model,c={jointType:Number(t),capType:Number(n),billboard:i,widthUnits:ze[o],widthScale:s,miterLimit:r,widthMinPixels:a,widthMaxPixels:A};l.shaderInputs.setProps({path:c}),l.draw(this.context.renderPass)}_getModel(){return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Qi({topology:"triangle-list",attributes:{indices:new Uint16Array([0,1,2,1,4,2,1,3,4,3,5,4]),positions:{value:new Float32Array([0,0,0,-1,0,1,1,-1,1,1,1,0]),size:2}}}),isInstanced:!0})}calculatePositions(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateSegmentTypes(e){const{pathTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("segmentTypes")}}Rs.defaultProps=Is,Rs.layerName="PathLayer";var Fs,Os={exports:{}};const Ds=/* @__PURE__ */lt(function(){if(Fs)return Os.exports;function e(e,n,r){r=r||2;var o,s,a,c,u,h,d,p=n&&n.length,g=p?n[0]*r:e.length,m=t(e,0,g,r,!0),b=[];if(!m||m.next===m.prev)return b;if(p&&(m=function(e,n,i,r){var o,s,a,c=[];for(o=0,s=n.length;o<s;o++)(a=t(e,n[o]*r,o<s-1?n[o+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),c.push(f(a));for(c.sort(A),o=0;o<c.length;o++)i=l(c[o],i);return i}(e,n,m,r)),e.length>80*r){o=a=e[0],s=c=e[1];for(var y=r;y<g;y+=r)(u=e[y])<o&&(o=u),(h=e[y+1])<s&&(s=h),u>a&&(a=u),h>c&&(c=h);d=0!==(d=Math.max(a-o,c-s))?32767/d:0}return i(m,b,r,o,s,d,0),b}function t(e,t,n,i,r){var o,s;if(r===B(e,t,n,i)>0)for(o=t;o<n;o+=i)s=C(o,e[o],e[o+1],s);else for(o=n-i;o>=t;o-=i)s=C(o,e[o],e[o+1],s);return s&&g(s,s.next)&&(x(s),s=s.next),s}function n(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!g(i,i.next)&&0!==p(i.prev,i,i.next))i=i.next;else{if(x(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function i(e,t,A,l,c,f,h){if(e){!h&&f&&function(e,t,n,i){var r=e;do{0===r.z&&(r.z=u(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,n,i,r,o,s,a,A,l=1;do{for(n=e,e=null,o=null,s=0;n;){for(s++,i=n,a=0,t=0;t<l&&(a++,i=i.nextZ);t++);for(A=l;a>0||A>0&&i;)0!==a&&(0===A||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,A--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=i}o.nextZ=null,l*=2}while(s>1)}(r)}(e,l,c,f);for(var d,p,g=e;e.prev!==e.next;)if(d=e.prev,p=e.next,f?o(e,l,c,f):r(e))t.push(d.i/A|0),t.push(e.i/A|0),t.push(p.i/A|0),x(e),e=p.next,g=p.next;else if((e=p)===g){h?1===h?i(e=s(n(e),t,A),t,A,l,c,f,2):2===h&&a(e,t,A,l,c,f):i(n(e),t,A,l,c,f,1);break}}}function r(e){var t=e.prev,n=e,i=e.next;if(p(t,n,i)>=0)return!1;for(var r=t.x,o=n.x,s=i.x,a=t.y,A=n.y,l=i.y,c=r<o?r<s?r:s:o<s?o:s,u=a<A?a<l?a:l:A<l?A:l,f=r>o?r>s?r:s:o>s?o:s,d=a>A?a>l?a:l:A>l?A:l,g=i.next;g!==t;){if(g.x>=c&&g.x<=f&&g.y>=u&&g.y<=d&&h(r,a,o,A,s,l,g.x,g.y)&&p(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function o(e,t,n,i){var r=e.prev,o=e,s=e.next;if(p(r,o,s)>=0)return!1;for(var a=r.x,A=o.x,l=s.x,c=r.y,f=o.y,d=s.y,g=a<A?a<l?a:l:A<l?A:l,m=c<f?c<d?c:d:f<d?f:d,b=a>A?a>l?a:l:A>l?A:l,y=c>f?c>d?c:d:f>d?f:d,v=u(g,m,t,n,i),_=u(b,y,t,n,i),C=e.prevZ,x=e.nextZ;C&&C.z>=v&&x&&x.z<=_;){if(C.x>=g&&C.x<=b&&C.y>=m&&C.y<=y&&C!==r&&C!==s&&h(a,c,A,f,l,d,C.x,C.y)&&p(C.prev,C,C.next)>=0)return!1;if(C=C.prevZ,x.x>=g&&x.x<=b&&x.y>=m&&x.y<=y&&x!==r&&x!==s&&h(a,c,A,f,l,d,x.x,x.y)&&p(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;C&&C.z>=v;){if(C.x>=g&&C.x<=b&&C.y>=m&&C.y<=y&&C!==r&&C!==s&&h(a,c,A,f,l,d,C.x,C.y)&&p(C.prev,C,C.next)>=0)return!1;C=C.prevZ}for(;x&&x.z<=_;){if(x.x>=g&&x.x<=b&&x.y>=m&&x.y<=y&&x!==r&&x!==s&&h(a,c,A,f,l,d,x.x,x.y)&&p(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function s(e,t,i){var r=e;do{var o=r.prev,s=r.next.next;!g(o,s)&&m(o,r,r.next,s)&&v(o,s)&&v(s,o)&&(t.push(o.i/i|0),t.push(r.i/i|0),t.push(s.i/i|0),x(r),x(r.next),r=e=s),r=r.next}while(r!==e);return n(r)}function a(e,t,r,o,s,a){var A=e;do{for(var l=A.next.next;l!==A.prev;){if(A.i!==l.i&&d(A,l)){var c=_(A,l);return A=n(A,A.next),c=n(c,c.next),i(A,t,r,o,s,a,0),void i(c,t,r,o,s,a,0)}l=l.next}A=A.next}while(A!==e)}function A(e,t){return e.x-t.x}function l(e,t){var i=function(e,t){var n,i=t,r=e.x,o=e.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==t);if(!n)return null;var A,l=n,u=n.x,f=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=u&&r!==i.x&&h(o<f?r:s,o,u,f,o<f?s:r,o,i.x,i.y)&&(A=Math.abs(o-i.y)/(r-i.x),v(i,e)&&(A<d||A===d&&(i.x>n.x||i.x===n.x&&c(n,i)))&&(n=i,d=A)),i=i.next}while(i!==l);return n}(e,t);if(!i)return t;var r=_(i,e);return n(r,r.next),n(i,i.next)}function c(e,t){return p(e.prev,e,t.prev)<0&&p(t.next,e,e.next)<0}function u(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function f(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function h(e,t,n,i,r,o,s,a){return(r-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(i-a)>=(n-s)*(t-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function d(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&m(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(v(e,t)&&v(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(p(e.prev,e,t.prev)||p(e,t.prev,t))||g(e,t)&&p(e.prev,e,e.next)>0&&p(t.prev,t,t.next)>0)}function p(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function g(e,t){return e.x===t.x&&e.y===t.y}function m(e,t,n,i){var r=y(p(e,t,n)),o=y(p(e,t,i)),s=y(p(n,i,e)),a=y(p(n,i,t));return r!==o&&s!==a||(!(0!==r||!b(e,n,t))||(!(0!==o||!b(e,i,t))||(!(0!==s||!b(n,e,i))||!(0!==a||!b(n,t,i)))))}function b(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function y(e){return e>0?1:e<0?-1:0}function v(e,t){return p(e.prev,e,e.next)<0?p(e,t,e.next)>=0&&p(e,e.prev,t)>=0:p(e,t,e.prev)<0||p(e,e.next,t)<0}function _(e,t){var n=new w(e.i,e.x,e.y),i=new w(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function C(e,t,n,i){var r=new w(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function x(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function w(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function B(e,t,n,i){for(var r=0,o=t,s=n-i;o<n;o+=i)r+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return r}return Fs=1,Os.exports=e,Os.exports.default=e,e.deviation=function(e,t,n,i){var r=t&&t.length,o=r?t[0]*n:e.length,s=Math.abs(B(e,0,o,n));if(r)for(var a=0,A=t.length;a<A;a++){var l=t[a]*n,c=a<A-1?t[a+1]*n:e.length;s-=Math.abs(B(e,l,c,n))}var u=0;for(a=0;a<i.length;a+=3){var f=i[a]*n,h=i[a+1]*n,d=i[a+2]*n;u+=Math.abs((e[f]-e[d])*(e[h+1]-e[f+1])-(e[f]-e[h])*(e[d+1]-e[f+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},e.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},i=0,r=0;r<e.length;r++){for(var o=0;o<e[r].length;o++)for(var s=0;s<t;s++)n.vertices.push(e[r][o][s]);r>0&&(i+=e[r-1].length,n.holes.push(i))}return n},Os.exports}()),Ns=$o,Us=es,ks={};function Gs(e){return"positions"in e?e.positions:e}function zs(e){return"holeIndices"in e?e.holeIndices:null}function Vs(e,t,n,i,r){let o=t;const s=n.length;for(let a=0;a<s;a++)for(let t=0;t<i;t++)e[o++]=n[a][t]||0;if(!function(e){const t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}(n))for(let a=0;a<i;a++)e[o++]=n[0][a]||0;return ks.start=t,ks.end=o,ks.size=i,ts(e,r,ks),o}function Hs(e,t,n,i,r=0,o,s){const a=(o=o||n.length)-r;if(a<=0)return t;let A=t;for(let l=0;l<a;l++)e[A++]=n[r+l];if(!function(e,t,n,i){for(let r=0;r<t;r++)if(e[n+r]!==e[i-t+r])return!1;return!0}(n,i,r,o))for(let l=0;l<i;l++)e[A++]=n[r+l];return ks.start=t,ks.end=A,ks.size=i,ts(e,s,ks),A}function js(e,t){!function(e){if(e=e&&e.positions||e,!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error("invalid polygon")}(e);const n=[],i=[];if("positions"in e){const{positions:r,holeIndices:o}=e;if(o){let e=0;for(let s=0;s<=o.length;s++)e=Hs(n,e,r,t,o[s-1],o[s],0===s?Ns:Us),i.push(e);return i.pop(),{positions:n,holeIndices:i}}e=r}if(!function(e){return Array.isArray(e[0])}(e))return Hs(n,0,e,t,0,n.length,Ns),n;if(!function(e){return e.length>=1&&e[0].length>=2&&Number.isFinite(e[0][0])}(e)){let r=0;for(const[o,s]of e.entries())r=Vs(n,r,s,t,0===o?Ns:Us),i.push(r);return i.pop(),{positions:n,holeIndices:i}}return Vs(n,0,e,t,Ns),n}function Qs(e,t,n){const i=e.length/3;let r=0;for(let o=0;o<i;o++){const s=(o+1)%i;r+=e[3*o+t]*e[3*s+n],r-=e[3*s+t]*e[3*o+n]}return Math.abs(r/2)}function Js(e,t,n,i){const r=e.length/3;for(let o=0;o<r;o++){const r=3*o,s=e[r+0],a=e[r+1],A=e[r+2];e[r+t]=s,e[r+n]=a,e[r+i]=A}}class Ks extends po{constructor(e){const{fp64:t,IndexType:n=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:t?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(e){const{attributes:t}=this;return"indices"===e?t.indices&&t.indices.subarray(0,this.vertexCount):t[e]}updateGeometry(e){super.updateGeometry(e);const t=this.buffers.indices;if(t)this.vertexCount=(t.value||t).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){const t=js(e,this.positionSize);return this.opts.resolution?ls(Gs(t),zs(t),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?function(e,t=null,n){const{size:i=2,normalize:r=!0,edgeTypes:o=!1}=n||{};t=t||[];const s=[],a=[];let A=0,l=0;for(let u=0;u<=t.length;u++){const r=t[u]||e.length,o=l,c=ps(e,i,A,r);for(let t=c;t<r;t++)s[l++]=e[t];for(let t=A;t<c;t++)s[l++]=e[t];ms(s,i,o,l),gs(s,i,o,l,n?.maxLatitude),A=r,a[u]=l}a.pop();const c=ls(s,a,{size:i,gridResolution:360,gridOffset:[-180,-180],edgeTypes:o});if(r)for(const u of c)bs(u.positions,i);return c}(Gs(t),zs(t),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):t}return e}getGeometrySize(e){if(Ws(e)){let t=0;for(const n of e)t+=this.getGeometrySize(n);return t}return Gs(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,t){if(e&&Ws(e))for(const n of e){const e=this.getGeometrySize(n);t.geometrySize=e,this.updateGeometryAttributes(n,t),t.vertexStart+=e,t.indexStart=this.indexStarts[t.geometryIndex+1]}else{const n=e;this._updateIndices(n,t),this._updatePositions(n,t),this._updateVertexValid(n,t)}}_updateIndices(e,{geometryIndex:t,vertexStart:n,indexStart:i}){const{attributes:r,indexStarts:o,typedArrayManager:s}=this;let a=r.indices;if(!a||!e)return;let A=i;const l=function(e,t,n,i){let r=zs(e);r&&(r=r.map(e=>e/t));let o=Gs(e);const s=i&&3===t;if(n){const e=o.length;o=o.slice();const i=[];for(let r=0;r<e;r+=t){i[0]=o[r],i[1]=o[r+1],s&&(i[2]=o[r+2]);const e=n(i);o[r]=e[0],o[r+1]=e[1],s&&(o[r+2]=e[2])}}if(s){const e=Qs(o,0,1),t=Qs(o,0,2),i=Qs(o,1,2);if(!e&&!t&&!i)return[];e>t&&e>i||(t>i?(n||(o=o.slice()),Js(o,0,2,1)):(n||(o=o.slice()),Js(o,2,0,1)))}return Ds(o,r,t)}(e,this.positionSize,this.opts.preproject,this.opts.full3d);a=s.allocate(a,i+l.length,{copy:!0});for(let c=0;c<l.length;c++)a[A++]=l[c]+n;o[t+1]=i+l.length,r.indices=a}_updatePositions(e,{vertexStart:t,geometrySize:n}){const{attributes:{positions:i},positionSize:r}=this;if(!i||!e)return;const o=Gs(e);for(let s=t,a=0;a<n;s++,a++){const e=o[a*r],t=o[a*r+1],n=r>2?o[a*r+2]:0;i[3*s]=e,i[3*s+1]=t,i[3*s+2]=n}}_updateVertexValid(e,{vertexStart:t,geometrySize:n}){const{positionSize:i}=this,r=this.attributes.vertexValid,o=e&&zs(e);if(e&&e.edgeTypes?r.set(e.edgeTypes,t):r.fill(1,t,t+n),o)for(let s=0;s<o.length;s++)r[t+o[s]/i-1]=0;r[t+n-1]=0}}function Ws(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}const qs="layout(std140) uniform solidPolygonUniforms {\n bool extruded;\n bool isWireframe;\n float elevationScale;\n} solidPolygon;\n",Ys={name:"solidPolygon",vs:qs,fs:qs,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},Xs="in vec4 fillColors;\nin vec4 lineColors;\nin vec3 pickingColors;\nout vec4 vColor;\nstruct PolygonProps {\nvec3 positions;\nvec3 positions64Low;\nvec3 normal;\nfloat elevations;\n};\nvec3 project_offset_normal(vec3 vector) {\nif (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\nreturn normalize(vector * project.commonUnitsPerWorldUnit);\n}\nreturn project_normal(vector);\n}\nvoid calculatePosition(PolygonProps props) {\nvec3 pos = props.positions;\nvec3 pos64Low = props.positions64Low;\nvec3 normal = props.normal;\nvec4 colors = solidPolygon.isWireframe ? lineColors : fillColors;\ngeometry.worldPosition = props.positions;\ngeometry.pickingColor = pickingColors;\nif (solidPolygon.extruded) {\npos.z += props.elevations * solidPolygon.elevationScale;\n}\ngl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (solidPolygon.extruded) {\n#ifdef IS_SIDE_VERTEX\nnormal = project_offset_normal(normal);\n#else\nnormal = project_normal(normal);\n#endif\ngeometry.normal = normal;\nvec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, colors.a * layer.opacity);\n} else {\nvColor = vec4(colors.rgb, colors.a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",Zs=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${Xs}\nvoid main(void) {\nPolygonProps props;\nprops.positions = vertexPositions;\nprops.positions64Low = vertexPositions64Low;\nprops.elevations = elevations;\nprops.normal = vec3(0.0, 0.0, 1.0);\ncalculatePosition(props);\n}\n`,$s=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\nin vec2 positions;\nin vec3 vertexPositions;\nin vec3 nextVertexPositions;\nin vec3 vertexPositions64Low;\nin vec3 nextVertexPositions64Low;\nin float elevations;\nin float instanceVertexValid;\n${Xs}\nvoid main(void) {\nif(instanceVertexValid < 0.5){\ngl_Position = vec4(0.);\nreturn;\n}\nPolygonProps props;\nvec3 pos;\nvec3 pos64Low;\nvec3 nextPos;\nvec3 nextPos64Low;\n#if RING_WINDING_ORDER_CW == 1\npos = vertexPositions;\npos64Low = vertexPositions64Low;\nnextPos = nextVertexPositions;\nnextPos64Low = nextVertexPositions64Low;\n#else\npos = nextVertexPositions;\npos64Low = nextVertexPositions64Low;\nnextPos = vertexPositions;\nnextPos64Low = vertexPositions64Low;\n#endif\nprops.positions = mix(pos, nextPos, positions.x);\nprops.positions64Low = mix(pos64Low, nextPos64Low, positions.x);\nprops.normal = vec3(\npos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\nnextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n0.0);\nprops.elevations = elevations * positions.y;\ncalculatePosition(props);\n}\n`,ea=[0,0,0,255],ta={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:e=>e.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ea},getLineColor:{type:"accessor",value:ea},material:!0},na={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class ia extends co{getShaders(e){return super.getShaders({vs:"top"===e?Zs:$s,fs:"#version 300 es\n#define SHADER_NAME solid-polygon-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[Jn,zn,Kn,Ys]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const{viewport:e}=this.context;let{coordinateSystem:t}=this.props;const{_full3d:n}=this.props;let i;e.isGeospatial&&"default"===t&&(t="lnglat"),"lnglat"===t&&(i=n?e.projectPosition.bind(e):e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Ks({preproject:i,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const r=this.getAttributeManager(),o=!0;r.remove(["instancePickingColors"]),r.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:na,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:na,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:na,accessor:"getFillColor",defaultValue:ea},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:na,accessor:"getLineColor",defaultValue:ea},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(e,{index:t,target:n})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,n)}})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n}=t,i=this.props.data;return i[0]&&i[0].__source&&(t.object=i.find(e=>e.__source.index===n)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let n=0;n<t.length;n++)t[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{extruded:t,filled:n,wireframe:i,elevationScale:r}=this.props,{topModel:o,sideModel:s,wireframeModel:a,polygonTesselator:A}=this.state,l={extruded:Boolean(t),elevationScale:r,isWireframe:!1};a&&i&&(a.setInstanceCount(A.instanceCount-1),a.shaderInputs.setProps({solidPolygon:{...l,isWireframe:!0}}),a.draw(this.context.renderPass)),s&&n&&(s.setInstanceCount(A.instanceCount-1),s.shaderInputs.setProps({solidPolygon:l}),s.draw(this.context.renderPass)),o&&n&&(o.setVertexCount(A.vertexCount),o.shaderInputs.setProps({solidPolygon:l}),o.draw(this.context.renderPass))}updateState(e){super.updateState(e),this.updateGeometry(e);const{props:t,oldProps:n,changeFlags:i}=e,r=this.getAttributeManager();(i.extensionsChanged||t.filled!==n.filled||t.extruded!==n.extruded)&&(this.state.models?.forEach(e=>e.destroy()),this.setState(this._getModels()),r.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){const{polygonTesselator:t}=this.state,i=e.data.attributes||{};t.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:i.getPolygon,buffers:i,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:e._full3d}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:e,filled:t,extruded:n}=this.props;let i,r,o;if(t){const t=this.getShaders("top");t.defines.NON_INSTANCED_MODEL=1;const n=this.getAttributeManager().getBufferLayouts({isInstanced:!1});i=new ki(this.context.device,{...t,id:`${e}-top`,topology:"triangle-list",bufferLayout:n,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){const t=this.getAttributeManager().getBufferLayouts({isInstanced:!0});r=new ki(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:t,geometry:new Qi({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new ki(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:t,geometry:new Qi({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:[r,o,i].filter(Boolean),topModel:i,sideModel:r,wireframeModel:o}}calculateIndices(e){const{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){const{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}}function ra({data:e,getIndex:t,dataRange:n,replace:i}){const{startRow:r=0,endRow:o=1/0}=n,s=e.length;let a=s,A=s;for(let u=0;u<s;u++){const n=t(e[u]);if(a>u&&n>=r&&(a=u),n>=o){A=u;break}}let l=a;const c=A-a!==i.length?e.slice(A):void 0;for(let u=0;u<i.length;u++)e[l++]=i[u];if(c){for(let t=0;t<c.length;t++)e[l++]=c[t];e.length=l}return{startRow:a,endRow:a+i.length}}ia.defaultProps=ta,ia.layerName="SolidPolygonLayer";const oa=[0,0,0,255],sa={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:e=>e.polygon},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:oa},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class aa extends fo{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&Ce.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){const t=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(t&&Array.isArray(e.dataChanged)){const t=this.state.paths.slice(),n=e.dataChanged.map(e=>ra({data:t,getIndex:e=>e.__source.index,dataRange:e,replace:this._getPaths(e)}));this.setState({paths:t,pathsDiff:n})}else t&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){const{data:t,getPolygon:n,positionFormat:i,_normalize:r}=this.props,o=[],s="XY"===i?2:3,{startRow:a,endRow:A}=e,{iterable:l,objectInfo:c}=ir(t,a,A);for(const u of l){c.index++;let e=n(u,c);r&&(e=js(e,s));const{holeIndices:t}=e,i=e.positions||e;if(t)for(let n=0;n<=t.length;n++){const e=i.slice(t[n-1]||0,t[n]||i.length);o.push(this.getSubLayerRow({path:e},u,c.index))}else o.push(this.getSubLayerRow({path:i},u,c.index))}return o}renderLayers(){const{data:e,_dataDiff:t,stroked:n,filled:i,extruded:r,wireframe:o,_normalize:s,_windingOrder:a,elevationScale:A,transitions:l,positionFormat:c}=this.props,{lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d,lineJointRounded:p,lineMiterLimit:g,lineDashJustified:m}=this.props,{getFillColor:b,getLineColor:y,getLineWidth:v,getLineDashArray:_,getElevation:C,getPolygon:x,updateTriggers:w,material:B}=this.props,{paths:M,pathsDiff:S}=this.state,T=this.getSubLayerClass("fill",ia),E=this.getSubLayerClass("stroke",Rs),P=this.shouldRenderSubLayer("fill",M)&&new T({_dataDiff:t,extruded:r,elevationScale:A,filled:i,wireframe:o,_normalize:s,_windingOrder:a,getElevation:C,getFillColor:b,getLineColor:r&&o?y:oa,material:B,transitions:l},this.getSubLayerProps({id:"fill",updateTriggers:w&&{getPolygon:w.getPolygon,getElevation:w.getElevation,getFillColor:w.getFillColor,lineColors:r&&o,getLineColor:w.getLineColor}}),{data:e,positionFormat:c,getPolygon:x});return[!r&&P,!r&&n&&this.shouldRenderSubLayer("stroke",M)&&new E({_dataDiff:S&&(()=>S),widthUnits:u,widthScale:f,widthMinPixels:h,widthMaxPixels:d,jointRounded:p,miterLimit:g,dashJustified:m,_pathType:"loop",transitions:l&&{getWidth:l.getLineWidth,getColor:l.getLineColor,getPath:l.getPolygon},getColor:this.getSubLayerAccessor(y),getWidth:this.getSubLayerAccessor(v),getDashArray:this.getSubLayerAccessor(_)},this.getSubLayerProps({id:"stroke",updateTriggers:w&&{getWidth:w.getLineWidth,getColor:w.getLineColor,getDashArray:w.getLineDashArray}}),{data:M,positionFormat:c,getPath:e=>e.path}),r&&P]}}aa.layerName="PolygonLayer",aa.defaultProps=sa;const Aa="layout(std140) uniform sdfUniforms {\n float gamma;\n bool enabled;\n float buffer;\n float outlineBuffer;\n vec4 outlineColor;\n} sdf;\n",la={name:"sdf",vs:Aa,fs:Aa,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},ca={none:0,start:1,center:2,end:3},ua={name:"text",vs:`layout(std140) uniform textUniforms {\n highp vec2 cutoffPixels;\n highp ivec2 align;\n highp float fontSize;\n bool flipY;\n} text;\n\n#define ALIGN_MODE_START ${ca.start}\n#define ALIGN_MODE_CENTER ${ca.center}\n#define ALIGN_MODE_END ${ca.end}\n`,getUniforms:({contentCutoffPixels:e=[0,0],contentAlignHorizontal:t="none",contentAlignVertical:n="none",fontSize:i,viewport:r})=>({cutoffPixels:e,align:[ca[t],ca[n]],fontSize:i,flipY:r?.flipY??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}},fa=.75;class ha extends zo{getShaders(){const e=super.getShaders();return{...e,modules:[...e.modules,ua,la],vs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nin vec4 instanceClipRect;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nfloat getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) {\nif (clipEnd < clipStart) return 0.0;\nif (mode == ALIGN_MODE_START) {\nreturn max(- (anchor + clipStart), 0.0);\n}\nif (mode == ALIGN_MODE_CENTER) {\nfloat _min = max(0., anchor + clipStart);\nfloat _max = min(extent, anchor + clipEnd);\nreturn _min < _max ? (_min + _max) / 2.0 - anchor : 0.0;\n}\nif (mode == ALIGN_MODE_END) {\nreturn min(extent - (anchor + clipEnd), 0.);\n}\nreturn 0.0;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),\nicon.sizeMinPixels, icon.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nvec2 anchorPosScreen;\nif (icon.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nanchorPosScreen = gl_Position.xy / gl_Position.w;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\nvec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0));\nanchorPosScreen = anchorPos.xy / anchorPos.w;\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nanchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (text.align.x > 0 || text.align.y > 0) {\nvec2 viewportPixels = project.viewportSize / project.devicePixelRatio;\nvec2 scrollPixels = vec2(\ngetPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x),\n-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y)\n);\npixelOffset += scrollPixels;\ngl_Position.xy += project_pixel_size_to_clipspace(scrollPixels);\n}\nif (instanceClipRect.z >= 0.) {\nif (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.x > 0.) {\nfloat vpWidth = project.viewportSize.x / project.devicePixelRatio;\nfloat l = max(anchorPosScreen.x + xy.x, 0.0);\nfloat r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth);\nif (r - l < text.cutoffPixels.x) {\ngl_Position = vec4(0.0);\n}\n}\n}\nif (instanceClipRect.w >= 0.) {\nif (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) {\ngl_Position = vec4(0.0);\n}\nelse if (text.cutoffPixels.y > 0.) {\nfloat vpHeight = project.viewportSize.y / project.devicePixelRatio;\nfloat t = max(anchorPosScreen.y - xy.y - wh.y, 0.0);\nfloat b = min(anchorPosScreen.y - xy.y, vpHeight);\nif (b - t < text.cutoffPixels.y) {\ngl_Position = vec4(0.0);\n}\n}\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / icon.iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME multi-icon-layer-fragment-shader\nprecision highp float;\nuniform sampler2D iconsTexture;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nif (!bool(picking.isActive)) {\nfloat alpha = texture(iconsTexture, vTextureCoords).a;\nvec4 color = vColor;\nif (sdf.enabled) {\nfloat distance = alpha;\nalpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);\nif (sdf.outlineBuffer > 0.0) {\nfloat inFill = alpha;\nfloat inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);\ncolor = mix(sdf.outlineColor, vColor, inFill);\nalpha = inBorder;\n}\n}\nfloat a = alpha * color.a;\nif (a < icon.alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color.rgb, a * layer.opacity);\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){super.initializeState();const e=this.getAttributeManager();e.attributes.instanceIconDefs.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(e,{index:t,target:n})=>this.encodePickingColor(t,n)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e,{outlineColor:r}=t;if(i.updateTriggersChanged&&(i.updateTriggersChanged.getIcon||i.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),r!==n.outlineColor){const e=[r[0]/255,r[1]/255,r[2]/255,(r[3]??255)/255];this.setState({outlineColor:e})}!t.sdf&&t.outlineWidth&&Ce.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){const{sdf:t,smoothing:n,fontSize:i,outlineWidth:r,contentCutoffPixels:o,contentAlignHorizontal:s,contentAlignVertical:a}=this.props,{outlineColor:A}=this.state,l=r?Math.max(n,fa*(1-r)):-1,c=this.state.model,u={buffer:fa,outlineBuffer:l,gamma:n,enabled:Boolean(t),outlineColor:A},f={contentCutoffPixels:o,contentAlignHorizontal:s,contentAlignVertical:a,fontSize:i,viewport:this.context.viewport};if(c.shaderInputs.setProps({sdf:u,text:f}),super.draw(e),t&&r){const{iconManager:e}=this.state;e.getTexture()&&(c.shaderInputs.setProps({sdf:{...u,outlineBuffer:fa}}),c.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:t,endRow:n}){const{data:i,getIcon:r,getIconOffsets:o}=this.props;let s=e.getVertexOffset(t);const a=e.value,{iterable:A,objectInfo:l}=ir(i,t,n);for(const c of A){l.index++;const t=r(c,l),n=o(c,l);if(t){let i=0;for(const r of Array.from(t)){const t=super.getInstanceIconDef(r);t[0]=n[2*i],t[1]+=n[2*i+1],t[6]=1,a.set(t,s),s+=e.size,i++}}}}}ha.defaultProps={getIconOffsets:{type:"accessor",value:e=>e.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"},ha.layerName="MultiIconLayer";const da=1e20;class pa{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:i=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=i,this.radius=n,this.lang=a;const A=this.size=e+4*t,l=this._createCanvas(A),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(A*A),this.gridInner=new Float64Array(A*A),this.f=new Float64Array(A),this.z=new Float64Array(A+1),this.v=new Uint16Array(A)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:i,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(n),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),A=Math.min(this.size-this.buffer,s+Math.ceil(i)),l=a+2*this.buffer,c=A+2*this.buffer,u=Math.max(l*c,0),f=new Uint8ClampedArray(u),h={data:f,width:l,height:c,glyphWidth:a,glyphHeight:A,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===A)return h;const{ctx:d,buffer:p,gridInner:g,gridOuter:m}=this;this.lang&&(d.lang=this.lang),d.clearRect(p,p,a,A),d.fillText(e,p,p+s);const b=d.getImageData(p,p,a,A);m.fill(da,0,u),g.fill(0,0,u);for(let y=0;y<A;y++)for(let e=0;e<a;e++){const t=b.data[4*(y*a+e)+3]/255;if(0===t)continue;const n=(y+p)*l+e+p;if(1===t)m[n]=0,g[n]=da;else{const e=.5-t;m[n]=e>0?e*e:0,g[n]=e<0?e*e:0}}ga(m,0,0,l,c,l,this.f,this.v,this.z),ga(g,p,p,a,A,l,this.f,this.v,this.z);for(let y=0;y<u;y++){const e=Math.sqrt(m[y])-Math.sqrt(g[y]);f[y]=Math.round(255-255*(e/this.radius+this.cutoff))}return h}}function ga(e,t,n,i,r,o,s,a,A){for(let l=t;l<t+i;l++)ma(e,n*o+l,o,r,s,a,A);for(let l=n;l<n+r;l++)ma(e,l*o+t,1,i,s,a,A)}function ma(e,t,n,i,r,o,s){o[0]=0,s[0]=-da,s[1]=da,r[0]=e[t];for(let a=1,A=0,l=0;a<i;a++){r[a]=e[t+a*n];const i=a*a;do{const e=o[A];l=(r[a]-r[e]+i-e*e)/(a-e)/2}while(l<=s[A]&&--A>-1);A++,o[A]=a,s[A]=l,s[A+1]=da}for(let a=0,A=0;a<i;a++){for(;s[A+1]<a;)A++;const i=o[A],l=a-i;e[t+a*n]=r[i]+l*l}}const ba=[];function ya(e,t,n,i){let r=0;for(let o=t;o<n;o++){const t=e[o];r+=i[t]?.advance||0}return r}function va(e,t,n,i,r,o){let s=t,a=0;for(let A=t;A<n;A++){const t=ya(e,A,A+1,r);a+t>i&&(s<A&&o.push(A),s=A,a=0),a+=t}return a}function _a(e,t,n,i,r=0,o){void 0===o&&(o=e.length);const s=[];return"break-all"===t?va(e,r,o,n,i,s):function(e,t,n,i,r,o){let s=t,a=t,A=t,l=0;for(let c=t;c<n;c++)if(" "===e[c]?A=c+1:" "!==e[c+1]&&c+1!==n||(A=c+1),A>a){let t=ya(e,a,A,r);l+t>i&&(s<a&&(o.push(a),s=a,l=0),t>i&&(t=va(e,a,A,i,r,o),s=o[o.length-1])),a=A,l+=t}}(e,r,o,n,i,s),s}function Ca(e,t,n,i,r,o){let s=0,a=0;for(let A=t;A<n;A++){const t=i[e[A]];t&&(a=Math.max(a,t.height))}for(let A=t;A<n;A++){const t=e[A],n=i[t];n?(r[A]=s+n.anchorX,s+=n.advance):(Ce.warn(`Missing character: ${t} (${t.codePointAt(0)})`)(),r[A]=s,s+=32)}o[0]=s,o[1]=a}class xa{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){const t=this._cache[e];return t&&(this._deleteOrder(e),this._appendOrder(e)),t}set(e,t){this._cache[e]?(this.delete(e),this._cache[e]=t,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=t,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){const t=this._order.indexOf(e);t>=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}}const wa={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:function(){const e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1};let Ba=new xa(3);function Ma(e,t,n,i){e.font=`${i} ${n}px ${t}`,e.fillStyle="#000",e.textBaseline="alphabetic",e.textAlign="left"}class Sa{constructor(){this.props={...wa}}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();const t=function(e,t){let n;n="string"==typeof t?new Set(Array.from(t)):new Set(t);const i=Ba.get(e);if(!i)return n;for(const r in i.mapping)n.has(r)&&n.delete(r);return n}(this._key,this.props.characterSet),n=Ba.get(this._key);if(n&&0===t.size)return void(this._atlas!==n&&(this._atlas=n));const i=this._generateFontAtlas(t,n);this._atlas=i,Ba.set(this._key,i)}_generateFontAtlas(e,t){const{fontFamily:n,fontWeight:i,fontSize:r,buffer:o,sdf:s,radius:a,cutoff:A}=this.props;let l=t&&t.data;l||(l=document.createElement("canvas"),l.width=1024);const c=l.getContext("2d",{willReadFrequently:!0});Ma(c,n,r,i);const u=e=>function(e,t,n){if(void 0===n){const n=e.measureText("A");return n.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(n.fontBoundingBoxAscent),descent:Math.ceil(n.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:.9*t,descent:.3*t}}const i=e.measureText(n);return i.actualBoundingBoxAscent?{advance:i.width,width:Math.ceil(i.actualBoundingBoxRight-i.actualBoundingBoxLeft),ascent:Math.ceil(i.actualBoundingBoxAscent),descent:Math.ceil(i.actualBoundingBoxDescent)}:{advance:i.width,width:i.width,ascent:.9*t,descent:.3*t}}(c,r,e);let f;this._getFontRenderer?f=this._getFontRenderer(this.props):s&&(f={measure:u,draw:Ta(this.props)});const{mapping:h,canvasHeight:d,xOffset:p,yOffsetMin:g,yOffsetMax:m}=function({characterSet:e,measureText:t,buffer:n,maxCanvasWidth:i,mapping:r={},xOffset:o=0,yOffsetMin:s=0,yOffsetMax:a=0}){let A=o,l=s,c=a;for(const f of e)if(!r[f]){const{advance:e,width:o,ascent:s,descent:a}=t(f),u=s+a;A+o+2*n>i&&(A=0,l=c),r[f]={x:A+n,y:l+n,width:o,height:u,advance:e,anchorX:o/2,anchorY:s},A+=o+2*n,c=Math.max(c,l+u+2*n)}return{mapping:r,xOffset:A,yOffsetMin:l,yOffsetMax:c,canvasHeight:(u=c,Math.pow(2,Math.ceil(Math.log2(u))))};var u}({measureText:e=>f?f.measure(e):u(e),buffer:o,characterSet:e,maxCanvasWidth:1024,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffsetMin:t.yOffsetMin,yOffsetMax:t.yOffsetMax}});if(l.height!==d){const e=l.height>0?c.getImageData(0,0,l.width,l.height):null;l.height=d,e&&c.putImageData(e,0,0)}if(Ma(c,n,r,i),f)for(const y of e){const e=h[y],{data:t,left:n=0,top:i=0}=f.draw(y),r=e.x-n,o=e.y-i,s=Math.max(0,Math.round(r)),a=Math.max(0,Math.round(o)),A=Math.min(t.width,l.width-s),u=Math.min(t.height,l.height-a);c.putImageData(t,s,a,0,0,A,u),e.x+=s-r,e.y+=a-o}else for(const y of e){const e=h[y];c.fillText(y,e.x,e.y+e.anchorY)}const b=f?f.measure():u();return{baselineOffset:(b.ascent-b.descent)/2,xOffset:p,yOffsetMin:g,yOffsetMax:m,mapping:h,data:l,width:l.width,height:l.height}}_getKey(){const{fontFamily:e,fontWeight:t,fontSize:n,buffer:i,sdf:r,radius:o,cutoff:s}=this.props;return r?`${e} ${t} ${n} ${i} ${o} ${s}`:`${e} ${t} ${n} ${i}`}}function Ta({fontSize:e,buffer:t,radius:n,cutoff:i,fontFamily:r,fontWeight:o}){const s=new pa({fontSize:e,buffer:t,radius:n,cutoff:i,fontFamily:r,fontWeight:`${o}`});return e=>{const{data:n,width:i,height:r}=s.draw(e),o=new ImageData(i,r);return function(e,t){for(let n=0;n<e.length;n++)t.data[4*n+3]=e[n]}(n,o),{data:o,left:t,top:t}}}const Ea="layout(std140) uniform textBackgroundUniforms {\n bool billboard;\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n vec4 borderRadius;\n vec4 padding;\n highp int sizeUnits;\n bool stroked;\n} textBackground;\n",Pa={name:"textBackground",vs:Ea,fs:Ea,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},Ia={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:e=>e.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}};class La extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME text-background-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceRects;\nin vec4 instanceClipRect;\nin float instanceSizes;\nin float instanceAngles;\nin vec2 instancePixelOffsets;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout float vLineWidth;\nout vec2 uv;\nout vec2 dimensions;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = radians(angle);\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvLineWidth = instanceLineWidths;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),\ntextBackground.sizeMinPixels, textBackground.sizeMaxPixels\n);\nfloat instanceScale = sizePixels / text.fontSize;\ndimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw;\nvec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles);\npixelOffset += instancePixelOffsets;\npixelOffset.y *= -1.0;\nvec2 xy = project_size_to_pixel(instanceClipRect.xy);\nvec2 wh = project_size_to_pixel(instanceClipRect.zw);\nif (text.flipY) {\nxy.y = -xy.y - wh.y;\n}\nif (instanceClipRect.z >= 0.0) {\ndimensions.x = wh.x;\npixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x);\n}\nif (instanceClipRect.w >= 0.0) {\ndimensions.y = wh.y;\npixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y);\n}\nif (textBackground.billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nif (text.flipY) {\noffset_common.y *= -1.;\n}\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME text-background-layer-fragment-shader\nprecision highp float;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin float vLineWidth;\nin vec2 uv;\nin vec2 dimensions;\nout vec4 fragColor;\nfloat round_rect(vec2 p, vec2 size, vec4 radii) {\nvec2 pixelPositionCB = (p - 0.5) * size;\nvec2 sizeCB = size * 0.5;\nfloat maxBorderRadius = min(size.x, size.y) * 0.5;\nvec4 borderRadius = vec4(min(radii, maxBorderRadius));\nborderRadius.xy =\n(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;\nborderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;\nvec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;\nreturn -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);\n}\nfloat rect(vec2 p, vec2 size) {\nvec2 pixelPosition = p * size;\nreturn min(min(pixelPosition.x, size.x - pixelPosition.x),\nmin(pixelPosition.y, size.y - pixelPosition.y));\n}\nvec4 get_stroked_fragColor(float dist) {\nfloat isBorder = smoothedge(dist, vLineWidth);\nreturn mix(vFillColor, vLineColor, isBorder);\n}\nvoid main(void) {\ngeometry.uv = uv;\nif (textBackground.borderRadius != vec4(0.0)) {\nfloat distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);\nfloat shapeAlpha = smoothedge(-distToEdge, 0.0);\nif (shapeAlpha == 0.0) {\ndiscard;\n}\nif (textBackground.stroked) {\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= shapeAlpha;\n} else {\nif (textBackground.stroked) {\nfloat distToEdge = rect(uv, dimensions);\nfragColor = get_stroked_fragColor(distToEdge);\n} else {\nfragColor = vFillColor;\n}\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Jn,Kn,Pa,ua]})}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);const{changeFlags:t}=e;t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{billboard:t,sizeScale:n,sizeUnits:i,sizeMinPixels:r,sizeMaxPixels:o,getLineWidth:s,fontSize:a}=this.props;let{padding:A,borderRadius:l}=this.props;A.length<4&&(A=[A[0],A[1],A[0],A[1]]),Array.isArray(l)||(l=[l,l,l,l]);const c=this.state.model,u={billboard:t,stroked:Boolean(s),borderRadius:l,padding:A,sizeUnits:ze[i],sizeScale:n,sizeMinPixels:r,sizeMaxPixels:o},f={fontSize:a,viewport:this.context.viewport};c.shaderInputs.setProps({textBackground:u,text:f}),c.draw(this.context.renderPass)}_getModel(){return new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Qi({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,0,1,1,1])}}}),isInstanced:!0})}}La.defaultProps=Ia,La.layerName="TextBackgroundLayer";const Ra={start:1,middle:0,end:-1},Fa={top:1,center:0,bottom:-1},Oa=[0,0,0,255],Da={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:Oa},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:wa.characterSet},fontFamily:wa.fontFamily,fontWeight:wa.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:Oa},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:e=>e.text},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:Oa},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"]}};class Na extends fo{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{const{size:[n,i]}=this.transformParagraph(e,t),{getTextAnchor:r,getAlignmentBaseline:o}=this.props;return[(Ra["function"==typeof r?r(e,t):r]-1)*n/2,(Fa["function"==typeof o?o(e,t):o]-1)*i/2,n,i]},this.getIconOffsets=(e,t)=>{const{getTextAnchor:n,getAlignmentBaseline:i}=this.props,{x:r,y:o,rowWidth:s,size:[,a]}=this.transformParagraph(e,t),A=Ra["function"==typeof n?n(e,t):n],l=Fa["function"==typeof i?i(e,t):i],c=r.length,u=new Array(2*c);let f=0;for(let h=0;h<c;h++)u[f++]=(A-1)*s[h]/2+r[h],u[f++]=(l-1)*a/2+o[h];return u}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new Sa},this.props.maxWidth>0&&Ce.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){const{props:t,oldProps:n,changeFlags:i}=e;(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||t.lineHeight!==n.lineHeight||t.wordBreak!==n.wordBreak||t.maxWidth!==n.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(){const{fontSettings:e,fontFamily:t,fontWeight:n,_getFontRenderer:i}=this.props,{fontAtlasManager:r,characterSet:o}=this.state,s={...e,characterSet:o,fontFamily:t,fontWeight:n,_getFontRenderer:i};if(!r.mapping)return r.setProps(s),!0;for(const a in s)if(s[a]!==r.props[a])return r.setProps(s),!0;return!1}_updateText(){const{data:e,characterSet:t}=this.props,n=e.attributes?.getText;let i,{getText:r}=this.props,o=e.startIndices;const s="auto"===t&&/* @__PURE__ */new Set;if(n&&o){const{texts:t,characterCount:a}=function({value:e,length:t,stride:n,offset:i,startIndices:r,characterSet:o}){const s=e.BYTES_PER_ELEMENT,a=n?n/s:1,A=i?i/s:0,l=r[t]||Math.ceil((e.length-A)/a),c=o&&/* @__PURE__ */new Set,u=new Array(t);let f=e;if(a>1||A>0){f=new(0,e.constructor)(l);for(let t=0;t<l;t++)f[t]=e[t*a+A]}for(let h=0;h<t;h++){const e=r[h],t=r[h+1]||l,n=f.subarray(e,t);u[h]=String.fromCodePoint.apply(null,n),c&&n.forEach(c.add,c)}if(c)for(const h of c)o.add(String.fromCodePoint(h));return{texts:u,characterCount:l}}({...ArrayBuffer.isView(n)?{value:n}:n,length:e.length,startIndices:o,characterSet:s});i=a,r=(e,{index:n})=>t[n]}else{const{iterable:t,objectInfo:n}=ir(e);o=[0],i=0;for(const e of t){n.index++;const t=Array.from(r(e,n)||"");s&&t.forEach(s.add,s),i+=t.length,o.push(i)}}this.setState({getText:r,startIndices:o,numInstances:i,characterSet:s||t})}transformParagraph(e,t){const{fontAtlasManager:n}=this.state,i=n.mapping,{baselineOffset:r}=n.atlas,{fontSize:o}=n.props,s=this.state.getText,{wordBreak:a,lineHeight:A,maxWidth:l}=this.props;return function(e,t,n,i,r,o){const s=Array.from(e),a=s.length,A=new Array(a),l=new Array(a),c=new Array(a),u=("break-word"===i||"break-all"===i)&&isFinite(r)&&r>0,f=[0,0],h=[0,0];let d=0,p=t+n/2,g=0,m=0;for(let b=0;b<=a;b++){const e=s[b];if("\n"!==e&&b!==a||(m=b),m>g){const e=u?_a(s,i,r,o,g,m):ba;for(let t=0;t<=e.length;t++){const i=0===t?g:e[t-1],r=t<e.length?e[t]:m;Ca(s,i,r,o,A,h);for(let e=i;e<r;e++)l[e]=p,c[e]=h[0];d++,p+=n,f[0]=Math.max(f[0],h[0])}g=m}"\n"===e&&(A[g]=0,l[g]=0,c[g]=0,g++)}return f[1]=d*n,{x:A,y:l,rowWidth:c,size:f}}(s(e,t)||"",r,A*o,a,l*o,i)}renderLayers(){const{startIndices:e,numInstances:t,getText:n,fontAtlasManager:{atlas:i,mapping:r},styleVersion:o}=this.state,{data:s,_dataDiff:a,getPosition:A,getColor:l,getSize:c,getAngle:u,getPixelOffset:f,getBackgroundColor:h,getBorderColor:d,getBorderWidth:p,getContentBox:g,backgroundBorderRadius:m,backgroundPadding:b,background:y,billboard:v,fontSettings:_,outlineWidth:C,outlineColor:x,sizeScale:w,sizeUnits:B,sizeMinPixels:M,sizeMaxPixels:S,contentCutoffPixels:T,contentAlignHorizontal:E,contentAlignVertical:P,transitions:I,updateTriggers:L}=this.props,R=this.getSubLayerClass("characters",ha),F=this.getSubLayerClass("background",La),{fontSize:O}=this.state.fontAtlasManager.props;return[y&&new F({getFillColor:h,getLineColor:d,getLineWidth:p,borderRadius:m,padding:b,getPosition:A,getSize:c,getAngle:u,getPixelOffset:f,getClipRect:g,billboard:v,sizeScale:w,sizeUnits:B,sizeMinPixels:M,sizeMaxPixels:S,fontSize:O,transitions:I&&{getPosition:I.getPosition,getAngle:I.getAngle,getSize:I.getSize,getFillColor:I.getBackgroundColor,getLineColor:I.getBorderColor,getLineWidth:I.getBorderWidth,getPixelOffset:I.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:L.getPosition,getAngle:L.getAngle,getSize:L.getSize,getFillColor:L.getBackgroundColor,getLineColor:L.getBorderColor,getLineWidth:L.getBorderWidth,getPixelOffset:L.getPixelOffset,getBoundingRect:{getText:L.getText,getTextAnchor:L.getTextAnchor,getAlignmentBaseline:L.getAlignmentBaseline,styleVersion:o}}}),{data:s.attributes&&s.attributes.background?{length:s.length,attributes:s.attributes.background}:s,_dataDiff:a,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new R({sdf:_.sdf,smoothing:Number.isFinite(_.smoothing)?_.smoothing:wa.smoothing,outlineWidth:C/(_.radius||wa.radius),outlineColor:x,iconAtlas:i,iconMapping:r,getPosition:A,getColor:l,getSize:c,getAngle:u,getPixelOffset:f,getContentBox:g,billboard:v,sizeScale:w,sizeUnits:B,sizeMinPixels:M,sizeMaxPixels:S,fontSize:O,contentCutoffPixels:T,contentAlignHorizontal:E,contentAlignVertical:P,transitions:I&&{getPosition:I.getPosition,getAngle:I.getAngle,getColor:I.getColor,getSize:I.getSize,getPixelOffset:I.getPixelOffset,getContentBox:I.getContentBox}},this.getSubLayerProps({id:"characters",updateTriggers:{all:L.getText,getPosition:L.getPosition,getAngle:L.getAngle,getColor:L.getColor,getSize:L.getSize,getPixelOffset:L.getPixelOffset,getContentBox:L.getContentBox,getIconOffsets:{getTextAnchor:L.getTextAnchor,getAlignmentBaseline:L.getAlignmentBaseline,styleVersion:o}}}),{data:s,_dataDiff:a,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){!function(e){Ce.assert(Number.isFinite(e)&&e>=3,"Invalid cache limit"),Ba=new xa(e)}(e)}}Na.defaultProps=Da,Na.layerName="TextLayer";const Ua={circle:{type:Zo,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:zo,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:Na,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"}}},ka={type:Rs,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Ga={type:ia,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function za({type:e,props:t}){const n={};for(const i in t)n[i]=e.defaultProps[t[i]];return n}function Va(e,t){const{transitions:n,updateTriggers:i}=e.props,r={updateTriggers:{},transitions:n&&{getPosition:n.geometry}};for(const o in t){const s=t[o];let a=e.props[o];o.startsWith("get")&&(a=e.getSubLayerAccessor(a),r.updateTriggers[s]=i[o],n&&(r.transitions[s]=n[o])),r[s]=a}return r}function Ha(e,t,n={}){const i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:r=0,endRow:o=e.length}=n;for(let s=r;s<o;s++){const n=e[s],{geometry:r}=n;if(r)if("GeometryCollection"===r.type){Ce.assert(Array.isArray(r.geometries),"GeoJSON does not have geometries array");const{geometries:e}=r;for(let r=0;r<e.length;r++){ja(e[r],i,t,n,s)}}else ja(r,i,t,n,s)}return i}function ja(e,t,n,i,r){const{type:o,coordinates:s}=e,{pointFeatures:a,lineFeatures:A,polygonFeatures:l,polygonOutlineFeatures:c}=t;if(function(e,t){let n=Qa[e];Ce.assert(n,`Unknown GeoJSON type ${e}`);for(;t&&--n>0;)t=t[0];return t&&Number.isFinite(t[0])}(o,s))switch(o){case"Point":a.push(n({geometry:e},i,r));break;case"MultiPoint":s.forEach(e=>{a.push(n({geometry:{type:"Point",coordinates:e}},i,r))});break;case"LineString":A.push(n({geometry:e},i,r));break;case"MultiLineString":s.forEach(e=>{A.push(n({geometry:{type:"LineString",coordinates:e}},i,r))});break;case"Polygon":l.push(n({geometry:e},i,r)),s.forEach(e=>{c.push(n({geometry:{type:"LineString",coordinates:e}},i,r))});break;case"MultiPolygon":s.forEach(e=>{l.push(n({geometry:{type:"Polygon",coordinates:e}},i,r)),e.forEach(e=>{c.push(n({geometry:{type:"LineString",coordinates:e}},i,r))})})}else Ce.warn(`${o} coordinates are malformed`)()}const Qa={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Ja(e){return e.geometry.coordinates}function Ka(e,t){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:i,lines:r,polygons:o}=e,s=function(e,t){const n={points:null,lines:null,polygons:null};for(const i in n){const r=e[i].globalFeatureIds.value;n[i]=new Uint8ClampedArray(4*r.length);const o=[];for(let e=0;e<r.length;e++)t(r[e],o),n[i][4*e+0]=o[0],n[i][4*e+1]=o[1],n[i][4*e+2]=o[2],n[i][4*e+3]=255}return n}(e,t);n.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:4,value:s.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},n.lines.data={length:r.pathIndices.value.length-1,startIndices:r.pathIndices.value,attributes:{...r.attributes,getPath:r.positions,instancePickingColors:{size:4,value:s.lines}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},n.lines._pathType="open";const a=o.positions.value.length/o.positions.size,A=Array(a).fill(1);for(const l of o.primitivePolygonIndices.value)A[l-1]=0;return n.polygons.data={length:o.polygonIndices.value.length-1,startIndices:o.polygonIndices.value,attributes:{...o.attributes,getPolygon:o.positions,instanceVertexValid:{size:1,value:new Uint16Array(A)},pickingColors:{size:4,value:s.polygons}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},n.polygons._normalize=!1,o.triangles&&(n.polygons.data.attributes.indices=o.triangles.value),n.polygonsOutline.data={length:o.primitivePolygonIndices.value.length-1,startIndices:o.primitivePolygonIndices.value,attributes:{...o.attributes,getPath:o.positions,instancePickingColors:{size:4,value:s.polygons}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},n.polygonsOutline._pathType="open",n}const Wa=["points","linestrings","polygons"],qa={...za(Ua.circle),...za(Ua.icon),...za(Ua.text),...za(ka),...za(Ga),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:e=>e.properties.icon},getText:{type:"accessor",value:e=>e.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class Ya extends fo{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:t}){if(!t.dataChanged)return;const{data:n}=this.props,i=n&&"points"in n&&"polygons"in n&&"lines"in n;this.setState({binary:i}),i?this._updateStateBinary({props:e,changeFlags:t}):this._updateStateJSON({props:e,changeFlags:t})}_updateStateBinary({props:e,changeFlags:t}){const n=Ka(e.data,this.encodePickingColor);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:t}){const n=function(e){if(Array.isArray(e))return e;switch(Ce.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return Ce.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}(e.data),i=this.getSubLayerRow.bind(this);let r={};const o={};if(Array.isArray(t.dataChanged)){const e=this.state.features;for(const t in e)r[t]=e[t].slice(),o[t]=[];for(const s of t.dataChanged){const t=Ha(n,i,s);for(const n in e)o[n].push(ra({data:r[n],getIndex:e=>e.__source.index,dataRange:s,replace:t[n]}))}}else r=Ha(n,i);const s=function(e,t){const n={points:{},lines:{},polygons:{},polygonsOutline:{}},{pointFeatures:i,lineFeatures:r,polygonFeatures:o,polygonOutlineFeatures:s}=e;return n.points.data=i,n.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),n.points.getPosition=Ja,n.lines.data=r,n.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),n.lines.getPath=Ja,n.polygons.data=o,n.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),n.polygons.getPolygon=Ja,n.polygonsOutline.data=s,n.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),n.polygonsOutline.getPath=Ja,n}(r,o);this.setState({features:r,featuresDiff:o,layerProps:s})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:n,sourceLayer:i}=t;return t.featureType=Wa.find(e=>i.id.startsWith(`${this.id}-${e}-`)),n>=0&&i.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(t.index=this.props.data.points.globalFeatureIds.value[n]),t}_updateAutoHighlight(e){const t=`${this.id}-points-`,n="points"===e.featureType;for(const i of this.getSubLayers())i.id.startsWith(t)===n&&i.updateAutoHighlight(e)}_renderPolygonLayer(){const{extruded:e,wireframe:t}=this.props,{layerProps:n}=this.state,i="polygons-fill",r=this.shouldRenderSubLayer(i,n.polygons?.data)&&this.getSubLayerClass(i,Ga.type);if(r){const o=Va(this,Ga.props),s=e&&t;return s||delete o.getLineColor,o.updateTriggers.lineColors=s,new r(o,this.getSubLayerProps({id:i,updateTriggers:o.updateTriggers}),n.polygons)}return null}_renderLineLayers(){const{extruded:e,stroked:t}=this.props,{layerProps:n}=this.state,i="polygons-stroke",r="linestrings",o=!e&&t&&this.shouldRenderSubLayer(i,n.polygonsOutline?.data)&&this.getSubLayerClass(i,ka.type),s=this.shouldRenderSubLayer(r,n.lines?.data)&&this.getSubLayerClass(r,ka.type);if(o||s){const e=Va(this,ka.props);return[o&&new o(e,this.getSubLayerProps({id:i,updateTriggers:e.updateTriggers}),n.polygonsOutline),s&&new s(e,this.getSubLayerProps({id:r,updateTriggers:e.updateTriggers}),n.lines)]}return null}_renderPointLayers(){const{pointType:e}=this.props,{layerProps:t,binary:n}=this.state;let{highlightedObjectIndex:i}=this.props;!n&&Number.isFinite(i)&&(i=t.points.data.findIndex(e=>e.__source.index===i));const r=new Set(e.split("+")),o=[];for(const s of r){const e=`points-${s}`,r=Ua[s],a=r&&this.shouldRenderSubLayer(e,t.points?.data)&&this.getSubLayerClass(e,r.type);if(a){const A=Va(this,r.props);let l=t.points;if("text"===s&&n){const{instancePickingColors:e,...t}=l.data.attributes;l={...l,data:{...l.data,attributes:t}}}o.push(new a(A,this.getSubLayerProps({id:e,updateTriggers:A.updateTriggers,highlightedObjectIndex:i}),l))}}return o}renderLayers(){const{extruded:e}=this.props,t=this._renderPolygonLayer();return[!e&&t,this._renderLineLayers(),this._renderPointLayers(),e&&t]}getSubLayerAccessor(e){const{binary:t}=this.state;return t&&"function"==typeof e?(t,n)=>{const{data:i,index:r}=n,o=function(e,t){if(!e)return null;const n="startIndices"in e?e.startIndices[t]:t,i=e.featureIds.value[n];return-1!==n?function(e,t,n){const i={properties:{...e.properties[t]}};for(const r in e.numericProps)i.properties[r]=e.numericProps[r].value[n];return i}(e,i,n):null}(i,r);return e(o,n)}:super.getSubLayerAccessor(e)}}Ya.layerName="GeoJsonLayer",Ya.defaultProps=qa;const Xa={...aa.defaultProps};class Za extends fo{indexToBounds(){return null}renderLayers(){const{elevationScale:e,extruded:t,wireframe:n,filled:i,stroked:r,lineWidthUnits:o,lineWidthScale:s,lineWidthMinPixels:a,lineWidthMaxPixels:A,lineJointRounded:l,lineMiterLimit:c,lineDashJustified:u,getElevation:f,getFillColor:h,getLineColor:d,getLineWidth:p}=this.props,{updateTriggers:g,material:m,transitions:b}=this.props,y=this.getSubLayerClass("cell",aa),{updateTriggers:v,..._}=this.indexToBounds()||{};return new y({filled:i,wireframe:n,extruded:t,elevationScale:e,stroked:r,lineWidthUnits:o,lineWidthScale:s,lineWidthMinPixels:a,lineWidthMaxPixels:A,lineJointRounded:l,lineMiterLimit:c,lineDashJustified:u,material:m,transitions:b,getElevation:f,getFillColor:h,getLineColor:d,getLineWidth:p},this.getSubLayerProps({id:"cell",updateTriggers:g&&{...v,getElevation:g.getElevation,getFillColor:g.getFillColor,getLineColor:g.getLineColor,getLineWidth:g.getLineWidth}}),_)}}Za.layerName="GeoCellLayer",Za.defaultProps=Xa;var $a=Object.defineProperty,eA=(e,t)=>{for(var n in t)$a(e,n,{get:t[n],enumerable:!0})},tA={};eA(tA,{ARRAY_TYPE:()=>iA,EPSILON:()=>nA,RANDOM:()=>rA,equals:()=>AA,setMatrixArrayType:()=>oA,toRadian:()=>aA});var nA=1e-6,iA="undefined"!=typeof Float32Array?Float32Array:Array,rA=Math.random;function oA(e){iA=e}var sA=Math.PI/180;function aA(e){return e*sA}function AA(e,t){return Math.abs(e-t)<=nA*Math.max(1,Math.abs(e),Math.abs(t))}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var lA={};function cA(){var e=new iA(4);return iA!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function uA(e){var t=new iA(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function fA(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function hA(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function dA(e,t,n,i){var r=new iA(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r}function pA(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e}function gA(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function mA(e,t){var n=t[0],i=t[1],r=t[2],o=t[3],s=n*o-r*i;return s?(s=1/s,e[0]=o*s,e[1]=-i*s,e[2]=-r*s,e[3]=n*s,e):null}function bA(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e}function yA(e){return e[0]*e[3]-e[2]*e[1]}function vA(e,t,n){var i=t[0],r=t[1],o=t[2],s=t[3],a=n[0],A=n[1],l=n[2],c=n[3];return e[0]=i*a+o*A,e[1]=r*a+s*A,e[2]=i*l+o*c,e[3]=r*l+s*c,e}function _A(e,t,n){var i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);return e[0]=i*A+o*a,e[1]=r*A+s*a,e[2]=i*-a+o*A,e[3]=r*-a+s*A,e}function CA(e,t,n){var i=t[0],r=t[1],o=t[2],s=t[3],a=n[0],A=n[1];return e[0]=i*a,e[1]=r*a,e[2]=o*A,e[3]=s*A,e}function xA(e,t){var n=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=n,e[2]=-n,e[3]=i,e}function wA(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function BA(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function MA(e){return Math.hypot(e[0],e[1],e[2],e[3])}function SA(e,t,n,i){return e[2]=i[2]/i[0],n[0]=i[0],n[1]=i[1],n[3]=i[3]-e[2]*n[1],[e,t,n]}function TA(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function EA(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function PA(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function IA(e,t){var n=e[0],i=e[1],r=e[2],o=e[3],s=t[0],a=t[1],A=t[2],l=t[3];return Math.abs(n-s)<=nA*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=nA*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-A)<=nA*Math.max(1,Math.abs(r),Math.abs(A))&&Math.abs(o-l)<=nA*Math.max(1,Math.abs(o),Math.abs(l))}function LA(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function RA(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e[2]=t[2]+n[2]*i,e[3]=t[3]+n[3]*i,e}eA(lA,{LDU:()=>SA,add:()=>TA,adjoint:()=>bA,clone:()=>uA,copy:()=>fA,create:()=>cA,determinant:()=>yA,equals:()=>IA,exactEquals:()=>PA,frob:()=>MA,fromRotation:()=>xA,fromScaling:()=>wA,fromValues:()=>dA,identity:()=>hA,invert:()=>mA,mul:()=>FA,multiply:()=>vA,multiplyScalar:()=>LA,multiplyScalarAndAdd:()=>RA,rotate:()=>_A,scale:()=>CA,set:()=>pA,str:()=>BA,sub:()=>OA,subtract:()=>EA,transpose:()=>gA});var FA=vA,OA=EA;var DA={};eA(DA,{add:()=>cc,calculateW:()=>Vl,clone:()=>sc,conjugate:()=>ql,copy:()=>Ac,create:()=>Rl,dot:()=>hc,equals:()=>_c,exactEquals:()=>vc,exp:()=>Hl,fromEuler:()=>Xl,fromMat3:()=>Yl,fromValues:()=>ac,getAngle:()=>Nl,getAxisAngle:()=>Dl,identity:()=>Fl,invert:()=>Wl,len:()=>gc,length:()=>pc,lerp:()=>dc,ln:()=>jl,mul:()=>uc,multiply:()=>Ul,normalize:()=>yc,pow:()=>Ql,random:()=>Kl,rotateX:()=>kl,rotateY:()=>Gl,rotateZ:()=>zl,rotationTo:()=>Cc,scale:()=>fc,set:()=>lc,setAxes:()=>wc,setAxisAngle:()=>Ol,slerp:()=>Jl,sqlerp:()=>xc,sqrLen:()=>bc,squaredLength:()=>mc,str:()=>Zl});var NA={};function UA(){var e=new iA(3);return iA!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function kA(e){var t=new iA(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function GA(e){var t=e[0],n=e[1],i=e[2];return Math.hypot(t,n,i)}function zA(e,t,n){var i=new iA(3);return i[0]=e,i[1]=t,i[2]=n,i}function VA(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function HA(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function jA(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function QA(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function JA(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function KA(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function WA(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function qA(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function YA(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function XA(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function ZA(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e}function $A(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function el(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e[2]=t[2]+n[2]*i,e}function tl(e,t){var n=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return Math.hypot(n,i,r)}function nl(e,t){var n=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return n*n+i*i+r*r}function il(e){var t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function rl(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function ol(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function sl(e,t){var n=t[0],i=t[1],r=t[2],o=n*n+i*i+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function al(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Al(e,t,n){var i=t[0],r=t[1],o=t[2],s=n[0],a=n[1],A=n[2];return e[0]=r*A-o*a,e[1]=o*s-i*A,e[2]=i*a-r*s,e}function ll(e,t,n,i){var r=t[0],o=t[1],s=t[2];return e[0]=r+i*(n[0]-r),e[1]=o+i*(n[1]-o),e[2]=s+i*(n[2]-s),e}function cl(e,t,n,i,r,o){var s=o*o,a=s*(2*o-3)+1,A=s*(o-2)+o,l=s*(o-1),c=s*(3-2*o);return e[0]=t[0]*a+n[0]*A+i[0]*l+r[0]*c,e[1]=t[1]*a+n[1]*A+i[1]*l+r[1]*c,e[2]=t[2]*a+n[2]*A+i[2]*l+r[2]*c,e}function ul(e,t,n,i,r,o){var s=1-o,a=s*s,A=o*o,l=a*s,c=3*o*a,u=3*A*s,f=A*o;return e[0]=t[0]*l+n[0]*c+i[0]*u+r[0]*f,e[1]=t[1]*l+n[1]*c+i[1]*u+r[1]*f,e[2]=t[2]*l+n[2]*c+i[2]*u+r[2]*f,e}function fl(e,t){t=t||1;var n=2*rA()*Math.PI,i=2*rA()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*r,e[1]=Math.sin(n)*r,e[2]=i*t,e}function hl(e,t,n){var i=t[0],r=t[1],o=t[2],s=n[3]*i+n[7]*r+n[11]*o+n[15];return s=s||1,e[0]=(n[0]*i+n[4]*r+n[8]*o+n[12])/s,e[1]=(n[1]*i+n[5]*r+n[9]*o+n[13])/s,e[2]=(n[2]*i+n[6]*r+n[10]*o+n[14])/s,e}function dl(e,t,n){var i=t[0],r=t[1],o=t[2];return e[0]=i*n[0]+r*n[3]+o*n[6],e[1]=i*n[1]+r*n[4]+o*n[7],e[2]=i*n[2]+r*n[5]+o*n[8],e}function pl(e,t,n){var i=n[0],r=n[1],o=n[2],s=n[3],a=t[0],A=t[1],l=t[2],c=r*l-o*A,u=o*a-i*l,f=i*A-r*a,h=r*f-o*u,d=o*c-i*f,p=i*u-r*c,g=2*s;return c*=g,u*=g,f*=g,h*=2,d*=2,p*=2,e[0]=a+c+h,e[1]=A+u+d,e[2]=l+f+p,e}function gl(e,t,n,i){var r=[],o=[];return r[0]=t[0]-n[0],r[1]=t[1]-n[1],r[2]=t[2]-n[2],o[0]=r[0],o[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),o[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}function ml(e,t,n,i){var r=[],o=[];return r[0]=t[0]-n[0],r[1]=t[1]-n[1],r[2]=t[2]-n[2],o[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),o[1]=r[1],o[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}function bl(e,t,n,i){var r=[],o=[];return r[0]=t[0]-n[0],r[1]=t[1]-n[1],r[2]=t[2]-n[2],o[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),o[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),o[2]=r[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e}function yl(e,t){var n=e[0],i=e[1],r=e[2],o=t[0],s=t[1],a=t[2],A=Math.sqrt(n*n+i*i+r*r)*Math.sqrt(o*o+s*s+a*a),l=A&&al(e,t)/A;return Math.acos(Math.min(Math.max(l,-1),1))}function vl(e){return e[0]=0,e[1]=0,e[2]=0,e}function _l(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Cl(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function xl(e,t){var n=e[0],i=e[1],r=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(n-o)<=nA*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-s)<=nA*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=nA*Math.max(1,Math.abs(r),Math.abs(a))}eA(NA,{add:()=>jA,angle:()=>yl,bezier:()=>ul,ceil:()=>WA,clone:()=>kA,copy:()=>VA,create:()=>UA,cross:()=>Al,dist:()=>Tl,distance:()=>tl,div:()=>Sl,divide:()=>KA,dot:()=>al,equals:()=>xl,exactEquals:()=>Cl,floor:()=>qA,forEach:()=>Ll,fromValues:()=>zA,hermite:()=>cl,inverse:()=>ol,len:()=>Pl,length:()=>GA,lerp:()=>ll,max:()=>XA,min:()=>YA,mul:()=>Ml,multiply:()=>JA,negate:()=>rl,normalize:()=>sl,random:()=>fl,rotateX:()=>gl,rotateY:()=>ml,rotateZ:()=>bl,round:()=>ZA,scale:()=>$A,scaleAndAdd:()=>el,set:()=>HA,sqrDist:()=>El,sqrLen:()=>Il,squaredDistance:()=>nl,squaredLength:()=>il,str:()=>_l,sub:()=>Bl,subtract:()=>QA,transformMat3:()=>dl,transformMat4:()=>hl,transformQuat:()=>pl,zero:()=>vl});var wl,Bl=QA,Ml=JA,Sl=KA,Tl=tl,El=nl,Pl=GA,Il=il,Ll=(wl=UA(),function(e,t,n,i,r,o){var s,a;for(t||(t=3),n||(n=0),a=i?Math.min(i*t+n,e.length):e.length,s=n;s<a;s+=t)wl[0]=e[s],wl[1]=e[s+1],wl[2]=e[s+2],r(wl,wl,o),e[s]=wl[0],e[s+1]=wl[1],e[s+2]=wl[2];return e});function Rl(){var e=new iA(4);return iA!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Fl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Ol(e,t,n){n*=.5;var i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function Dl(e,t){var n=2*Math.acos(t[3]),i=Math.sin(n/2);return i>nA?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),n}function Nl(e,t){var n=hc(e,t);return Math.acos(2*n*n-1)}function Ul(e,t,n){var i=t[0],r=t[1],o=t[2],s=t[3],a=n[0],A=n[1],l=n[2],c=n[3];return e[0]=i*c+s*a+r*l-o*A,e[1]=r*c+s*A+o*a-i*l,e[2]=o*c+s*l+i*A-r*a,e[3]=s*c-i*a-r*A-o*l,e}function kl(e,t,n){n*=.5;var i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);return e[0]=i*A+s*a,e[1]=r*A+o*a,e[2]=o*A-r*a,e[3]=s*A-i*a,e}function Gl(e,t,n){n*=.5;var i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);return e[0]=i*A-o*a,e[1]=r*A+s*a,e[2]=o*A+i*a,e[3]=s*A-r*a,e}function zl(e,t,n){n*=.5;var i=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(n),A=Math.cos(n);return e[0]=i*A+r*a,e[1]=r*A-i*a,e[2]=o*A+s*a,e[3]=s*A-o*a,e}function Vl(e,t){var n=t[0],i=t[1],r=t[2];return e[0]=n,e[1]=i,e[2]=r,e[3]=Math.sqrt(Math.abs(1-n*n-i*i-r*r)),e}function Hl(e,t){var n=t[0],i=t[1],r=t[2],o=t[3],s=Math.sqrt(n*n+i*i+r*r),a=Math.exp(o),A=s>0?a*Math.sin(s)/s:0;return e[0]=n*A,e[1]=i*A,e[2]=r*A,e[3]=a*Math.cos(s),e}function jl(e,t){var n=t[0],i=t[1],r=t[2],o=t[3],s=Math.sqrt(n*n+i*i+r*r),a=s>0?Math.atan2(s,o)/s:0;return e[0]=n*a,e[1]=i*a,e[2]=r*a,e[3]=.5*Math.log(n*n+i*i+r*r+o*o),e}function Ql(e,t,n){return jl(e,t),fc(e,e,n),Hl(e,e),e}function Jl(e,t,n,i){var r,o,s,a,A,l=t[0],c=t[1],u=t[2],f=t[3],h=n[0],d=n[1],p=n[2],g=n[3];return(o=l*h+c*d+u*p+f*g)<0&&(o=-o,h=-h,d=-d,p=-p,g=-g),1-o>nA?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-i)*r)/s,A=Math.sin(i*r)/s):(a=1-i,A=i),e[0]=a*l+A*h,e[1]=a*c+A*d,e[2]=a*u+A*p,e[3]=a*f+A*g,e}function Kl(e){var t=rA(),n=rA(),i=rA(),r=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=r*Math.sin(2*Math.PI*n),e[1]=r*Math.cos(2*Math.PI*n),e[2]=o*Math.sin(2*Math.PI*i),e[3]=o*Math.cos(2*Math.PI*i),e}function Wl(e,t){var n=t[0],i=t[1],r=t[2],o=t[3],s=n*n+i*i+r*r+o*o,a=s?1/s:0;return e[0]=-n*a,e[1]=-i*a,e[2]=-r*a,e[3]=o*a,e}function ql(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Yl(e,t){var n,i=t[0]+t[4]+t[8];if(i>0)n=Math.sqrt(i+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var r=0;t[4]>t[0]&&(r=1),t[8]>t[3*r+r]&&(r=2);var o=(r+1)%3,s=(r+2)%3;n=Math.sqrt(t[3*r+r]-t[3*o+o]-t[3*s+s]+1),e[r]=.5*n,n=.5/n,e[3]=(t[3*o+s]-t[3*s+o])*n,e[o]=(t[3*o+r]+t[3*r+o])*n,e[s]=(t[3*s+r]+t[3*r+s])*n}return e}function Xl(e,t,n,i){var r=.5*Math.PI/180;t*=r,n*=r,i*=r;var o=Math.sin(t),s=Math.cos(t),a=Math.sin(n),A=Math.cos(n),l=Math.sin(i),c=Math.cos(i);return e[0]=o*A*c-s*a*l,e[1]=s*a*c+o*A*l,e[2]=s*A*l-o*a*c,e[3]=s*A*c+o*a*l,e}function Zl(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}!function(){var e,t=(e=new iA(4),iA!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var $l,ec,tc,nc,ic,rc,oc,sc=function(e){var t=new iA(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},ac=function(e,t,n,i){var r=new iA(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r},Ac=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},lc=function(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e},cc=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},uc=Ul,fc=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},hc=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},dc=function(e,t,n,i){var r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+i*(n[0]-r),e[1]=o+i*(n[1]-o),e[2]=s+i*(n[2]-s),e[3]=a+i*(n[3]-a),e},pc=function(e){var t=e[0],n=e[1],i=e[2],r=e[3];return Math.hypot(t,n,i,r)},gc=pc,mc=function(e){var t=e[0],n=e[1],i=e[2],r=e[3];return t*t+n*n+i*i+r*r},bc=mc,yc=function(e,t){var n=t[0],i=t[1],r=t[2],o=t[3],s=n*n+i*i+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=n*s,e[1]=i*s,e[2]=r*s,e[3]=o*s,e},vc=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},_c=function(e,t){var n=e[0],i=e[1],r=e[2],o=e[3],s=t[0],a=t[1],A=t[2],l=t[3];return Math.abs(n-s)<=nA*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=nA*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-A)<=nA*Math.max(1,Math.abs(r),Math.abs(A))&&Math.abs(o-l)<=nA*Math.max(1,Math.abs(o),Math.abs(l))},Cc=($l=UA(),ec=zA(1,0,0),tc=zA(0,1,0),function(e,t,n){var i=al(t,n);return i<-.999999?(Al($l,ec,t),Pl($l)<1e-6&&Al($l,tc,t),sl($l,$l),Ol(e,$l,Math.PI),e):i>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Al($l,t,n),e[0]=$l[0],e[1]=$l[1],e[2]=$l[2],e[3]=1+i,yc(e,e))}),xc=(nc=Rl(),ic=Rl(),function(e,t,n,i,r,o){return Jl(nc,t,r,o),Jl(ic,n,i,o),Jl(e,nc,ic,2*o*(1-o)),e}),wc=(rc=new iA(9),iA!=Float32Array&&(rc[1]=0,rc[2]=0,rc[3]=0,rc[5]=0,rc[6]=0,rc[7]=0),rc[0]=1,rc[4]=1,rc[8]=1,oc=rc,function(e,t,n,i){return oc[0]=n[0],oc[3]=n[1],oc[6]=n[2],oc[1]=i[0],oc[4]=i[1],oc[7]=i[2],oc[2]=-t[0],oc[5]=-t[1],oc[8]=-t[2],yc(e,Yl(e,oc))}),Bc={};function Mc(){var e=new iA(2);return iA!=Float32Array&&(e[0]=0,e[1]=0),e}function Sc(e){var t=new iA(2);return t[0]=e[0],t[1]=e[1],t}function Tc(e,t){var n=new iA(2);return n[0]=e,n[1]=t,n}function Ec(e,t){return e[0]=t[0],e[1]=t[1],e}function Pc(e,t,n){return e[0]=t,e[1]=n,e}function Ic(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Lc(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function Rc(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e}function Fc(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e}function Oc(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function Dc(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function Nc(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function Uc(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e}function kc(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e}function Gc(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function zc(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e}function Vc(e,t){var n=t[0]-e[0],i=t[1]-e[1];return Math.hypot(n,i)}function Hc(e,t){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function jc(e){var t=e[0],n=e[1];return Math.hypot(t,n)}function Qc(e){var t=e[0],n=e[1];return t*t+n*n}function Jc(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Kc(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Wc(e,t){var n=t[0],i=t[1],r=n*n+i*i;return r>0&&(r=1/Math.sqrt(r)),e[0]=t[0]*r,e[1]=t[1]*r,e}function qc(e,t){return e[0]*t[0]+e[1]*t[1]}function Yc(e,t,n){var i=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=i,e}function Xc(e,t,n,i){var r=t[0],o=t[1];return e[0]=r+i*(n[0]-r),e[1]=o+i*(n[1]-o),e}function Zc(e,t){t=t||1;var n=2*rA()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e}function $c(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[2]*r,e[1]=n[1]*i+n[3]*r,e}function eu(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[2]*r+n[4],e[1]=n[1]*i+n[3]*r+n[5],e}function tu(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[3]*r+n[6],e[1]=n[1]*i+n[4]*r+n[7],e}function nu(e,t,n){var i=t[0],r=t[1];return e[0]=n[0]*i+n[4]*r+n[12],e[1]=n[1]*i+n[5]*r+n[13],e}function iu(e,t,n,i){var r=t[0]-n[0],o=t[1]-n[1],s=Math.sin(i),a=Math.cos(i);return e[0]=r*a-o*s+n[0],e[1]=r*s+o*a+n[1],e}function ru(e,t){var n=e[0],i=e[1],r=t[0],o=t[1],s=Math.sqrt(n*n+i*i)*Math.sqrt(r*r+o*o),a=s&&(n*r+i*o)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function ou(e){return e[0]=0,e[1]=0,e}function su(e){return"vec2("+e[0]+", "+e[1]+")"}function au(e,t){return e[0]===t[0]&&e[1]===t[1]}function Au(e,t){var n=e[0],i=e[1],r=t[0],o=t[1];return Math.abs(n-r)<=nA*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-o)<=nA*Math.max(1,Math.abs(i),Math.abs(o))}eA(Bc,{add:()=>Ic,angle:()=>ru,ceil:()=>Oc,clone:()=>Sc,copy:()=>Ec,create:()=>Mc,cross:()=>Yc,dist:()=>hu,distance:()=>Vc,div:()=>fu,divide:()=>Fc,dot:()=>qc,equals:()=>Au,exactEquals:()=>au,floor:()=>Dc,forEach:()=>gu,fromValues:()=>Tc,inverse:()=>Kc,len:()=>lu,length:()=>jc,lerp:()=>Xc,max:()=>Uc,min:()=>Nc,mul:()=>uu,multiply:()=>Rc,negate:()=>Jc,normalize:()=>Wc,random:()=>Zc,rotate:()=>iu,round:()=>kc,scale:()=>Gc,scaleAndAdd:()=>zc,set:()=>Pc,sqrDist:()=>du,sqrLen:()=>pu,squaredDistance:()=>Hc,squaredLength:()=>Qc,str:()=>su,sub:()=>cu,subtract:()=>Lc,transformMat2:()=>$c,transformMat2d:()=>eu,transformMat3:()=>tu,transformMat4:()=>nu,zero:()=>ou});var lu=jc,cu=Lc,uu=Rc,fu=Fc,hu=Vc,du=Hc,pu=Qc,gu=function(){var e=Mc();return function(t,n,i,r,o,s){var a,A;for(n||(n=2),i||(i=0),A=r?Math.min(r*n+i,t.length):t.length,a=i;a<A;a+=n)e[0]=t[a],e[1]=t[a+1],o(e,e,s),t[a]=e[0],t[a+1]=e[1];return t}}(),mu=(1+Math.sqrt(5))/2,bu=2*Math.PI/5,yu=Math.PI/5,vu=Math.PI/10,_u=2*Math.atan(mu),Cu=Math.PI-_u,xu=(Math.sqrt(5)-1)/2,wu=3-Math.sqrt(5);tA.setMatrixArrayType(Float64Array);var Bu=class e{constructor(e){this.vertices=e,this.isWindingCorrect()||this.vertices.reverse()}getArea(){let e=0;const t=this.vertices.length;for(let n=0;n<t;n++){const i=(n+1)%t;e+=(this.vertices[i][0]-this.vertices[n][0])*(this.vertices[i][1]+this.vertices[n][1])}return e}isWindingCorrect(){return this.getArea()>=0}getVertices(){return this.vertices}scale(e){for(const t of this.vertices)Bc.scale(t,t,e);return this}rotate180(){for(const e of this.vertices)Bc.negate(e,e);return this}reflectY(){for(const e of this.vertices)e[1]=-e[1];return this.vertices.reverse(),this}translate(e){for(const t of this.vertices)Bc.add(t,t,e);return this}transform(e){for(const t of this.vertices)Bc.transformMat2(t,t,e);return this}transform2d(e){for(const t of this.vertices)Bc.transformMat2d(t,t,e);return this}clone(){return new e(this.vertices.map(e=>Bc.clone(e)))}getCenter(){const e=this.vertices.length;return this.vertices.reduce((t,n)=>[t[0]+n[0]/e,t[1]+n[1]/e],[0,0])}containsPoint(e){if(!this.isWindingCorrect())throw new Error("Pentagon is not counter-clockwise");const t=this.vertices.length;let n=1;for(let i=0;i<t;i++){const r=this.vertices[i],o=this.vertices[(i+1)%t],s=r[0]-o[0],a=r[1]-o[1],A=e[0]-r[0],l=e[1]-r[1],c=s*l-a*A;if(c<0){const e=Math.sqrt(A*A+l*l);n=Math.min(n,c/e)}}return n}splitEdges(t){if(t<=1)return this;const n=[],i=this.vertices.length;for(let e=0;e<i;e++){const r=this.vertices[e],o=this.vertices[(e+1)%i];n.push(Bc.clone(r));for(let e=1;e<t;e++){const i=e/t,s=Bc.create();Bc.lerp(s,r,o,i),n.push(s)}}return new e(n)}};tA.setMatrixArrayType(Float64Array);var Mu=[0,0],Su=[0,1],Tu=[.7885966681787006,1.6149108024237764],Eu=[1.6171013659387945,1.054928690397459],Pu=[Math.cos(vu),Math.sin(vu)],Iu=2*Bc.length(Tu)*Math.cos(yu),Lu=yu-Math.atan2(Tu[1],Tu[0]),Ru=2*xu/Iu;[Mu,Su,Tu,Eu,Pu].forEach(e=>{Bc.scale(e,e,Ru),Bc.rotate(e,e,[0,0],Lu)});var Fu=new Bu([Mu,Su,Tu,Eu,Pu]),Ou=Math.atan2(Tu[1],Tu[0])-yu,Du=xu/Math.cos(yu),Nu=Ou+yu,Uu=[Du*Math.cos(Nu),Du*Math.sin(Nu)],ku=Ou-yu,Gu=[Du*Math.cos(ku),Du*Math.sin(ku)],zu=new Bu([[0,0],Uu,Gu]),Vu=lA.fromValues(Uu[0],Uu[1],Gu[0],Gu[1]);lA.invert(lA.create(),Vu);var Hu=new Float64Array([-.0022392098386786394,21308606513250217e-22,-2.559257686421274e-9,33701965267802837e-28,-4667545312611249e-30,667492870384816e-32]),ju=new Float64Array([.0022392089963541657,28831978048607556e-22,5.08622073997266e-9,102018123778161e-25,21912872306767718e-30,49284235482523806e-33]);tA.setMatrixArrayType(Float64Array);var Qu=new class{applyCoefficients(e,t){const n=Math.sin(e),i=Math.cos(e),r=2*(i-n)*(i+n);let o,s;return o=r*t[5]+t[4],s=r*o+t[3],o=r*s-o+t[2],s=r*o-s+t[1],o=r*s-o+t[0],e+2*n*i*o}forward(e){return this.applyCoefficients(e,Hu)}inverse(e){return this.applyCoefficients(e,ju)}};function Ju(e){return e*(Math.PI/180)}function Ku(e){return e*(180/Math.PI)}function Wu(e){return[Bc.length(e),Math.atan2(e[1],e[0])]}function qu(e){const t=Math.atan2(e[1],e[0]),n=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[t,Math.acos(e[2]/n)]}function Yu([e,t]){const n=Math.sin(t);return[n*Math.cos(e),n*Math.sin(e),Math.cos(t)]}function Xu(e){return((e+180)%360+360)%360-180}function Zu([e,t]){const n=Xu(Ku(e)-93),i=Math.PI/2-t;return[n,Ku(Qu.inverse(i))]}function $u(e){const t=e.map(e=>Yu(function([e,t]){const n=Ju(e+93),i=Ju(t),r=Qu.forward(i);return[n,Math.PI/2-r]}(e))),n=NA.create();for(const o of t)NA.add(n,n,o);NA.normalize(n,n);let[i,r]=Zu(qu(n));return(r>89.99||r<-89.99)&&(i=e[0][0]),i=Xu(i),e.map(e=>{let[t,n]=e;for(;t-i>180;)t-=360;for(;t-i<-180;)t+=360;return[t,n]})}tA.setMatrixArrayType(Float64Array);var ef=Math.sqrt(5),tf=Math.sqrt(.2),nf=Math.sqrt((1-tf)/2),rf=Math.sqrt((1+tf)/2),of=.5,sf=Math.sqrt((2.5-ef)/10),af=Math.sqrt((2.5+ef)/10),Af=Math.sqrt((1+tf)/8),lf=Math.sqrt((1-tf)/8),cf=Math.sqrt((3-ef)/8),uf=Math.sqrt((3+ef)/8),ff=[[0,0],[nf,0],[sf,of],[-Af,cf],[-Af,-cf],[sf,-of],[-rf,0],[-lf,-uf],[af,-of],[af,of],[-lf,uf],[0,0]].map(([e,t])=>[-t,e]).map((e,t)=>0===t?[0,0,0,1]:11===t?[0,-1,0,0]:[...e,0,t<6?rf:nf]);tA.setMatrixArrayType(Float64Array);var hf=["vu","uw","vw","vw","vw"],df=["wu","uw","vw","vu","uw"],pf=["wu","uv","wv","wu","uw"],gf=["vu","uv","wv","wu","uw"],mf=[hf,gf,pf,df,pf,gf,pf,df,df,df,gf,gf],bf=[4,2,3,2,0,4,3,2,2,0,3,0],yf=[0,1,2,4,3,5,7,8,6,11,10,9],vf=[];var _f=0;function Cf(e,t,n){if(_f>11)throw new Error(`Too many origins: ${_f}`);const i=DA.create();DA.conjugate(i,n);const r={id:_f,axis:e,quat:n,inverseQuat:i,angle:t,orientation:mf[_f],firstQuintant:bf[_f]};vf.push(r),_f++}!function(){Cf([0,0],0,ff[0]);for(let e=0;e<5;e++){const t=e*bu,n=t+yu;Cf([t,Cu],yu,ff[e+1]),Cf([n,Math.PI-Cu],yu,ff[(e+3)%5+6])}Cf([0,Math.PI],0,ff[11])}(),vf.sort((e,t)=>yf.indexOf(e.id)-yf.indexOf(t.id)),vf.forEach((e,t)=>e.id=t);var xf=class{forward([e,t]){return[Math.tan(t),e]}inverse([e,t]){return[t,Math.atan(e)]}},wf=NA.create(),Bf=NA.create(),Mf=NA.create(),Sf=NA.create();function Tf(e,t){NA.lerp(wf,e,t,.5),NA.normalize(wf,wf),NA.cross(wf,e,wf);const n=NA.length(wf);if(n<1e-8){const n=NA.subtract(NA.create(),e,t);return.5*NA.length(n)}return n}function Ef(e,t,n,i){const r=NA.angle(t,n);if(r<1e-12)return NA.lerp(e,t,n,i);const o=Math.sin((1-i)*r)/Math.sin(r),s=Math.sin(i*r)/Math.sin(r),a=NA.scale(NA.create(),t,o),A=NA.scale(NA.create(),n,s);return NA.add(e,a,A)}tA.setMatrixArrayType(Float64Array);var Pf=NA.create(),If=NA.create(),Lf=NA.create(),Rf=NA.create(),Ff=class{constructor(e){this._area=null,this.vertices=e,Object.freeze(this.vertices)}getBoundary(e=1,t=!0){const n=[],i=this.vertices.length;for(let r=0;r<i*e;r++){const t=r/e;n.push(this.slerp(t))}return t&&n.push(n[0]),n}slerp(e){const t=this.vertices.length,n=e%1,i=Math.floor(e%t),r=(i+1)%t;return Ef(NA.create(),this.vertices[i],this.vertices[r],n)}getTransformedVertices(e){const t=this.vertices.length,n=Math.floor(e%t),i=(n+1)%t,r=(n+t-1)%t,o=NA.clone(this.vertices[n]),s=NA.clone(this.vertices[i]),a=NA.clone(this.vertices[r]);return NA.sub(s,s,o),NA.sub(a,a,o),[o,s,a]}containsPoint(e){const t=this.vertices.length;let n=1/0;for(let i=0;i<t;i++){const[t,r,o]=this.getTransformedVertices(i),s=NA.sub(NA.create(),e,t);NA.normalize(s,s),NA.normalize(r,r),NA.normalize(o,o);const a=NA.cross(NA.create(),r,s),A=NA.cross(NA.create(),s,o),l=NA.dot(t,a),c=NA.dot(t,A);n=Math.min(n,l,c)}return n}getTriangleArea(e,t,n){NA.lerp(Pf,t,n,.5),NA.lerp(If,n,e,.5),NA.lerp(Lf,e,t,.5),NA.normalize(Pf,Pf),NA.normalize(If,If),NA.normalize(Lf,Lf);const i=(r=Pf,o=If,s=Lf,NA.cross(Bf,o,s),NA.dot(r,Bf));var r,o,s;const a=Math.max(-1,Math.min(1,i));return Math.abs(a)<1e-8?2*a:2*Math.asin(a)}getArea(){return null===this._area&&(this._area=this._getArea()),this._area}_getArea(){if(this.vertices.length<3)return 0;if(3===this.vertices.length)return this._area=this.getTriangleArea(this.vertices[0],this.vertices[1],this.vertices[2]),this._area;NA.set(Rf,0,0,0);for(const t of this.vertices)NA.add(Rf,Rf,t);NA.normalize(Rf,Rf);let e=0;for(let t=0;t<this.vertices.length;t++){const n=this.vertices[t],i=this.vertices[(t+1)%this.vertices.length],r=this.getTriangleArea(Rf,n,i);isNaN(r)||(e+=r)}return this._area=e,this._area}isWindingCorrect(){this.getArea()}};tA.setMatrixArrayType(Float64Array);var Of=class extends Ff{constructor(e){if(3!==e.length)throw new Error("SphericalTriangleShape requires exactly 3 vertices");super(e)}};tA.setMatrixArrayType(Float64Array);var Df=class{forward(e,t,n){const[i,r,o]=t,s=new Of([i,r,o]),a=NA.subtract(NA.create(),e,i);NA.normalize(a,a);const A=function(e,t,n,i,r){NA.cross(Bf,i,r);const o=NA.dot(t,Bf),s=NA.dot(n,Bf);return NA.scale(Mf,t,s),NA.scale(Sf,n,o),NA.sub(e,Sf,Mf)}(NA.create(),i,a,r,o);NA.normalize(A,A);const l=Tf(i,e)/Tf(i,A),c=l/s.getArea();return function(e,[t,n,i]){return[e[0]*t[0]+e[1]*n[0]+e[2]*i[0],e[0]*t[1]+e[1]*n[1]+e[2]*i[1]]}([1-l,c*new Of([i,A,o]).getArea(),c*new Of([i,r,A]).getArea()],n)}inverse(e,t,n){const[i,r,o]=n,s=new Of([i,r,o]),a=function(e,[t,n,i]){const r=[t[0]-i[0],t[1]-i[1]],o=[i[0]-n[0],i[1]-n[1]],s=[e[0]-i[0],e[1]-i[1]],a=o[0]*r[1]-o[1]*r[0],A=(o[0]*s[1]-o[1]*s[0])/a,l=(r[0]*s[1]-r[1]*s[0])/a;return[A,l,1-(A+l)]}(e,t),A=1-1e-14;if(a[0]>A)return i;if(a[1]>A)return r;if(a[2]>A)return o;const l=NA.create();NA.cross(l,r,o);const c=s.getArea(),u=1-a[0],f=a[2]/u*c,h=Math.sin(f),d=Math.sin(f/2),p=2*d*d,g=NA.dot(i,r),m=NA.dot(r,o),b=NA.dot(o,i),y=NA.length(l),v=h*NA.dot(i,l)+p*(g*m-b),_=p*y*(1+g),C=2/Math.acos(m)*Math.atan2(_,v),x=Ef(NA.create(),r,o,C),w=Tf(i,x);return Ef([0,0,0],i,x,this.safeAcos(u*w)/this.safeAcos(w))}safeAcos(e){return e<.001?2*e+e*e*e/3:Math.acos(1-2*e*e)}},Nf=-1;tA.setMatrixArrayType(Float64Array);var Uf=([e,t])=>Bc.fromValues(e-t,t);tA.setMatrixArrayType(Float64Array);var kf=Bc.fromValues(1,0),Gf=Bc.fromValues(0,1),zf=Bc.negate(Bc.create(),kf),Vf=Bc.negate(Bc.create(),Gf),Hf=Bc.fromValues(0,0),jf=(e,[t,n])=>{let i=Hf,r=Hf;switch(1===t&&1===n?(i=kf,r=Gf):t===Nf&&1===n?(i=Vf,r=zf):1===t&&n===Nf?(i=Gf,r=kf):t===Nf&&n===Nf&&(i=zf,r=Vf),e){case 0:return Hf;case 1:return i;case 2:return Bc.add(Bc.create(),r,i);case 3:return Bc.scaleAndAdd(Bc.create(),r,i,2);default:throw new Error(`Invalid Quaternary value: ${e}`)}},Qf=e=>[[1,1],[1,Nf],[1,1],[Nf,1]][e];function Jf(e){return Array.from({length:e.length},(t,n)=>e.indexOf(n))}var Kf=[0,1,3,4,5,6,7,2],Wf=[0,1,2,7,3,4,5,6];Jf(Kf),Jf(Wf);var qf=(e,t,n,i,r)=>{if(t<=0)return;const o=e[t]||0,s=e[t-1];let a=!0,A=!0;if(i!==(0===n[0]+n[1])?(a=1===o||2===o,A=1===o):(a=o<2,A=0===o),!a)return;const l=A?s:s+4,c=r[l];e[t-1]=c%4,e[t]=(o+4+Math.floor(c/4)-Math.floor(l/4))%4};tA.setMatrixArrayType(Float64Array);var Yf=Bc.fromValues(-1,1),Xf=(e,t,n,i,r=true)=>{const o=Bc.create(),s=[1,1];let a=BigInt(e);const A=[];for(;a>0n||A.length<t;)A.push(Number(a%4n)),a>>=2n;const l=i?Wf:Kf;for(let c=A.length-1;c>=0;c--)r&&qf(A,c,s,n,l),Bc.multiply(s,s,Qf(A[c]));s[0]=1,s[1]=1;for(let c=A.length-1;c>=0;c--){Bc.scale(o,o,2);const e=jf(A[c],s);Bc.add(o,o,e),Bc.multiply(s,s,Qf(A[c]))}return{q:A[0]||0,offset:Uf(o),flips:s}};tA.setMatrixArrayType(Float64Array);var Zf=Bc.clone(Gu),$f=Bc.negate(Bc.create(),Gu),eh=[0,1,2,3,4].map(e=>{const t=lA.create();return lA.fromRotation(t,bu*e),t}),th=Bc.create();function nh(e){const t=zu.clone();return t.transform(eh[e]),t}tA.setMatrixArrayType(Float64Array);tA.setMatrixArrayType(Float64Array);var ih=new class{constructor(){if(this.vertices=[],this.invocations=0,this.addFaceCenters(),this.addVertices(),this.addMidpoints(),62!==this.vertices.length)throw new Error("Failed to construct CRS: vertices length is not 62");Object.freeze(this.vertices)}getVertex(e){this.invocations++,this.invocations;for(const t of this.vertices)if(NA.distance(e,t)<1e-5)return t;throw new Error("Failed to find vertex in CRS")}addFaceCenters(){vf.forEach(e=>this.add(Yu(e.axis)))}addVertices(){const e=Math.atan(wu);for(const t of vf)for(let n=0;n<5;n++){const i=Yu([(2*n+1)*Math.PI/5+t.angle,e]);NA.transformQuat(i,i,t.quat),this.add(i)}}addMidpoints(){const e=Math.atan(xu);for(const t of vf)for(let n=0;n<5;n++){const i=Yu([2*n*Math.PI/5+t.angle,e]);NA.transformQuat(i,i,t.quat),this.add(i)}}add(e){const t=NA.normalize(NA.create(),e);return!this.vertices.find(e=>NA.distance(t,e)<1e-5)&&(this.vertices.push(t),!0)}};function rh(e){const t=function(e){if(0n===e)return-1;if(1n&e||0b100n==(0b111n&e)||0b10000n==(0b11111n&e))return 30;let t=29,n=e>>1n;if(0n===n)return-1;let i,r=Number(0xFFFFFFFFn&n);for(0===r?(n>>=32n,t-=16,i=Number(n)):i=r,65535&i||(i>>=16,t-=8),t>=6&&!(255&i)&&(i>>=8,t-=4),t>=4&&!(15&i)&&(i>>=4,t-=2);t>-1&&!(1&i);)t-=1,i>>=t<2?1:2;return t}(e);if(-1===t)return{origin:vf[0],segment:0,S:0n,resolution:t};let n=58n,i=0;if(30===t){const t=1n&e?1n:0b100n&e?3n:5n;n=58n+t,i=1n===t?0:3n===t?32:40}const r=Number(e>>n)+i;let o,s;if(0===t)o=vf[r],s=0;else{const e=Math.floor(r/5);o=vf[e],s=(r+o.firstQuintant)%5}if(!o)throw new Error(`Could not parse origin: ${r}`);if(t<2)return{origin:o,segment:s,S:0n,resolution:t};return{origin:o,segment:s,S:(e&(1n<<n)-1n)>>n-BigInt(2*(t-2+1)),resolution:t}}tA.setMatrixArrayType(Float64Array),lA.create();var oh=new class{constructor(){this.faceTriangles=[],this.sphericalTriangles=[],this.polyhedral=new Df,this.gnomonic=new xf}forward(e,t){const n=vf[t],i=Yu(e),r=NA.create();NA.transformQuat(r,i,n.inverseQuat);const o=qu(r),s=this.gnomonic.forward(o);s[1]=s[1]-n.angle;const a=this.getFaceTriangleIndex(s),A=this.shouldReflect(s);let l=this.getFaceTriangle(a,A,!1),c=this.getSphericalTriangle(a,t,A);return this.polyhedral.forward(i,c,l)}inverse(e,t){const n=Wu(e),i=this.getFaceTriangleIndex(n),r=this.shouldReflect(n),o=this.getFaceTriangle(i,r,!1),s=this.getSphericalTriangle(i,t,r);return qu(this.polyhedral.inverse(e,o,s))}shouldReflect(e){const[t,n]=e,i=function([e,t]){return[e*Math.cos(t),e*Math.sin(t)]}([t,this.normalizeGamma(n)])[0];return i>xu}getFaceTriangleIndex([e,t]){return(Math.floor(t/yu)+10)%10}getFaceTriangle(e,t=!1,n=!1){let i=e;return t&&(i+=n?20:10),this.faceTriangles[i]||(this.faceTriangles[i]=t?this._getReflectedFaceTriangle(e,n):this._getFaceTriangle(e),Object.freeze(this.faceTriangles[i])),this.faceTriangles[i]}_getFaceTriangle(e){const t=Math.floor((e+1)/2)%5,[n,i,r]=nh(t).getVertices(),o=Bc.create();Bc.lerp(o,i,r,.5);return e%2==0?[n,o,i]:[n,r,o]}_getReflectedFaceTriangle(e,t=!1){let[n,i,r]=this._getFaceTriangle(e).map(e=>Bc.clone(e));const o=e%2==0;Bc.negate(n,n);const s=o?i:r;return Bc.scaleAndAdd(n,n,s,t?1+1/Math.cos(Cu):2),[n,r,i]}getSphericalTriangle(e,t,n=!1){let i=10*t+e;return n&&(i+=120),this.sphericalTriangles[i]||(this.sphericalTriangles[i]=this._getSphericalTriangle(e,t,n),Object.freeze(this.sphericalTriangles[i])),this.sphericalTriangles[i]}_getSphericalTriangle(e,t,n=!1){const i=vf[t];return this.getFaceTriangle(e,n,!0).map(e=>{const[t,n]=Wu(e),r=[t,n+i.angle],o=Yu(this.gnomonic.inverse(r));return NA.transformQuat(o,o,i.quat),ih.getVertex(o)})}normalizeGamma(e){const t=e/bu;return(t-Math.round(t))*bu}};function sh({S:e,segment:t,origin:n,resolution:i}){const{quintant:r,orientation:o}=function(e,t){const n=t.orientation,i=n===hf||n===df?-1:1,r=(e-t.firstQuintant+5)%5,o=n[r];return{quintant:(t.firstQuintant+i*r+5)%5,orientation:o}}(t,n);if(1===i){return nh(r)}if(0===i)return function(){const e=[];for(const t of eh)e.push(Bc.transformMat2(Bc.create(),Uu,t));return e.reverse(),new Bu(e)}();const s=i-2+1,a=((e,t,n,i=!0)=>{let r=BigInt(e);const o="wv"===n||"vw"===n,s="wu"===n||"uw"===n;("vu"===n||"wu"===n||"vw"===n)&&(r=(1n<<BigInt(2*t))-r-1n);const a=Xf(r,t,o,s,i);if(s){const{offset:[e,t],flips:[n,i]}=a;a.offset=[t,e],n===Nf&&Bc.add(a.offset,a.offset,Yf),i===Nf&&Bc.subtract(a.offset,a.offset,Yf)}if(o){const{offset:[e,n],flips:i}=a,r=(1<<t)-(e+n);i[0]=-i[0],a.offset[1]=r,a.flips=i}return a})(e,s,o);return function(e,t,n){const i=Fu.clone();Bc.transformMat2(th,n.offset,Vu),1===n.flips[0]&&n.flips[1]===Nf&&i.rotate180();const{q:r}=n,o=n.flips[0]+n.flips[1];return((-2===o||2===o)&&r>1||0===o&&(0===r||3===r))&&i.reflectY(),n.flips[0]===Nf&&n.flips[1]===Nf?i.rotate180():n.flips[0]===Nf?i.translate($f):n.flips[1]===Nf&&i.translate(Zf),i.translate(th),i.scale(1/2**e),i.transform(eh[t]),i}(s,r,a)}var ah=12742014.4/Math.sqrt(15),Ah=new Array(31);Ah[0]=12742014.4/Math.sqrt(3);for(let $M=1;$M<=30;$M++)Ah[$M]=ah/(1<<$M-1);tA.setMatrixArrayType(Float64Array);var lh=function(e){var t,n=void 0!==(e=e||{})?e:{},i={};for(t in n)n.hasOwnProperty(t)&&(i[t]=n[t]);var r,o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",r=function(e,t,n){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){if(200==i.status||0==i.status&&i.response)t(i.response);else{var r=j(e);r?t(r.buffer):n()}},i.onerror=n,i.send(null)};var s=n.print||function(){}.bind(),a=n.printErr||function(){}.bind();for(t in i)i.hasOwnProperty(t)&&(n[t]=i[t]);i=null,n.arguments&&n.arguments;var A=0;var l=!1;function c(e){var t,i=n["_"+e];return t="Cannot call unknown function "+e+", make sure it is exported",i||ie("Assertion failed: "+t),i}function u(e,t,n,i,r){var o={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);(function(e,t,n){(function(e,t,n,i){if(!(i>0))return 0;for(var r=n,o=n+i-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s);if(a<=127){if(n>=o)break;t[n++]=a}else if(a<=2047){if(n+1>=o)break;t[n++]=192|a>>6,t[n++]=128|63&a}else if(a<=65535){if(n+2>=o)break;t[n++]=224|a>>12,t[n++]=128|a>>6&63,t[n++]=128|63&a}else{if(n+3>=o)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63,t[n++]=128|a>>6&63,t[n++]=128|63&a}}t[n]=0})(e,d,t,n)})(e,t=q(n),n)}return t},array:function(e){var t,n,i=q(e.length);return t=e,n=i,h.set(t,n),i}};var s=c(e),a=[],A=0;if(i)for(var l=0;l<i.length;l++){var u=o[n[l]];u?(0===A&&(A=X()),a[l]=u(i[l])):a[l]=i[l]}var f,p=s.apply(null,a);return f=p,p="string"===t?v(f):"boolean"===t?Boolean(f):f,0!==A&&Y(A),p}var f,h,d,p,g,m,b,y="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function v(e,t){return e?function(e,t,n){for(var i=t+n,r=t;e[r]&&!(r>=i);)++r;if(r-t>16&&e.subarray&&y)return y.decode(e.subarray(t,r));for(var o="";t<r;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var A=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|A:(7&s)<<18|a<<12|A<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var l=s-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&s)<<6|a)}else o+=String.fromCharCode(s)}return o}(d,e,t):""}function _(e,t){return e%t>0&&(e+=t-e%t),e}function C(e){f=e,n.HEAP8=h=new Int8Array(e),n.HEAP16=p=new Int16Array(e),n.HEAP32=g=new Int32Array(e),n.HEAPU8=d=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=m=new Float32Array(e),n.HEAPF64=b=new Float64Array(e)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var x=n.TOTAL_MEMORY||33554432;function w(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var i=t.func;"number"==typeof i?void 0===t.arg?n.dynCall_v(i):n.dynCall_vi(i,t.arg):i(void 0===t.arg?null:t.arg)}else t()}}x=(f=n.buffer?n.buffer:new ArrayBuffer(x)).byteLength,C(f),g[7156]=5271536;var B=[],M=[],S=[],T=[];function E(e){B.unshift(e)}function P(e){T.unshift(e)}var I=Math.abs,L=Math.ceil,R=Math.floor,F=Math.min,O=0,D=null;n.preloadedImages={},n.preloadedAudios={};var N,U,k=null,G="data:application/octet-stream;base64,";function z(e){return String.prototype.startsWith?e.startsWith(G):0===e.indexOf(G)}k="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";function V(){return h.length}var H="function"==typeof atob?atob:function(e){var t,n,i,r,o,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",A="",l=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=a.indexOf(e.charAt(l++))<<2|(r=a.indexOf(e.charAt(l++)))>>4,n=(15&r)<<4|(o=a.indexOf(e.charAt(l++)))>>2,i=(3&o)<<6|(s=a.indexOf(e.charAt(l++))),A+=String.fromCharCode(t),64!==o&&(A+=String.fromCharCode(n)),64!==s&&(A+=String.fromCharCode(i))}while(l<e.length);return A};function j(e){if(z(e))return function(e){try{for(var t=H(e),n=new Uint8Array(t.length),i=0;i<t.length;++i)n[i]=t.charCodeAt(i);return n}catch(r){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(G.length))}var Q=function(e,t,n){var i=new e.Int8Array(n),r=new e.Int32Array(n);new e.Uint8Array(n),new e.Float32Array(n);var o=new e.Float64Array(n),s=0|t.o,a=0|t.p,A=e.Math.floor,l=e.Math.abs,c=e.Math.sqrt,u=e.Math.pow,f=e.Math.cos,h=e.Math.sin,d=e.Math.tan,p=e.Math.acos,g=e.Math.asin,m=e.Math.atan,b=e.Math.atan2,y=e.Math.ceil,v=e.Math.imul,_=e.Math.min,C=e.Math.max,x=e.Math.clz32,w=t.b,B=t.c,M=t.d,S=t.e,T=t.f,E=t.g,P=t.h,I=t.i,L=28656;function R(e,t,n,i){return 0|F(e|=0,t|=0,n|=0,i|=0,0)}function F(e,t,n,i,o){var s,a=0,A=0,l=0,c=0;if(s=L,L=L+16|0,A=s,!(0|O(e|=0,t|=0,n|=0,i|=0,o|=0)))return L=s,0|(i=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(a=0|ct(15,A)))break;A=0|r[(l=A)>>2],l=0|r[l+4>>2]}else c=0|$t(0|n,0|(a=((0|n)<0)<<31>>31),3,0),l=0|B(),a=0|Wt(0|n,0|a,1,0),a=0|Wt(0|(a=0|$t(0|c,0|l,0|a,0|B())),0|B(),1,0),l=0|B(),r[A>>2]=a,r[A+4>>2]=l,A=a;if(un(0|i,0,A<<3),0|o){un(0|o,0,A<<2),a=0|D(e,t,n,i,o,A,l,0);break}(a=0|Kt(A,4))?(c=0|D(e,t,n,i,a,A,l,0),Jt(a),a=c):a=13}else a=2}while(0);return L=s,0|(c=a)}function O(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s,a,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0;if(a=L,L=L+16|0,g=a+8|0,r[(p=s=a)>>2]=e,r[p+4>>2]=t,(0|n)<0)return L=a,0|(g=2);if(r[(A=i)>>2]=e,r[A+4>>2]=t,(A=!!(0|o))&&(r[o>>2]=0),0|ze(e,t))return L=a,0|(g=9);r[g>>2]=0;e:do{if((0|n)>=1)if(A)for(h=1,f=0,d=0,p=1,A=e;;){if(!(f|d)){if(0|(A=0|N(A,t,4,g,s)))break e;if(0|ze(A=0|r[(t=s)>>2],t=0|r[t+4>>2])){A=9;break e}}if(0|(A=0|N(A,t,0|r[26800+(d<<2)>>2],g,s)))break e;if(A=0|r[(t=s)>>2],t=0|r[t+4>>2],r[(e=i+(h<<3)|0)>>2]=A,r[e+4>>2]=t,r[o+(h<<2)>>2]=p,l=(0|(e=f+1|0))==(0|p),u=6==(0|(c=d+1|0)),0|ze(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}h=h+1|0,f=l?0:e,d=l?u?0:c:d}else for(h=1,f=0,d=0,p=1,A=e;;){if(!(f|d)){if(0|(A=0|N(A,t,4,g,s)))break e;if(0|ze(A=0|r[(t=s)>>2],t=0|r[t+4>>2])){A=9;break e}}if(0|(A=0|N(A,t,0|r[26800+(d<<2)>>2],g,s)))break e;if(A=0|r[(t=s)>>2],t=0|r[t+4>>2],r[(e=i+(h<<3)|0)>>2]=A,r[e+4>>2]=t,l=(0|(e=f+1|0))==(0|p),u=6==(0|(c=d+1|0)),0|ze(A,t)){A=9;break e}if((0|(p=p+(u&l&1)|0))>(0|n)){A=0;break}h=h+1|0,f=l?0:e,d=l?u?0:c:d}else A=0}while(0);return L=a,0|(g=A)}function D(e,t,n,i,o,s,a,A){n|=0,i|=0,o|=0,A|=0;var l,c,u,f=0,h=0,d=0,p=0,g=0,m=0,b=0;if(u=L,L=L+16|0,l=u+8|0,c=u,f=0|tn(0|(e|=0),0|(t|=0),0|(s|=0),0|(a|=0)),d=0|B(),!(!(0|(b=0|r[(m=p=i+(f<<3)|0)>>2]))&!(0|(m=0|r[m+4>>2]))|(h=(0|b)==(0|e)&(0|m)==(0|t))))do{f=0|en(0|(f=0|Wt(0|f,0|d,1,0)),0|B(),0|s,0|a),d=0|B(),h=(0|(m=0|r[(b=p=i+(f<<3)|0)>>2]))==(0|e)&(0|(b=0|r[b+4>>2]))==(0|t)}while(!(!(0|m)&!(0|b)|h));if(f=o+(f<<2)|0,h&&(0|r[f>>2])<=(0|A))return L=u,0|(b=0);if(r[(b=p)>>2]=e,r[b+4>>2]=t,r[f>>2]=A,(0|A)>=(0|n))return L=u,0|(b=0);switch(h=A+1|0,r[l>>2]=0,0|(f=0|N(e,t,2,l,c))){case 9:g=9;break;case 0:(f=0|D(0|r[(f=c)>>2],0|r[f+4>>2],n,i,o,s,a,h))||(g=9)}e:do{if(9==(0|g)){switch(r[l>>2]=0,0|(f=0|N(e,t,3,l,c))){case 9:break;case 0:if(0|(f=0|D(0|r[(f=c)>>2],0|r[f+4>>2],n,i,o,s,a,h)))break e;break;default:break e}switch(r[l>>2]=0,0|(f=0|N(e,t,1,l,c))){case 9:break;case 0:if(0|(f=0|D(0|r[(f=c)>>2],0|r[f+4>>2],n,i,o,s,a,h)))break e;break;default:break e}switch(r[l>>2]=0,0|(f=0|N(e,t,5,l,c))){case 9:break;case 0:if(0|(f=0|D(0|r[(f=c)>>2],0|r[f+4>>2],n,i,o,s,a,h)))break e;break;default:break e}switch(r[l>>2]=0,0|(f=0|N(e,t,4,l,c))){case 9:break;case 0:if(0|(f=0|D(0|r[(f=c)>>2],0|r[f+4>>2],n,i,o,s,a,h)))break e;break;default:break e}switch(r[l>>2]=0,0|(f=0|N(e,t,6,l,c))){case 9:break;case 0:if(0|(f=0|D(0|r[(f=c)>>2],0|r[f+4>>2],n,i,o,s,a,h)))break e;break;default:break e}return L=u,0|(b=0)}}while(0);return L=u,0|(b=f)}function N(e,t,n,i,o){e|=0,t|=0,o|=0;var s,a,A=0,l=0,c=0,u=0,f=0,h=0,d=0;if((n|=0)>>>0>6)return 0|(o=1);if(f=(0|r[(i|=0)>>2])%6|0,r[i>>2]=f,(0|f)>0){A=0;do{n=0|ye(n),A=A+1|0}while((0|A)<(0|r[i>>2]))}if(f=0|rn(0|e,0|t,45),B(),(a=127&f)>>>0>121)return 0|(o=5);s=0|je(e,t),A=0|rn(0|e,0|t,52),B(),A&=15;e:do{if(A){for(;;){if(c=0|rn(0|e,0|t,0|(l=3*(15-A|0)|0)),B(),7==(0|(c&=7))){t=5;break}if(d=!(0|qe(A)),A=A+-1|0,h=0|on(7,0,0|l),t&=~B(),e=0|on(0|r[(d?432:16)+(28*c|0)+(n<<2)>>2],0,0|l)|e&~h,t|=l=0|B(),!(n=0|r[(d?640:224)+(28*c|0)+(n<<2)>>2])){n=0;break e}if(!A){u=8;break e}}return 0|t}u=8}while(0);8==(0|u)&&(e|=0|on(0|(d=0|r[848+(28*a|0)+(n<<2)>>2]),0,45),t=B()|-1040385&t,n=0|r[4272+(28*a|0)+(n<<2)>>2],127&~d||(d=0|on(0|r[848+(28*a|0)+20>>2],0,45),t=B()|-1040385&t,n=0|r[4272+(28*a|0)+20>>2],e=0|Je(d|e,t),t=0|B(),r[i>>2]=1+(0|r[i>>2]))),c=0|rn(0|e,0|t,45),B(),c&=127;e:do{if(0|z(c)){t:do{if(1==(0|je(e,t))){if((0|a)!=(0|c)){if(0|Q(c,0|r[7696+(28*a|0)>>2])){e=0|We(e,t),l=1,t=0|B();break}M(27795,26864,533,26872)}switch(0|s){case 3:e=0|Je(e,t),t=0|B(),r[i>>2]=1+(0|r[i>>2]),l=0;break t;case 5:e=0|We(e,t),t=0|B(),r[i>>2]=5+(0|r[i>>2]),l=0;break t;case 0:return 0|(d=9);default:return 0|(d=1)}}else l=0}while(0);if((0|n)>0){A=0;do{e=0|Qe(e,t),t=0|B(),A=A+1|0}while((0|A)!=(0|n))}if((0|a)!=(0|c)){if(!(0|V(c))){if(!!(0|l)|5!=(0|je(e,t)))break;r[i>>2]=1+(0|r[i>>2]);break}switch(127&f){case 8:case 118:break e}3!=(0|je(e,t))&&(r[i>>2]=1+(0|r[i>>2]))}}else if((0|n)>0){A=0;do{e=0|Je(e,t),t=0|B(),A=A+1|0}while((0|A)!=(0|n))}}while(0);return r[i>>2]=((0|r[i>>2])+n|0)%6|0,r[(d=o)>>2]=e,r[d+4>>2]=t,0|(d=0)}function U(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o,s,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0;if(s=L,L=L+16|0,p=s+8|0,r[(d=o=s)>>2]=e,r[d+4>>2]=t,(0|n)<0)return L=s,0|(p=2);if(!n)return r[(p=i)>>2]=e,r[p+4>>2]=t,L=s,0|(p=0);r[p>>2]=0;e:do{if(0|ze(e,t))e=9;else{a=0,d=e;do{if(0|(e=0|N(d,t,4,p,o)))break e;if(a=a+1|0,0|ze(d=0|r[(t=o)>>2],t=0|r[t+4>>2])){e=9;break e}}while((0|a)<(0|n));r[(h=i)>>2]=d,r[h+4>>2]=t,h=n+-1|0,f=0,e=1;do{if(a=26800+(f<<2)|0,5==(0|f))for(l=0|r[a>>2],A=0,a=e;;){if(0|(e=0|N(0|r[(e=o)>>2],0|r[e+4>>2],l,p,o)))break e;if((0|A)!=(0|h)){if(c=0|r[(u=o)>>2],u=0|r[u+4>>2],r[(e=i+(a<<3)|0)>>2]=c,r[e+4>>2]=u,0|ze(c,u)){e=9;break e}e=a+1|0}else e=a;if((0|(A=A+1|0))>=(0|n))break;a=e}else for(l=o,u=0|r[a>>2],c=0,a=e,A=0|r[l>>2],l=0|r[l+4>>2];;){if(0|(e=0|N(A,l,u,p,o)))break e;if(A=0|r[(l=o)>>2],l=0|r[l+4>>2],r[(e=i+(a<<3)|0)>>2]=A,r[e+4>>2]=l,e=a+1|0,0|ze(A,l)){e=9;break e}if((0|(c=c+1|0))>=(0|n))break;a=e}f=f+1|0}while(f>>>0<6);e=(0|d)==(0|r[(e=o)>>2])&&(0|t)==(0|r[e+4>>2])?0:9}}while(0);return L=s,0|(p=e)}function k(e,t,n,i){n|=0,i|=0;var o,s,a,A=0,l=0;for(a=L,L=L+16|0,o=a,s=a+8|0,A=(A=!(0|ze(e|=0,t|=0)))?1:2;;){if(r[s>>2]=0,!(0|N(e,t,A,s,o))&((0|r[(l=o)>>2])==(0|n)?(0|r[l+4>>2])==(0|i):0)){e=4;break}if((A=A+1|0)>>>0>=7){A=7,e=4;break}}return 4==(0|e)?(L=a,0|A):0}function G(e,t,n,i,s,a,A){t|=0,n|=0,i|=0,s|=0,a|=0,A|=0;var l,c,u,f,h,d,p,g,m,b,y=0,v=0,_=0,C=0,x=0,w=0,M=0,S=0,T=0,E=0,P=0,I=0,R=0,F=0,O=0,D=0,N=0,U=0,k=0;if(b=L,L=L+64|0,p=b+48|0,g=b+32|0,m=b+24|0,l=b+8|0,c=b,(0|(v=0|r[(e|=0)>>2]))<=0)return L=b,0|(O=0);for(u=e+4|0,f=p+8|0,h=g+8|0,d=l+8|0,y=0,R=0;;){I=(_=0|r[u>>2])+(R<<4)|0,r[p>>2]=r[I>>2],r[p+4>>2]=r[I+4>>2],r[p+8>>2]=r[I+8>>2],r[p+12>>2]=r[I+12>>2],(0|R)==(v+-1|0)?(r[g>>2]=r[_>>2],r[g+4>>2]=r[_+4>>2],r[g+8>>2]=r[_+8>>2],r[g+12>>2]=r[_+12>>2]):(I=_+(R+1<<4)|0,r[g>>2]=r[I>>2],r[g+4>>2]=r[I+4>>2],r[g+8>>2]=r[I+8>>2],r[g+12>>2]=r[I+12>>2]),v=0|ne(p,g,i,m);e:do{if(v)_=0,y=v;else if(_=0|r[(v=m)>>2],(0|(v=0|r[v+4>>2]))>0|!(0|v)&_>>>0>0){P=0,I=0;t:for(;;){if(N=1/(+(_>>>0)+4294967296*+(0|v)),k=+o[p>>3],U=+((v=0|qt(0|_,0|v,0|P,0|I))>>>0)+4294967296*+(0|B()),D=+(P>>>0)+4294967296*+(0|I),o[l>>3]=N*(k*U)+N*(+o[g>>3]*D),o[d>>3]=N*(+o[f>>3]*U)+N*(+o[h>>3]*D),0|(v=0|Ye(l,i,c))){y=v;break}w=0|tn(0|(T=0|r[(E=c)>>2]),0|(E=0|r[E+4>>2]),0|t,0|n),C=0|B(),_=0|r[(x=v=A+(w<<3)|0)>>2],x=0|r[x+4>>2];n:do{if(!(0|_)&!(0|x))F=v,O=16;else for(M=0,S=0;;){if((0|M)>(0|n)|(0|M)==(0|n)&S>>>0>t>>>0){y=1;break t}if((0|_)==(0|T)&(0|x)==(0|E))break n;if(w=0|en(0|(v=0|Wt(0|w,0|C,1,0)),0|B(),0|t,0|n),C=0|B(),S=0|Wt(0|S,0|M,1,0),M=0|B(),!(0|(_=0|r[(x=v=A+(w<<3)|0)>>2]))&!(0|(x=0|r[x+4>>2]))){F=v,O=16;break}}}while(0);if(16!=(0|O)||(O=0,!(0|T)&!(0|E))||(r[(S=F)>>2]=T,r[S+4>>2]=E,S=a+(r[s>>2]<<3)|0,r[S>>2]=T,r[S+4>>2]=E,S=0|Wt(0|r[(S=s)>>2],0|r[S+4>>2],1,0),T=0|B(),r[(E=s)>>2]=S,r[E+4>>2]=T),P=0|Wt(0|P,0|I,1,0),I=0|B(),_=0|r[(v=m)>>2],!((0|(v=0|r[v+4>>2]))>(0|I)|(0|v)==(0|I)&_>>>0>P>>>0)){_=1;break e}}_=0}else _=1}while(0);if(R=R+1|0,!_){O=21;break}if((0|R)>=(0|(v=0|r[e>>2]))){y=0,O=21;break}}return 21==(0|O)?(L=b,0|y):0}function z(e){return(e|=0)>>>0>121?0|(e=0):0|(e=0|r[7696+(28*e|0)+16>>2])}function V(e){return 4==(0|(e|=0))|117==(0|e)|0}function H(e){return 0|r[11120+(216*(0|r[(e|=0)>>2])|0)+(72*(0|r[e+4>>2])|0)+(24*(0|r[e+8>>2])|0)+(r[e+12>>2]<<3)>>2]}function j(e){return 0|r[11120+(216*(0|r[(e|=0)>>2])|0)+(72*(0|r[e+4>>2])|0)+(24*(0|r[e+8>>2])|0)+(r[e+12>>2]<<3)+4>>2]}function Q(e,t){return t|=0,(0|r[7696+(28*(e|=0)|0)+20>>2])==(0|t)?0|(t=1):0|(t=(0|r[7696+(28*e|0)+24>>2])==(0|t))}function J(e,t){return 0|r[848+(28*(e|=0)|0)+((t|=0)<<2)>>2]}function K(e,t){return t|=0,(0|r[848+(28*(e|=0)|0)>>2])==(0|t)?0|(t=0):(0|r[848+(28*e|0)+4>>2])==(0|t)?0|(t=1):(0|r[848+(28*e|0)+8>>2])==(0|t)?0|(t=2):(0|r[848+(28*e|0)+12>>2])==(0|t)?0|(t=3):(0|r[848+(28*e|0)+16>>2])==(0|t)?0|(t=4):(0|r[848+(28*e|0)+20>>2])==(0|t)?0|(t=5):0|((0|r[848+(28*e|0)+24>>2])==(0|t)?6:7)}function W(e){var t,n,i;return t=(i=+o[(e|=0)+16>>3])-(n=+o[e+24>>3]),+(i<n?t+6.283185307179586:t)}function q(e){return+o[(e|=0)+16>>3]<+o[e+24>>3]|0}function Y(e){return+(+o[(e|=0)>>3]-+o[e+8>>3])}function X(e,t){e|=0;var n,i,r=0;return(r=+o[(t|=0)>>3])>=+o[e+8>>3]&&r<=+o[e>>3]?(n=+o[e+16>>3],r=+o[e+24>>3],t=(i=+o[t+8>>3])>=r,e=i<=n&1,n<r?t&&(e=1):t||(e=0),0|(t=!!(0|e))):0|(t=0)}function Z(e,t){t|=0;var n,i,r,s,a,A=0,l=0,c=0,u=0;return+o[(e|=0)>>3]<+o[t+8>>3]||+o[e+8>>3]>+o[t>>3]?0|(A=0):(r=(l=+o[e+16>>3])<(u=+o[(n=e+24|0)>>3]),c=(a=+o[(A=t+16|0)>>3])<(s=+o[(i=t+24|0)>>3]),t=u-a<s-l,e=r?c|t?1:2:0,t=c?r?1:t?2:1:0,(l=+at(l,e))<+at(+o[i>>3],t)||(u=+at(+o[n>>3],e))>+at(+o[A>>3],t)?0|(c=0):0|(c=1))}function $(e,t){t|=0;var n,i,r,s,a,A=0,l=0,c=0,u=0;return+o[(e|=0)>>3]<+o[t>>3]||+o[e+8>>3]>+o[t+8>>3]?0|(A=0):(r=(s=+o[(A=e+16|0)>>3])<(l=+o[e+24>>3]),c=(u=+o[(n=t+16|0)>>3])<(a=+o[(i=t+24|0)>>3]),t=l-u<a-s,e=r?c|t?1:2:0,t=c?r?1:t?2:1:0,(l=+at(l,e))<=+at(+o[i>>3],t)?0|(c=(u=+at(+o[A>>3],e))>=+at(+o[n>>3],t)):0|(c=0))}function ee(e,t){e|=0,t|=0;var n,i,s,a,A,l=0;s=L,L=L+176|0,r[(i=s)>>2]=4,l=+o[t>>3],o[i+8>>3]=l,a=+o[t+16>>3],o[i+16>>3]=a,o[i+24>>3]=l,l=+o[t+24>>3],o[i+32>>3]=l,A=+o[t+8>>3],o[i+40>>3]=A,o[i+48>>3]=l,o[i+56>>3]=A,o[i+64>>3]=a,n=(t=i+72|0)+96|0;do{r[t>>2]=0,t=t+4|0}while((0|t)<(0|n));cn(0|e,0|i,168),L=s}function te(e,t,n){e|=0,t|=0,n|=0;var i,a,c,u,f,h,d,p=0,g=0,m=0,b=0,v=0,C=0,x=0;h=L,L=L+288|0,f=h+264|0,b=h+96|0,g=(p=m=h)+96|0;do{r[p>>2]=0,p=p+4|0}while((0|p)<(0|g));return 0|(t=0|tt(t,m))?(L=h,0|(C=t)):($e(m=0|r[(g=m)>>2],g=0|r[g+4>>2],f),et(m,g,b),u=+At(f,b+8|0),o[f>>3]=+o[e>>3],o[(g=f+8|0)>>3]=+o[e+16>>3],o[b>>3]=+o[e+8>>3],o[(m=b+8|0)>>3]=+o[e+24>>3],a=+At(f,b),x=+o[g>>3]-+o[m>>3],c=+l(+x),d=+o[f>>3]-+o[b>>3],i=+l(+d),!(0==x|0==d)&&(x=+an(+c,+i),x=+y(+a*a/+An(+x/+An(+c,+i),3)/(u*(2.59807621135*u)*.8)),o[s>>3]=x,v=~~x>>>0,C=+l(x)>=1?x>0?~~+_(+A(x/4294967296),4294967295)>>>0:~~+y((x-+(~~x>>>0))/4294967296)>>>0:0,2146435072&~r[s+4>>2])?(b=!(0|v)&!(0|C),r[(t=n)>>2]=b?1:v,r[t+4>>2]=b?0:C,t=0):t=1,L=h,0|(C=t))}function ne(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var a,c,u,f,h=0,d=0,p=0;f=L,L=L+288|0,c=f+264|0,u=f+96|0,a=(h=d=f)+96|0;do{r[h>>2]=0,h=h+4|0}while((0|h)<(0|a));return 0|(n=0|tt(n,d))?(L=f,0|(i=n)):($e(h=0|r[(n=d)>>2],n=0|r[n+4>>2],c),et(h,n,u),p=+At(c,u+8|0),p=+y(+ +At(e,t)/(2*p)),o[s>>3]=p,n=~~p>>>0,h=+l(p)>=1?p>0?~~+_(+A(p/4294967296),4294967295)>>>0:~~+y((p-+(~~p>>>0))/4294967296)>>>0:0,2146435072&~r[s+4>>2]?(d=!(0|n)&!(0|h),r[i>>2]=d?1:n,r[i+4>>2]=d?0:h,L=f,0|(i=0)):(L=f,0|(i=1)))}function ie(e,t,n,i){t|=0,n|=0,i|=0,r[(e|=0)>>2]=t,r[e+4>>2]=n,r[e+8>>2]=i}function re(e){var t,n=0,i=0,o=0,s=0,a=0;n=0|r[(e|=0)>>2],i=0|r[(t=e+4|0)>>2],(0|n)<0&&(i=i-n|0,r[t>>2]=i,r[(a=e+8|0)>>2]=(0|r[a>>2])-n,r[e>>2]=0,n=0),(0|i)<0?(n=n-i|0,r[e>>2]=n,s=(0|r[(a=e+8|0)>>2])-i|0,r[a>>2]=s,r[t>>2]=0,i=0):(a=s=e+8|0,s=0|r[s>>2]),(0|s)<0&&(n=n-s|0,r[e>>2]=n,i=i-s|0,r[t>>2]=i,r[a>>2]=0,s=0),(0|(o=(0|s)<(0|(o=(0|i)<(0|n)?i:n))?s:o))<=0||(r[e>>2]=n-o,r[t>>2]=i-o,r[a>>2]=s-o)}function oe(e,t){t|=0;var n,i;i=0|r[(e|=0)+8>>2],n=+((0|r[e+4>>2])-i|0),o[t>>3]=+((0|r[e>>2])-i|0)-.5*n,o[t+8>>3]=.8660254037844386*n}function se(e,t,n){e|=0,t|=0,r[(n|=0)>>2]=(0|r[t>>2])+(0|r[e>>2]),r[n+4>>2]=(0|r[t+4>>2])+(0|r[e+4>>2]),r[n+8>>2]=(0|r[t+8>>2])+(0|r[e+8>>2])}function ae(e,t,n){e|=0,t|=0,r[(n|=0)>>2]=(0|r[e>>2])-(0|r[t>>2]),r[n+4>>2]=(0|r[e+4>>2])-(0|r[t+4>>2]),r[n+8>>2]=(0|r[e+8>>2])-(0|r[t+8>>2])}function Ae(e,t){t|=0;var n,i=0;i=0|v(0|r[(e|=0)>>2],t),r[e>>2]=i,n=0|v(0|r[(i=e+4|0)>>2],t),r[i>>2]=n,t=0|v(0|r[(e=e+8|0)>>2],t),r[e>>2]=t}function le(e){var t,n,i=0,o=0,s=0,a=0,A=0;A=(0|(n=0|r[(e|=0)>>2]))<0,e=(e=(o=(0|(a=((t=(0|(s=(0|r[e+4>>2])-(A?n:0)|0))<0)?0-s|0:0)+((0|r[e+8>>2])-(A?n:0))|0))<0)?0:a)-((s=(0|(o=(0|e)<(0|(o=(0|(i=(t?0:s)-(o?a:0)|0))<(0|(a=(A?0:n)-(t?s:0)-(o?a:0)|0))?i:a))?e:o))>0)?o:0)|0,i=i-(s?o:0)|0;e:do{switch(a-(s?o:0)|0){case 0:switch(0|i){case 0:return 0|(A=0|e?1==(0|e)?1:7:0);case 1:return 0|(A=0|e?1==(0|e)?3:7:2);default:break e}case 1:switch(0|i){case 0:return 0|(A=0|e?1==(0|e)?5:7:4);case 1:if(e)break e;return 0|(e=6);default:break e}}}while(0);return 0|(A=7)}function ce(e){var t,n,i=0,o=0,s=0,a=0,A=0,l=0,c=0;if(l=0|r[(n=(e|=0)+8|0)>>2],(t=(0|r[e>>2])-l|0)>>>0>715827881|(l=(0|r[(c=e+4|0)>>2])-l|0)>>>0>715827881){if(a=2147483647-t|0,A=-2147483648-t|0,(s=(0|t)>0)?(0|a)<(0|t):(0|A)>(0|t))return 0|(c=1);if(o=t<<1,s?(2147483647-o|0)<(0|t):(-2147483648-o|0)>(0|t))return 0|(c=1);if((0|l)>0?(2147483647-l|0)<(0|l):(-2147483648-l|0)>(0|l))return 0|(c=1);if(i=3*t|0,o=l<<1,(s?(0|a)<(0|o):(0|A)>(0|o))||((0|t)>-1?(-2147483648|i)>=(0|l):(-2147483648^i)<(0|l)))return 0|(c=1)}else o=l<<1,i=3*t|0;return s=0|jt(.14285714285714285*+(i-l|0)),r[e>>2]=s,a=0|jt(.14285714285714285*+(o+t|0)),r[c>>2]=a,r[n>>2]=0,i=(o=(0|a)<(0|s))?s:a,(0|(o=o?a:s))<0&&((-2147483648==(0|o)||((0|i)>0?(2147483647-i|0)<(0|o):(-2147483648-i|0)>(0|o)))&&M(27795,26892,354,26903),((0|i)>-1?(-2147483648|i)>=(0|o):(-2147483648^i)<(0|o))&&M(27795,26892,354,26903)),i=a-s|0,(0|s)<0?(o=0-s|0,r[c>>2]=i,r[n>>2]=o,r[e>>2]=0,s=0):(i=a,o=0),(0|i)<0&&(s=s-i|0,r[e>>2]=s,o=o-i|0,r[n>>2]=o,r[c>>2]=0,i=0),A=s-o|0,a=i-o|0,(0|o)<0?(r[e>>2]=A,r[c>>2]=a,r[n>>2]=0,i=a,a=A,o=0):a=s,(0|(s=(0|o)<(0|(s=(0|i)<(0|a)?i:a))?o:s))<=0||(r[e>>2]=a-s,r[c>>2]=i-s,r[n>>2]=o-s),0|(c=0)}function ue(e){var t,n=0,i=0,o=0,s=0,a=0,A=0,l=0;if(s=0|r[(t=(e|=0)+8|0)>>2],(a=(0|r[e>>2])-s|0)>>>0>715827881|(s=(0|r[(A=e+4|0)>>2])-s|0)>>>0>715827881){if((i=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 0|(A=1);if(n=a<<1,(o=(0|s)>0)?(2147483647-s|0)<(0|s):(-2147483648-s|0)>(0|s))return 0|(A=1);if(l=s<<1,o?(2147483647-l|0)<(0|s):(-2147483648-l|0)>(0|s))return 0|(l=1);if(i?(2147483647-n|0)<(0|s):(-2147483648-n|0)>(0|s))return 0|(l=1);if(i=3*s|0,(0|s)>-1?(-2147483648|i)>=(0|a):(-2147483648^i)<(0|a))return 0|(l=1)}else i=3*s|0,n=a<<1;return o=0|jt(.14285714285714285*+(n+s|0)),r[e>>2]=o,s=0|jt(.14285714285714285*+(i-a|0)),r[A>>2]=s,r[t>>2]=0,n=(i=(0|s)<(0|o))?o:s,(0|(i=i?s:o))<0&&((-2147483648==(0|i)||((0|n)>0?(2147483647-n|0)<(0|i):(-2147483648-n|0)>(0|i)))&&M(27795,26892,402,26917),((0|n)>-1?(-2147483648|n)>=(0|i):(-2147483648^n)<(0|i))&&M(27795,26892,402,26917)),n=s-o|0,(0|o)<0?(i=0-o|0,r[A>>2]=n,r[t>>2]=i,r[e>>2]=0,o=0):(n=s,i=0),(0|n)<0&&(o=o-n|0,r[e>>2]=o,i=i-n|0,r[t>>2]=i,r[A>>2]=0,n=0),a=o-i|0,s=n-i|0,(0|i)<0?(r[e>>2]=a,r[A>>2]=s,r[t>>2]=0,n=s,s=a,i=0):s=o,(0|(o=(0|i)<(0|(o=(0|n)<(0|s)?n:s))?i:o))<=0||(r[e>>2]=s-o,r[A>>2]=n-o,r[t>>2]=i-o),0|(l=0)}function fe(e){var t,n,i=0,o=0,s=0,a=0,A=0;o=0|r[(t=(e|=0)+8|0)>>2],s=0|jt(.14285714285714285*+((3*(i=(0|r[e>>2])-o|0)|0)-(o=(0|r[(n=e+4|0)>>2])-o|0)|0)),r[e>>2]=s,i=0|jt(.14285714285714285*+((o<<1)+i|0)),r[n>>2]=i,r[t>>2]=0,o=i-s|0,(0|s)<0?(A=0-s|0,r[n>>2]=o,r[t>>2]=A,r[e>>2]=0,i=o,s=0,o=A):o=0,(0|i)<0&&(s=s-i|0,r[e>>2]=s,o=o-i|0,r[t>>2]=o,r[n>>2]=0,i=0),A=s-o|0,a=i-o|0,(0|o)<0?(r[e>>2]=A,r[n>>2]=a,r[t>>2]=0,i=a,a=A,o=0):a=s,(0|(s=(0|o)<(0|(s=(0|i)<(0|a)?i:a))?o:s))<=0||(r[e>>2]=a-s,r[n>>2]=i-s,r[t>>2]=o-s)}function he(e){var t,n,i=0,o=0,s=0,a=0,A=0;o=0|r[(t=(e|=0)+8|0)>>2],s=0|jt(.14285714285714285*+(((i=(0|r[e>>2])-o|0)<<1)+(o=(0|r[(n=e+4|0)>>2])-o|0)|0)),r[e>>2]=s,i=0|jt(.14285714285714285*+((3*o|0)-i|0)),r[n>>2]=i,r[t>>2]=0,o=i-s|0,(0|s)<0?(A=0-s|0,r[n>>2]=o,r[t>>2]=A,r[e>>2]=0,i=o,s=0,o=A):o=0,(0|i)<0&&(s=s-i|0,r[e>>2]=s,o=o-i|0,r[t>>2]=o,r[n>>2]=0,i=0),A=s-o|0,a=i-o|0,(0|o)<0?(r[e>>2]=A,r[n>>2]=a,r[t>>2]=0,i=a,a=A,o=0):a=s,(0|(s=(0|o)<(0|(s=(0|i)<(0|a)?i:a))?o:s))<=0||(r[e>>2]=a-s,r[n>>2]=i-s,r[t>>2]=o-s)}function de(e){var t,n,i,o=0,s=0,a=0,A=0;o=0|r[(e|=0)>>2],s=0|r[(n=e+4|0)>>2],a=0|r[(i=e+8|0)>>2],A=s+(3*o|0)|0,r[e>>2]=A,s=a+(3*s|0)|0,r[n>>2]=s,o=(3*a|0)+o|0,r[i>>2]=o,a=s-A|0,(0|A)<0?(o=o-A|0,r[n>>2]=a,r[i>>2]=o,r[e>>2]=0,s=a,a=0):a=A,(0|s)<0&&(a=a-s|0,r[e>>2]=a,o=o-s|0,r[i>>2]=o,r[n>>2]=0,s=0),t=a-o|0,A=s-o|0,(0|o)<0?(r[e>>2]=t,r[n>>2]=A,r[i>>2]=0,a=t,o=0):A=s,(0|(s=(0|o)<(0|(s=(0|A)<(0|a)?A:a))?o:s))<=0||(r[e>>2]=a-s,r[n>>2]=A-s,r[i>>2]=o-s)}function pe(e){var t,n,i,o=0,s=0,a=0,A=0;A=0|r[(e|=0)>>2],a=(3*(o=0|r[(n=e+4|0)>>2])|0)+A|0,A=(s=0|r[(i=e+8|0)>>2])+(3*A|0)|0,r[e>>2]=A,r[n>>2]=a,o=(3*s|0)+o|0,r[i>>2]=o,s=a-A|0,(0|A)<0?(o=o-A|0,r[n>>2]=s,r[i>>2]=o,r[e>>2]=0,A=0):s=a,(0|s)<0&&(A=A-s|0,r[e>>2]=A,o=o-s|0,r[i>>2]=o,r[n>>2]=0,s=0),t=A-o|0,a=s-o|0,(0|o)<0?(r[e>>2]=t,r[n>>2]=a,r[i>>2]=0,A=t,o=0):a=s,(0|(s=(0|o)<(0|(s=(0|a)<(0|A)?a:A))?o:s))<=0||(r[e>>2]=A-s,r[n>>2]=a-s,r[i>>2]=o-s)}function ge(e,t){e|=0;var n,i,o,s=0,a=0,A=0;((t|=0)+-1|0)>>>0>=6||(A=(0|r[15440+(12*t|0)>>2])+(0|r[e>>2])|0,r[e>>2]=A,o=e+4|0,a=(0|r[15440+(12*t|0)+4>>2])+(0|r[o>>2])|0,r[o>>2]=a,i=e+8|0,t=(0|r[15440+(12*t|0)+8>>2])+(0|r[i>>2])|0,r[i>>2]=t,s=a-A|0,(0|A)<0?(t=t-A|0,r[o>>2]=s,r[i>>2]=t,r[e>>2]=0,a=0):(s=a,a=A),(0|s)<0&&(a=a-s|0,r[e>>2]=a,t=t-s|0,r[i>>2]=t,r[o>>2]=0,s=0),n=a-t|0,A=s-t|0,(0|t)<0?(r[e>>2]=n,r[o>>2]=A,r[i>>2]=0,a=n,t=0):A=s,(0|(s=(0|t)<(0|(s=(0|A)<(0|a)?A:a))?t:s))<=0||(r[e>>2]=a-s,r[o>>2]=A-s,r[i>>2]=t-s))}function me(e){var t,n,i,o=0,s=0,a=0,A=0;A=0|r[(e|=0)>>2],a=(o=0|r[(n=e+4|0)>>2])+A|0,A=(s=0|r[(i=e+8|0)>>2])+A|0,r[e>>2]=A,r[n>>2]=a,o=s+o|0,r[i>>2]=o,s=a-A|0,(0|A)<0?(o=o-A|0,r[n>>2]=s,r[i>>2]=o,r[e>>2]=0,a=0):(s=a,a=A),(0|s)<0&&(a=a-s|0,r[e>>2]=a,o=o-s|0,r[i>>2]=o,r[n>>2]=0,s=0),t=a-o|0,A=s-o|0,(0|o)<0?(r[e>>2]=t,r[n>>2]=A,r[i>>2]=0,a=t,o=0):A=s,(0|(s=(0|o)<(0|(s=(0|A)<(0|a)?A:a))?o:s))<=0||(r[e>>2]=a-s,r[n>>2]=A-s,r[i>>2]=o-s)}function be(e){var t,n,i,o=0,s=0,a=0,A=0;o=0|r[(e|=0)>>2],a=0|r[(n=e+4|0)>>2],s=0|r[(i=e+8|0)>>2],A=a+o|0,r[e>>2]=A,a=s+a|0,r[n>>2]=a,o=s+o|0,r[i>>2]=o,s=a-A|0,(0|A)<0?(o=o-A|0,r[n>>2]=s,r[i>>2]=o,r[e>>2]=0,a=0):(s=a,a=A),(0|s)<0&&(a=a-s|0,r[e>>2]=a,o=o-s|0,r[i>>2]=o,r[n>>2]=0,s=0),t=a-o|0,A=s-o|0,(0|o)<0?(r[e>>2]=t,r[n>>2]=A,r[i>>2]=0,a=t,o=0):A=s,(0|(s=(0|o)<(0|(s=(0|A)<(0|a)?A:a))?o:s))<=0||(r[e>>2]=a-s,r[n>>2]=A-s,r[i>>2]=o-s)}function ye(e){switch(0|(e|=0)){case 1:e=5;break;case 5:e=4;break;case 4:e=6;break;case 6:e=2;break;case 2:e=3;break;case 3:e=1}return 0|e}function ve(e){switch(0|(e|=0)){case 1:e=3;break;case 3:e=2;break;case 2:e=6;break;case 6:e=4;break;case 4:e=5;break;case 5:e=1}return 0|e}function _e(e){var t,n,i,o=0,s=0,a=0,A=0;o=0|r[(e|=0)>>2],s=0|r[(n=e+4|0)>>2],a=0|r[(i=e+8|0)>>2],A=s+(o<<1)|0,r[e>>2]=A,s=a+(s<<1)|0,r[n>>2]=s,o=(a<<1)+o|0,r[i>>2]=o,a=s-A|0,(0|A)<0?(o=o-A|0,r[n>>2]=a,r[i>>2]=o,r[e>>2]=0,s=a,a=0):a=A,(0|s)<0&&(a=a-s|0,r[e>>2]=a,o=o-s|0,r[i>>2]=o,r[n>>2]=0,s=0),t=a-o|0,A=s-o|0,(0|o)<0?(r[e>>2]=t,r[n>>2]=A,r[i>>2]=0,a=t,o=0):A=s,(0|(s=(0|o)<(0|(s=(0|A)<(0|a)?A:a))?o:s))<=0||(r[e>>2]=a-s,r[n>>2]=A-s,r[i>>2]=o-s)}function Ce(e){var t,n,i,o=0,s=0,a=0,A=0;A=0|r[(e|=0)>>2],a=((o=0|r[(n=e+4|0)>>2])<<1)+A|0,A=(s=0|r[(i=e+8|0)>>2])+(A<<1)|0,r[e>>2]=A,r[n>>2]=a,o=(s<<1)+o|0,r[i>>2]=o,s=a-A|0,(0|A)<0?(o=o-A|0,r[n>>2]=s,r[i>>2]=o,r[e>>2]=0,A=0):s=a,(0|s)<0&&(A=A-s|0,r[e>>2]=A,o=o-s|0,r[i>>2]=o,r[n>>2]=0,s=0),t=A-o|0,a=s-o|0,(0|o)<0?(r[e>>2]=t,r[n>>2]=a,r[i>>2]=0,A=t,o=0):a=s,(0|(s=(0|o)<(0|(s=(0|a)<(0|A)?a:A))?o:s))<=0||(r[e>>2]=A-s,r[n>>2]=a-s,r[i>>2]=o-s)}function xe(e,t){t|=0;var n,i,o,s=0,a=0,A=0;return o=(0|(i=(0|r[(e|=0)>>2])-(0|r[t>>2])|0))<0,n=(0|(a=(0|r[e+4>>2])-(0|r[t+4>>2])-(o?i:0)|0))<0,t=(t=(e=(0|(A=(o?0-i|0:0)+(0|r[e+8>>2])-(0|r[t+8>>2])+(n?0-a|0:0)|0))<0)?0:A)-((a=(0|(e=(0|t)<(0|(e=(0|(s=(n?0:a)-(e?A:0)|0))<(0|(A=(o?0:i)-(n?a:0)-(e?A:0)|0))?s:A))?t:e))>0)?e:0)|0,s=s-(a?e:0)|0,0|((0|(e=(0|(e=A-(a?e:0)|0))>-1?e:0-e|0))>(0|(t=(0|(s=(0|s)>-1?s:0-s|0))>(0|(t=(0|t)>-1?t:0-t|0))?s:t))?e:t)}function we(e){var t,n,i,o;n=(o=0|r[(t=(e|=0)+8|0)>>2])-(0|r[e>>2])|0,r[e>>2]=n,e=(0|r[(i=e+4|0)>>2])-o|0,r[i>>2]=e,r[t>>2]=0-(e+n)}function Be(e){var t,n,i=0,o=0,s=0,a=0,A=0;i=0-(o=0|r[(e|=0)>>2])|0,r[e>>2]=i,r[(t=e+8|0)>>2]=0,a=(s=0|r[(n=e+4|0)>>2])+o|0,(0|o)>0?(r[n>>2]=a,r[t>>2]=o,r[e>>2]=0,i=0,s=a):o=0,(0|s)<0?(A=i-s|0,r[e>>2]=A,o=o-s|0,r[t>>2]=o,r[n>>2]=0,a=A-o|0,i=0-o|0,(0|o)<0?(r[e>>2]=a,r[n>>2]=i,r[t>>2]=0,s=i,o=0):(s=0,a=A)):a=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(r[e>>2]=a-i,r[n>>2]=s-i,r[t>>2]=o-i)}function Me(e,t){var n=0;switch(n=0|rn(0|(e|=0),0|(t|=0),56),B(),7&n){case 0:case 7:return 0|(n=0)}return n=-2130706433&t|134217728,!0&268435456==(2013265920&t)?!0&16777216==(117440512&t)&!!(0|ze(e,n))?0|(n=0):0|(n=0|Ne(e,n)):0|(n=0)}function Se(e,t,n){n|=0;var i,o,s=0,a=0;return o=L,L=L+16|0,i=o,a=-2130706433&(t|=0)|134217728,!0&268435456==(2013265920&t)?(s=0|rn(0|(e|=0),0|t,56),B(),s=0|function(e,t,n){e|=0,t|=0,n|=0;var i=0,o=0,s=0;if(s=L,L=L+16|0,o=s,i=0|ze(e,t),(n+-1|0)>>>0>5)return L=s,0|(o=-1);if(i=!!(0|i),1==(0|n)&i)return L=s,0|(o=-1);do{if(!(0|Ft(e,t,o))){if(i){i=(5+(0|r[26352+(n<<2)>>2])-(0|r[o>>2])|0)%5|0;break}i=(6+(0|r[26384+(n<<2)>>2])-(0|r[o>>2])|0)%6|0;break}i=-1}while(0);return o=i,L=s,0|o}(e,a,7&s),-1==(0|s)?(r[n>>2]=0,L=o,0|(a=6)):(0|Ze(e,a,i)&&M(27795,26932,282,26947),t=0|rn(0|e,0|t,52),B(),t&=15,0|ze(e,a)?Pe(i,t,s,2,n):Fe(i,t,s,2,n),L=o,0|(a=0))):(L=o,0|(a=6))}function Te(e,t,n){var i,s;i=L,L=L+16|0,function(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var s=0,a=0,A=0,l=0,c=0;if(l=L,L=L+16|0,function(e,t,n){e|=0,t|=0,n|=0;var i=0,s=0,a=0;a=L,L=L+32|0,function(e,t){e|=0,t|=0;var n=0,i=0,r=0;n=+o[e>>3],i=+f(+n),n=+h(+n),o[t+16>>3]=n,n=+o[e+8>>3],r=i*+f(+n),o[t>>3]=r,n=i*+h(+n),o[t+8>>3]=n}(e,s=a),r[t>>2]=0,o[n>>3]=5,(i=+Rt(16400,s))<+o[n>>3]&&(r[t>>2]=0,o[n>>3]=i);(i=+Rt(16424,s))<+o[n>>3]&&(r[t>>2]=1,o[n>>3]=i);(i=+Rt(16448,s))<+o[n>>3]&&(r[t>>2]=2,o[n>>3]=i);(i=+Rt(16472,s))<+o[n>>3]&&(r[t>>2]=3,o[n>>3]=i);(i=+Rt(16496,s))<+o[n>>3]&&(r[t>>2]=4,o[n>>3]=i);(i=+Rt(16520,s))<+o[n>>3]&&(r[t>>2]=5,o[n>>3]=i);(i=+Rt(16544,s))<+o[n>>3]&&(r[t>>2]=6,o[n>>3]=i);(i=+Rt(16568,s))<+o[n>>3]&&(r[t>>2]=7,o[n>>3]=i);(i=+Rt(16592,s))<+o[n>>3]&&(r[t>>2]=8,o[n>>3]=i);(i=+Rt(16616,s))<+o[n>>3]&&(r[t>>2]=9,o[n>>3]=i);(i=+Rt(16640,s))<+o[n>>3]&&(r[t>>2]=10,o[n>>3]=i);(i=+Rt(16664,s))<+o[n>>3]&&(r[t>>2]=11,o[n>>3]=i);(i=+Rt(16688,s))<+o[n>>3]&&(r[t>>2]=12,o[n>>3]=i);(i=+Rt(16712,s))<+o[n>>3]&&(r[t>>2]=13,o[n>>3]=i);(i=+Rt(16736,s))<+o[n>>3]&&(r[t>>2]=14,o[n>>3]=i);(i=+Rt(16760,s))<+o[n>>3]&&(r[t>>2]=15,o[n>>3]=i);(i=+Rt(16784,s))<+o[n>>3]&&(r[t>>2]=16,o[n>>3]=i);(i=+Rt(16808,s))<+o[n>>3]&&(r[t>>2]=17,o[n>>3]=i);(i=+Rt(16832,s))<+o[n>>3]&&(r[t>>2]=18,o[n>>3]=i);if(!((i=+Rt(16856,s))<+o[n>>3]))return void(L=a);r[t>>2]=19,o[n>>3]=i,L=a}(e,n,c=l),(a=+p(+(1-.5*+o[c>>3])))<1e-16)return r[i>>2]=0,r[i+4>>2]=0,r[i+8>>2]=0,r[i+12>>2]=0,void(L=l);c=0|r[n>>2],s=+ot((s=+o[15920+(24*c|0)>>3])-+ot(+function(e,t){e|=0,t|=0;var n=0,i=0,r=0,s=0,a=0;return s=+o[t>>3],i=+f(+s),r=+o[t+8>>3]-+o[e+8>>3],a=i*+h(+r),n=+o[e>>3],+ +b(+a,+(+h(+s)*+f(+n)-+f(+r)*(i*+h(+n))))}(15600+(c<<4)|0,e))),A=0|qe(t)?+ot(s+-.3334731722518321):s;if(s=2.618033988749896*+d(+a),(0|t)>0){e=0;do{s*=2.6457513110645907,e=e+1|0}while((0|e)!=(0|t))}a=+f(+A)*s,o[i>>3]=a,A=+h(+A)*s,o[i+8>>3]=A,L=l}(e|=0,t|=0,n|=0,s=i),function(e,t){e|=0;var n,i,s,a,A=0,c=0,u=0,f=0,h=0,d=0,p=0;r[(a=8+(t|=0)|0)>>2]=0,i=+o[e>>3],f=+l(+i),s=+o[e+8>>3],f+=.5*(h=1.1547005383792515*+l(+s)),f-=+(0|(A=~~f)),h-=+(0|(e=~~h));do{if(f<.5){if(f<.3333333333333333){if(r[t>>2]=A,h<.5*(f+1)){r[t+4>>2]=e;break}e=e+1|0,r[t+4>>2]=e;break}if(e=(1&!(h<(p=1-f)))+e|0,r[t+4>>2]=e,p<=h&h<2*f){A=A+1|0,r[t>>2]=A;break}r[t>>2]=A;break}if(!(f<.6666666666666666)){if(A=A+1|0,r[t>>2]=A,h<.5*f){r[t+4>>2]=e;break}e=e+1|0,r[t+4>>2]=e;break}if(h<1-f){if(r[t+4>>2]=e,2*f-1<h){r[t>>2]=A;break}}else e=e+1|0,r[t+4>>2]=e;A=A+1|0,r[t>>2]=A}while(0);do{if(i<0){if(1&e){A=~~(+(0|A)-(2*(+((d=0|qt(0|A,((0|A)<0)<<31>>31,0|(d=(e+1|0)/2|0),((0|d)<0)<<31>>31))>>>0)+4294967296*+(0|B()))+1)),r[t>>2]=A;break}A=~~(+(0|A)-2*(+((d=0|qt(0|A,((0|A)<0)<<31>>31,0|(d=(0|e)/2|0),((0|d)<0)<<31>>31))>>>0)+4294967296*+(0|B()))),r[t>>2]=A;break}}while(0);d=t+4|0,s<0&&(A=A-((1|e<<1)/2|0)|0,r[t>>2]=A,e=0-e|0,r[d>>2]=e),c=e-A|0,(0|A)<0?(u=0-A|0,r[d>>2]=c,r[a>>2]=u,r[t>>2]=0,e=c,A=0):u=0,(0|e)<0&&(A=A-e|0,r[t>>2]=A,u=u-e|0,r[a>>2]=u,r[d>>2]=0,e=0),n=A-u|0,c=e-u|0,(0|u)<0&&(r[t>>2]=n,r[d>>2]=c,r[a>>2]=0,e=c,A=n,u=0),(0|(c=(0|u)<(0|(c=(0|e)<(0|A)?e:A))?u:c))<=0||(r[t>>2]=A-c,r[d>>2]=e-c,r[a>>2]=u-c)}(s,n+4|0),L=i}function Ee(e,t,n,i,s){t|=0,n|=0,i|=0,s|=0;var a,A=0,u=0;if(A=+function(e){e|=0;var t=0,n=0;return n=+o[e>>3],t=+o[e+8>>3],+ +c(+(n*n+t*t))}(e|=0),A<1e-16)return t=15600+(t<<4)|0,r[s>>2]=r[t>>2],r[s+4>>2]=r[t+4>>2],r[s+8>>2]=r[t+8>>2],void(r[s+12>>2]=r[t+12>>2]);if(u=+b(+ +o[e+8>>3],+ +o[e>>3]),(0|n)>0){e=0;do{A*=.37796447300922725,e=e+1|0}while((0|e)!=(0|n))}a=.3333333333333333*A,i?(n=!(0|qe(n)),A=+m(.381966011250105*(n?a:.37796447300922725*a))):(A=+m(.381966011250105*A),0|qe(n)&&(u=+ot(u+.3334731722518321))),function(e,t,n,i){e|=0,t=+t,n=+n,i|=0;var s=0,a=0,A=0,c=0;if(n<1e-16)return r[i>>2]=r[e>>2],r[i+4>>2]=r[e+4>>2],r[i+8>>2]=r[e+8>>2],void(r[i+12>>2]=r[e+12>>2]);a=t<0?t+6.283185307179586:t,a=t>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(s=+l(+(a+-3.141592653589793))<1e-16,t=+o[e>>3],s){t-=n,o[i>>3]=t,s=i;break}if(A=+f(+n),n=+h(+n),t=A*+h(+t)+ +f(+a)*(n*+f(+t)),t=+g(+((t=t>1?1:t)<-1?-1:t)),o[i>>3]=t,+l(+(t+-1.5707963267948966))<1e-16)return o[i>>3]=1.5707963267948966,void(o[i+8>>3]=0);if(+l(+(t+1.5707963267948966))<1e-16)return o[i>>3]=-1.5707963267948966,void(o[i+8>>3]=0);if(c=1/+f(+t),a=n*+h(+a)*c,n=+o[e>>3],t=c*((A-+h(+t)*+h(+n))/+f(+n)),A=a>1?1:a,t=t>1?1:t,(t=+o[e+8>>3]+ +b(+(A<-1?-1:A),+(t<-1?-1:t)))>3.141592653589793)do{t+=-6.283185307179586}while(t>3.141592653589793);if(t<-3.141592653589793)do{t+=6.283185307179586}while(t<-3.141592653589793);return void(o[i+8>>3]=t)}t=+o[e>>3]+n,o[i>>3]=t,s=i}while(0);if(+l(+(t+-1.5707963267948966))<1e-16)return o[s>>3]=1.5707963267948966,void(o[i+8>>3]=0);if(+l(+(t+1.5707963267948966))<1e-16)return o[s>>3]=-1.5707963267948966,void(o[i+8>>3]=0);if(t=+o[e+8>>3],t>3.141592653589793)do{t+=-6.283185307179586}while(t>3.141592653589793);if(t<-3.141592653589793)do{t+=6.283185307179586}while(t<-3.141592653589793);o[i+8>>3]=t}(15600+(t<<4)|0,+ot(+o[15920+(24*t|0)>>3]-u),A,s)}function Pe(e,t,n,i,s){e|=0,t|=0,n|=0,i|=0,s|=0;var a,A,l,c,u,f,h,d,p,g,m,b,y,v,_,C,x,w,B,S,T,E,P=0,I=0,R=0,F=0,O=0,D=0;if(E=L,L=L+272|0,F=E+240|0,B=E,S=E+224|0,T=E+208|0,m=E+176|0,b=E+160|0,y=E+192|0,v=E+144|0,_=E+128|0,C=E+112|0,x=E+96|0,w=E+80|0,r[(P=E+256|0)>>2]=t,r[F>>2]=r[e>>2],r[F+4>>2]=r[e+4>>2],r[F+8>>2]=r[e+8>>2],r[F+12>>2]=r[e+12>>2],Ie(F,P,B),r[s>>2]=0,(0|(F=i+n+(5==(0|i)&1)|0))<=(0|n))L=E;else{A=S+4|0,l=m+4|0,c=n+5|0,u=16880+((a=0|r[P>>2])<<2)|0,f=16960+(a<<2)|0,h=_+8|0,d=C+8|0,p=x+8|0,g=T+4|0,R=n;e:for(;;){I=B+((0|R)%5<<4)|0,r[T>>2]=r[I>>2],r[T+4>>2]=r[I+4>>2],r[T+8>>2]=r[I+8>>2],r[T+12>>2]=r[I+12>>2];do{}while(2==(0|Le(T,a,0,1)));if((0|R)>(0|n)&!!(0|qe(t))){if(r[m>>2]=r[T>>2],r[m+4>>2]=r[T+4>>2],r[m+8>>2]=r[T+8>>2],r[m+12>>2]=r[T+12>>2],oe(A,b),i=0|r[m>>2],P=0|r[17040+(80*i|0)+(r[S>>2]<<2)>>2],r[m>>2]=r[18640+(80*i|0)+(20*P|0)>>2],(0|(I=0|r[18640+(80*i|0)+(20*P|0)+16>>2]))>0){e=0;do{me(l),e=e+1|0}while((0|e)<(0|I))}switch(I=18640+(80*i|0)+(20*P|0)+4|0,r[y>>2]=r[I>>2],r[y+4>>2]=r[I+4>>2],r[y+8>>2]=r[I+8>>2],Ae(y,3*(0|r[u>>2])|0),se(l,y,l),re(l),oe(l,v),O=+(0|r[f>>2]),o[_>>3]=3*O,o[h>>3]=0,D=-1.5*O,o[C>>3]=D,o[d>>3]=2.598076211353316*O,o[x>>3]=D,o[p>>3]=-2.598076211353316*O,0|r[17040+(80*(0|r[m>>2])|0)+(r[T>>2]<<2)>>2]){case 1:e=C,i=_;break;case 3:e=x,i=C;break;case 2:e=_,i=x;break;default:e=12;break e}It(b,v,i,e,w),Ee(w,0|r[m>>2],a,1,s+8+(r[s>>2]<<4)|0),r[s>>2]=1+(0|r[s>>2])}if((0|R)<(0|c)&&(oe(g,m),Ee(m,0|r[T>>2],a,1,s+8+(r[s>>2]<<4)|0),r[s>>2]=1+(0|r[s>>2])),r[S>>2]=r[T>>2],r[S+4>>2]=r[T+4>>2],r[S+8>>2]=r[T+8>>2],r[S+12>>2]=r[T+12>>2],(0|(R=R+1|0))>=(0|F)){e=3;break}}3!=(0|e)?12==(0|e)&&M(26970,27017,572,27027):L=E}}function Ie(e,t,n){e|=0,t|=0,n|=0;var i,o=0,s=0,a=0,A=0,l=0;i=L,L=L+128|0,s=i,A=20240,l=(a=o=i+64|0)+60|0;do{r[a>>2]=r[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));A=20304,l=(a=s)+60|0;do{r[a>>2]=r[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));o=(l=!(0|qe(0|r[t>>2])))?o:s,_e(s=e+4|0),Ce(s),0|qe(0|r[t>>2])&&(pe(s),r[t>>2]=1+(0|r[t>>2])),r[n>>2]=r[e>>2],se(s,o,t=n+4|0),re(t),r[n+16>>2]=r[e>>2],se(s,o+12|0,t=n+20|0),re(t),r[n+32>>2]=r[e>>2],se(s,o+24|0,t=n+36|0),re(t),r[n+48>>2]=r[e>>2],se(s,o+36|0,t=n+52|0),re(t),r[n+64>>2]=r[e>>2],se(s,o+48|0,n=n+68|0),re(n),L=i}function Le(e,t,n,i){n|=0,i|=0;var o,s,a,A,l,c,u=0,f=0,h=0,d=0,p=0;if(c=L,L=L+32|0,l=c+12|0,s=c,p=(e|=0)+4|0,d=0|r[16960+((t|=0)<<2)>>2],d=(A=!!(0|i))?3*d|0:d,u=0|r[p>>2],o=0|r[(a=e+8|0)>>2],A){if((0|(u=o+u+(i=0|r[(f=e+12|0)>>2])|0))==(0|d))return L=c,0|(p=1);h=f}else u=o+u+(i=0|r[(h=e+12|0)>>2])|0;if((0|u)<=(0|d))return L=c,0|(p=0);do{if((0|i)>0){if(i=0|r[e>>2],(0|o)>0){f=18640+(80*i|0)+60|0,i=e;break}i=18640+(80*i|0)+40|0,n?(ie(l,d,0,0),ae(p,l,s),be(s),se(s,l,p),f=i,i=e):(f=i,i=e)}else f=18640+(80*(0|r[e>>2])|0)+20|0,i=e}while(0);if(r[i>>2]=r[f>>2],(0|r[(u=f+16|0)>>2])>0){i=0;do{me(p),i=i+1|0}while((0|i)<(0|r[u>>2]))}return e=f+4|0,r[l>>2]=r[e>>2],r[l+4>>2]=r[e+4>>2],r[l+8>>2]=r[e+8>>2],t=0|r[16880+(t<<2)>>2],Ae(l,A?3*t|0:t),se(p,l,p),re(p),i=A&&((0|r[a>>2])+(0|r[p>>2])+(0|r[h>>2])|0)==(0|d)?1:2,L=c,0|(p=i)}function Re(e,t){e|=0,t|=0;var n=0;do{n=0|Le(e,t,0,1)}while(2==(0|n));return 0|n}function Fe(e,t,n,i,s){e|=0,t|=0,n|=0,i|=0,s|=0;var a,A,l,c,u,f,h,d,p,g,m,b,y,v,_,C,x,w,B=0,S=0,T=0,E=0,P=0;if(w=L,L=L+240|0,v=w+208|0,_=w,C=w+192|0,x=w+176|0,p=w+160|0,g=w+144|0,m=w+128|0,b=w+112|0,y=w+96|0,r[(B=w+224|0)>>2]=t,r[v>>2]=r[e>>2],r[v+4>>2]=r[e+4>>2],r[v+8>>2]=r[e+8>>2],r[v+12>>2]=r[e+12>>2],Oe(v,B,_),r[s>>2]=0,(0|(d=i+n+(6==(0|i)&1)|0))<=(0|n))L=w;else{A=n+6|0,l=16960+((a=0|r[B>>2])<<2)|0,c=g+8|0,u=m+8|0,f=b+8|0,h=C+4|0,S=0,T=n,i=-1;e:for(;;){if(e=_+((B=(0|T)%6|0)<<4)|0,r[C>>2]=r[e>>2],r[C+4>>2]=r[e+4>>2],r[C+8>>2]=r[e+8>>2],r[C+12>>2]=r[e+12>>2],e=S,S=0|Le(C,a,0,1),(0|T)>(0|n)&!!(0|qe(t))&&(1!=(0|e)&&(0|r[C>>2])!=(0|i))){switch(oe(_+((B+5|0)%6<<4)+4|0,x),oe(_+(B<<4)+4|0,p),E=+(0|r[l>>2]),o[g>>3]=3*E,o[c>>3]=0,P=-1.5*E,o[m>>3]=P,o[u>>3]=2.598076211353316*E,o[b>>3]=P,o[f>>3]=-2.598076211353316*E,B=0|r[v>>2],0|r[17040+(80*B|0)+(((0|i)==(0|B)?r[C>>2]:i)<<2)>>2]){case 1:e=m,i=g;break;case 3:e=b,i=m;break;case 2:e=g,i=b;break;default:e=8;break e}It(x,p,i,e,y),0|Lt(x,y)||0|Lt(p,y)||(Ee(y,0|r[v>>2],a,1,s+8+(r[s>>2]<<4)|0),r[s>>2]=1+(0|r[s>>2]))}if((0|T)<(0|A)&&(oe(h,x),Ee(x,0|r[C>>2],a,1,s+8+(r[s>>2]<<4)|0),r[s>>2]=1+(0|r[s>>2])),(0|(T=T+1|0))>=(0|d)){e=3;break}i=0|r[C>>2]}3!=(0|e)?8==(0|e)&&M(27054,27017,737,27099):L=w}}function Oe(e,t,n){e|=0,t|=0,n|=0;var i,o=0,s=0,a=0,A=0,l=0;i=L,L=L+160|0,s=i,A=20368,l=(a=o=i+80|0)+72|0;do{r[a>>2]=r[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));A=20448,l=(a=s)+72|0;do{r[a>>2]=r[A>>2],a=a+4|0,A=A+4|0}while((0|a)<(0|l));o=(l=!(0|qe(0|r[t>>2])))?o:s,_e(s=e+4|0),Ce(s),0|qe(0|r[t>>2])&&(pe(s),r[t>>2]=1+(0|r[t>>2])),r[n>>2]=r[e>>2],se(s,o,t=n+4|0),re(t),r[n+16>>2]=r[e>>2],se(s,o+12|0,t=n+20|0),re(t),r[n+32>>2]=r[e>>2],se(s,o+24|0,t=n+36|0),re(t),r[n+48>>2]=r[e>>2],se(s,o+36|0,t=n+52|0),re(t),r[n+64>>2]=r[e>>2],se(s,o+48|0,t=n+68|0),re(t),r[n+80>>2]=r[e>>2],se(s,o+60|0,n=n+84|0),re(n),L=i}function De(e,t){return t=0|rn(0|(e|=0),0|(t|=0),45),B(),127&t}function Ne(e,t){e|=0;var n=0,r=0,o=0,s=0;return!0&134217728==(-16777216&(t|=0))?(r=0|rn(0|e,0|t,52),B(),r&=15,n=0|rn(0|e,0|t,45),B(),(n&=127)>>>0>121?0|(e=0):!(613566756&(s=0|on(0|(o=0|rn(0|e,0|t,0|(s=3*(15^r)|0))),0|B(),0|s))&(0|qt(-1227133514,-1171,0|s,0|(o=0|B()))))&!(4681&o&B())&&15==(0|r)|!(0|(s=0|rn(0|(0|on(0|~e,0|~t,0|(s=19+(3*r|0)|0))),0|B(),0|s)))&!(0|B())?0|i[20528+n|0]?!(0|e)&!(0|(t&=8191))?0|(s=1):(s=0|sn(0|e,0|t),B(),0|!!((63-s|0)%3|0)):0|(s=1):0|(s=0)):0|(e=0)}function Ue(e,t,n,i){e|=0,n|=0,i|=0;var o=0,s=0,a=0,A=0;if(o=0|on(0|(t|=0),0,52),s=0|B(),n=0|on(0|n,0,45),n=0|s|B()|134225919,(0|t)<1)return s=-1,i=n,r[(t=e)>>2]=s,void(r[(e=e+4|0)>>2]=i);for(s=1,o=-1;A=0|on(7,0,0|(a=3*(15-s|0)|0)),n&=~B(),o=o&~A|(a=0|on(0|i,0,0|a)),n=0|n|B(),(0|s)!=(0|t);)s=s+1|0;r[(a=A=e)>>2]=o,r[(A=A+4|0)>>2]=n}function ke(e,t,n,i){n|=0,i|=0;var o=0,s=0;if(s=0|rn(0|(e|=0),0|(t|=0),52),B(),n>>>0>15)return 0|(i=4);if((0|(s&=15))<(0|n))return 0|(i=12);if((0|s)==(0|n))return r[i>>2]=e,r[i+4>>2]=t,0|(i=0);if(o=0|on(0|n,0,52),o|=e,e=B()|-15728641&t,(0|s)>(0|n))do{t=0|on(7,0,3*(14-n|0)|0),n=n+1|0,o|=t,e=0|B()|e}while((0|n)<(0|s));return r[i>>2]=o,r[i+4>>2]=e,0|(i=0)}function Ge(e,t,n,i){n|=0,i|=0;var o=0,s=0,a=0;if(s=0|rn(0|(e|=0),0|(t|=0),52),B(),!((0|n)<16&(0|(s&=15))<=(0|n)))return 0|(i=4);o=n-s|0,n=0|rn(0|e,0|t,45),B();e:do{if(0|z(127&n)){t:do{if(0|s){for(n=1;!((a=0|on(7,0,3*(15-n|0)|0))&e|0)&!((0|B())&t);){if(!(n>>>0<s>>>0))break t;n=n+1|0}n=0|yt(7,0,o,((0|o)<0)<<31>>31),o=0|B();break e}}while(0);n=0|Wt(0|(n=0|$t(0|(n=0|yt(7,0,o,((0|o)<0)<<31>>31)),0|B(),5,0)),0|B(),-5,-1),n=0|Wt(0|(n=0|Zt(0|n,0|B(),6,0)),0|B(),1,0),o=0|B()}else n=0|yt(7,0,o,((0|o)<0)<<31>>31),o=0|B()}while(0);return r[(a=i)>>2]=n,r[a+4>>2]=o,0|(a=0)}function ze(e,t){var n=0,i=0,r=0;if(r=0|rn(0|(e|=0),0|(t|=0),45),B(),!(0|z(127&r)))return 0|(r=0);r=0|rn(0|e,0|t,52),B(),r&=15;e:do{if(r)for(i=1;;){if(n=0|rn(0|e,0|t,3*(15-i|0)|0),B(),0|(n&=7))break e;if(!(i>>>0<r>>>0)){n=0;break}i=i+1|0}else n=0}while(0);return 0|(r=1&!(0|n))}function Ve(e,t,n,i){return e|=0,t|=0,(0|(i|=0))<(0|(n|=0))?(i=e,w(0|(n=t)),0|i):(n=0|on(-1,-1,3+(3*(i-n|0)|0)|0),i=0|on(0|~n,0|~B(),3*(15-i|0)|0),n=~B()&t,i=~i&e,w(0|n),0|i)}function He(e,t,n,i){n|=0,i|=0;var o=0;return o=0|rn(0|(e|=0),0|(t|=0),52),B(),(0|n)<16&(0|(o&=15))<=(0|n)?((0|o)<(0|n)&&(o=0|on(-1,-1,3+(3*(n+-1-o|0)|0)|0),o=0|on(0|~o,0|~B(),3*(15-n|0)|0),t=~B()&t,e&=~o),o=0|on(0|n,0,52),n=-15728641&t|B(),r[i>>2]=e|o,r[i+4>>2]=n,0|(i=0)):0|(i=4)}function je(e,t){var n=0,i=0,r=0;if(r=0|rn(0|(e|=0),0|(t|=0),52),B(),!(r&=15))return 0|(r=0);for(i=1;;){if(n=0|rn(0|e,0|t,3*(15-i|0)|0),B(),0|(n&=7)){i=5;break}if(!(i>>>0<r>>>0)){n=0,i=5;break}i=i+1|0}return 5==(0|i)?0|n:0}function Qe(e,t){var n=0,i=0,r=0,o=0,s=0,a=0,A=0;if(A=0|rn(0|(e|=0),0|(t|=0),52),B(),!(A&=15))return A=e,w(0|(a=t)),0|A;for(a=1,n=0;;){i=0|on(7,0,0|(o=3*(15-a|0)|0)),r=0|B(),s=0|rn(0|e,0|t,0|o),B(),e=(o=0|on(0|ye(7&s),0,0|o))|e&~i,t=(s=0|B())|t&~r;e:do{if(!n)if(!(o&i|0)&!(s&r|0))n=0;else if(i=0|rn(0|e,0|t,52),B(),i&=15){n=1;t:for(;;){switch(s=0|rn(0|e,0|t,3*(15-n|0)|0),B(),7&s){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<i>>>0)){n=1;break e}n=n+1|0}for(n=1;;){if(r=0|rn(0|e,0|t,0|(s=3*(15-n|0)|0)),B(),o=0|on(7,0,0|s),t&=~B(),e=e&~o|(s=0|on(0|ye(7&r),0,0|s)),t=0|t|B(),!(n>>>0<i>>>0)){n=1;break}n=n+1|0}}else n=1}while(0);if(!(a>>>0<A>>>0))break;a=a+1|0}return w(0|t),0|e}function Je(e,t){var n=0,i=0,r=0,o=0,s=0;if(i=0|rn(0|(e|=0),0|(t|=0),52),B(),!(i&=15))return i=e,w(0|(n=t)),0|i;for(n=1;s=0|rn(0|e,0|t,0|(o=3*(15-n|0)|0)),B(),r=0|on(7,0,0|o),t&=~B(),e=(o=0|on(0|ye(7&s),0,0|o))|e&~r,t=0|B()|t,n>>>0<i>>>0;)n=n+1|0;return w(0|t),0|e}function Ke(e,t){var n=0,i=0,r=0,o=0,s=0,a=0,A=0;if(A=0|rn(0|(e|=0),0|(t|=0),52),B(),!(A&=15))return A=e,w(0|(a=t)),0|A;for(a=1,n=0;;){i=0|on(7,0,0|(o=3*(15-a|0)|0)),r=0|B(),s=0|rn(0|e,0|t,0|o),B(),e=(o=0|on(0|ve(7&s),0,0|o))|e&~i,t=(s=0|B())|t&~r;e:do{if(!n)if(!(o&i|0)&!(s&r|0))n=0;else if(i=0|rn(0|e,0|t,52),B(),i&=15){n=1;t:for(;;){switch(s=0|rn(0|e,0|t,3*(15-n|0)|0),B(),7&s){case 1:break t;case 0:break;default:n=1;break e}if(!(n>>>0<i>>>0)){n=1;break e}n=n+1|0}for(n=1;;){if(o=0|on(7,0,0|(r=3*(15-n|0)|0)),s=t&~B(),t=0|rn(0|e,0|t,0|r),B(),e=e&~o|(t=0|on(0|ve(7&t),0,0|r)),t=0|s|B(),!(n>>>0<i>>>0)){n=1;break}n=n+1|0}}else n=1}while(0);if(!(a>>>0<A>>>0))break;a=a+1|0}return w(0|t),0|e}function We(e,t){var n=0,i=0,r=0,o=0,s=0;if(i=0|rn(0|(e|=0),0|(t|=0),52),B(),!(i&=15))return i=e,w(0|(n=t)),0|i;for(n=1;o=0|on(7,0,0|(s=3*(15-n|0)|0)),r=t&~B(),t=0|rn(0|e,0|t,0|s),B(),e=(t=0|on(0|ve(7&t),0,0|s))|e&~o,t=0|B()|r,n>>>0<i>>>0;)n=n+1|0;return w(0|t),0|e}function qe(e){return(0|(e|=0))%2|0}function Ye(e,t,n){n|=0;var i,o=0;return i=L,L=L+16|0,o=i,(t|=0)>>>0>15?(L=i,0|(o=4)):2146435072&~r[(e|=0)+4>>2]&&2146435072&~r[e+8+4>>2]?(Te(e,t,o),t=0|function(e,t){e|=0;var n,i=0,o=0,s=0,a=0,A=0,l=0,c=0,u=0;if(n=L,L=L+64|0,l=n+40|0,o=n+24|0,s=n+12|0,a=n,on(0|(t|=0),0,52),i=134225919|B(),!t)return(0|r[e+4>>2])>2||(0|r[e+8>>2])>2||(0|r[e+12>>2])>2?(l=0,w(0|(A=0)),L=n,0|l):(on(0|H(e),0,45),A=0|B()|i,l=-1,w(0|A),L=n,0|l);if(r[l>>2]=r[e>>2],r[l+4>>2]=r[e+4>>2],r[l+8>>2]=r[e+8>>2],r[l+12>>2]=r[e+12>>2],A=l+4|0,(0|t)>0)for(e=-1;r[o>>2]=r[A>>2],r[o+4>>2]=r[A+4>>2],r[o+8>>2]=r[A+8>>2],1&t?(fe(A),r[s>>2]=r[A>>2],r[s+4>>2]=r[A+4>>2],r[s+8>>2]=r[A+8>>2],de(s)):(he(A),r[s>>2]=r[A>>2],r[s+4>>2]=r[A+4>>2],r[s+8>>2]=r[A+8>>2],pe(s)),ae(o,s,a),re(a),c=0|on(7,0,0|(u=3*(15-t|0)|0)),i&=~B(),e=(u=0|on(0|le(a),0,0|u))|e&~c,i=0|B()|i,(0|t)>1;)t=t+-1|0;else e=-1;e:do{if((0|r[A>>2])<=2&&(0|r[l+8>>2])<=2&&(0|r[l+12>>2])<=2){if(t=0|on(0|(o=0|H(l)),0,45),t|=e,e=B()|-1040385&i,a=0|j(l),!(0|z(o))){if((0|a)<=0)break;for(s=0;;){if(o=0|rn(0|t,0|e,52),B(),o&=15)for(i=1;l=0|rn(0|t,0|e,0|(u=3*(15-i|0)|0)),B(),c=0|on(7,0,0|u),e&=~B(),t=t&~c|(u=0|on(0|ye(7&l),0,0|u)),e=0|e|B(),i>>>0<o>>>0;)i=i+1|0;if((0|(s=s+1|0))==(0|a))break e}}s=0|rn(0|t,0|e,52),B(),s&=15;t:do{if(s){i=1;n:for(;;){switch(u=0|rn(0|t,0|e,3*(15-i|0)|0),B(),7&u){case 1:break n;case 0:break;default:break t}if(!(i>>>0<s>>>0))break t;i=i+1|0}if(0|Q(o,0|r[l>>2]))for(i=1;c=0|on(7,0,0|(l=3*(15-i|0)|0)),u=e&~B(),e=0|rn(0|t,0|e,0|l),B(),t=t&~c|(e=0|on(0|ve(7&e),0,0|l)),e=0|u|B(),i>>>0<s>>>0;)i=i+1|0;else for(i=1;l=0|rn(0|t,0|e,0|(u=3*(15-i|0)|0)),B(),c=0|on(7,0,0|u),e&=~B(),t=t&~c|(u=0|on(0|ye(7&l),0,0|u)),e=0|e|B(),i>>>0<s>>>0;)i=i+1|0}}while(0);if((0|a)>0){i=0;do{t=0|Qe(t,e),e=0|B(),i=i+1|0}while((0|i)!=(0|a))}}else t=0,e=0}while(0);return u=t,w(0|(c=e)),L=n,0|u}(o,t),o=0|B(),r[n>>2]=t,r[n+4>>2]=o,!(0|t)&!(0|o)&&M(27795,27122,1050,27145),L=i,0|(o=0)):(L=i,0|(o=3))}function Xe(e,t,n){var i,o=0,s=0,a=0;if(i=(n|=0)+4|0,s=0|rn(0|(e|=0),0|(t|=0),52),B(),s&=15,a=0|rn(0|e,0|t,45),B(),o=!(0|s),0|z(127&a)){if(o)return 0|(a=1);o=1}else{if(o)return 0|(a=0);o=0|r[i>>2]||0|r[n+8>>2]?1:1&!!(0|r[n+12>>2])}for(n=1;1&n?de(i):pe(i),a=0|rn(0|e,0|t,3*(15-n|0)|0),B(),ge(i,7&a),n>>>0<s>>>0;)n=n+1|0;return 0|o}function Ze(e,t,n){n|=0;var i,o,s=0,a=0,A=0,l=0,c=0,u=0;if(o=L,L=L+16|0,i=o,u=0|rn(0|(e|=0),0|(t|=0),45),B(),(u&=127)>>>0>121)return r[n>>2]=0,r[n+4>>2]=0,r[n+8>>2]=0,r[n+12>>2]=0,L=o,0|(u=5);e:do{if(0|z(u)&&(A=0|rn(0|e,0|t,52),B(),0|(A&=15))){s=1;t:for(;;){switch(c=0|rn(0|e,0|t,3*(15-s|0)|0),B(),7&c){case 5:break t;case 0:break;default:s=t;break e}if(!(s>>>0<A>>>0)){s=t;break e}s=s+1|0}for(a=1,s=t;l=0|on(7,0,0|(t=3*(15-a|0)|0)),c=s&~B(),s=0|rn(0|e,0|s,0|t),B(),e=e&~l|(s=0|on(0|ve(7&s),0,0|t)),s=0|c|B(),a>>>0<A>>>0;)a=a+1|0}else s=t}while(0);if(c=7696+(28*u|0)|0,r[n>>2]=r[c>>2],r[n+4>>2]=r[c+4>>2],r[n+8>>2]=r[c+8>>2],r[n+12>>2]=r[c+12>>2],!(0|Xe(e,s,n)))return L=o,0|(u=0);if(l=n+4|0,r[i>>2]=r[l>>2],r[i+4>>2]=r[l+4>>2],r[i+8>>2]=r[l+8>>2],A=0|rn(0|e,0|s,52),B(),c=15&A,1&A?(pe(l),A=c+1|0):A=c,0|z(u)){e:do{if(c)for(t=1;;){if(a=0|rn(0|e,0|s,3*(15-t|0)|0),B(),0|(a&=7)){s=a;break e}if(!(t>>>0<c>>>0)){s=0;break}t=t+1|0}else s=0}while(0);s=4==(0|s)&1}else s=0;if(0|Le(n,A,s,0)){if(0|z(u))do{}while(0|Le(n,A,0,0));(0|A)!=(0|c)&&he(l)}else(0|A)!=(0|c)&&(r[l>>2]=r[i>>2],r[l+4>>2]=r[i+4>>2],r[l+8>>2]=r[i+8>>2]);return L=o,0|(u=0)}function $e(e,t,n){n|=0;var i,o,s=0;return o=L,L=L+16|0,0|(s=0|Ze(e|=0,t|=0,i=o))?(L=o,0|s):(s=0|rn(0|e,0|t,52),B(),function(e,t,n){var i,o;t|=0,n|=0,i=L,L=L+16|0,oe(4+(e|=0)|0,o=i),Ee(o,0|r[e>>2],t,0,n),L=i}(i,15&s,n),L=o,0|(s=0))}function et(e,t,n){n|=0;var i,r=0,o=0,s=0;if(i=L,L=L+16|0,0|(r=0|Ze(e|=0,t|=0,s=i)))return L=i,0|(s=r);r=0|rn(0|e,0|t,45),B(),r=!(0|z(127&r)),o=0|rn(0|e,0|t,52),B(),o&=15;e:do{if(!r){if(0|o)for(r=1;;){if(!(!((0|on(7,0,3*(15-r|0)|0))&e|0)&!((0|B())&t)))break e;if(!(r>>>0<o>>>0))break;r=r+1|0}return Pe(s,o,0,5,n),L=i,0|0}}while(0);return Fe(s,o,0,6,n),L=i,0|0}function tt(e,t){t|=0;var n=0,i=0,o=0,s=0,a=0,A=0,l=0;if((e|=0)>>>0>15)return 0|(A=4);if(on(0|e,0,52),A=134225919|B(),!e){n=0,i=0;do{0|z(i)&&(on(0|i,0,45),a=0|A|B(),r[(e=t+(n<<3)|0)>>2]=-1,r[e+4>>2]=a,n=n+1|0),i=i+1|0}while(122!=(0|i));return 0|(n=0)}n=0,a=0;do{if(0|z(a)){for(on(0|a,0,45),i=1,o=-1,s=0|A|B();o&=~(l=0|on(7,0,3*(15-i|0)|0)),s&=~B(),(0|i)!=(0|e);)i=i+1|0;r[(l=t+(n<<3)|0)>>2]=o,r[l+4>>2]=s,n=n+1|0}a=a+1|0}while(122!=(0|a));return 0|(n=0)}function nt(e,t,n,i){e|=0,i|=0;var o=0,s=0,a=0;o=0|rn(0|(t|=0),0|(n|=0),52),B(),!(0|t)&!(0|n)|(0|i)>15|(0|(o&=15))>(0|i)?(s=-1,t=-1,n=0,o=0):(t=0|Ve(t,n,o+1|0,i),a=-15728641&B(),n=0|on(0|i,0,52),s=o,t=(t=!(0|ze(n|=t,a=0|a|B())))?-1:i,o=a),r[(a=e)>>2]=n,r[a+4>>2]=o,r[e+8>>2]=s,r[e+12>>2]=t}function it(e,t,n,i){n|=0,i|=0;var o=0,s=0;return o=0|rn(0|(e|=0),0|(t|=0),52),B(),o&=15,r[(s=i+8|0)>>2]=o,!(0|e)&!(0|t)|(0|n)>15|(0|o)>(0|n)?(r[(n=i)>>2]=0,r[n+4>>2]=0,r[s>>2]=-1,void(r[i+12>>2]=-1)):(e=0|Ve(e,t,o+1|0,n),s=-15728641&B(),o=0|on(0|n,0,52),o|=e,s=0|s|B(),r[(e=i)>>2]=o,r[e+4>>2]=s,e=i+12|0,0|ze(o,s)?void(r[e>>2]=n):void(r[e>>2]=-1))}function rt(e){var t,n=0,i=0,o=0,s=0,a=0,A=0,l=0,c=0;if(!(!(0|(n=0|r[(i=e|=0)>>2]))&!(0|(i=0|r[i+4>>2]))||(o=0|rn(0|n,0|i,52),B(),n=0|Wt(0|(l=0|on(1,0,3*(15^(o&=15))|0)),0|B(),0|n,0|i),i=0|B(),r[(l=e)>>2]=n,r[l+4>>2]=i,(0|o)<(0|(A=0|r[(l=e+8|0)>>2]))))){for(t=e+12|0,a=o;;){if((0|a)==(0|A)){o=5;break}if(c=(0|a)==(0|r[t>>2]),o=0|rn(0|n,0|i,0|(s=3*(15-a|0)|0)),B(),c&1==(0|(o&=7))&!0){o=7;break}if(!(7==(0|o)&!0)){o=10;break}if(n=0|Wt(0|n,0|i,0|(c=0|on(1,0,0|s)),0|B()),i=0|B(),r[(c=e)>>2]=n,r[c+4>>2]=i,!((0|a)>(0|A))){o=10;break}a=a+-1|0}if(5==(0|o))return r[(c=e)>>2]=0,r[c+4>>2]=0,r[l>>2]=-1,void(r[t>>2]=-1);if(7==(0|o))return A=0|Wt(0|n,0|i,0|(A=0|on(1,0,0|s)),0|B()),l=0|B(),r[(c=e)>>2]=A,r[c+4>>2]=l,void(r[t>>2]=a+-1)}}function ot(e){var t;return t=(e=+e)<0?e+6.283185307179586:e,+(e>=6.283185307179586?t+-6.283185307179586:t)}function st(e,t){return t|=0,+l(+(+o[(e|=0)>>3]-+o[t>>3]))<17453292519943298e-27?0|(t=+l(+(+o[e+8>>3]-+o[t+8>>3]))<17453292519943298e-27):0|(t=0)}function at(e,t){switch(e=+e,0|(t|=0)){case 1:e=e<0?e+6.283185307179586:e;break;case 2:e=e>0?e+-6.283185307179586:e}return+e}function At(e,t){e|=0;var n,i,r,s=0;return i=+o[(t|=0)>>3],n=+o[e>>3],s=(r=+h(.5*(i-n)))*r+(s=+h(.5*(+o[t+8>>3]-+o[e+8>>3])))*(+f(+i)*+f(+n)*s),2*+b(+ +c(+s),+ +c(+(1-s)))*6371.007180918475}function lt(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(o[t>>3]=+o[20656+(e<<3)>>3],0|(t=0))}function ct(e,t){t|=0;var n=0;return(e|=0)>>>0>15?0|(t=4):(n=0|$t(0|(n=0|yt(7,0,e,((0|e)<0)<<31>>31)),0|B(),120,0),e=0|B(),r[t>>2]=2|n,r[t+4>>2]=e,0|(t=0))}function ut(e,t,n){e|=0,n|=0;var i,r,s,a,A=0,l=0,u=0,p=0,g=0,y=0;return y=+o[(t|=0)>>3],s=+o[e>>3],g=+h(.5*(y-s)),u=+o[t+8>>3],r=+o[e+8>>3],p=+h(.5*(u-r)),i=+f(+s),a=+f(+y),p=2*+b(+ +c(+(p=g*g+p*(a*i*p))),+ +c(+(1-p))),g=+o[n>>3],y=+h(.5*(g-y)),A=+o[n+8>>3],u=+h(.5*(A-u)),l=+f(+g),u=2*+b(+ +c(+(u=y*y+u*(a*l*u))),+ +c(+(1-u))),g=+h(.5*(s-g)),A=+h(.5*(r-A)),A=2*+b(+ +c(+(A=g*g+A*(i*l*A))),+ +c(+(1-A))),4*+m(+ +c(+ +d(.5*(l=.5*(p+u+A)))*+d(.5*(l-p))*+d(.5*(l-u))*+d(.5*(l-A))))}function ft(e,t,n){n|=0;var i,s,a,A=0,l=0;if(a=L,L=L+192|0,s=a,0|(l=0|$e(e|=0,t|=0,i=a+168|0)))return L=a,0|(n=l);if(0|et(e,t,s)&&M(27795,27190,415,27199),(0|(t=0|r[s>>2]))>0){if(A=+ut(s+8|0,s+8+((1!=(0|t)&1)<<4)|0,i)+0,1!=(0|t)){e=1;do{A+=+ut(s+8+((l=e)<<4)|0,s+8+((0|(e=e+1|0))%(0|t)<<4)|0,i)}while((0|e)<(0|t))}}else A=0;return o[n>>3]=A,L=a,0|(n=0)}function ht(e){e|=0;var t,n,i=0;return(t=0|Kt(1,12))||M(27280,27235,49,27293),0|(i=0|r[(n=e+4|0)>>2])?(r[(i=i+8|0)>>2]=t,r[n>>2]=t,0|t):(0|r[e>>2]&&M(27310,27235,61,27333),r[(i=e)>>2]=t,r[n>>2]=t,0|t)}function dt(e,t){e|=0,t|=0;var n,i;return(i=0|Qt(24))||M(27347,27235,78,27361),r[i>>2]=r[t>>2],r[i+4>>2]=r[t+4>>2],r[i+8>>2]=r[t+8>>2],r[i+12>>2]=r[t+12>>2],r[i+16>>2]=0,0|(n=0|r[(t=e+4|0)>>2])?(r[n+16>>2]=i,r[t>>2]=i,0|i):(0|r[e>>2]&&M(27376,27235,82,27361),r[e>>2]=i,r[t>>2]=i,0|i)}function pt(e){var t=0,n=0,i=0,o=0;if(e|=0)for(i=1;;){if(0|(t=0|r[e>>2]))do{if(0|(n=0|r[t>>2]))do{o=n,n=0|r[n+16>>2],Jt(o)}while(0|n);o=t,t=0|r[t+8>>2],Jt(o)}while(0|t);if(t=e,e=0|r[e+8>>2],i||Jt(t),!e)break;i=0}}function gt(e,t,n){e|=0;var i=0,s=0,a=0,A=0,l=0,c=0,u=0,f=0;if(!(0|X(t|=0,n|=0)))return 0|(e=0);if(t=0|q(t),i=+o[n>>3],s=t&(s=+o[n+8>>3])<0?s+6.283185307179586:s,!(e=0|r[e>>2]))return 0|(e=0);if(t){t=0,u=s,n=e;e:for(;;){for(;A=+o[n>>3],s=+o[n+8>>3],f=0|r[(n=n+16|0)>>2],a=+o[(f=0|f?f:e)>>3],l=+o[f+8>>3],A>a?(c=A,A=l):(c=a,a=A,A=s,s=l),(i=i==a|i==c?i+2220446049250313e-31:i)<a|i>c;)if(!(n=0|r[n>>2])){n=22;break e}if(((c=(l=A<0?A+6.283185307179586:A)+(i-a)/(c-a)*((A=s<0?s+6.283185307179586:s)-l))<0?c+6.283185307179586:c)>(u=l==u|A==u?u+-2220446049250313e-31:u)&&(t^=1),!(n=0|r[n>>2])){n=22;break}}if(22==(0|n))return 0|t}else{t=0,u=s,n=e;e:for(;;){for(;A=+o[n>>3],s=+o[n+8>>3],f=0|r[(n=n+16|0)>>2],a=+o[(f=0|f?f:e)>>3],l=+o[f+8>>3],A>a?(c=A,A=l):(c=a,a=A,A=s,s=l),(i=i==a|i==c?i+2220446049250313e-31:i)<a|i>c;)if(!(n=0|r[n>>2])){n=22;break e}if(A+(i-a)/(c-a)*(s-A)>(u=A==u|s==u?u+-2220446049250313e-31:u)&&(t^=1),!(n=0|r[n>>2])){n=22;break}}if(22==(0|n))return 0|t}return 0}function mt(e,t,n,o,s){n|=0,o|=0,s|=0;var a,A,l,c,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0;if(c=L,L=L+32|0,v=c+16|0,l=c,u=0|rn(0|(e|=0),0|(t|=0),52),B(),u&=15,m=0|rn(0|n,0|o,52),B(),(0|u)!=(15&m))return L=c,0|(v=12);if(p=0|rn(0|e,0|t,45),B(),p&=127,g=0|rn(0|n,0|o,45),B(),p>>>0>121|(g&=127)>>>0>121)return L=c,0|(v=5);if(m=(0|p)!=(0|g)){if(7==(0|(h=0|K(p,g))))return L=c,0|(v=1);7==(0|(d=0|K(g,p)))?M(27514,27538,161,27548):(b=h,f=d)}else b=0,f=0;a=0|z(p),A=0|z(g),r[v>>2]=0,r[v+4>>2]=0,r[v+8>>2]=0,r[v+12>>2]=0;do{if(b){if(h=(0|(g=0|r[4272+(28*p|0)+(b<<2)>>2]))>0,A)if(h){p=0,d=n,h=o;do{d=0|Ke(d,h),h=0|B(),1==(0|(f=0|ve(f)))&&(f=0|ve(1)),p=p+1|0}while((0|p)!=(0|g));g=f,p=d,d=h}else g=f,p=n,d=o;else if(h){p=0,d=n,h=o;do{d=0|We(d,h),h=0|B(),f=0|ve(f),p=p+1|0}while((0|p)!=(0|g));g=f,p=d,d=h}else g=f,p=n,d=o;if(Xe(p,d,v),m||M(27563,27538,191,27548),(h=!!(0|a))&(f=!!(0|A))&&M(27590,27538,192,27548),h){if(7==(0|(f=0|je(e,t)))){u=5;break}if(0|i[22e3+(7*f|0)+b|0]){u=1;break}p=d=0|r[21168+(28*f|0)+(b<<2)>>2]}else if(f){if(7==(0|(f=0|je(p,d)))){u=5;break}if(0|i[22e3+(7*f|0)+g|0]){u=1;break}p=0,d=0|r[21168+(28*g|0)+(f<<2)>>2]}else p=0,d=0;if((p|d|0)<0)u=5;else{if((0|d)>0){h=v+4|0,f=0;do{be(h),f=f+1|0}while((0|f)!=(0|d))}if(r[l>>2]=0,r[l+4>>2]=0,r[l+8>>2]=0,ge(l,b),0|u)for(;0|qe(u)?de(l):pe(l),(0|u)>1;)u=u+-1|0;if((0|p)>0){u=0;do{be(l),u=u+1|0}while((0|u)!=(0|p))}se(y=v+4|0,l,y),re(y),y=51}}else if(Xe(n,o,v),!!(0|a)&!!(0|A))if((0|g)!=(0|p)&&M(27621,27538,261,27548),7==(0|(f=0|je(e,t)))|7==(0|(u=0|je(n,o))))u=5;else if(0|i[22e3+(7*f|0)+u|0])u=1;else if((0|(f=0|r[21168+(28*f|0)+(u<<2)>>2]))>0){h=v+4|0,u=0;do{be(h),u=u+1|0}while((0|u)!=(0|f));y=51}else y=51;else y=51}while(0);return 51==(0|y)&&(u=v+4|0,r[s>>2]=r[u>>2],r[s+4>>2]=r[u+4>>2],r[s+8>>2]=r[u+8>>2],u=0),L=c,0|(v=u)}function bt(e,t,n,i){n|=0,i|=0;var o,s,a,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0;if(a=L,L=L+48|0,o=a+36|0,c=a+24|0,u=a+12|0,f=a,A=0|rn(0|(e|=0),0|(t|=0),52),B(),A&=15,d=0|rn(0|e,0|t,45),B(),(d&=127)>>>0>121)return L=a,0|(i=5);if(s=0|z(d),on(0|A,0,52),m=134225919|B(),r[(l=i)>>2]=-1,r[l+4>>2]=m,!A)return 7==(0|(A=0|le(n)))||127==(0|(A=0|J(d,A)))?(L=a,0|(m=1)):(p=0|on(0|A,0,45),g=0|B(),g=-1040385&r[(d=i)+4>>2]|g,r[(m=i)>>2]=r[d>>2]|p,r[m+4>>2]=g,L=a,0|(m=0));for(r[o>>2]=r[n>>2],r[o+4>>2]=r[n+4>>2],r[o+8>>2]=r[n+8>>2],n=A;;){if(l=n,n=n+-1|0,r[c>>2]=r[o>>2],r[c+4>>2]=r[o+4>>2],r[c+8>>2]=r[o+8>>2],0|qe(l)){if(0|(A=0|ce(o))){n=13;break}r[u>>2]=r[o>>2],r[u+4>>2]=r[o+4>>2],r[u+8>>2]=r[o+8>>2],de(u)}else{if(0|(A=0|ue(o))){n=13;break}r[u>>2]=r[o>>2],r[u+4>>2]=r[o+4>>2],r[u+8>>2]=r[o+8>>2],pe(u)}if(ae(c,u,f),re(f),y=0|r[(A=i)>>2],A=0|r[A+4>>2],b=0|on(7,0,0|(v=3*(15-l|0)|0)),A&=~B(),v=0|on(0|le(f),0,0|v),A=0|B()|A,r[(m=i)>>2]=v|y&~b,r[m+4>>2]=A,(0|l)<=1){n=14;break}}e:do{if(13!=(0|n)&&14==(0|n))if((0|r[o>>2])<=1&&(0|r[o+4>>2])<=1&&(0|r[o+8>>2])<=1){f=127==(0|(A=0|J(d,n=0|le(o))))?0:0|z(A);t:do{if(n){if(s){if(7==(0|(A=0|je(e,t)))){A=5;break e}if((0|(l=0|r[21376+(28*A|0)+(n<<2)>>2]))>0){A=n,n=0;do{A=0|ye(A),n=n+1|0}while((0|n)!=(0|l))}else A=n;if(1==(0|A)){A=9;break e}127==(0|(n=0|J(d,A)))&&M(27648,27538,411,27678),0|z(n)?M(27693,27538,412,27678):(g=n,p=l,h=A)}else g=A,p=0,h=n;if((0|(u=0|r[4272+(28*d|0)+(h<<2)>>2]))<=-1&&M(27724,27538,419,27678),!f){if((0|p)<0){A=5;break e}if(0|p){A=0,n=0|r[(l=i)>>2],l=0|r[l+4>>2];do{n=0|Je(n,l),l=0|B(),r[(v=i)>>2]=n,r[v+4>>2]=l,A=A+1|0}while((0|A)<(0|p))}if((0|u)<=0){A=g,n=58;break}for(A=0,n=0|r[(l=i)>>2],l=0|r[l+4>>2];;)if(n=0|Je(n,l),l=0|B(),r[(v=i)>>2]=n,r[v+4>>2]=l,(0|(A=A+1|0))==(0|u)){A=g,n=58;break t}}if(7==(0|(c=0|K(g,d)))&&M(27514,27538,428,27678),n=0|r[(A=i)>>2],A=0|r[A+4>>2],(0|u)>0){l=0;do{n=0|Je(n,A),A=0|B(),r[(v=i)>>2]=n,r[v+4>>2]=A,l=l+1|0}while((0|l)!=(0|u))}if(7==(0|(A=0|je(n,A)))&&M(27795,27538,440,27678),n=0|V(g),(0|(n=0|r[(n?21792:21584)+(28*c|0)+(A<<2)>>2]))<0&&M(27795,27538,454,27678),n){A=0,l=0|r[(c=i)>>2],c=0|r[c+4>>2];do{l=0|Qe(l,c),c=0|B(),r[(v=i)>>2]=l,r[v+4>>2]=c,A=A+1|0}while((0|A)<(0|n));A=g,n=58}else A=g,n=58}else if(!!(0|s)&!!(0|f)){if(7==(0|(n=0|je(e,t)))|7==(0|(l=0|je(0|r[(l=i)>>2],0|r[l+4>>2])))){A=5;break e}if((0|(l=0|r[21376+(28*n|0)+(l<<2)>>2]))<0){A=5;break e}if(l){n=0,c=0|r[(u=i)>>2],u=0|r[u+4>>2];do{c=0|Je(c,u),u=0|B(),r[(v=i)>>2]=c,r[v+4>>2]=u,n=n+1|0}while((0|n)<(0|l));n=58}else n=59}else n=58}while(0);if(58==(0|n)&&f&&(n=59),59==(0|n)&&1==(0|je(0|r[(v=i)>>2],0|r[v+4>>2]))){A=9;break}b=0|r[(v=i)>>2],v=-1040385&r[v+4>>2],y=0|on(0|A,0,45),v=0|v|B(),r[(A=i)>>2]=b|y,r[A+4>>2]=v,A=0}else A=1}while(0);return L=a,0|(v=A)}function yt(e,t,n,i){e|=0,t|=0;var r=0,o=0,s=0;if(!(0|(n|=0))&!(0|(i|=0)))return o=1,w(0|(r=0)),0|o;o=e,r=t,e=1,t=0;do{e=0|$t(0|((s=!0&!(1&n))?1:o),0|(s?0:r),0|e,0|t),t=0|B(),n=0|nn(0|n,0|i,1),i=0|B(),o=0|$t(0|o,0|r,0|o,0|r),r=0|B()}while(!(!(0|n)&!(0|i)));return w(0|t),0|e}function vt(e,t,n,i){n|=0,i|=0;var s,a=0,A=0,l=0,c=0,u=0,h=0;s=L,L=L+16|0,A=s,l=0|rn(0|(e|=0),0|(t|=0),52),B(),l&=15;do{if(l){if(!(a=0|$e(e,t,A))){u=+o[A>>3],c=1/+f(+u),h=+o[25968+(l<<3)>>3],o[n>>3]=u+h,o[n+8>>3]=u-h,u=+o[A+8>>3],c*=h,o[n+16>>3]=c+u,o[n+24>>3]=u-c;break}return L=s,0|(l=a)}if(a=0|rn(0|e,0|t,45),B(),(a&=127)>>>0>121)return L=s,0|(l=5);A=22064+(a<<5)|0,r[n>>2]=r[A>>2],r[n+4>>2]=r[A+4>>2],r[n+8>>2]=r[A+8>>2],r[n+12>>2]=r[A+12>>2],r[n+16>>2]=r[A+16>>2],r[n+20>>2]=r[A+20>>2],r[n+24>>2]=r[A+24>>2],r[n+28>>2]=r[A+28>>2];break}while(0);return function(e,t){t=+t;var n,i,r,s,a,A,l,c=0,u=0;c=(s=+o[(r=16+(e|=0)|0)>>3])-(i=+o[(n=e+24|0)>>3]),c=s<i?c+6.283185307179586:c,u=+o[e>>3],c=.5*(c*t-c),u+=t=.5*((l=u-(A=+o[(a=e+8|0)>>3]))*t-l),o[e>>3]=u>1.5707963267948966?1.5707963267948966:u,t=A-t,o[a>>3]=t<-1.5707963267948966?-1.5707963267948966:t,t=(t=s+c)>3.141592653589793?t+-6.283185307179586:t,o[r>>3]=t<-3.141592653589793?t+6.283185307179586:t,t=(t=i-c)>3.141592653589793?t+-6.283185307179586:t,o[n>>3]=t<-3.141592653589793?t+6.283185307179586:t}(n,i?1.4:1.1),(0|r[(i=26096+(l<<3)|0)>>2])==(0|e)&&(0|r[i+4>>2])==(0|t)&&(o[n>>3]=1.5707963267948966),(0|r[(l=26224+(l<<3)|0)>>2])==(0|e)&&(0|r[l+4>>2])==(0|t)&&(o[n+8>>3]=-1.5707963267948966),1.5707963267948966!=+o[n>>3]&&-1.5707963267948966!=+o[n+8>>3]?(L=s,0|(l=0)):(o[n+16>>3]=3.141592653589793,o[n+24>>3]=-3.141592653589793,L=s,0|(l=0))}function _t(e){var t,n,o,s,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0;if(s=L,L=L+336|0,t=s+168|0,n=s,!(0|(A=0|r[(l=e|=0)>>2]))&!(0|(l=0|r[l+4>>2])))L=s;else{if(0|i[(a=e+28|0)|0]?(A=0|Ct(A,l),l=0|B()):i[a|0]=1,!(0|r[r[(o=e+20|0)>>2]>>2]))return 0|(A=0|r[(a=e+24|0)>>2])&&Jt(A),r[(C=e)>>2]=0,r[C+4>>2]=0,r[e+8>>2]=0,r[o>>2]=0,r[e+12>>2]=-1,r[e+16>>2]=0,r[a>>2]=0,void(L=s);c=15&(a=0|r[(C=e+16|0)>>2]);e:do{if(!(0|A)&!(0|l))_=e+24|0;else{y=e+12|0,m=3==(0|c),g=255&a,d=3==(1|c),b=e+24|0,p=(c+-1|0)>>>0<3,f=3==(2|c),h=n+8|0;t:for(;;){if(u=0|rn(0|A,0|l,52),B(),(0|(u&=15))==(0|r[y>>2])){switch(15&g){case 0:case 2:case 3:if(0|(c=0|$e(A,l,t))){v=15;break t}if(0|St(0|r[o>>2],0|r[b>>2],t)){v=19;break t}}if(d&&(c=0|r[4+(0|r[o>>2])>>2],r[t>>2]=r[c>>2],r[t+4>>2]=r[c+4>>2],r[t+8>>2]=r[c+8>>2],r[t+12>>2]=r[c+12>>2],0|X(26832,t))){if(0|Ye(0|r[4+(0|r[o>>2])>>2],u,n)){v=25;break}if((0|r[(c=n)>>2])==(0|A)&&(0|r[c+4>>2])==(0|l)){v=29;break}}if(p){if(0|(c=0|et(A,l,t))){v=32;break}if(0|vt(A,l,n,0)){v=36;break}if(f&&0|Tt(0|r[o>>2],0|r[b>>2],t,n)){v=42;break}if(d&&0|Pt(0|r[o>>2],0|r[b>>2],t,n)){v=42;break}}if(m){if(a=0|vt(A,l,t,1),c=0|r[b>>2],0|a){v=45;break}if(0|Z(c,t)){if(ee(n,t),0|$(t,0|r[b>>2])){v=53;break}if(0|St(0|r[o>>2],0|r[b>>2],h)){v=53;break}if(0|Pt(0|r[o>>2],0|r[b>>2],n,t)){v=53;break}}}}do{if((0|u)<(0|r[y>>2])){if(a=0|vt(A,l,t,1),c=0|r[b>>2],0|a){v=58;break t}if(!(0|Z(c,t))){v=73;break}if(0|$(0|r[b>>2],t)&&(ee(n,t),0|Tt(0|r[o>>2],0|r[b>>2],n,t))){v=65;break t}if(0|(A=0|He(A,l,u+1|0,n))){v=67;break t}A=0|r[(l=n)>>2],l=0|r[l+4>>2]}else v=73}while(0);if(73==(0|v)&&(v=0,A=0|Ct(A,l),l=0|B()),!(0|A)&!(0|l)){_=b;break e}}switch(0|v){case 15:0|(a=0|r[b>>2])&&Jt(a),r[(v=e)>>2]=0,r[v+4>>2]=0,r[o>>2]=0,r[y>>2]=-1,r[C>>2]=0,r[b>>2]=0,r[e+8>>2]=c,v=20;break;case 19:r[e>>2]=A,r[e+4>>2]=l,v=20;break;case 25:M(27795,27761,470,27772);break;case 29:case 42:return r[e>>2]=A,r[e+4>>2]=l,void(L=s);case 32:return 0|(a=0|r[b>>2])&&Jt(a),r[(_=e)>>2]=0,r[_+4>>2]=0,r[o>>2]=0,r[y>>2]=-1,r[C>>2]=0,r[b>>2]=0,r[e+8>>2]=c,void(L=s);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Jt(c),r[(v=e)>>2]=0,r[v+4>>2]=0,r[o>>2]=0,r[y>>2]=-1,r[C>>2]=0,r[b>>2]=0,r[e+8>>2]=a,v=55;break;case 53:r[e>>2]=A,r[e+4>>2]=l,v=55;break;case 58:0|c&&Jt(c),r[(v=e)>>2]=0,r[v+4>>2]=0,r[o>>2]=0,r[y>>2]=-1,r[C>>2]=0,r[b>>2]=0,r[e+8>>2]=a,v=71;break;case 65:r[e>>2]=A,r[e+4>>2]=l,v=71;break;case 67:return 0|(a=0|r[b>>2])&&Jt(a),r[(_=e)>>2]=0,r[_+4>>2]=0,r[o>>2]=0,r[y>>2]=-1,r[C>>2]=0,r[b>>2]=0,r[e+8>>2]=A,void(L=s)}if(20==(0|v))return void(L=s);if(55==(0|v))return void(L=s);if(71==(0|v))return void(L=s)}}while(0);0|(a=0|r[_>>2])&&Jt(a),r[(v=e)>>2]=0,r[v+4>>2]=0,r[e+8>>2]=0,r[o>>2]=0,r[e+12>>2]=-1,r[C>>2]=0,r[_>>2]=0,L=s}}function Ct(e,t){var n,i=0,o=0,s=0,a=0,A=0,l=0,c=0,u=0,f=0;n=L,L=L+16|0,f=n,o=0|rn(0|(e|=0),0|(t|=0),52),B(),o&=15,i=0|rn(0|e,0|t,45),B();do{if(o){for(;i=0|on(o+4095|0,0,52),s=B()|-15728641&t,i=i|e|(A=0|on(7,0,0|(a=3*(15-o|0)|0))),s|=l=0|B(),c=0|rn(0|e,0|t,0|a),B(),o=o+-1|0,!((c&=7)>>>0<6);){if(!o){u=4;break}t=s,e=i}if(4==(0|u)){i=0|rn(0|i,0|s,45),B();break}return f=0|on(((f=!(0|c)&!!(0|ze(i,s)))?2:1)+c|0,0,0|a),u=0|B()|t&~l,f|=e&~A,w(0|u),L=n,0|f}}while(0);return(i&=127)>>>0>120?(f=0,w(0|(u=0)),L=n,0|f):(Ue(f,0,i+1|0,0),u=0|r[f+4>>2],f=0|r[f>>2],w(0|u),L=n,0|f)}function xt(e,t,n){e|=0;var i,s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0;if(!(0|X(t|=0,n|=0)))return 0|(d=0);if(t=0|q(t),s=+o[n>>3],a=t&(a=+o[n+8>>3])<0?a+6.283185307179586:a,(0|(d=0|r[e>>2]))<=0)return 0|(d=0);if(i=0|r[e+4>>2],t){t=0,h=a,n=-1,e=0;e:for(;;){for(f=e;l=+o[i+(f<<4)>>3],a=+o[i+(f<<4)+8>>3],A=+o[i+((e=(n+2|0)%(0|d)|0)<<4)>>3],c=+o[i+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=a,a=c),(s=s==A|s==u?s+2220446049250313e-31:s)<A|s>u;){if((0|(n=f+1|0))>=(0|d)){n=22;break e}e=f,f=n,n=e}if(((u=(c=l<0?l+6.283185307179586:l)+(s-A)/(u-A)*((l=a<0?a+6.283185307179586:a)-c))<0?u+6.283185307179586:u)>(h=c==h|l==h?h+-2220446049250313e-31:h)&&(t^=1),(0|(e=f+1|0))>=(0|d)){n=22;break}n=f}if(22==(0|n))return 0|t}else{t=0,h=a,n=-1,e=0;e:for(;;){for(f=e;l=+o[i+(f<<4)>>3],a=+o[i+(f<<4)+8>>3],A=+o[i+((e=(n+2|0)%(0|d)|0)<<4)>>3],c=+o[i+(e<<4)+8>>3],l>A?(u=l,l=c):(u=A,A=l,l=a,a=c),(s=s==A|s==u?s+2220446049250313e-31:s)<A|s>u;){if((0|(n=f+1|0))>=(0|d)){n=22;break e}e=f,f=n,n=e}if(l+(s-A)/(u-A)*(a-l)>(h=l==h|a==h?h+-2220446049250313e-31:h)&&(t^=1),(0|(e=f+1|0))>=(0|d)){n=22;break}n=f}if(22==(0|n))return 0|t}return 0}function wt(e,t){t|=0;var n,i,s,a,A,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0;if(!(i=0|r[(e|=0)>>2]))return r[t>>2]=0,r[t+4>>2]=0,r[t+8>>2]=0,r[t+12>>2]=0,r[t+16>>2]=0,r[t+20>>2]=0,r[t+24>>2]=0,void(r[t+28>>2]=0);if(o[(s=t+8|0)>>3]=17976931348623157e292,o[(a=t+24|0)>>3]=17976931348623157e292,o[t>>3]=-17976931348623157e292,o[(A=t+16|0)>>3]=-17976931348623157e292,!((0|i)<=0)){for(n=0|r[e+4>>2],m=17976931348623157e292,b=-17976931348623157e292,y=0,e=-1,h=17976931348623157e292,d=17976931348623157e292,g=-17976931348623157e292,u=-17976931348623157e292,v=0;c=+o[n+(v<<4)>>3],p=+o[n+(v<<4)+8>>3],f=+o[n+(((0|(e=e+2|0))==(0|i)?0:e)<<4)+8>>3],c<h&&(o[s>>3]=c,h=c),p<d&&(o[a>>3]=p,d=p),c>g?o[t>>3]=c:c=g,p>u&&(o[A>>3]=p,u=p),m=p>0&p<m?p:m,b=p<0&p>b?p:b,y|=+l(+(p-f))>3.141592653589793,(0|(e=v+1|0))!=(0|i);)_=v,g=c,v=e,e=_;y&&(o[A>>3]=b,o[a>>3]=m)}}function Bt(e){return 0|((e|=0)>>>0<4?0:15)}function Mt(e,t){t|=0;var n,i=0,s=0,a=0,A=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0,x=0,w=0,B=0,M=0;if(b=0|r[(e|=0)>>2]){if(o[(y=t+8|0)>>3]=17976931348623157e292,o[(v=t+24|0)>>3]=17976931348623157e292,o[t>>3]=-17976931348623157e292,o[(_=t+16|0)>>3]=-17976931348623157e292,(0|b)>0){for(a=0|r[e+4>>2],g=17976931348623157e292,m=-17976931348623157e292,s=0,i=-1,f=17976931348623157e292,h=17976931348623157e292,p=-17976931348623157e292,c=-17976931348623157e292,C=0;A=+o[a+(C<<4)>>3],d=+o[a+(C<<4)+8>>3],u=+o[a+(((0|(B=i+2|0))==(0|b)?0:B)<<4)+8>>3],A<f&&(o[y>>3]=A,f=A),d<h&&(o[v>>3]=d,h=d),A>p?o[t>>3]=A:A=p,d>c&&(o[_>>3]=d,c=d),g=d>0&d<g?d:g,m=d<0&d>m?d:m,s|=+l(+(d-u))>3.141592653589793,(0|(i=C+1|0))!=(0|b);)B=C,p=A,C=i,i=B;s&&(o[_>>3]=m,o[v>>3]=g)}}else r[t>>2]=0,r[t+4>>2]=0,r[t+8>>2]=0,r[t+12>>2]=0,r[t+16>>2]=0,r[t+20>>2]=0,r[t+24>>2]=0,r[t+28>>2]=0;if(!((0|(i=0|r[(B=e+8|0)>>2]))<=0)){n=e+12|0,w=0;do{if(a=0|r[n>>2],s=w,v=t+((w=w+1|0)<<5)|0,_=0|r[a+(s<<3)>>2]){if(o[(C=t+(w<<5)+8|0)>>3]=17976931348623157e292,o[(e=t+(w<<5)+24|0)>>3]=17976931348623157e292,o[v>>3]=-17976931348623157e292,o[(x=t+(w<<5)+16|0)>>3]=-17976931348623157e292,(0|_)>0){for(b=0|r[a+(s<<3)+4>>2],g=17976931348623157e292,m=-17976931348623157e292,a=0,s=-1,y=0,f=17976931348623157e292,h=17976931348623157e292,d=-17976931348623157e292,c=-17976931348623157e292;A=+o[b+(y<<4)>>3],p=+o[b+(y<<4)+8>>3],u=+o[b+(((0|(s=s+2|0))==(0|_)?0:s)<<4)+8>>3],A<f&&(o[C>>3]=A,f=A),p<h&&(o[e>>3]=p,h=p),A>d?o[v>>3]=A:A=d,p>c&&(o[x>>3]=p,c=p),g=p>0&p<g?p:g,m=p<0&p>m?p:m,a|=+l(+(p-u))>3.141592653589793,(0|(s=y+1|0))!=(0|_);)M=y,y=s,d=A,s=M;a&&(o[x>>3]=m,o[e>>3]=g)}}else r[v>>2]=0,r[v+4>>2]=0,r[v+8>>2]=0,r[v+12>>2]=0,r[v+16>>2]=0,r[v+20>>2]=0,r[v+24>>2]=0,r[v+28>>2]=0,i=0|r[B>>2]}while((0|w)<(0|i))}}function St(e,t,n){var i=0,o=0,s=0;if(!(0|xt(e|=0,t|=0,n|=0)))return 0|(o=0);if((0|r[(o=e+8|0)>>2])<=0)return 0|(o=1);for(i=e+12|0,e=0;;){if(s=e,e=e+1|0,0|xt((0|r[i>>2])+(s<<3)|0,t+(e<<5)|0,n)){e=0,i=6;break}if((0|e)>=(0|r[o>>2])){e=1,i=6;break}}return 6==(0|i)?0|e:0}function Tt(e,t,n,i){i|=0;var o,s,a=0,A=0,l=0,c=0,u=0;if(s=L,L=L+16|0,o=s,!(0|xt(e|=0,t|=0,l=(n|=0)+8|0)))return L=s,0|(c=0);c=e+8|0;e:do{if((0|r[c>>2])>0){for(A=e+12|0,a=0;;){if(u=a,a=a+1|0,0|xt((0|r[A>>2])+(u<<3)|0,t+(a<<5)|0,l)){a=0;break}if((0|a)>=(0|r[c>>2]))break e}return L=s,0|a}}while(0);if(0|Et(e,t,n,i))return L=s,0|(u=0);r[o>>2]=r[n>>2],r[o+4>>2]=l,a=0|r[c>>2];e:do{if((0|a)>0)for(e=e+12|0,l=0,A=a;;){if(a=0|r[e>>2],(0|r[a+(l<<3)>>2])>0){if(0|xt(o,i,0|r[a+(l<<3)+4>>2])){a=0;break e}if(a=l+1|0,0|Et((0|r[e>>2])+(l<<3)|0,t+(a<<5)|0,n,i)){a=0;break e}A=0|r[c>>2]}else a=l+1|0;if(!((0|a)<(0|A))){a=1;break}l=a}else a=1}while(0);return L=s,0|(u=a)}function Et(e,t,n,i){e|=0,n|=0;var s,a,A,l,c,u,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0,x=0,w=0,B=0,M=0;if(u=L,L=L+176|0,l=u+172|0,f=u+168|0,c=u,!(0|Z(t|=0,i|=0)))return L=u,0|(e=0);if(function(e,t,n,i){var s,a,A,l,c;t|=0,n|=0,i|=0,e=(a=+o[16+(e|=0)>>3])<(c=+o[e+24>>3]),s=(l=+o[t+16>>3])<(A=+o[t+24>>3]),t=c-l<A-a,r[n>>2]=e?s|t?1:2:0,r[i>>2]=s?e?1:t?2:1:0}(t,i,l,f),cn(0|c,0|n,168),(0|r[n>>2])>0){t=0;do{C=+at(+o[(B=c+8+(t<<4)+8|0)>>3],0|r[f>>2]),o[B>>3]=C,t=t+1|0}while((0|t)<(0|r[n>>2]))}a=+o[i>>3],A=+o[i+8>>3],C=+at(+o[i+16>>3],0|r[f>>2]),s=+at(+o[i+24>>3],0|r[f>>2]);e:do{if((0|r[e>>2])>0){if(i=e+4|0,(0|(f=0|r[c>>2]))<=0)for(t=0;;)if((0|(t=t+1|0))>=(0|r[e>>2])){t=0;break e}for(n=0;;){if(t=0|r[i>>2],v=+o[t+(n<<4)>>3],_=+at(+o[t+(n<<4)+8>>3],0|r[l>>2]),t=0|r[i>>2],B=(0|(n=n+1|0))%(0|r[e>>2])|0,h=+o[t+(B<<4)>>3],d=+at(+o[t+(B<<4)+8>>3],0|r[l>>2]),!(v>=a)|!(h>=a)&&!(v<=A)|!(h<=A)&&!(_<=s)|!(d<=s)&&!(_>=C)|!(d>=C)){y=h-v,m=d-_,t=0;do{if(M=t,B=(0|(t=t+1|0))==(0|f)?0:t,h=+o[c+8+(M<<4)+8>>3],d=+o[c+8+(B<<4)+8>>3]-h,p=+o[c+8+(M<<4)>>3],!(0==(b=y*d-m*(g=+o[c+8+(B<<4)>>3]-p))||(x=_-h,w=v-p,g=(x*g-d*w)/b,g<0|g>1))&&(b=(y*x-m*w)/b)>=0&b<=1){t=1;break e}}while((0|t)<(0|f))}if((0|n)>=(0|r[e>>2])){t=0;break}}}else t=0}while(0);return L=u,0|(M=t)}function Pt(e,t,n,i){var o=0,s=0,a=0;if(0|Et(e|=0,t|=0,n|=0,i|=0))return 0|(s=1);if((0|r[(s=e+8|0)>>2])<=0)return 0|(s=0);for(o=e+12|0,e=0;;){if(a=e,e=e+1|0,0|Et((0|r[o>>2])+(a<<3)|0,t+(e<<5)|0,n,i)){e=1,o=6;break}if((0|e)>=(0|r[s>>2])){e=0,o=6;break}}return 6==(0|o)?0|e:0}function It(e,t,n,i,r){t|=0,n|=0,i|=0,r|=0;var s,a,A,l,c,u,f,h=0;l=+o[(e|=0)>>3],A=+o[t>>3]-l,a=+o[e+8>>3],s=+o[t+8>>3]-a,u=+o[n>>3],h=((h=+o[i>>3]-u)*(a-(f=+o[n+8>>3]))-(l-u)*(c=+o[i+8>>3]-f))/(A*c-s*h),o[r>>3]=l+A*h,o[r+8>>3]=a+s*h}function Lt(e,t){return t|=0,+l(+(+o[(e|=0)>>3]-+o[t>>3]))<1.1920928955078125e-7?0|(t=+l(+(+o[e+8>>3]-+o[t+8>>3]))<1.1920928955078125e-7):0|(t=0)}function Rt(e,t){t|=0;var n,i,r;return+((r=+o[(e|=0)>>3]-+o[t>>3])*r+(i=+o[e+8>>3]-+o[t+8>>3])*i+(n=+o[e+16>>3]-+o[t+16>>3])*n)}function Ft(e,t,n){n|=0;var i,o,s,a,A=0,l=0,c=0,u=0;if(a=L,L=L+32|0,u=a,0|(A=0|Ze(e|=0,t|=0,o=a+16|0)))return L=a,0|(n=A);i=0|De(e,t),s=0|je(e,t),function(e,t){e=7696+(28*(e|=0)|0)|0,r[(t|=0)>>2]=r[e>>2],r[t+4>>2]=r[e+4>>2],r[t+8>>2]=r[e+8>>2],r[t+12>>2]=r[e+12>>2]}(i,u),A=0|function(e,t){e|=0;var n=0,i=0;if((t|=0)>>>0>20)return-1;do{if((0|r[11120+(216*t|0)>>2])!=(0|e))if((0|r[11120+(216*t|0)+8>>2])!=(0|e))if((0|r[11120+(216*t|0)+16>>2])!=(0|e))if((0|r[11120+(216*t|0)+24>>2])!=(0|e))if((0|r[11120+(216*t|0)+32>>2])!=(0|e))if((0|r[11120+(216*t|0)+40>>2])!=(0|e))if((0|r[11120+(216*t|0)+48>>2])!=(0|e))if((0|r[11120+(216*t|0)+56>>2])!=(0|e))if((0|r[11120+(216*t|0)+64>>2])!=(0|e))if((0|r[11120+(216*t|0)+72>>2])!=(0|e))if((0|r[11120+(216*t|0)+80>>2])!=(0|e))if((0|r[11120+(216*t|0)+88>>2])!=(0|e))if((0|r[11120+(216*t|0)+96>>2])!=(0|e))if((0|r[11120+(216*t|0)+104>>2])!=(0|e))if((0|r[11120+(216*t|0)+112>>2])!=(0|e))if((0|r[11120+(216*t|0)+120>>2])!=(0|e))if((0|r[11120+(216*t|0)+128>>2])!=(0|e)){if((0|r[11120+(216*t|0)+136>>2])!=(0|e)){if((0|r[11120+(216*t|0)+144>>2])==(0|e)){e=0,n=2,i=0;break}if((0|r[11120+(216*t|0)+152>>2])==(0|e)){e=0,n=2,i=1;break}if((0|r[11120+(216*t|0)+160>>2])==(0|e)){e=0,n=2,i=2;break}if((0|r[11120+(216*t|0)+168>>2])==(0|e)){e=1,n=2,i=0;break}if((0|r[11120+(216*t|0)+176>>2])==(0|e)){e=1,n=2,i=1;break}if((0|r[11120+(216*t|0)+184>>2])==(0|e)){e=1,n=2,i=2;break}if((0|r[11120+(216*t|0)+192>>2])==(0|e)){e=2,n=2,i=0;break}if((0|r[11120+(216*t|0)+200>>2])==(0|e)){e=2,n=2,i=1;break}if((0|r[11120+(216*t|0)+208>>2])==(0|e)){e=2,n=2,i=2;break}return-1}e=2,n=1,i=2}else e=2,n=1,i=1;else e=2,n=1,i=0;else e=1,n=1,i=2;else e=1,n=1,i=1;else e=1,n=1,i=0;else e=0,n=1,i=2;else e=0,n=1,i=1;else e=0,n=1,i=0;else e=2,n=0,i=2;else e=2,n=0,i=1;else e=2,n=0,i=0;else e=1,n=0,i=2;else e=1,n=0,i=1;else e=1,n=0,i=0;else e=0,n=0,i=2;else e=0,n=0,i=1;else e=0,n=0,i=0}while(0);return 0|r[11120+(216*t|0)+(72*n|0)+(24*e|0)+(i<<3)+4>>2]}(i,0|r[o>>2]);do{if(0|z(i)){switch(0|i){case 4:l=0;break;case 14:l=1;break;case 24:l=2;break;case 38:l=3;break;case 49:l=4;break;case 58:l=5;break;case 63:l=6;break;case 72:l=7;break;case 83:l=8;break;case 97:l=9;break;case 107:l=10;break;case 117:l=11;break;default:M(27795,27797,75,27806)}if(c=0|r[26416+(24*l|0)+8>>2],t=0|r[26416+(24*l|0)+16>>2],(0|(e=0|r[o>>2]))!=(0|r[u>>2])&&(u=0|V(i))|(0|(e=0|r[o>>2]))==(0|t)&&(A=(A+1|0)%6|0),3==(0|s)&(0|e)==(0|t)){A=(A+5|0)%6|0;break}5==(0|s)&(0|e)==(0|c)&&(A=(A+1|0)%6|0)}}while(0);return r[n>>2]=A,L=a,0|(n=0)}function Ot(e,t,n,i){n|=0,i|=0;var o,s,a,A,l,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0;if(l=L,L=L+32|0,v=l+24|0,A=l+20|0,a=l+8|0,s=l+16|0,o=l,d=(d=!(0|ze(e|=0,t|=0)))?6:5,g=0|rn(0|e,0|t,52),B(),d>>>0<=n>>>0)return L=l,0|(i=2);!(m=!(0|(g&=15)))&&!((b=0|on(7,0,3*(15^g)|0))&e|0)&!((0|B())&t)?c=n:u=4;e:do{if(4==(0|u)){if((0|((c=!!(0|ze(e,t)))?4:5))<(0|n))return L=l,0|(i=1);if(0|Ft(e,t,v))return L=l,0|(i=1);if(u=(0|r[v>>2])+n|0,7==(0|(b=0|r[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return L=l,0|(i=1);r[A>>2]=0,c=0|N(e,t,b,A,a);do{if(!c){if(p=0|r[(h=a)>>2],u=(f=(h=0|r[h+4>>2])>>>0<t>>>0|(0|h)==(0|t)&p>>>0<e>>>0)?p:e,f=f?h:t,!m&&!(p&(m=0|on(7,0,3*(15^g)|0))|0)&!(h&(0|B())))c=n;else{if(h=(n+-1+d|0)%(0|d)|0,c=0|ze(e,t),(0|h)<0&&M(27795,27797,248,27822),(0|((d=!!(0|c))?4:5))<(0|h)&&M(27795,27797,248,27822),0|Ft(e,t,v)&&M(27795,27797,248,27822),c=(0|r[v>>2])+h|0,7==(0|(h=0|r[(c=d?26704+((0|c)%5<<2)|0:26736+((0|c)%6<<2)|0)>>2]))&&M(27795,27797,248,27822),r[s>>2]=0,0|(c=0|N(e,t,h,s,o)))break;d=0|r[(p=o)>>2],p=0|r[p+4>>2];do{if(p>>>0<f>>>0|(0|p)==(0|f)&d>>>0<u>>>0){if(u=0|ze(d,p)?0|k(d,p,e,t):0|r[26800+(((0|r[s>>2])+(0|r[26768+(h<<2)>>2])|0)%6<<2)>>2],c=0|ze(d,p),(u+-1|0)>>>0>5){c=-1,u=d,f=p;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=d,f=p;break}do{if(!(0|Ft(d,p,v))){if(c){c=(5+(0|r[26352+(u<<2)>>2])-(0|r[v>>2])|0)%5|0;break}c=(6+(0|r[26384+(u<<2)>>2])-(0|r[v>>2])|0)%6|0;break}c=-1}while(0);u=d,f=p}else c=n}while(0);p=0|r[(h=a)>>2],h=0|r[h+4>>2]}if((0|u)==(0|p)&(0|f)==(0|h)){if(e=(d=!!(0|ze(p,h)))?0|k(p,h,e,t):0|r[26800+(((0|r[A>>2])+(0|r[26768+(b<<2)>>2])|0)%6<<2)>>2],c=0|ze(p,h),(e+-1|0)>>>0<=5&&!(1==(0|e)&(y=!!(0|c))))do{if(!(0|Ft(p,h,v))){if(y){c=(5+(0|r[26352+(e<<2)>>2])-(0|r[v>>2])|0)%5|0;break}c=(6+(0|r[26384+(e<<2)>>2])-(0|r[v>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|d&5==(0|c)?0:c}t=f,e=u;break e}}while(0);return L=l,0|(i=c)}}while(0);return y=0|on(0|c,0,56),v=B()|-2130706433&t|536870912,r[i>>2]=y|e,r[i+4>>2]=v,L=l,0|(i=0)}function Dt(e,t){e|=0;var n,i,o=0,s=0;return i=L,L=L+16|0,n=i,!0&536870912==(2013265920&(t|=0))&&0|Ne(e,o=-2130706433&t|134217728)?(s=0|rn(0|e,0|t,56),B(),o=(s=!(0|Ot(e,o,7&s,n)))&((0|r[(o=n)>>2])==(0|e)?(0|r[o+4>>2])==(0|t):0)&1,L=i,0|o):(L=i,0|(o=0))}function Nt(e,t,n){e|=0,n|=0;var i=0;(0|(t|=0))>0?(i=0|Kt(t,4),r[e>>2]=i,i||M(27835,27858,40,27872)):r[e>>2]=0,r[e+4>>2]=t,r[e+8>>2]=0,r[e+12>>2]=n}function Ut(e){var t,n,i,s=0,a=0,A=0,c=0;t=(e|=0)+4|0,n=e+12|0,i=e+8|0;e:for(;;){for(a=0|r[t>>2],s=0;;){if((0|s)>=(0|a))break e;if(A=0|r[e>>2],c=0|r[A+(s<<2)>>2])break;s=s+1|0}s=A+(~~(+l(+ +u(10,+ +(15-(0|r[n>>2])|0))*(+o[c>>3]+ +o[c+8>>3]))%+(0|a))>>>0<<2)|0,a=0|r[s>>2];t:do{if(0|a){if(A=c+32|0,(0|a)==(0|c))r[s>>2]=r[A>>2];else{if(!(s=0|r[(a=a+32|0)>>2]))break;for(;(0|s)!=(0|c);)if(!(s=0|r[(a=s+32|0)>>2]))break t;r[a>>2]=r[A>>2]}Jt(c),r[i>>2]=(0|r[i>>2])-1}}while(0)}Jt(0|r[e>>2])}function kt(e){var t,n=0,i=0;for(t=0|r[(e|=0)+4>>2],i=0;;){if((0|i)>=(0|t)){n=0,i=4;break}if(n=0|r[(0|r[e>>2])+(i<<2)>>2]){i=4;break}i=i+1|0}return 4==(0|i)?0|n:0}function Gt(e,t){t|=0;var n=0,i=0,s=0,a=0;if(n=~~(+l(+ +u(10,+ +(15-(0|r[(e|=0)+12>>2])|0))*(+o[t>>3]+ +o[t+8>>3]))%+(0|r[e+4>>2]))>>>0,n=(0|r[e>>2])+(n<<2)|0,!(i=0|r[n>>2]))return 0|(a=1);a=t+32|0;do{if((0|i)!=(0|t)){if(!(n=0|r[i+32>>2]))return 0|(a=1);for(s=n;;){if((0|s)==(0|t)){s=8;break}if(!(n=0|r[s+32>>2])){n=1,s=10;break}i=s,s=n}if(8==(0|s)){r[i+32>>2]=r[a>>2];break}if(10==(0|s))return 0|n}else r[n>>2]=r[a>>2]}while(0);return Jt(t),r[(a=e+8|0)>>2]=(0|r[a>>2])-1,0|(a=0)}function zt(e,t,n){e|=0,t|=0,n|=0;var i,s=0,a=0,A=0;(i=0|Qt(40))||M(27888,27858,98,27901),r[i>>2]=r[t>>2],r[i+4>>2]=r[t+4>>2],r[i+8>>2]=r[t+8>>2],r[i+12>>2]=r[t+12>>2],r[(a=i+16|0)>>2]=r[n>>2],r[a+4>>2]=r[n+4>>2],r[a+8>>2]=r[n+8>>2],r[a+12>>2]=r[n+12>>2],r[i+32>>2]=0,a=~~(+l(+ +u(10,+ +(15-(0|r[e+12>>2])|0))*(+o[t>>3]+ +o[t+8>>3]))%+(0|r[e+4>>2]))>>>0,a=(0|r[e>>2])+(a<<2)|0,s=0|r[a>>2];do{if(s){for(;!(0|st(s,t)&&0|st(s+16|0,n));)if(a=0|r[s+32>>2],!(0|r[(s=0|a?a:s)+32>>2])){A=10;break}if(10==(0|A)){r[s+32>>2]=i;break}return Jt(i),0|(A=s)}r[a>>2]=i}while(0);return r[(A=e+8|0)>>2]=1+(0|r[A>>2]),0|(A=i)}function Vt(e,t,n){t|=0,n|=0;var i=0,s=0;if(s=~~(+l(+ +u(10,+ +(15-(0|r[(e|=0)+12>>2])|0))*(+o[t>>3]+ +o[t+8>>3]))%+(0|r[e+4>>2]))>>>0,!(s=0|r[(0|r[e>>2])+(s<<2)>>2]))return 0|(n=0);if(!n){for(e=s;;){if(0|st(e,t)){i=10;break}if(!(e=0|r[e+32>>2])){e=0,i=10;break}}if(10==(0|i))return 0|e}for(e=s;;){if(0|st(e,t)&&0|st(e+16|0,n)){i=10;break}if(!(e=0|r[e+32>>2])){e=0,i=10;break}}return 10==(0|i)?0|e:0}function Ht(e,t){t|=0;var n=0;if(n=~~(+l(+ +u(10,+ +(15-(0|r[(e|=0)+12>>2])|0))*(+o[t>>3]+ +o[t+8>>3]))%+(0|r[e+4>>2]))>>>0,!(e=0|r[(0|r[e>>2])+(n<<2)>>2]))return 0|(n=0);for(;;){if(0|st(e,t)){t=5;break}if(!(e=0|r[e+32>>2])){e=0,t=5;break}}return 5==(0|t)?0|e:0}function jt(e){return 0|+fn(+(e=+e))}function Qt(e){e|=0;var t,n=0,i=0,o=0,s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0;t=L,L=L+16|0,d=t;do{if(e>>>0<245){if(e=(u=e>>>0<11?16:e+11&-8)>>>3,3&(i=(h=0|r[6981])>>>e))return o=0|r[(i=(e=27964+((n=(1&i^1)+e|0)<<1<<2)|0)+8|0)>>2],(0|(a=0|r[(s=o+8|0)>>2]))==(0|e)?r[6981]=h&~(1<<n):(r[a+12>>2]=e,r[i>>2]=a),C=n<<3,r[o+4>>2]=3|C,r[(C=o+C+4|0)>>2]=1|r[C>>2],L=t,0|(C=s);if(u>>>0>(f=0|r[6983])>>>0){if(0|i)return n=((n=i<<e&((n=2<<e)|0-n))&0-n)-1|0,a=0|r[(e=(n=27964+((o=((i=(n>>>=l=n>>>12&16)>>>5&8)|l|(a=(n>>>=i)>>>2&4)|(e=(n>>>=a)>>>1&2)|(o=(n>>>=e)>>>1&1))+(n>>>o)|0)<<1<<2)|0)+8|0)>>2],(0|(i=0|r[(l=a+8|0)>>2]))==(0|n)?(e=h&~(1<<o),r[6981]=e):(r[i+12>>2]=n,r[e>>2]=i,e=h),A=(C=o<<3)-u|0,r[a+4>>2]=3|u,r[(s=a+u|0)+4>>2]=1|A,r[a+C>>2]=A,0|f&&(o=0|r[6986],i=27964+((n=f>>>3)<<1<<2)|0,e&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6981]=e|n,n=i,e=i+8|0),r[e>>2]=o,r[n+12>>2]=o,r[o+8>>2]=n,r[o+12>>2]=i),r[6983]=A,r[6986]=s,L=t,0|(C=l);if(a=0|r[6982]){for(i=(a&0-a)-1|0,i=c=0|r[28228+(((o=(i>>>=s=i>>>12&16)>>>5&8)|s|(A=(i>>>=o)>>>2&4)|(l=(i>>>=A)>>>1&2)|(c=(i>>>=l)>>>1&1))+(i>>>c)<<2)>>2],l=c,c=(-8&r[c+4>>2])-u|0;(e=0|r[i+16>>2])||(e=0|r[i+20>>2]);)i=e,l=(s=(A=(-8&r[e+4>>2])-u|0)>>>0<c>>>0)?e:l,c=s?A:c;if((A=l+u|0)>>>0>l>>>0){s=0|r[l+24>>2],n=0|r[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|r[(e=l+20|0)>>2])&&!(n=0|r[(e=l+16|0)>>2])){i=0;break}for(;;)if(i=0|r[(o=n+20|0)>>2])n=i,e=o;else{if(!(i=0|r[(o=n+16|0)>>2]))break;n=i,e=o}r[e>>2]=0,i=n}else i=0|r[l+8>>2],r[i+12>>2]=n,r[n+8>>2]=i,i=n}while(0);do{if(0|s){if(n=0|r[l+28>>2],(0|l)==(0|r[(e=28228+(n<<2)|0)>>2])){if(r[e>>2]=i,!i){r[6982]=a&~(1<<n);break}}else if(r[((0|r[(C=s+16|0)>>2])==(0|l)?C:s+20)>>2]=i,!i)break;r[i+24>>2]=s,0|(n=0|r[l+16>>2])&&(r[i+16>>2]=n,r[n+24>>2]=i),0|(n=0|r[l+20>>2])&&(r[i+20>>2]=n,r[n+24>>2]=i)}}while(0);return c>>>0<16?(C=c+u|0,r[l+4>>2]=3|C,r[(C=l+C+4|0)>>2]=1|r[C>>2]):(r[l+4>>2]=3|u,r[A+4>>2]=1|c,r[A+c>>2]=c,0|f&&(o=0|r[6986],i=27964+((n=f>>>3)<<1<<2)|0,(n=1<<n)&h?n=0|r[(e=i+8|0)>>2]:(r[6981]=n|h,n=i,e=i+8|0),r[e>>2]=o,r[n+12>>2]=o,r[o+8>>2]=n,r[o+12>>2]=i),r[6983]=c,r[6986]=A),L=t,0|(C=l+8|0)}h=u}else h=u}else h=u}else if(e>>>0<=4294967231)if(u=-8&(e=e+11|0),o=0|r[6982]){s=0-u|0,c=(e>>>=8)?u>>>0>16777215?31:u>>>((c=14-((l=((m=e<<(h=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|h|(c=((m<<=l)+245760|0)>>>16&2))+(m<<c>>>15)|0)+7|0)&1|c<<1:0,i=0|r[28228+(c<<2)>>2];e:do{if(i)for(e=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),a=0;;){if((A=(-8&r[i+4>>2])-u|0)>>>0<s>>>0){if(!A){e=i,s=0,m=65;break e}e=i,s=A}if(a=!(0|(m=0|r[i+20>>2]))|(0|m)==(0|(i=0|r[i+16+(l>>>31<<2)>>2]))?a:m,!i){i=a,m=61;break}l<<=1}else i=0,e=0,m=61}while(0);if(61==(0|m)){if(!(0|i)&!(0|e)){if(!(e=((e=2<<c)|0-e)&o)){h=u;break}h=(e&0-e)-1|0,e=0,i=0|r[28228+(((a=(h>>>=A=h>>>12&16)>>>5&8)|A|(l=(h>>>=a)>>>2&4)|(c=(h>>>=l)>>>1&2)|(i=(h>>>=c)>>>1&1))+(h>>>i)<<2)>>2]}i?m=65:(l=e,A=s)}if(65==(0|m))for(a=i;;){if(s=(i=(h=(-8&r[a+4>>2])-u|0)>>>0<s>>>0)?h:s,e=i?a:e,(i=0|r[a+16>>2])||(i=0|r[a+20>>2]),!i){l=e,A=s;break}a=i}if(0|l&&A>>>0<((0|r[6983])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){a=0|r[l+24>>2],n=0|r[l+12>>2];do{if((0|n)==(0|l)){if(!(n=0|r[(e=l+20|0)>>2])&&!(n=0|r[(e=l+16|0)>>2])){n=0;break}for(;;)if(i=0|r[(s=n+20|0)>>2])n=i,e=s;else{if(!(i=0|r[(s=n+16|0)>>2]))break;n=i,e=s}r[e>>2]=0}else C=0|r[l+8>>2],r[C+12>>2]=n,r[n+8>>2]=C}while(0);do{if(a){if(e=0|r[l+28>>2],(0|l)==(0|r[(i=28228+(e<<2)|0)>>2])){if(r[i>>2]=n,!n){o&=~(1<<e),r[6982]=o;break}}else if(r[((0|r[(C=a+16|0)>>2])==(0|l)?C:a+20)>>2]=n,!n)break;r[n+24>>2]=a,0|(e=0|r[l+16>>2])&&(r[n+16>>2]=e,r[e+24>>2]=n),(e=0|r[l+20>>2])&&(r[n+20>>2]=e,r[e+24>>2]=n)}}while(0);e:do{if(A>>>0<16)C=A+u|0,r[l+4>>2]=3|C,r[(C=l+C+4|0)>>2]=1|r[C>>2];else{if(r[l+4>>2]=3|u,r[f+4>>2]=1|A,r[f+A>>2]=A,n=A>>>3,A>>>0<256){i=27964+(n<<1<<2)|0,(e=0|r[6981])&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6981]=e|n,n=i,e=i+8|0),r[e>>2]=f,r[n+12>>2]=f,r[f+8>>2]=n,r[f+12>>2]=i;break}if(n=28228+((i=(n=A>>>8)?A>>>0>16777215?31:A>>>((i=14-((v=((C=n<<(_=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|_|(i=((C<<=v)+245760|0)>>>16&2))+(C<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,r[f+28>>2]=i,r[(e=f+16|0)+4>>2]=0,r[e>>2]=0,!(o&(e=1<<i))){r[6982]=o|e,r[n>>2]=f,r[f+24>>2]=n,r[f+12>>2]=f,r[f+8>>2]=f;break}n=0|r[n>>2];t:do{if((-8&r[n+4>>2])!=(0|A)){for(o=A<<(31==(0|i)?0:25-(i>>>1)|0);e=0|r[(i=n+16+(o>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|A)){n=e;break t}o<<=1,n=e}r[i>>2]=f,r[f+24>>2]=n,r[f+12>>2]=f,r[f+8>>2]=f;break e}}while(0);C=0|r[(_=n+8|0)>>2],r[C+12>>2]=f,r[_>>2]=f,r[f+8>>2]=C,r[f+12>>2]=n,r[f+24>>2]=0}}while(0);return L=t,0|(C=l+8|0)}h=u}else h=u;else h=-1}while(0);if((i=0|r[6983])>>>0>=h>>>0)return n=i-h|0,e=0|r[6986],n>>>0>15?(C=e+h|0,r[6986]=C,r[6983]=n,r[C+4>>2]=1|n,r[e+i>>2]=n,r[e+4>>2]=3|h):(r[6983]=0,r[6986]=0,r[e+4>>2]=3|i,r[(C=e+i+4|0)>>2]=1|r[C>>2]),L=t,0|(C=e+8|0);if((A=0|r[6984])>>>0>h>>>0)return v=A-h|0,r[6984]=v,_=(C=0|r[6987])+h|0,r[6987]=_,r[_+4>>2]=1|v,r[C+4>>2]=3|h,L=t,0|(C=C+8|0);if(0|r[7099]?e=0|r[7101]:(r[7101]=4096,r[7100]=4096,r[7102]=-1,r[7103]=-1,r[7104]=0,r[7092]=0,r[7099]=-16&d^1431655768,e=4096),l=h+48|0,(u=(a=e+(c=h+47|0)|0)&(s=0-e|0))>>>0<=h>>>0)return L=t,0|(C=0);if(0|(e=0|r[7091])&&(d=(f=0|r[7089])+u|0)>>>0<=f>>>0|d>>>0>e>>>0)return L=t,0|(C=0);e:do{if(4&r[7092])n=0,m=143;else{i=0|r[6987];t:do{if(i){for(o=28372;!((d=0|r[o>>2])>>>0<=i>>>0&&(d+(0|r[o+4>>2])|0)>>>0>i>>>0);){if(!(e=0|r[o+8>>2])){m=128;break t}o=e}if((n=a-A&s)>>>0<2147483647)if((0|(e=0|hn(0|n)))==((0|r[o>>2])+(0|r[o+4>>2])|0)){if(-1!=(0|e)){A=n,a=e,m=145;break e}}else o=e,m=136;else n=0}else m=128}while(0);do{if(128==(0|m))if(-1!=(0|(i=0|hn(0)))&&(n=i,g=(n=((g=(p=0|r[7100])+-1|0)&n|0?(g+n&0-p)-n|0:0)+u|0)+(p=0|r[7089])|0,n>>>0>h>>>0&n>>>0<2147483647)){if(0|(d=0|r[7091])&&g>>>0<=p>>>0|g>>>0>d>>>0){n=0;break}if((0|(e=0|hn(0|n)))==(0|i)){A=n,a=i,m=145;break e}o=e,m=136}else n=0}while(0);do{if(136==(0|m)){if(i=0-n|0,!(l>>>0>n>>>0&n>>>0<2147483647&-1!=(0|o))){if(-1==(0|o)){n=0;break}A=n,a=o,m=145;break e}if((e=c-n+(e=0|r[7101])&0-e)>>>0>=2147483647){A=n,a=o,m=145;break e}if(-1==(0|hn(0|e))){hn(0|i),n=0;break}A=e+n|0,a=o,m=145;break e}}while(0);r[7092]=4|r[7092],m=143}}while(0);if(143==(0|m)&&u>>>0<2147483647&&!(-1==(0|(v=0|hn(0|u)))|1^(y=(b=(g=0|hn(0))-v|0)>>>0>(h+40|0)>>>0)|v>>>0<g>>>0&-1!=(0|v)&-1!=(0|g)^1)&&(A=y?b:n,a=v,m=145),145==(0|m)){n=(0|r[7089])+A|0,r[7089]=n,n>>>0>(0|r[7090])>>>0&&(r[7090]=n),c=0|r[6987];e:do{if(c){for(n=28372;;){if((0|a)==((e=0|r[n>>2])+(i=0|r[n+4>>2])|0)){m=154;break}if(!(o=0|r[n+8>>2]))break;n=o}if(!(154!=(0|m)||(_=n+4|0,8&r[n+12>>2]))&&a>>>0>c>>>0&e>>>0<=c>>>0){r[_>>2]=i+A,_=c+(v=7&(v=c+8|0)?0-v&7:0)|0,v=(C=(0|r[6984])+A|0)-v|0,r[6987]=_,r[6984]=v,r[_+4>>2]=1|v,r[c+C+4>>2]=40,r[6988]=r[7103];break}for(a>>>0<(0|r[6985])>>>0&&(r[6985]=a),i=a+A|0,n=28372;;){if((0|r[n>>2])==(0|i)){m=162;break}if(!(e=0|r[n+8>>2]))break;n=e}if(162==(0|m)&&!(8&r[n+12>>2])){r[n>>2]=a,r[(f=n+4|0)>>2]=(0|r[f>>2])+A,u=(f=a+(7&(f=a+8|0)?0-f&7:0)|0)+h|0,l=(n=i+(7&(n=i+8|0)?0-n&7:0)|0)-f-h|0,r[f+4>>2]=3|h;t:do{if((0|c)==(0|n))C=(0|r[6984])+l|0,r[6984]=C,r[6987]=u,r[u+4>>2]=1|C;else{if((0|r[6986])==(0|n)){C=(0|r[6983])+l|0,r[6983]=C,r[6986]=u,r[u+4>>2]=1|C,r[u+C>>2]=C;break}if(1==(3&(e=0|r[n+4>>2]))){A=-8&e,o=e>>>3;n:do{if(e>>>0<256){if(e=0|r[n+8>>2],(0|(i=0|r[n+12>>2]))==(0|e)){r[6981]=r[6981]&~(1<<o);break}r[e+12>>2]=i,r[i+8>>2]=e;break}a=0|r[n+24>>2],e=0|r[n+12>>2];do{if((0|e)==(0|n)){if(e=0|r[(o=(i=n+16|0)+4|0)>>2])i=o;else if(!(e=0|r[i>>2])){e=0;break}for(;;)if(o=0|r[(s=e+20|0)>>2])e=o,i=s;else{if(!(o=0|r[(s=e+16|0)>>2]))break;e=o,i=s}r[i>>2]=0}else C=0|r[n+8>>2],r[C+12>>2]=e,r[e+8>>2]=C}while(0);if(!a)break;o=28228+((i=0|r[n+28>>2])<<2)|0;do{if((0|r[o>>2])==(0|n)){if(r[o>>2]=e,0|e)break;r[6982]=r[6982]&~(1<<i);break n}if(r[((0|r[(C=a+16|0)>>2])==(0|n)?C:a+20)>>2]=e,!e)break n}while(0);if(r[e+24>>2]=a,0|(o=0|r[(i=n+16|0)>>2])&&(r[e+16>>2]=o,r[o+24>>2]=e),!(i=0|r[i+4>>2]))break;r[e+20>>2]=i,r[i+24>>2]=e}while(0);n=n+A|0,s=A+l|0}else s=l;if(r[(n=n+4|0)>>2]=-2&r[n>>2],r[u+4>>2]=1|s,r[u+s>>2]=s,n=s>>>3,s>>>0<256){i=27964+(n<<1<<2)|0,(e=0|r[6981])&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6981]=e|n,n=i,e=i+8|0),r[e>>2]=u,r[n+12>>2]=u,r[u+8>>2]=n,r[u+12>>2]=i;break}n=s>>>8;do{if(n){if(s>>>0>16777215){o=31;break}o=s>>>((o=14-((v=((C=n<<(_=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|_|(o=((C<<=v)+245760|0)>>>16&2))+(C<<o>>>15)|0)+7|0)&1|o<<1}else o=0}while(0);if(n=28228+(o<<2)|0,r[u+28>>2]=o,r[(e=u+16|0)+4>>2]=0,r[e>>2]=0,!((e=0|r[6982])&(i=1<<o))){r[6982]=e|i,r[n>>2]=u,r[u+24>>2]=n,r[u+12>>2]=u,r[u+8>>2]=u;break}n=0|r[n>>2];n:do{if((-8&r[n+4>>2])!=(0|s)){for(o=s<<(31==(0|o)?0:25-(o>>>1)|0);e=0|r[(i=n+16+(o>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|s)){n=e;break n}o<<=1,n=e}r[i>>2]=u,r[u+24>>2]=n,r[u+12>>2]=u,r[u+8>>2]=u;break t}}while(0);C=0|r[(_=n+8|0)>>2],r[C+12>>2]=u,r[_>>2]=u,r[u+8>>2]=C,r[u+12>>2]=n,r[u+24>>2]=0}}while(0);return L=t,0|(C=f+8|0)}for(n=28372;!((e=0|r[n>>2])>>>0<=c>>>0&&(C=e+(0|r[n+4>>2])|0)>>>0>c>>>0);)n=0|r[n+8>>2];n=(e=(e=(s=C+-47|0)+(7&(e=s+8|0)?0-e&7:0)|0)>>>0<(s=c+16|0)>>>0?c:e)+8|0,_=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(i=A+-40|0)-v|0,r[6987]=_,r[6984]=v,r[_+4>>2]=1|v,r[a+i+4>>2]=40,r[6988]=r[7103],r[(i=e+4|0)>>2]=27,r[n>>2]=r[7093],r[n+4>>2]=r[7094],r[n+8>>2]=r[7095],r[n+12>>2]=r[7096],r[7093]=a,r[7094]=A,r[7096]=0,r[7095]=n,n=e+24|0;do{_=n,r[(n=n+4|0)>>2]=7}while((_+8|0)>>>0<C>>>0);if((0|e)!=(0|c)){if(a=e-c|0,r[i>>2]=-2&r[i>>2],r[c+4>>2]=1|a,r[e>>2]=a,n=a>>>3,a>>>0<256){i=27964+(n<<1<<2)|0,(e=0|r[6981])&(n=1<<n)?n=0|r[(e=i+8|0)>>2]:(r[6981]=e|n,n=i,e=i+8|0),r[e>>2]=c,r[n+12>>2]=c,r[c+8>>2]=n,r[c+12>>2]=i;break}if(i=28228+((o=(n=a>>>8)?a>>>0>16777215?31:a>>>((o=14-((v=((C=n<<(_=(n+1048320|0)>>>16&8))+520192|0)>>>16&4)|_|(o=((C<<=v)+245760|0)>>>16&2))+(C<<o>>>15)|0)+7|0)&1|o<<1:0)<<2)|0,r[c+28>>2]=o,r[c+20>>2]=0,r[s>>2]=0,!((n=0|r[6982])&(e=1<<o))){r[6982]=n|e,r[i>>2]=c,r[c+24>>2]=i,r[c+12>>2]=c,r[c+8>>2]=c;break}n=0|r[i>>2];t:do{if((-8&r[n+4>>2])!=(0|a)){for(o=a<<(31==(0|o)?0:25-(o>>>1)|0);e=0|r[(i=n+16+(o>>>31<<2)|0)>>2];){if((-8&r[e+4>>2])==(0|a)){n=e;break t}o<<=1,n=e}r[i>>2]=c,r[c+24>>2]=n,r[c+12>>2]=c,r[c+8>>2]=c;break e}}while(0);C=0|r[(_=n+8|0)>>2],r[C+12>>2]=c,r[_>>2]=c,r[c+8>>2]=C,r[c+12>>2]=n,r[c+24>>2]=0}}else!(0|(C=0|r[6985]))|a>>>0<C>>>0&&(r[6985]=a),r[7093]=a,r[7094]=A,r[7096]=0,r[6990]=r[7099],r[6989]=-1,r[6994]=27964,r[6993]=27964,r[6996]=27972,r[6995]=27972,r[6998]=27980,r[6997]=27980,r[7e3]=27988,r[6999]=27988,r[7002]=27996,r[7001]=27996,r[7004]=28004,r[7003]=28004,r[7006]=28012,r[7005]=28012,r[7008]=28020,r[7007]=28020,r[7010]=28028,r[7009]=28028,r[7012]=28036,r[7011]=28036,r[7014]=28044,r[7013]=28044,r[7016]=28052,r[7015]=28052,r[7018]=28060,r[7017]=28060,r[7020]=28068,r[7019]=28068,r[7022]=28076,r[7021]=28076,r[7024]=28084,r[7023]=28084,r[7026]=28092,r[7025]=28092,r[7028]=28100,r[7027]=28100,r[7030]=28108,r[7029]=28108,r[7032]=28116,r[7031]=28116,r[7034]=28124,r[7033]=28124,r[7036]=28132,r[7035]=28132,r[7038]=28140,r[7037]=28140,r[7040]=28148,r[7039]=28148,r[7042]=28156,r[7041]=28156,r[7044]=28164,r[7043]=28164,r[7046]=28172,r[7045]=28172,r[7048]=28180,r[7047]=28180,r[7050]=28188,r[7049]=28188,r[7052]=28196,r[7051]=28196,r[7054]=28204,r[7053]=28204,r[7056]=28212,r[7055]=28212,_=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(C=A+-40|0)-v|0,r[6987]=_,r[6984]=v,r[_+4>>2]=1|v,r[a+C+4>>2]=40,r[6988]=r[7103]}while(0);if((n=0|r[6984])>>>0>h>>>0)return v=n-h|0,r[6984]=v,_=(C=0|r[6987])+h|0,r[6987]=_,r[_+4>>2]=1|v,r[C+4>>2]=3|h,L=t,0|(C=C+8|0)}return r[(C=27920)>>2]=12,L=t,0|(C=0)}function Jt(e){var t=0,n=0,i=0,o=0,s=0,a=0,A=0,l=0;if(e|=0){n=e+-8|0,o=0|r[6985],l=n+(t=-8&(e=0|r[e+-4>>2]))|0;do{if(1&e)A=n,a=n;else{if(i=0|r[n>>2],!(3&e))return;if(s=i+t|0,(a=n+(0-i)|0)>>>0<o>>>0)return;if((0|r[6986])==(0|a)){if(3&~(t=0|r[(e=l+4|0)>>2])){A=a,t=s;break}return r[6983]=s,r[e>>2]=-2&t,r[a+4>>2]=1|s,void(r[a+s>>2]=s)}if(n=i>>>3,i>>>0<256){if(e=0|r[a+8>>2],(0|(t=0|r[a+12>>2]))==(0|e)){r[6981]=r[6981]&~(1<<n),A=a,t=s;break}r[e+12>>2]=t,r[t+8>>2]=e,A=a,t=s;break}o=0|r[a+24>>2],e=0|r[a+12>>2];do{if((0|e)==(0|a)){if(e=0|r[(n=(t=a+16|0)+4|0)>>2])t=n;else if(!(e=0|r[t>>2])){e=0;break}for(;;)if(n=0|r[(i=e+20|0)>>2])e=n,t=i;else{if(!(n=0|r[(i=e+16|0)>>2]))break;e=n,t=i}r[t>>2]=0}else A=0|r[a+8>>2],r[A+12>>2]=e,r[e+8>>2]=A}while(0);if(o){if(t=0|r[a+28>>2],(0|r[(n=28228+(t<<2)|0)>>2])==(0|a)){if(r[n>>2]=e,!e){r[6982]=r[6982]&~(1<<t),A=a,t=s;break}}else if(r[((0|r[(A=o+16|0)>>2])==(0|a)?A:o+20)>>2]=e,!e){A=a,t=s;break}r[e+24>>2]=o,0|(n=0|r[(t=a+16|0)>>2])&&(r[e+16>>2]=n,r[n+24>>2]=e),(t=0|r[t+4>>2])?(r[e+20>>2]=t,r[t+24>>2]=e,A=a,t=s):(A=a,t=s)}else A=a,t=s}}while(0);if(!(a>>>0>=l>>>0)&&1&(i=0|r[(e=l+4|0)>>2])){if(2&i)r[e>>2]=-2&i,r[A+4>>2]=1|t,r[a+t>>2]=t,o=t;else{if((0|r[6987])==(0|l)){if(l=(0|r[6984])+t|0,r[6984]=l,r[6987]=A,r[A+4>>2]=1|l,(0|A)!=(0|r[6986]))return;return r[6986]=0,void(r[6983]=0)}if((0|r[6986])==(0|l))return l=(0|r[6983])+t|0,r[6983]=l,r[6986]=a,r[A+4>>2]=1|l,void(r[a+l>>2]=l);o=(-8&i)+t|0,n=i>>>3;do{if(i>>>0<256){if(t=0|r[l+8>>2],(0|(e=0|r[l+12>>2]))==(0|t)){r[6981]=r[6981]&~(1<<n);break}r[t+12>>2]=e,r[e+8>>2]=t;break}s=0|r[l+24>>2],e=0|r[l+12>>2];do{if((0|e)==(0|l)){if(e=0|r[(n=(t=l+16|0)+4|0)>>2])t=n;else if(!(e=0|r[t>>2])){n=0;break}for(;;)if(n=0|r[(i=e+20|0)>>2])e=n,t=i;else{if(!(n=0|r[(i=e+16|0)>>2]))break;e=n,t=i}r[t>>2]=0,n=e}else n=0|r[l+8>>2],r[n+12>>2]=e,r[e+8>>2]=n,n=e}while(0);if(0|s){if(e=0|r[l+28>>2],(0|r[(t=28228+(e<<2)|0)>>2])==(0|l)){if(r[t>>2]=n,!n){r[6982]=r[6982]&~(1<<e);break}}else if(r[((0|r[(i=s+16|0)>>2])==(0|l)?i:s+20)>>2]=n,!n)break;r[n+24>>2]=s,0|(t=0|r[(e=l+16|0)>>2])&&(r[n+16>>2]=t,r[t+24>>2]=n),0|(e=0|r[e+4>>2])&&(r[n+20>>2]=e,r[e+24>>2]=n)}}while(0);if(r[A+4>>2]=1|o,r[a+o>>2]=o,(0|A)==(0|r[6986]))return void(r[6983]=o)}if(e=o>>>3,o>>>0<256)return n=27964+(e<<1<<2)|0,(t=0|r[6981])&(e=1<<e)?e=0|r[(t=n+8|0)>>2]:(r[6981]=t|e,e=n,t=n+8|0),r[t>>2]=A,r[e+12>>2]=A,r[A+8>>2]=e,void(r[A+12>>2]=n);e=28228+((i=(e=o>>>8)?o>>>0>16777215?31:o>>>((i=14-((s=((l=e<<(a=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(i=((l<<=s)+245760|0)>>>16&2))+(l<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,r[A+28>>2]=i,r[A+20>>2]=0,r[A+16>>2]=0,t=0|r[6982],n=1<<i;e:do{if(t&n){e=0|r[e>>2];t:do{if((-8&r[e+4>>2])!=(0|o)){for(i=o<<(31==(0|i)?0:25-(i>>>1)|0);t=0|r[(n=e+16+(i>>>31<<2)|0)>>2];){if((-8&r[t+4>>2])==(0|o)){e=t;break t}i<<=1,e=t}r[n>>2]=A,r[A+24>>2]=e,r[A+12>>2]=A,r[A+8>>2]=A;break e}}while(0);l=0|r[(a=e+8|0)>>2],r[l+12>>2]=A,r[a>>2]=A,r[A+8>>2]=l,r[A+12>>2]=e,r[A+24>>2]=0}else r[6982]=t|n,r[e>>2]=A,r[A+24>>2]=e,r[A+12>>2]=A,r[A+8>>2]=A}while(0);if(l=(0|r[6989])-1|0,r[6989]=l,!(0|l)){for(e=28380;e=0|r[e>>2];)e=e+8|0;r[6989]=-1}}}}function Kt(e,t){t|=0;var n=0;return(e|=0)?(n=0|v(t,e),(t|e)>>>0>65535&&(n=((n>>>0)/(e>>>0)|0)==(0|t)?n:-1)):n=0,(e=0|Qt(n))&&3&r[e+-4>>2]?(un(0|e,0,0|n),0|e):0|e}function Wt(e,t,n,i){return 0|(w((t|=0)+(i|=0)+((n=(e|=0)+(n|=0)>>>0)>>>0<e>>>0|0)>>>0|0),n)}function qt(e,t,n,i){return 0|(w(0|(i=(t|=0)-(i|=0)-((n|=0)>>>0>(e|=0)>>>0|0)>>>0)),e-n>>>0)}function Yt(e){return 0|((e|=0)?31-(0|x(e^e-1)):32)}function Xt(e,t,n,i,o){o|=0;var s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0;if(u=e|=0,a=n|=0,A=h=i|=0,!(c=l=t|=0))return s=!!(0|o),A?s?(r[o>>2]=0|e,r[o+4>>2]=0&t,o=0,0|(w(0|(h=0)),o)):(o=0,0|(w(0|(h=0)),o)):(s&&(r[o>>2]=(u>>>0)%(a>>>0),r[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(w(0|(h=0)),o));s=!(0|A);do{if(a){if(!s){if((s=(0|x(0|A))-(0|x(0|c))|0)>>>0<=31){a=f=s+1|0,e=u>>>(f>>>0)&(t=s-31>>31)|c<<(A=31-s|0),t&=c>>>(f>>>0),s=0,A=u<<A;break}return o?(r[o>>2]=0|e,r[o+4>>2]=l|0&t,o=0,0|(w(0|(h=0)),o)):(o=0,0|(w(0|(h=0)),o))}if((s=a-1|0)&a|0){a=A=33+(0|x(0|a))-(0|x(0|c))|0,e=(f=32-A|0)-1>>31&c>>>((d=A-32|0)>>>0)|(c<<f|u>>>(A>>>0))&(t=d>>31),t&=c>>>(A>>>0),s=u<<(p=64-A|0)&(l=f>>31),A=(c<<p|u>>>(d>>>0))&l|u<<f&A-33>>31;break}return 0|o&&(r[o>>2]=s&u,r[o+4>>2]=0),1==(0|a)?(p=0|e,0|(w(0|(d=l|0&t)),p)):(d=c>>>((p=0|Yt(0|a))>>>0)|0,p=c<<32-p|u>>>(p>>>0),0|(w(0|d),p))}if(s)return 0|o&&(r[o>>2]=(c>>>0)%(a>>>0),r[o+4>>2]=0),p=(c>>>0)/(a>>>0)>>>0,0|(w(0|(d=0)),p);if(!u)return 0|o&&(r[o>>2]=0,r[o+4>>2]=(c>>>0)%(A>>>0)),p=(c>>>0)/(A>>>0)>>>0,0|(w(0|(d=0)),p);if(!((s=A-1|0)&A))return 0|o&&(r[o>>2]=0|e,r[o+4>>2]=s&c|0&t),d=0,p=c>>>((0|Yt(0|A))>>>0),0|(w(0|d),p);if((s=(0|x(0|A))-(0|x(0|c))|0)>>>0<=30){a=t=s+1|0,e=c<<(A=31-s|0)|u>>>(t>>>0),t=c>>>(t>>>0),s=0,A=u<<A;break}return o?(r[o>>2]=0|e,r[o+4>>2]=l|0&t,p=0,0|(w(0|(d=0)),p)):(p=0,0|(w(0|(d=0)),p))}while(0);if(a){c=0|Wt(0|(f=0|n),0|(u=h|0&i),-1,-1),n=0|B(),l=A,A=0;do{i=l,l=s>>>31|l<<1,s=A|s<<1,qt(0|c,0|n,0|(i=e<<1|i>>>31),0|(h=e>>>31|t<<1)),A=1&(d=(p=0|B())>>31|((0|p)<0?-1:0)<<1),e=0|qt(0|i,0|h,d&f|0,(((0|p)<0?-1:0)>>31|((0|p)<0?-1:0)<<1)&u),t=0|B(),a=a-1|0}while(0|a);c=l,l=0}else c=A,l=0,A=0;return a=0,0|o&&(r[o>>2]=e,r[o+4>>2]=t),p=s<<1&-2|A,0|(w(0|(d=(0|s)>>>31|(c|a)<<1|l)),p)}function Zt(e,t,n,i){n|=0;var r,o,s,a,A;return o=(i|=0)>>31|((0|i)<0?-1:0)<<1,r=((0|i)<0?-1:0)>>31|((0|i)<0?-1:0)<<1,s=0|qt((A=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(a=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|A,0|a),e=o^A,t=r^a,0|qt((0|Xt(s,0|B(),0|qt(o^n|0,r^i|0,0|o,0|r),0|B(),0))^e,(0|B())^t,0|e,0|t)}function $t(e,t,n,i){t|=0,i|=0;var r,o;return n=0|function(e,t){var n,i,r,o=0;return e=((n=0|v(o=65535&(t|=0),r=65535&(e|=0)))>>>16)+(0|v(o,i=e>>>16))|0,t=0|v(o=t>>>16,r),0|(w((e>>>16)+(0|v(o,i))+(((65535&e)+t|0)>>>16)|0),e+t<<16|65535&n)}(r=e|=0,o=n|=0),e=0|B(),0|(w((0|v(t,o))+(0|v(i,r))+e|0&e),n)}function en(e,t,n,i){n|=0;var o,s,a,A,l,c;return o=L,L=L+16|0,A=0|o,c=(i|=0)>>31|((0|i)<0?-1:0)<<1,l=((0|i)<0?-1:0)>>31|((0|i)<0?-1:0)<<1,Xt(e=0|qt((a=(t|=0)>>31|((0|t)<0?-1:0)<<1)^(e|=0)|0,(s=((0|t)<0?-1:0)>>31|((0|t)<0?-1:0)<<1)^t|0,0|a,0|s),t=0|B(),0|qt(c^n|0,l^i|0,0|c,0|l),0|B(),A),i=0|qt(r[A>>2]^a|0,r[A+4>>2]^s|0,0|a,0|s),n=0|B(),L=o,0|(w(0|n),i)}function tn(e,t,n,i){var o,s;return s=L,L=L+16|0,Xt(e|=0,t|=0,n|=0,i|=0,o=0|s),L=s,0|(w(0|r[o+4>>2]),r[o>>2])}function nn(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(w(t>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(w(0|((0|t)<0?-1:0)),t>>n-32)}function rn(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(w(t>>>n|0),e>>>n|(t&(1<<n)-1)<<32-n):(w(0),t>>>n-32|0)}function on(e,t,n){return e|=0,t|=0,(0|(n|=0))<32?(w(t<<n|(e&(1<<n)-1<<32-n)>>>32-n),e<<n):(w(e<<n-32),0)}function sn(e,t,n){return e|=0,32==(0|(t=0|x(t|=0)))&&(t=t+(0|x(e))|0),w(0),0|t}function an(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+C(+e,+t)}function An(e,t){return t=+t,(e=+e)!=e?+t:t!=t?+e:+_(+e,+t)}function ln(e){return(e=+e)>=0?+A(e+.5):+y(e-.5)}function cn(e,t,n){e|=0,t|=0;var o,s,a=0;if((0|(n|=0))>=8192)return E(0|e,0|t,0|n),0|e;if(s=0|e,o=e+n|0,(3&e)==(3&t)){for(;3&e;){if(!n)return 0|s;i[e|0]=0|i[t|0],e=e+1|0,t=t+1|0,n=n-1|0}for(a=(n=-4&o)-64|0;(0|e)<=(0|a);)r[e>>2]=r[t>>2],r[e+4>>2]=r[t+4>>2],r[e+8>>2]=r[t+8>>2],r[e+12>>2]=r[t+12>>2],r[e+16>>2]=r[t+16>>2],r[e+20>>2]=r[t+20>>2],r[e+24>>2]=r[t+24>>2],r[e+28>>2]=r[t+28>>2],r[e+32>>2]=r[t+32>>2],r[e+36>>2]=r[t+36>>2],r[e+40>>2]=r[t+40>>2],r[e+44>>2]=r[t+44>>2],r[e+48>>2]=r[t+48>>2],r[e+52>>2]=r[t+52>>2],r[e+56>>2]=r[t+56>>2],r[e+60>>2]=r[t+60>>2],e=e+64|0,t=t+64|0;for(;(0|e)<(0|n);)r[e>>2]=r[t>>2],e=e+4|0,t=t+4|0}else for(n=o-4|0;(0|e)<(0|n);)i[e|0]=0|i[t|0],i[e+1|0]=0|i[t+1|0],i[e+2|0]=0|i[t+2|0],i[e+3|0]=0|i[t+3|0],e=e+4|0,t=t+4|0;for(;(0|e)<(0|o);)i[e|0]=0|i[t|0],e=e+1|0,t=t+1|0;return 0|s}function un(e,t,n){t|=0;var o,s=0,a=0,A=0;if(o=(e|=0)+(n|=0)|0,t&=255,(0|n)>=67){for(;3&e;)i[e|0]=t,e=e+1|0;for(A=t|t<<8|t<<16|t<<24,a=(s=-4&o)-64|0;(0|e)<=(0|a);)r[e>>2]=A,r[e+4>>2]=A,r[e+8>>2]=A,r[e+12>>2]=A,r[e+16>>2]=A,r[e+20>>2]=A,r[e+24>>2]=A,r[e+28>>2]=A,r[e+32>>2]=A,r[e+36>>2]=A,r[e+40>>2]=A,r[e+44>>2]=A,r[e+48>>2]=A,r[e+52>>2]=A,r[e+56>>2]=A,r[e+60>>2]=A,e=e+64|0;for(;(0|e)<(0|s);)r[e>>2]=A,e=e+4|0}for(;(0|e)<(0|o);)i[e|0]=t,e=e+1|0;return o-n|0}function fn(e){return(e=+e)>=0?+A(e+.5):+y(e-.5)}function hn(e){e|=0;var t,n,i;return i=0|T(),(0|e)>0&(0|(t=(n=0|r[a>>2])+e|0))<(0|n)|(0|t)<0?(I(0|t),S(12),-1):(0|t)>(0|i)&&!(0|P(0|t))?(S(12),-1):(r[a>>2]=t,0|n)}return{___divdi3:Zt,___muldi3:$t,___remdi3:en,___uremdi3:tn,_areNeighborCells:function(e,t,n,i,o){o|=0;var s,a,A,l=0,c=0,u=0,f=0;if(A=L,L=L+64|0,a=A,s=A+56|0,!(!0&134217728==(2013265920&(t|=0))&!0&134217728==(2013265920&(i|=0))))return L=A,0|(o=5);if((0|(e|=0))==(0|(n|=0))&(0|t)==(0|i))return r[o>>2]=0,L=A,0|(o=0);if(c=0|rn(0|e,0|t,52),B(),c&=15,f=0|rn(0|n,0|i,52),B(),(0|c)!=(15&f))return L=A,0|(o=12);if(l=c+-1|0,c>>>0>1){ke(e,t,l,a),ke(n,i,l,s),u=0|r[(f=a)>>2],f=0|r[f+4>>2];e:do{if((0|u)==(0|r[s>>2])&&(0|f)==(0|r[s+4>>2])){l=0|rn(0|e,0|t,0|(c=3*(15^c)|0)),B(),l&=7,c=0|rn(0|n,0|i,0|c),B(),c&=7;do{if(!(0|l)|!(0|c))r[o>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|ze(u,f)){l=5;break}if((0|r[15536+(l<<2)>>2])!=(0|c)&&(0|r[15568+(l<<2)>>2])!=(0|c))break e;r[o>>2]=1,l=0}}while(0);return L=A,0|(o=l)}}while(0)}c=(l=a)+56|0;do{r[l>>2]=0,l=l+4|0}while((0|l)<(0|c));return R(e,t,1,a),l=(0|r[(t=a)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+8|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+16|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+24|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+32|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)||(0|r[(t=a+40|0)>>2])==(0|n)&&(0|r[t+4>>2])==(0|i)?1:1&((0|r[(l=a+48|0)>>2])==(0|n)?(0|r[l+4>>2])==(0|i):0),r[o>>2]=l,L=A,0|(o=0)},_bitshift64Ashr:nn,_bitshift64Lshr:rn,_bitshift64Shl:on,_calloc:Kt,_cellAreaKm2:function(e,t,n){return 0|(e=0|ft(e|=0,t|=0,n|=0))||(o[n>>3]=6371.007180918475*+o[n>>3]*6371.007180918475),0|e},_cellAreaM2:function(e,t,n){return 0|(e=0|ft(e|=0,t|=0,n|=0))||(o[n>>3]=6371.007180918475*+o[n>>3]*6371.007180918475*1e3*1e3),0|e},_cellAreaRads2:ft,_cellToBoundary:et,_cellToCenterChild:He,_cellToChildPos:function(e,t,n,i){n|=0,i|=0;var o,s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0;if(o=L,L=L+16|0,b=o,y=0|rn(0|(e|=0),0|(t|=0),52),B(),y&=15,n>>>0>15)return L=o,0|(y=4);if((0|y)<(0|n))return L=o,0|(y=12);if((0|y)!=(0|n))if(a=0|on(0|n,0,52),a|=e,l=B()|-15728641&t,(0|y)>(0|n)){c=n;do{m=0|on(7,0,3*(14-c|0)|0),c=c+1|0,a|=m,l=0|B()|l}while((0|c)<(0|y));m=a}else m=a;else m=e,l=t;g=0|rn(0|m,0|l,45),B();e:do{if(0|z(127&g)){if(c=0|rn(0|m,0|l,52),B(),0|(c&=15))for(a=1;;){if(!(!((g=0|on(7,0,3*(15-a|0)|0))&m|0)&!((0|B())&l))){u=33;break e}if(!(a>>>0<c>>>0))break;a=a+1|0}if(r[(g=i)>>2]=0,r[g+4>>2]=0,(0|y)>(0|n)){for(g=-15728641&t,p=y;;){if(d=p,(p=p+-1|0)>>>0>15|(0|y)<(0|p)){u=19;break}if((0|y)!=(0|p))if(a=0|on(0|p,0,52),a|=e,c=0|B()|g,(0|y)<(0|d))h=a;else{u=p;do{h=0|on(7,0,3*(14-u|0)|0),u=u+1|0,a|=h,c=0|B()|c}while((0|u)<(0|y));h=a}else h=e,c=t;if(f=0|rn(0|h,0|c,45),B(),0|z(127&f)){f=0|rn(0|h,0|c,52),B(),f&=15;t:do{if(f)for(u=1;;){if(a=0|rn(0|h,0|c,3*(15-u|0)|0),B(),0|(a&=7))break t;if(!(u>>>0<f>>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(c=0|rn(0|e,0|t,3*(15-d|0)|0),B(),7==(0|(c&=7))){s=5,u=42;break}if(1==(0|c)&(a=!!(0|a))){s=5,u=42;break}if(0|(h=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|yt(7,0,u=y-d|0,((0|u)<0)<<31>>31),f=0|B(),a?(a=0|Wt(0|(a=0|$t(0|u,0|f,5,0)),0|B(),-5,-1),a=0|Wt(0|(a=0|Zt(0|a,0|B(),6,0)),0|B(),1,0),c=0|B()):(a=u,c=f),d=0|Wt(0|a,0|c,0|(d=0|$t(0|u,0|f,0|(d=h+-1|0),((0|d)<0)<<31>>31)),0|B()),f=0|Wt(0|d,0|(h=0|B()),0|r[(f=i)>>2],0|r[f+4>>2]),h=0|B(),r[(d=i)>>2]=f,r[d+4>>2]=h),(0|p)<=(0|n)){u=37;break}}if(19==(0|u))M(27795,27122,1367,27158);else{if(37==(0|u)){s=0|r[(A=i)+4>>2],A=0|r[A>>2];break}if(42==(0|u))return L=o,0|s}}else s=0,A=0}else u=33}while(0);e:do{if(33==(0|u)){if(r[(g=i)>>2]=0,r[g+4>>2]=0,(0|y)>(0|n)){for(a=y;;){if(s=0|rn(0|e,0|t,3*(15-a|0)|0),B(),7==(0|(s&=7))){s=5;break}if(s=0|$t(0|(A=0|yt(7,0,A=y-a|0,((0|A)<0)<<31>>31)),0|B(),0|s,0),A=0|B(),A=0|Wt(0|r[(g=i)>>2],0|r[g+4>>2],0|s,0|A),s=0|B(),r[(g=i)>>2]=A,r[g+4>>2]=s,(0|(a=a+-1|0))<=(0|n))break e}return L=o,0|s}s=0,A=0}}while(0);return 0|Ge(m,l,y,b)&&M(27795,27122,1327,27173),((0|s)>-1|-1==(0|s)&A>>>0>4294967295)&((0|(b=0|r[(y=b)+4>>2]))>(0|s)|((0|b)==(0|s)?(0|r[y>>2])>>>0>A>>>0:0))?(L=o,0|(y=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(e,t,n,i){i|=0;var o,s,a=0,A=0;if(s=L,L=L+16|0,nt(o=s,e|=0,t|=0,n|=0),!(0|(e=0|r[(t=o)>>2]))&!(0|(t=0|r[t+4>>2])))return L=s,0;a=0,n=0;do{r[(A=i+(a<<3)|0)>>2]=e,r[A+4>>2]=t,a=0|Wt(0|a,0|n,1,0),n=0|B(),rt(o),e=0|r[(A=o)>>2],t=0|r[A+4>>2]}while(!(!(0|e)&!(0|t)));return L=s,0},_cellToChildrenSize:Ge,_cellToLatLng:$e,_cellToLocalIj:function(e,t,n,i,o,s){var a,A;return e|=0,t|=0,n|=0,i|=0,s|=0,A=L,L=L+16|0,a=A,(o|=0)?e=15:(e=0|mt(e,t,n,i,a))||(!function(e,t){var n;t|=0,n=0|r[8+(e|=0)>>2],r[t>>2]=(0|r[e>>2])-n,r[t+4>>2]=(0|r[e+4>>2])-n}(a,s),e=0),L=A,0|e},_cellToParent:ke,_cellToVertex:Ot,_cellToVertexes:function(e,t,n){n|=0;var i,o=0,s=0;return s=!(0|ze(e|=0,t|=0)),i=!(0|(o=0|Ot(e,t,0,n))),s?i?0|(o=0|Ot(e,t,1,n+8|0))||0|(o=0|Ot(e,t,2,n+16|0))||0|(o=0|Ot(e,t,3,n+24|0))||(o=0|Ot(e,t,4,n+32|0))?0|(s=o):0|Ot(e,t,5,n+40|0):0|(s=o):i?0|(o=0|Ot(e,t,1,n+8|0))||0|(o=0|Ot(e,t,2,n+16|0))||0|(o=0|Ot(e,t,3,n+24|0))||0|(o=0|Ot(e,t,4,n+32|0))?0|(s=o):(r[(s=n+40|0)>>2]=0,r[s+4>>2]=0,0|(s=0)):0|(s=o)},_cellsToDirectedEdge:function(e,t,n,i,o){return o|=0,7==(0|(n=0|k(e|=0,t|=0,n|=0,i|=0)))?0|(o=11):(i=0|on(0|n,0,56),t=-2130706433&t|B()|268435456,r[o>>2]=e|i,r[o+4>>2]=t,0|(o=0))},_cellsToLinkedMultiPolygon:function(e,t,n){n|=0;var i,s,a,A=0;if(a=L,L=L+32|0,i=a,0|(e=0|function(e,t,n){e|=0,n|=0;var i,o,s=0,a=0,A=0,l=0,c=0,u=0;if(o=L,L=L+176|0,i=o,(0|(t|=0))<1)return Nt(n,0,0),L=o,0;for(c=0|rn(0|r[(c=e)>>2],0|r[c+4>>2],52),B(),Nt(n,(0|t)>6?t:6,15&c),c=0;!(0|(s=0|et(0|r[(s=e+(c<<3)|0)>>2],0|r[s+4>>2],i)));){if((0|(s=0|r[i>>2]))>0){l=0;do{A=i+8+(l<<4)|0,(a=0|Vt(n,s=i+8+((0|(l=l+1|0))%(0|s)<<4)|0,A))?Gt(n,a):zt(n,A,s),s=0|r[i>>2]}while((0|l)<(0|s))}if((0|(c=c+1|0))>=(0|t)){s=0,u=13;break}}return 13==(0|u)?(L=o,0|s):(Ut(n),L=o,0|(u=s))}(e|=0,t|=0,s=a+16|0)))return L=a,0|(n=e);if(r[n>>2]=0,r[n+4>>2]=0,r[n+8>>2]=0,0|(e=0|kt(s)))do{t=0|ht(n);do{dt(t,e),A=e+16|0,r[i>>2]=r[A>>2],r[i+4>>2]=r[A+4>>2],r[i+8>>2]=r[A+8>>2],r[i+12>>2]=r[A+12>>2],Gt(s,e),e=0|Ht(s,i)}while(0|e);e=0|kt(s)}while(0|e);return Ut(s),(e=0|function(e){e|=0;var t=0,n=0,i=0,s=0,a=0,A=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0,x=0,w=0,B=0,S=0,T=0,E=0,P=0,I=0,L=0,R=0,F=0,O=0,D=0;if(s=e+8|0,0|r[s>>2])return 0|(D=1);if(i=0|r[e>>2],!i)return 0|(D=0);t=i,n=0;do{n=n+1|0,t=0|r[t+8>>2]}while(0|t);if(n>>>0<2)return 0|(D=0);F=0|Qt(n<<2),F||M(27396,27235,317,27415);R=0|Qt(n<<5),R||M(27437,27235,321,27415);r[e>>2]=0,B=e+4|0,r[B>>2]=0,r[s>>2]=0,n=0,L=0,w=0,d=0;e:for(;;){if(h=0|r[i>>2]){a=0,A=h;do{if(u=+o[A+8>>3],t=A,A=0|r[A+16>>2],c=+o[(s=(f=!(0|A))?h:A)+8>>3],+l(+(u-c))>3.141592653589793){D=14;break}a+=(c-u)*(+o[t>>3]+ +o[s>>3])}while(!f);if(14==(0|D)){D=0,a=0,t=h;do{x=+o[t+8>>3],P=0|r[(I=t+16|0)>>2],C=+o[(P=0|P?P:h)+8>>3],a+=(+o[t>>3]+ +o[P>>3])*((C<0?C+6.283185307179586:C)-(x<0?x+6.283185307179586:x)),t=0|r[(0|t?I:i)>>2]}while(0|t)}a>0?(r[F+(L<<2)>>2]=i,L=L+1|0,s=w,t=d):D=19}else D=19;if(19==(0|D)){D=0;do{if(!n){if(d){s=B,A=d+8|0,t=i,n=e;break}if(0|r[e>>2]){D=27;break e}s=B,A=e,t=i,n=e;break}if(0|r[(t=n+8|0)>>2]){D=21;break e}if(!(n=0|Kt(1,12))){D=23;break e}r[t>>2]=n,s=n+4|0,A=n,t=d}while(0);if(r[A>>2]=i,r[s>>2]=i,A=R+(w<<5)|0,f=0|r[i>>2]){for(o[(h=R+(w<<5)+8|0)>>3]=17976931348623157e292,o[(d=R+(w<<5)+24|0)>>3]=17976931348623157e292,o[A>>3]=-17976931348623157e292,o[(p=R+(w<<5)+16|0)>>3]=-17976931348623157e292,v=17976931348623157e292,_=-17976931348623157e292,s=0,g=f,u=17976931348623157e292,b=17976931348623157e292,y=-17976931348623157e292,c=-17976931348623157e292;a=+o[g>>3],x=+o[g+8>>3],g=0|r[g+16>>2],C=+o[((m=!(0|g))?f:g)+8>>3],a<u&&(o[h>>3]=a,u=a),x<b&&(o[d>>3]=x,b=x),a>y?o[A>>3]=a:a=y,x>c&&(o[p>>3]=x,c=x),v=x>0&x<v?x:v,_=x<0&x>_?x:_,s|=+l(+(x-C))>3.141592653589793,!m;)y=a;s&&(o[p>>3]=_,o[d>>3]=v)}else r[A>>2]=0,r[A+4>>2]=0,r[A+8>>2]=0,r[A+12>>2]=0,r[A+16>>2]=0,r[A+20>>2]=0,r[A+24>>2]=0,r[A+28>>2]=0;s=w+1|0}if(i=0|r[(I=i+8|0)>>2],r[I>>2]=0,!i){D=45;break}w=s,d=t}if(21==(0|D))M(27213,27235,35,27247);else if(23==(0|D))M(27267,27235,37,27247);else if(27==(0|D))M(27310,27235,61,27333);else if(45==(0|D)){e:do{if((0|L)>0){for(I=!(0|s),E=s<<2,P=!(0|e),T=0,t=0;;){if(S=0|r[F+(T<<2)>>2],I)D=73;else{if(!(w=0|Qt(E))){D=50;break}if(!(B=0|Qt(E))){D=52;break}t:do{if(P)n=0;else{for(s=0,n=0,A=e;i=R+(s<<5)|0,0|gt(0|r[A>>2],i,0|r[S>>2])?(r[w+(n<<2)>>2]=A,r[B+(n<<2)>>2]=i,m=n+1|0):m=n,A=0|r[A+8>>2];)s=s+1|0,n=m;if((0|m)>0)if(i=0|r[w>>2],1==(0|m))n=i;else for(p=0,g=-1,n=i,d=i;;){for(f=0|r[d>>2],i=0,A=0;h=(0|(s=0|r[r[w+(A<<2)>>2]>>2]))==(0|f)?i:i+(1&gt(s,0|r[B+(A<<2)>>2],0|r[f>>2]))|0,(0|(A=A+1|0))!=(0|m);)i=h;if(n=(s=(0|h)>(0|g))?d:n,(0|(i=p+1|0))==(0|m))break t;p=i,g=s?h:g,d=0|r[w+(i<<2)>>2]}else n=0}}while(0);if(Jt(w),Jt(B),n){if(i=0|r[(s=n+4|0)>>2])n=i+8|0;else if(0|r[n>>2]){D=70;break}r[n>>2]=S,r[s>>2]=S}else D=73}if(73==(0|D)){if(D=0,0|(t=0|r[S>>2]))do{B=t,t=0|r[t+16>>2],Jt(B)}while(0|t);Jt(S),t=1}if((0|(T=T+1|0))>=(0|L)){O=t;break e}}50==(0|D)?M(27452,27235,249,27471):52==(0|D)?M(27490,27235,252,27471):70==(0|D)&&M(27310,27235,61,27333)}else O=0}while(0);return Jt(F),Jt(R),0|(D=O)}return 0}(n))?(pt(n),L=a,0|(A=e)):(L=a,0|(A=0))},_childPosToCell:function(e,t,n,i,o,s){e|=0,t|=0,s|=0;var a,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0;if(a=L,L=L+16|0,A=a,(o|=0)>>>0>15)return L=a,0|(s=4);if(l=0|rn(0|(n|=0),0|(i|=0),52),B(),(0|(l&=15))>(0|o))return L=a,0|(s=12);if(0|Ge(n,i,o,A)&&M(27795,27122,1327,27173),!(((0|t)>-1|-1==(0|t)&e>>>0>4294967295)&((0|(u=0|r[(f=A)+4>>2]))>(0|t)|((0|u)==(0|t)?(0|r[f>>2])>>>0>e>>>0:0))))return L=a,0|(s=2);f=o-l|0,o=0|on(0|o,0,52),c=B()|-15728641&i,r[(u=s)>>2]=o|n,r[u+4>>2]=c,u=0|rn(0|n,0|i,45),B();e:do{if(0|z(127&u)){if(0|l)for(A=1;;){if(!(!((u=0|on(7,0,3*(15-A|0)|0))&n|0)&!((0|B())&i)))break e;if(!(A>>>0<l>>>0))break;A=A+1|0}if((0|f)<1)return L=a,0|(s=0);for(u=15^l,i=-1,c=1,A=1;;){l=0|yt(7,0,l=f-c|0,((0|l)<0)<<31>>31),n=0|B();do{if(A){if(A=0|Zt(0|(A=0|Wt(0|(A=0|$t(0|l,0|n,5,0)),0|B(),-5,-1)),0|B(),6,0),(0|t)>(0|(o=0|B()))|(0|t)==(0|o)&e>>>0>A>>>0){t=0|qt(0|(t=0|Wt(0|e,0|t,-1,-1)),0|B(),0|A,0|o),A=0|B(),p=0|r[(h=s)>>2],h=0|r[h+4>>2],d=0|on(7,0,0|(g=3*(u+i|0)|0)),h&=~B(),g=0|on(0|(o=0|Wt(0|(i=0|Zt(0|t,0|A,0|l,0|n)),0|(e=0|B()),2,0)),0|B(),0|g),h=0|B()|h,r[(o=s)>>2]=g|p&~d,r[o+4>>2]=h,e=0|qt(0|t,0|A,0|(e=0|$t(0|i,0|e,0|l,0|n)),0|B()),A=0,t=0|B();break}d=0|r[(g=s)>>2],g=0|r[g+4>>2],p=0|on(7,0,3*(u+i|0)|0),g&=~B(),r[(A=s)>>2]=d&~p,r[A+4>>2]=g,A=1;break}o=0|r[(d=s)>>2],d=0|r[d+4>>2],h=0|on(7,0,0|(i=3*(u+i|0)|0)),d&=~B(),i=0|on(0|(g=0|Zt(0|e,0|t,0|l,0|n)),0|(A=0|B()),0|i),d=0|B()|d,r[(p=s)>>2]=i|o&~h,r[p+4>>2]=d,e=0|qt(0|e,0|t,0|(A=0|$t(0|g,0|A,0|l,0|n)),0|B()),A=0,t=0|B()}while(0);if(!((0|f)>(0|c))){t=0;break}i=~c,c=c+1|0}return L=a,0|t}}while(0);if((0|f)<1)return L=a,0|(g=0);for(o=15^l,A=1;;){if(p=0|yt(7,0,p=f-A|0,((0|p)<0)<<31>>31),g=0|B(),n=0|r[(c=s)>>2],c=0|r[c+4>>2],i=0|on(7,0,0|(l=3*(o-A|0)|0)),c&=~B(),l=0|on(0|(h=0|Zt(0|e,0|t,0|p,0|g)),0|(d=0|B()),0|l),c=0|B()|c,r[(u=s)>>2]=l|n&~i,r[u+4>>2]=c,e=0|qt(0|e,0|t,0|(g=0|$t(0|h,0|d,0|p,0|g)),0|B()),t=0|B(),(0|f)<=(0|A)){t=0;break}A=A+1|0}return L=a,0|t},_compactCells:function(e,t,n,i){t|=0;var o,s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0,x=0,w=0,S=0,T=0,E=0,P=0,I=0,L=0;if(!(0|(n|=0))&!(0|(i|=0)))return 0|(L=0);if(a=0|r[(s=e|=0)>>2],!0&!(15728640&(s=0|r[s+4>>2]))){if(!((0|i)>0|!(0|i)&n>>>0>0))return 0|(L=0);if(r[(L=t)>>2]=a,r[L+4>>2]=s,1==(0|n)&!(0|i))return 0|(L=0);s=1,a=0;do{I=0|r[(P=e+(s<<3)|0)+4>>2],r[(L=t+(s<<3)|0)>>2]=r[P>>2],r[L+4>>2]=I,s=0|Wt(0|s,0|a,1,0),a=0|B()}while((0|a)<(0|i)|(0|a)==(0|i)&s>>>0<n>>>0);return 0|(s=0)}if(!(I=0|Qt(o=n<<3)))return 0|(L=13);if(cn(0|I,0|e,0|o),!(P=0|Kt(n,8)))return Jt(I),0|(L=13);e:for(;;){T=0|rn(0|(u=0|r[(s=I)>>2]),0|(s=0|r[s+4>>2]),52),B(),E=(T&=15)+-1|0,S=!!(0|T),w=(0|i)>0|!(0|i)&n>>>0>0;t:do{if(S&w){if(v=0|on(0|E,0,52),_=0|B(),E>>>0>15){if(!(!(0|u)&!(0|s))){L=16;break e}for(a=0,e=0;;){if(a=0|Wt(0|a,0|e,1,0),!((0|(e=0|B()))<(0|i)|(0|e)==(0|i)&a>>>0<n>>>0))break t;if(!(!(0|(x=0|r[(A=I+(a<<3)|0)>>2]))&!(0|(A=0|r[A+4>>2])))){s=A,L=16;break e}}}for(l=u,e=s,a=0,A=0;;){if(!(!(0|l)&!(0|e))){if(!(!0&!(117440512&e))){L=21;break e}if(f=0|rn(0|l,0|e,52),B(),(0|(f&=15))<(0|E)){s=12,L=27;break e}if((0|f)!=(0|E)&&(l|=v,e=-15728641&e|_,f>>>0>=T>>>0)){c=E;do{x=0|on(7,0,3*(14-c|0)|0),c=c+1|0,l|=x,e=0|B()|e}while(c>>>0<f>>>0)}if(d=0|tn(0|l,0|e,0|n,0|i),p=0|B(),!(!(0|(h=0|r[(f=c=P+(d<<3)|0)>>2]))&!(0|(f=0|r[f+4>>2])))){b=0,y=0;do{if((0|b)>(0|i)|(0|b)==(0|i)&y>>>0>n>>>0){L=31;break e}if((0|h)==(0|l)&(-117440513&f)==(0|e)){g=0|rn(0|h,0|f,56),B(),m=(g&=7)+1|0,x=0|rn(0|h,0|f,45),B();n:do{if(0|z(127&x)){if(h=0|rn(0|h,0|f,52),B(),!(h&=15)){f=6;break}for(f=1;;){if(!(!((x=0|on(7,0,3*(15-f|0)|0))&l|0)&!((0|B())&e))){f=7;break n}if(!(f>>>0<h>>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((g+2|0)>>>0>f>>>0){L=41;break e}x=0|on(0|m,0,56),e=B()|-117440513&e,r[(C=c)>>2]=0,r[C+4>>2]=0,l|=x}else d=0|en(0|(d=0|Wt(0|d,0|p,1,0)),0|B(),0|n,0|i),p=0|B();y=0|Wt(0|y,0|b,1,0),b=0|B(),h=0|r[(f=c=P+(d<<3)|0)>>2],f=0|r[f+4>>2]}while(!(!(0|h)&!(0|f)))}r[(x=c)>>2]=l,r[x+4>>2]=e}if(a=0|Wt(0|a,0|A,1,0),!((0|(A=0|B()))<(0|i)|(0|A)==(0|i)&a>>>0<n>>>0))break t;l=0|r[(e=I+(a<<3)|0)>>2],e=0|r[e+4>>2]}}}while(0);if(x=0|Wt(0|n,0|i,5,0),(C=0|B())>>>0<0|!(0|C)&x>>>0<11){L=85;break}if(x=0|Zt(0|n,0|i,6,0),B(),!(x=0|Kt(x,8))){L=48;break}do{if(w){for(m=0,e=0,g=0,b=0;;){if(!(0|(a=0|r[(A=f=P+(m<<3)|0)>>2]))&!(0|(A=0|r[A+4>>2])))C=g;else{h=0|rn(0|a,0|A,56),B(),l=(h&=7)+1|0,d=-117440513&A,C=0|rn(0|a,0|A,45),B();t:do{if(0|z(127&C)){if(p=0|rn(0|a,0|A,52),B(),0|(p&=15))for(c=1;;){if(!(!(a&(C=0|on(7,0,3*(15-c|0)|0))|0)&!(d&(0|B()))))break t;if(!(c>>>0<p>>>0))break;c=c+1|0}a|=A=0|on(0|l,0,56),A=0|B()|d,r[(l=f)>>2]=a,r[l+4>>2]=A,l=h+2|0}}while(0);7==(0|l)?(r[(C=x+(e<<3)|0)>>2]=a,r[C+4>>2]=-117440513&A,e=0|Wt(0|e,0|g,1,0),C=0|B()):C=g}if(m=0|Wt(0|m,0|b,1,0),!((0|(b=0|B()))<(0|i)|(0|b)==(0|i)&m>>>0<n>>>0))break;g=C}if(w){if(y=E>>>0>15,v=0|on(0|E,0,52),_=0|B(),!S){for(a=0,c=0,l=0,A=0;!(0|u)&!(0|s)||(r[(E=t+(a<<3)|0)>>2]=u,r[E+4>>2]=s,a=0|Wt(0|a,0|c,1,0),c=0|B()),l=0|Wt(0|l,0|A,1,0),(0|(A=0|B()))<(0|i)|(0|A)==(0|i)&l>>>0<n>>>0;)u=0|r[(s=I+(l<<3)|0)>>2],s=0|r[s+4>>2];s=C;break}for(a=0,c=0,A=0,l=0;;){do{if(!(!(0|u)&!(0|s))){if(p=0|rn(0|u,0|s,52),B(),y|(0|(p&=15))<(0|E)){L=80;break e}if((0|p)!=(0|E)){if(f=u|v,h=-15728641&s|_,p>>>0>=T>>>0){d=E;do{S=0|on(7,0,3*(14-d|0)|0),d=d+1|0,f|=S,h=0|B()|h}while(d>>>0<p>>>0)}}else f=u,h=s;g=0|tn(0|f,0|h,0|n,0|i),d=0,p=0,b=0|B();do{if((0|d)>(0|i)|(0|d)==(0|i)&p>>>0>n>>>0){L=81;break e}if((-117440513&(m=0|r[(S=P+(g<<3)|0)+4>>2]))==(0|h)&&(0|r[S>>2])==(0|f)){L=65;break}g=0|en(0|(S=0|Wt(0|g,0|b,1,0)),0|B(),0|n,0|i),b=0|B(),p=0|Wt(0|p,0|d,1,0),d=0|B(),S=P+(g<<3)|0}while((0|r[S>>2])!=(0|f)||(0|r[S+4>>2])!=(0|h));if(65==(0|L)&&(L=0,!0&100663296==(117440512&m)))break;r[(S=t+(a<<3)|0)>>2]=u,r[S+4>>2]=s,a=0|Wt(0|a,0|c,1,0),c=0|B()}}while(0);if(A=0|Wt(0|A,0|l,1,0),!((0|(l=0|B()))<(0|i)|(0|l)==(0|i)&A>>>0<n>>>0))break;u=0|r[(s=I+(A<<3)|0)>>2],s=0|r[s+4>>2]}s=C}else a=0,s=C}else a=0,e=0,s=0}while(0);if(un(0|P,0,0|o),cn(0|I,0|x,e<<3),Jt(x),!(0|e)&!(0|s)){L=89;break}t=t+(a<<3)|0,i=s,n=e}if(16==(0|L))!0&!(117440512&s)?(s=4,L=27):L=21;else if(31==(0|L))M(27795,27122,620,27132);else{if(41==(0|L))return Jt(I),Jt(P),0|(L=10);if(48==(0|L))return Jt(I),Jt(P),0|(L=13);80==(0|L)?M(27795,27122,711,27132):81==(0|L)?M(27795,27122,723,27132):85==(0|L)&&(cn(0|t,0|I,n<<3),L=89)}return 21==(0|L)?(Jt(I),Jt(P),0|(L=5)):27==(0|L)?(Jt(I),Jt(P),0|(L=s)):89==(0|L)?(Jt(I),Jt(P),0|(L=0)):0},_constructCell:function(e,t,n,o){n|=0,o|=0;var s=0,a=0,A=0,l=0,c=0,u=0;if((e|=0)>>>0>15)return 0|(o=4);if((t|=0)>>>0>121)return 0|(o=17);A=0|on(0|e,0,52),s=0|B(),l=0|on(0|t,0,45),s=0|s|B()|134225919;e:do{if((0|e)>=1){for(l=1,A=!!(0|i[20528+t|0]),a=-1;;){if((t=0|r[n+(l+-1<<2)>>2])>>>0>6){s=18,t=10;break}if(!(!(0|t)|1^A)){if(1==(0|t)){s=19,t=10;break}A=0}if(c=0|on(7,0,0|(u=3*(15-l|0)|0)),s&=~B(),a=(t=0|on(0|t,((0|t)<0)<<31>>31,0|u))|a&~c,s=0|B()|s,!((0|l)<(0|e)))break e;l=l+1|0}if(10==(0|t))return 0|s}else a=-1}while(0);return r[(u=o)>>2]=a,r[u+4>>2]=s,0|(u=0)},_destroyLinkedMultiPolygon:pt,_directedEdgeToBoundary:Se,_directedEdgeToCells:function(e,t,n){e|=0;var i,o,s,a=0;return i=L,L=L+16|0,a=i,!0&268435456==(2013265920&(t|=0))?(o=-2130706433&t|134217728,r[(s=n|=0)>>2]=e,r[s+4>>2]=o,r[a>>2]=0,t=0|rn(0|e,0|t,56),B(),a=0|N(e,o,7&t,a,n+8|0),L=i,0|a):(L=i,0|(a=6))},_edgeLengthKm:function(e,t,n){n|=0;var i,s=0,a=0,A=0,l=0,u=0,d=0,p=0;if(i=L,L=L+176|0,0|(e=0|Se(e|=0,t|=0,l=i)))return l=e,A=+o[n>>3],A*=6371.007180918475,o[n>>3]=A,L=i,0|l;if(o[n>>3]=0,(0|(e=0|r[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,o[n>>3]=A,L=i,0|l;t=e+-1|0,e=0,s=+o[l+8>>3],a=+o[l+16>>3],A=0;do{d=s,s=+o[l+8+((e=e+1|0)<<4)>>3],p=+h(.5*(s-d)),u=a,a=+o[l+8+(e<<4)+8>>3],u=p*p+(u=+h(.5*(a-u)))*(+f(+d)*+f(+s)*u),A+=2*+b(+ +c(+u),+ +c(+(1-u)))}while((0|e)!=(0|t));return o[n>>3]=A,l=0,p=A,p*=6371.007180918475,o[n>>3]=p,L=i,0|l},_edgeLengthM:function(e,t,n){n|=0;var i,s=0,a=0,A=0,l=0,u=0,d=0,p=0;if(i=L,L=L+176|0,0|(e=0|Se(e|=0,t|=0,l=i)))return l=e,A=+o[n>>3],A*=6371.007180918475,A*=1e3,o[n>>3]=A,L=i,0|l;if(o[n>>3]=0,(0|(e=0|r[l>>2]))<=1)return l=0,A=0,A*=6371.007180918475,A*=1e3,o[n>>3]=A,L=i,0|l;t=e+-1|0,e=0,s=+o[l+8>>3],a=+o[l+16>>3],A=0;do{d=s,s=+o[l+8+((e=e+1|0)<<4)>>3],p=+h(.5*(s-d)),u=a,a=+o[l+8+(e<<4)+8>>3],u=p*p+(u=+h(.5*(a-u)))*(+f(+d)*+f(+s)*u),A+=2*+b(+ +c(+u),+ +c(+(1-u)))}while((0|e)!=(0|t));return o[n>>3]=A,l=0,p=A,p*=6371.007180918475,p*=1e3,o[n>>3]=p,L=i,0|l},_edgeLengthRads:function(e,t,n){n|=0;var i,s=0,a=0,A=0,l=0,u=0,d=0,p=0;if(i=L,L=L+176|0,0|(e=0|Se(e|=0,t|=0,l=i)))return L=i,0|(l=e);if(o[n>>3]=0,(0|(e=0|r[l>>2]))<=1)return L=i,0|(l=0);t=e+-1|0,e=0,s=+o[l+8>>3],a=+o[l+16>>3],A=0;do{d=s,s=+o[l+8+((e=e+1|0)<<4)>>3],p=+h(.5*(s-d)),u=a,a=+o[l+8+(e<<4)+8>>3],u=p*p+(u=+h(.5*(a-u)))*(+f(+s)*+f(+d)*u),A+=2*+b(+ +c(+u),+ +c(+(1-u)))}while((0|e)<(0|t));return o[n>>3]=A,L=i,0|(l=0)},_emscripten_replace_memory:function(e){return i=new Int8Array(e),r=new Int32Array(e),o=new Float64Array(e),n=e,!0},_free:Jt,_getBaseCellNumber:De,_getDirectedEdgeDestination:function(e,t,n){e|=0,t|=0,n|=0;var i,o,s=0;return i=L,L=L+16|0,r[(s=i)>>2]=0,!0&268435456==(2013265920&t)?(o=0|rn(0|e,0|t,56),B(),s=0|N(e,-2130706433&t|134217728,7&o,s,n),L=i,0|s):(L=i,0|(s=6))},_getDirectedEdgeOrigin:function(e,t,n){return e|=0,n|=0,!0&268435456==(2013265920&(t|=0))?(r[n>>2]=e,r[n+4>>2]=-2130706433&t|134217728,0|(n=0)):0|(n=6)},_getHexagonAreaAvgKm2:lt,_getHexagonAreaAvgM2:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(o[t>>3]=+o[20784+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgKm:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(o[t>>3]=+o[20912+(e<<3)>>3],0|(t=0))},_getHexagonEdgeLengthAvgM:function(e,t){return t|=0,(e|=0)>>>0>15?0|(t=4):(o[t>>3]=+o[21040+(e<<3)>>3],0|(t=0))},_getIcosahedronFaces:function e(t,n,i){i|=0;var o,s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0;o=L,L=L+128|0,f=o+112|0,A=o+96|0,h=o,a=0|rn(0|(t|=0),0|(n|=0),52),B(),c=15&a,r[f>>2]=c,l=0|rn(0|t,0|n,45),B(),l&=127;e:do{if(0|z(l)){if(0|c)for(s=1;;){if(!(!((u=0|on(7,0,3*(15-s|0)|0))&t|0)&!((0|B())&n))){a=0;break e}if(!(s>>>0<c>>>0))break;s=s+1|0}if(!(1&a))return u=0|on(c+1|0,0,52),h=B()|-15728641&n,h=0|e((u|t)&~(f=0|on(7,0,3*(14-c|0)|0)),h&~B(),i),L=o,0|h;a=1}else a=0}while(0);if(!(s=0|Ze(t,n,A))){a?(Ie(A,f,h),u=5):(Oe(A,f,h),u=6);e:do{if(0|z(l))if(c)for(s=1;;){if(!(!((l=0|on(7,0,3*(15-s|0)|0))&t|0)&!((0|B())&n))){t=2;break e}if(!(s>>>0<c>>>0)){t=5;break}s=s+1|0}else t=5;else t=2}while(0);un(0|i,-1,t<<2);e:do{if(a)for(A=0;;){if(Re(l=h+(A<<4)|0,0|r[f>>2]),l=0|r[l>>2],-1==(0|(c=0|r[i>>2]))|(0|c)==(0|l))s=i;else{a=0;do{if((a=a+1|0)>>>0>=t>>>0){s=1;break e}c=0|r[(s=i+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(r[s>>2]=l,(A=A+1|0)>>>0>=u>>>0){s=0;break}}else for(A=0;;){if(Le(l=h+(A<<4)|0,0|r[f>>2],0,1),l=0|r[l>>2],-1==(0|(c=0|r[i>>2]))|(0|c)==(0|l))s=i;else{a=0;do{if((a=a+1|0)>>>0>=t>>>0){s=1;break e}c=0|r[(s=i+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(r[s>>2]=l,(A=A+1|0)>>>0>=u>>>0){s=0;break}}}while(0)}return L=o,0|(h=s)},_getIndexDigit:function(e,t,n,i){return i|=0,((n|=0)+-1|0)>>>0>14?0|(i=4):(n=0|rn(0|(e|=0),0|(t|=0),3*(15-n|0)|0),B(),r[i>>2]=7&n,0|(i=0))},_getNumCells:ct,_getPentagons:tt,_getRes0Cells:function(e){e|=0;var t=0,n=0,i=0;t=0;do{on(0|t,0,45),i=134225919|B(),r[(n=e+(t<<3)|0)>>2]=-1,r[n+4>>2]=i,t=t+1|0}while(122!=(0|t));return 0},_getResolution:function(e,t){return t=0|rn(0|(e|=0),0|(t|=0),52),B(),15&t},_greatCircleDistanceKm:At,_greatCircleDistanceM:function(e,t){e|=0;var n,i,r,s=0;return i=+o[(t|=0)>>3],n=+o[e>>3],s=(r=+h(.5*(i-n)))*r+(s=+h(.5*(+o[t+8>>3]-+o[e+8>>3])))*(+f(+i)*+f(+n)*s),2*+b(+ +c(+s),+ +c(+(1-s)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(e,t){e|=0;var n,i,r,s=0;return i=+o[(t|=0)>>3],n=+o[e>>3],s=(r=+h(.5*(i-n)))*r+(s=+h(.5*(+o[t+8>>3]-+o[e+8>>3])))*(+f(+i)*+f(+n)*s),2*+b(+ +c(+s),+ +c(+(1-s)))},_gridDisk:R,_gridDiskDistances:F,_gridDistance:function(e,t,n,i,o){n|=0,i|=0,o|=0;var s,a,A=0,l=0;return a=L,L=L+32|0,l=a,0|(s=0|mt(e|=0,t|=0,e,t,A=a+12|0))?(L=a,0|(l=s)):0|(e=0|mt(e,t,n,i,l))?(L=a,0|(l=e)):(A=0|xe(A,l),r[(l=o)>>2]=A,r[l+4>>2]=((0|A)<0)<<31>>31,L=a,0|(l=0))},_gridPathCells:function(e,t,n,i,o){n|=0,i|=0,o|=0;var s,a,A=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0,x=0,w=0,S=0,T=0;if(a=L,L=L+48|0,c=a+12|0,S=a,!(A=0|mt(e|=0,t|=0,e,t,s=a+24|0))&&!(A=0|mt(e,t,n,i,c))){w=((0|(x=0|xe(s,c)))<0)<<31>>31,r[s>>2]=0,r[s+4>>2]=0,r[s+8>>2]=0,r[c>>2]=0,r[c+4>>2]=0,r[c+8>>2]=0,0|mt(e,t,e,t,s)&&M(27795,27538,692,27747),0|mt(e,t,n,i,c)&&M(27795,27538,697,27747),we(s),we(c),d=0|x?1/+(0|x):0,n=0|r[s>>2],y=d*+((0|r[c>>2])-n|0),i=0|r[(v=s+4|0)>>2],_=d*+((0|r[c+4>>2])-i|0),A=0|r[(C=s+8|0)>>2],d*=+((0|r[c+8>>2])-A|0),r[S>>2]=n,r[(p=S+4|0)>>2]=i,r[(g=S+8|0)>>2]=A;e:do{if((0|x)<0)A=0;else for(m=0,b=0;;){T=y*(f=+(b>>>0)+4294967296*+(0|m))+ +(0|n),u=_*f+ +(0|i),f=d*f+ +(0|A),n=~~+ln(+T),c=~~+ln(+u),A=~~+ln(+f),T=+l(+(+(0|n)-T)),u=+l(+(+(0|c)-u)),f=+l(+(+(0|A)-f));do{if(!(T>u&T>f)){if(h=0-n|0,u>f){i=h-A|0;break}i=c,A=h-c|0;break}n=0-(c+A)|0,i=c}while(0);if(r[S>>2]=n,r[p>>2]=i,r[g>>2]=A,Be(S),0|(A=0|bt(e,t,S,o+(b<<3)|0)))break e;if(!((0|m)<(0|w)|(0|m)==(0|w)&b>>>0<x>>>0)){A=0;break e}n=0|Wt(0|b,0|m,1,0),m=i=0|B(),b=n,n=0|r[s>>2],i=0|r[v>>2],A=0|r[C>>2]}}while(0);return L=a,0|(S=A)}return L=a,0|(S=A)},_gridPathCellsSize:function(e,t,n,i,o){n|=0,i|=0,o|=0;var s,a=0,A=0,l=0;return s=L,L=L+32|0,l=s,(a=0|mt(e|=0,t|=0,e,t,A=s+12|0))||(a=0|mt(e,t,n,i,l))?(L=s,0|(l=a)):(i=0|Wt(0|(i=0|xe(A,l)),((0|i)<0)<<31>>31,1,0),A=0|B(),r[(l=o)>>2]=i,r[l+4>>2]=A,L=s,0|(l=0))},_gridRing:function(e,t,n,i){return 0|U(e|=0,t|=0,n|=0,i|=0)?(un(0|i,0,48*n|0),0|(i=0|function(e,t,n,i){e|=0,t|=0,n|=0,i|=0;var o=0,s=0,a=0,A=0,l=0,c=0,u=0,f=0,h=0;if(f=L,L=L+16|0,a=f,!n)return r[i>>2]=e,r[i+4>>2]=t,L=f,0|(i=0);do{if((0|n)>=0){if((0|n)>13780509){if(0|(o=0|ct(15,a)))break;o=0|r[(s=a)>>2],s=0|r[s+4>>2]}else u=0|$t(0|n,0|(o=((0|n)<0)<<31>>31),3,0),s=0|B(),o=0|Wt(0|n,0|o,1,0),o=0|Wt(0|(o=0|$t(0|u,0|s,0|o,0|B())),0|B(),1,0),s=0|B(),r[(u=a)>>2]=o,r[u+4>>2]=s;if(c=0|Kt(o,8)){if(!(u=0|Kt(o,4))){Jt(c),o=13;break}if(0|(o=0|D(e,t,n,c,u,o,s,0))){Jt(c),Jt(u);break}if(t=0|r[a>>2],(0|(a=0|r[a+4>>2]))>0|!(0|a)&t>>>0>0){o=0,A=0,l=0;do{!(0|(s=0|r[(e=c+(A<<3)|0)>>2]))&!(0|(e=0|r[e+4>>2]))||(0|r[u+(A<<2)>>2])!=(0|n)||(r[(h=i+(o<<3)|0)>>2]=s,r[h+4>>2]=e,o=o+1|0),A=0|Wt(0|A,0|l,1,0),l=0|B()}while((0|l)<(0|a)|(0|l)==(0|a)&A>>>0<t>>>0)}Jt(c),Jt(u),o=0}else o=13}else o=2}while(0);return L=f,0|(h=o)}(e,t,n,i))):0|(i=0)},_gridRingUnsafe:U,_i64Add:Wt,_i64Subtract:qt,_isPentagon:ze,_isResClassIII:function(e,t){return t=0|rn(0|(e|=0),0|(t|=0),52),B(),1&t},_isValidCell:Ne,_isValidDirectedEdge:Me,_isValidIndex:function(e,t){e|=0;var n=0,r=0,o=0,s=0;if(!0&134217728==(-16777216&(t|=0))&&(r=0|rn(0|e,0|t,52),B(),r&=15,n=0|rn(0|e,0|t,45),B(),(n&=127)>>>0<=121)&&!(613566756&(s=0|on(0|(o=0|rn(0|e,0|t,0|(s=3*(15^r)|0))),0|B(),0|s))&(0|qt(-1227133514,-1171,0|s,0|(o=0|B()))))&!(4681&o&B())&&15==(0|r)|!(0|(s=0|rn(0|(0|on(0|~e,0|~t,0|(s=19+(3*r|0)|0))),0|B(),0|s)))&!(0|B())){if(!(0|i[20528+n|0]))return 0|(s=1);if(!(0|e)&!(0|(n=8191&t)))return 0|(s=1);if(s=0|sn(0|e,0|n),B(),(63-s|0)%3|0)return 0|(s=1)}return 0|Me(e,t)?0|(s=1):0|(s=1&!!(0|Dt(e,t)))},_isValidVertex:Dt,_latLngToCell:Ye,_llvm_ctlz_i64:sn,_llvm_maxnum_f64:an,_llvm_minnum_f64:An,_llvm_round_f64:ln,_localIjToCell:function(e,t,n,i,o){var s,a;return e|=0,t|=0,n|=0,o|=0,a=L,L=L+16|0,s=a,(i|=0)?n=15:(n=0|function(e,t){t|=0;var n,i,o,s=0,a=0,A=0;if(a=0|r[(e|=0)>>2],r[t>>2]=a,A=0|r[e+4>>2],r[(i=t+4|0)>>2]=A,r[(o=t+8|0)>>2]=0,e=(s=(0|A)<(0|a))?a:A,(0|(s=s?A:a))<0){if(-2147483648==(0|s)||((0|e)>0?(2147483647-e|0)<(0|s):(-2147483648-e|0)>(0|s)))return 1;if((0|e)>-1?(-2147483648|e)>=(0|s):(-2147483648^e)<(0|s))return 1}return e=A-a|0,(0|a)<0?(s=0-a|0,r[i>>2]=e,r[o>>2]=s,r[t>>2]=0,a=0):(e=A,s=0),(0|e)<0&&(a=a-e|0,r[t>>2]=a,s=s-e|0,r[o>>2]=s,r[i>>2]=0,e=0),n=a-s|0,A=e-s|0,(0|s)<0?(r[t>>2]=n,r[i>>2]=A,r[o>>2]=0,e=A,A=n,s=0):A=a,(0|(a=(0|s)<(0|(a=(0|e)<(0|A)?e:A))?s:a))<=0||(r[t>>2]=A-a,r[i>>2]=e-a,r[o>>2]=s-a),0}(n,s))||(n=0|bt(e,t,s,o)),L=a,0|n},_malloc:Qt,_maxFaceCount:function(e,t,n){n|=0;var i=0,o=0;if(o=0|rn(0|(e|=0),0|(t|=0),45),B(),!(0|z(127&o)))return o=2,r[n>>2]=o,0;if(o=0|rn(0|e,0|t,52),B(),!(o&=15))return o=5,r[n>>2]=o,0;for(i=1;;){if(!(!((0|on(7,0,3*(15-i|0)|0))&e|0)&!((0|B())&t))){i=2,e=6;break}if(!(i>>>0<o>>>0)){i=5,e=6;break}i=i+1|0}return 6==(0|e)?(r[n>>2]=i,0):0},_maxGridDiskSize:function(e,t){t|=0;var n=0,i=0,o=0;return(0|(e|=0))<0?0|(t=2):(0|e)>13780509?0|(t=0|ct(15,t)):(o=0|$t(0|e,0|(n=((0|e)<0)<<31>>31),3,0),i=0|B(),n=0|Wt(0|e,0|n,1,0),n=0|Wt(0|(n=0|$t(0|o,0|i,0|n,0|B())),0|B(),1,0),e=0|B(),r[t>>2]=n,r[t+4>>2]=e,0|(t=0))},_maxPolygonToCellsSize:function(e,t,n,i){e|=0,t|=0,i|=0;var o,s=0,a=0,A=0,l=0,c=0;if(o=L,L=L+48|0,s=o+16|0,a=o+8|0,A=o,0|(n=0|Bt(n|=0)))return L=o,0|(A=n);if(l=0|r[(c=e)+4>>2],r[(n=a)>>2]=r[c>>2],r[n+4>>2]=l,wt(a,s),!(n=0|te(s,t,A))){if(t=0|r[a>>2],(0|(a=0|r[e+8>>2]))>0){s=0|r[e+12>>2],n=0;do{t=(0|r[s+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)<(0|a))}s=0|r[(n=A)>>2],(0|(n=0|r[n+4>>2]))<(0|(a=((0|t)<0)<<31>>31))|(0|n)==(0|a)&s>>>0<t>>>0?(r[(n=A)>>2]=t,r[n+4>>2]=a,n=a):t=s,l=0|Wt(0|t,0|n,12,0),c=0|B(),r[(n=A)>>2]=l,r[n+4>>2]=c,r[(n=i)>>2]=l,r[n+4>>2]=c,n=0}return L=o,0|(c=n)},_maxPolygonToCellsSizeExperimental:function(e,t,n,s){t|=0,n|=0,s|=0;var a,A,c=0,u=0,h=0,d=0,p=0,g=0,m=0,b=0;if(A=L,L=L+48|0,p=A+32|0,d=A+40|0,a=A,!(0|r[(e|=0)>>2]))return r[(g=s)>>2]=0,r[g+4>>2]=0,L=A,0|(g=0);Ue(p,0,0,0),c=0|r[(h=p)>>2],h=0|r[h+4>>2];do{if(t>>>0>15)r[(g=a)>>2]=0,r[g+4>>2]=0,r[a+8>>2]=4,r[a+12>>2]=-1,n=a+29|0,r[(g=a+16|0)>>2]=0,r[g+4>>2]=0,r[g+8>>2]=0,i[g+12|0]=0,i[n|0]=0|i[d|0],i[n+1|0]=0|i[d+1|0],i[n+2|0]=0|i[d+2|0],n=4,g=9;else{if(0|(n=0|Bt(n))){r[(p=a)>>2]=0,r[p+4>>2]=0,r[a+8>>2]=n,r[a+12>>2]=-1,g=a+29|0,r[(p=a+16|0)>>2]=0,r[p+4>>2]=0,r[p+8>>2]=0,i[p+12|0]=0,i[g|0]=0|i[d|0],i[g+1|0]=0|i[d+1|0],i[g+2|0]=0|i[d+2|0],g=9;break}if(!(n=0|Kt(1+(0|r[e+8>>2])|0,32))){r[(g=a)>>2]=0,r[g+4>>2]=0,r[a+8>>2]=13,r[a+12>>2]=-1,n=a+29|0,r[(g=a+16|0)>>2]=0,r[g+4>>2]=0,r[g+8>>2]=0,i[g+12|0]=0,i[n|0]=0|i[d|0],i[n+1|0]=0|i[d+1|0],i[n+2|0]=0|i[d+2|0],n=13,g=9;break}Mt(e,n),r[(b=a)>>2]=c,r[b+4>>2]=h,r[(h=a+8|0)>>2]=0,r[a+12>>2]=t,r[a+20>>2]=e,r[a+24>>2]=n,i[a+28|0]=0,i[(c=a+29|0)|0]=0|i[d|0],i[c+1|0]=0|i[d+1|0],i[c+2|0]=0|i[d+2|0],r[a+16>>2]=3,m=+Y(n),m*=+W(n),u=+l(+ +o[n>>3]),u=m/+f(+ +An(+u,+ +l(+ +o[n+8>>3])))*6371.007180918475*6371.007180918475,n=0|r[(c=a+12|0)>>2];e:do{if((0|n)>0)do{if(lt(n+-1|0,p),!(u/+o[p>>3]>10))break e;n=(b=0|r[c>>2])+-1|0,r[c>>2]=n}while((0|b)>1)}while(0);if(_t(a),r[(c=s)>>2]=0,r[c+4>>2]=0,!(!(0|(n=0|r[(c=a)>>2]))&!(0|(c=0|r[c+4>>2]))))do{Ge(n,c,t,p),d=p,d=0|Wt(0|r[(e=s)>>2],0|r[e+4>>2],0|r[d>>2],0|r[d+4>>2]),e=0|B(),r[(b=s)>>2]=d,r[b+4>>2]=e,_t(a),n=0|r[(b=a)>>2],c=0|r[b+4>>2]}while(!(!(0|n)&!(0|c)));n=0|r[h>>2]}}while(0);return L=A,0|(b=n)},_memcpy:cn,_memset:un,_originToDirectedEdges:function(e,t,n){n|=0;var i,o=0;return i=!(0|ze(e|=0,t|=0)),t&=-2130706433,r[(o=n)>>2]=i?e:0,r[o+4>>2]=i?285212672|t:0,r[(o=n+8|0)>>2]=e,r[o+4>>2]=301989888|t,r[(o=n+16|0)>>2]=e,r[o+4>>2]=318767104|t,r[(o=n+24|0)>>2]=e,r[o+4>>2]=335544320|t,r[(o=n+32|0)>>2]=e,r[o+4>>2]=352321536|t,r[(n=n+40|0)>>2]=e,r[n+4>>2]=369098752|t,0},_pentagonCount:function(){return 12},_polygonToCells:function(e,t,n,i){e|=0,t|=0,i|=0;var o,s,a,A,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0,y=0,v=0,_=0,C=0,x=0,w=0,M=0,S=0,T=0,E=0,P=0,I=0,R=0,F=0,N=0,U=0,k=0;if(A=L,L=L+112|0,o=A+80|0,h=A+72|0,s=A,a=A+56|0,0|(l=0|Bt(n|=0)))return L=A,0|(k=l);if(!(k=0|Qt(32+(r[(d=e+8|0)>>2]<<5)|0)))return L=A,0|(k=13);if(Mt(e,k),!(l=0|Bt(n))){if(U=0|r[(N=e)+4>>2],r[(l=h)>>2]=r[N>>2],r[l+4>>2]=U,wt(h,o),l=0|te(o,t,s))N=0,U=0;else{if(l=0|r[h>>2],(0|(c=0|r[d>>2]))>0){u=0|r[e+12>>2],n=0;do{l=(0|r[u+(n<<3)>>2])+l|0,n=n+1|0}while((0|n)!=(0|c));n=l}else n=l;c=0|r[(l=s)>>2],(0|(l=0|r[l+4>>2]))<(0|(u=((0|n)<0)<<31>>31))|(0|l)==(0|u)&c>>>0<n>>>0?(r[(l=s)>>2]=n,r[l+4>>2]=u,l=u):n=c,N=0|Wt(0|n,0|l,12,0),U=0|B(),r[(l=s)>>2]=N,r[l+4>>2]=U,l=0}if(!l){if(!(n=0|Kt(N,8)))return Jt(k),L=A,0|(k=13);if(!(f=0|Kt(N,8)))return Jt(k),Jt(n),L=A,0|(k=13);r[(R=o)>>2]=0,r[R+4>>2]=0,F=0|r[(R=e)+4>>2],r[(l=h)>>2]=r[R>>2],r[l+4>>2]=F,l=0|G(h,N,U,t,o,n,f);e:do{if(l)Jt(n),Jt(f),Jt(k);else{t:do{if((0|r[d>>2])>0){for(u=e+12|0,c=0;l=0|G((0|r[u>>2])+(c<<3)|0,N,U,t,o,n,f),c=c+1|0,!(0|l);)if((0|c)>=(0|r[d>>2]))break t;Jt(n),Jt(f),Jt(k);break e}}while(0);(0|U)>0|!(0|U)&N>>>0>0&&un(0|f,0,N<<3),R=0|r[(F=o)+4>>2];t:do{if((0|R)>0|!(0|R)&(0|r[F>>2])>>>0>0){E=n,P=f,I=n,R=f,F=n,l=n,M=n,S=f,T=f,n=f;n:for(;;){for(_=0,C=0,x=0,w=0,c=0,u=0;;){h=(f=s)+56|0;do{r[f>>2]=0,f=f+4|0}while((0|f)<(0|h));if(0|O(d=0|r[(t=E+(_<<3)|0)>>2],t=0|r[t+4>>2],1,s,0)){h=(f=s)+56|0;do{r[f>>2]=0,f=f+4|0}while((0|f)<(0|h));0|(f=0|Kt(7,4))&&(D(d,t,1,s,f,7,0,0),Jt(f))}for(v=0;;){b=0|r[(y=s+(v<<3)|0)>>2],y=0|r[y+4>>2];i:do{if(!(0|b)&!(0|y))f=c,h=u;else{if(p=0|tn(0|b,0|y,0|N,0|U),d=0|B(),!(!(0|(h=0|r[(t=f=i+(p<<3)|0)>>2]))&!(0|(t=0|r[t+4>>2])))){g=0,m=0;do{if((0|g)>(0|U)|(0|g)==(0|U)&m>>>0>N>>>0)break n;if((0|h)==(0|b)&(0|t)==(0|y)){f=c,h=u;break i}p=0|en(0|(f=0|Wt(0|p,0|d,1,0)),0|B(),0|N,0|U),d=0|B(),m=0|Wt(0|m,0|g,1,0),g=0|B(),h=0|r[(t=f=i+(p<<3)|0)>>2],t=0|r[t+4>>2]}while(!(!(0|h)&!(0|t)))}if(!(0|b)&!(0|y)){f=c,h=u;break}$e(b,y,a),0|St(e,k,a)&&(m=0|Wt(0|c,0|u,1,0),u=0|B(),r[(g=f)>>2]=b,r[g+4>>2]=y,r[(c=P+(c<<3)|0)>>2]=b,r[c+4>>2]=y,c=m),f=c,h=u}}while(0);if((v=v+1|0)>>>0>=7)break;c=f,u=h}if(_=0|Wt(0|_,0|C,1,0),C=0|B(),x=0|Wt(0|x,0|w,1,0),w=0|B(),c=0|r[(u=o)>>2],!((0|w)<(0|(u=0|r[u+4>>2]))|(0|w)==(0|u)&x>>>0<c>>>0))break;c=f,u=h}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{r[(w=E+(c<<3)|0)>>2]=0,r[w+4>>2]=0,c=0|Wt(0|c,0|u,1,0),u=0|B(),x=0|r[(w=o)+4>>2]}while((0|u)<(0|x)|((0|u)==(0|x)?c>>>0<(0|r[w>>2])>>>0:0))}if(r[(w=o)>>2]=f,r[w+4>>2]=h,!((0|h)>0|!(0|h)&f>>>0>0))break t;v=n,_=T,C=F,x=S,w=P,n=M,T=l,S=I,M=v,l=_,F=R,R=C,I=x,P=E,E=w}Jt(I),Jt(R),Jt(k),l=1;break e}l=f}while(0);Jt(k),Jt(n),Jt(l),l=0}}while(0);return L=A,0|(k=l)}}return Jt(k),L=A,0|(k=l)},_polygonToCellsExperimental:function(e,t,n,o,s,a){o|=0,s|=0,a|=0;var A,l,c,u=0,f=0,h=0,d=0,p=0,g=0,m=0,b=0;c=L,L=L+160|0,f=c+64|0,p=c+112|0,b=c,function(e,t,n,o){e|=0,t|=0,n|=0,o|=0;var s,a,A,l=0,c=0,u=0,f=0;A=L,L=L+48|0,s=A+40|0,a=A,Ue(c=A+32|0,0,0,0),u=0|r[c>>2],c=0|r[c+4>>2];do{if(n>>>0<=15){if(0|(l=0|Bt(o))){r[(o=a)>>2]=0,r[o+4>>2]=0,r[a+8>>2]=l,r[a+12>>2]=-1,u=a+29|0,r[(o=a+16|0)>>2]=0,r[o+4>>2]=0,r[o+8>>2]=0,i[o+12|0]=0,i[0|u]=0|i[0|s],i[u+1|0]=0|i[s+1|0],i[u+2|0]=0|i[s+2|0];break}if(l=0|Kt(1+(0|r[t+8>>2])|0,32)){Mt(t,l),r[(f=a)>>2]=u,r[f+4>>2]=c,r[a+8>>2]=0,r[a+12>>2]=n,r[a+16>>2]=o,r[a+20>>2]=t,r[a+24>>2]=l,i[a+28|0]=0,i[0|(u=a+29|0)]=0|i[0|s],i[u+1|0]=0|i[s+1|0],i[u+2|0]=0|i[s+2|0];break}r[(o=a)>>2]=0,r[o+4>>2]=0,r[a+8>>2]=13,r[a+12>>2]=-1,u=a+29|0,r[(o=a+16|0)>>2]=0,r[o+4>>2]=0,r[o+8>>2]=0,i[o+12|0]=0,i[0|u]=0|i[0|s],i[u+1|0]=0|i[s+1|0],i[u+2|0]=0|i[s+2|0];break}r[(u=a)>>2]=0,r[u+4>>2]=0,r[a+8>>2]=4,r[a+12>>2]=-1,f=a+29|0,r[(u=a+16|0)>>2]=0,r[u+4>>2]=0,r[u+8>>2]=0,i[u+12|0]=0,i[0|f]=0|i[0|s],i[f+1|0]=0|i[s+1|0],i[f+2|0]=0|i[s+2|0]}while(0);_t(a),r[e>>2]=r[a>>2],r[e+4>>2]=r[a+4>>2],r[e+8>>2]=r[a+8>>2],r[e+12>>2]=r[a+12>>2],r[e+16>>2]=r[a+16>>2],r[e+20>>2]=r[a+20>>2],r[e+24>>2]=r[a+24>>2],r[e+28>>2]=r[a+28>>2],L=A}(d=c+80|0,e|=0,t|=0,n|=0),nt(f,0|r[(h=d)>>2],0|r[h+4>>2],t),A=0|r[(h=f)>>2],h=0|r[h+4>>2],u=0|r[d+8>>2],r[(g=p+4|0)>>2]=r[d>>2],r[g+4>>2]=r[d+4>>2],r[g+8>>2]=r[d+8>>2],r[g+12>>2]=r[d+12>>2],r[g+16>>2]=r[d+16>>2],r[g+20>>2]=r[d+20>>2],r[g+24>>2]=r[d+24>>2],r[g+28>>2]=r[d+28>>2],r[(g=b)>>2]=A,r[g+4>>2]=h,r[(g=b+8|0)>>2]=u,t=p,n=(e=b+12|0)+36|0;do{r[e>>2]=r[t>>2],e=e+4|0,t=t+4|0}while((0|e)<(0|n));if(r[(p=b+48|0)>>2]=r[f>>2],r[p+4>>2]=r[f+4>>2],r[p+8>>2]=r[f+8>>2],r[p+12>>2]=r[f+12>>2],!(0|A)&!(0|h))return L=c,0|(b=u);n=b+16|0,l=b+24|0,d=b+28|0,u=0,f=0,t=A,e=h;do{if(!((0|u)<(0|s)|(0|u)==(0|s)&f>>>0<o>>>0)){m=4;break}if(h=f,f=0|Wt(0|f,0|u,1,0),u=0|B(),r[(h=a+(h<<3)|0)>>2]=t,r[h+4>>2]=e,rt(p),!(0|(t=0|r[(e=p)>>2]))&!(0|(e=0|r[e+4>>2]))){if(_t(n),!(0|(e=0|r[(t=n)>>2]))&!(0|(t=0|r[t+4>>2]))){m=10;break}it(e,t,0|r[d>>2],p),t=0|r[(e=p)>>2],e=0|r[e+4>>2]}r[(h=b)>>2]=t,r[h+4>>2]=e}while(!(!(0|t)&!(0|e)));return 4==(0|m)?(0|(t=0|r[(e=b+40|0)>>2])&&Jt(t),r[(m=b+16|0)>>2]=0,r[m+4>>2]=0,r[l>>2]=0,r[b+36>>2]=0,r[d>>2]=-1,r[b+32>>2]=0,r[e>>2]=0,it(0,0,0,p),r[b>>2]=0,r[b+4>>2]=0,r[g>>2]=0,L=c,0|(b=14)):(10==(0|m)&&(r[b>>2]=0,r[b+4>>2]=0,r[g>>2]=r[l>>2]),b=0|r[g>>2],L=c,0|b)},_readInt64AsDoubleFromPointer:function(e){return+(+((0|r[(e|=0)>>2])>>>0)+4294967296*+(0|r[e+4>>2]))},_res0CellCount:function(){return 122},_round:fn,_sbrk:hn,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(e,t,n,i,o,s,a){e|=0,i|=0,o|=0,s|=0;var A,l=0,c=0,u=0,f=0,h=0,d=0,p=0,g=0;if(A=L,L=L+16|0,g=A,!((0|(n|=0))>0|!(0|n)&(t|=0)>>>0>0))return L=A,0|(g=0);if((0|(a|=0))>=16)return L=A,0|(g=12);d=0,p=0,h=0,l=0;e:for(;;){if(f=0|rn(0|(c=0|r[(u=e+(d<<3)|0)>>2]),0|(u=0|r[u+4>>2]),52),B(),(15&f)>(0|a)){l=12,c=11;break}if(nt(g,c,u,a),!(0|(u=0|r[(f=g)>>2]))&!(0|(f=0|r[f+4>>2])))c=h;else{c=h;do{if(!((0|l)<(0|s)|(0|l)==(0|s)&c>>>0<o>>>0)){c=10;break e}r[(h=i+(c<<3)|0)>>2]=u,r[h+4>>2]=f,c=0|Wt(0|c,0|l,1,0),l=0|B(),rt(g),u=0|r[(h=g)>>2],f=0|r[h+4>>2]}while(!(!(0|u)&!(0|f)))}if(d=0|Wt(0|d,0|p,1,0),!((0|(p=0|B()))<(0|n)|(0|p)==(0|n)&d>>>0<t>>>0)){l=0,c=11;break}h=c}return 10==(0|c)?(L=A,0|(g=14)):11==(0|c)?(L=A,0|l):0},_uncompactCellsSize:function(e,t,n,i,o){e|=0,t|=0,n|=0,i|=0,o|=0;var s,a,A=0,l=0,c=0,u=0,f=0,h=0;a=L,L=L+16|0,s=a;e:do{if((0|n)>0|!(0|n)&t>>>0>0){for(f=0,l=0,A=0,h=0;;){if(!(!(0|(c=0|r[(u=e+(f<<3)|0)>>2]))&!(0|(u=0|r[u+4>>2]))||(u=!(0|Ge(c,u,i,s)),l=0|Wt(0|r[(c=s)>>2],0|r[c+4>>2],0|l,0|A),A=0|B(),u))){A=12;break}if(f=0|Wt(0|f,0|h,1,0),!((0|(h=0|B()))<(0|n)|(0|h)==(0|n)&f>>>0<t>>>0))break e}return L=a,0|A}l=0,A=0}while(0);return r[o>>2]=l,r[o+4>>2]=A,L=a,0|(o=0)},_vertexToLatLng:function(e,t,n){n|=0;var i,o,s,a,A=0,l=0;return a=L,L=L+192|0,o=a,s=a+168|0,A=0|rn(0|(e|=0),0|(t|=0),56),B(),A&=7,0|(i=0|Ze(e,l=-2130706433&t|134217728,s))?(L=a,0|(l=i)):(t=0|rn(0|e,0|t,52),B(),t&=15,0|ze(e,l)?Pe(s,t,A,1,o):Fe(s,t,A,1,o),l=o+8|0,r[n>>2]=r[l>>2],r[n+4>>2]=r[l+4>>2],r[n+8>>2]=r[l+8>>2],r[n+12>>2]=r[l+12>>2],L=a,0|(l=0))},establishStackSpace:function(e,t){L=e|=0},stackAlloc:function(e){var t;return t=L,L=(L=L+(e|=0)|0)+15&-16,0|t},stackRestore:function(e){L=e|=0},stackSave:function(){return 0|L}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(e){A=e},c:function(){return A},d:function(e,t,n,i){ie("Assertion failed: "+v(e)+", at: "+[t?v(t):"unknown filename",n,i?v(i):"unknown function"])},e:function(e){return n.___errno_location&&(g[n.___errno_location()>>2]=e),e},f:V,g:function(e,t,n){d.set(d.subarray(t,t+n),e)},h:function(e){var t=V(),n=16777216,i=2130706432;if(e>i)return!1;for(var r=Math.max(t,16777216);r<e;)r=r<=536870912?_(2*r,n):Math.min(_((3*r+2147483648)/4,n),i);return!!function(e){try{var t=new ArrayBuffer(e);if(t.byteLength!=e)return;return new Int8Array(t).set(h),J(t),C(t),1}catch(n){}}(r)},i:function(e){ie("OOM")},o:28640,p:28624},f);n.___divdi3=Q.___divdi3,n.___muldi3=Q.___muldi3,n.___remdi3=Q.___remdi3,n.___uremdi3=Q.___uremdi3,n._areNeighborCells=Q._areNeighborCells,n._bitshift64Ashr=Q._bitshift64Ashr,n._bitshift64Lshr=Q._bitshift64Lshr,n._bitshift64Shl=Q._bitshift64Shl,n._calloc=Q._calloc,n._cellAreaKm2=Q._cellAreaKm2,n._cellAreaM2=Q._cellAreaM2,n._cellAreaRads2=Q._cellAreaRads2,n._cellToBoundary=Q._cellToBoundary,n._cellToCenterChild=Q._cellToCenterChild,n._cellToChildPos=Q._cellToChildPos,n._cellToChildren=Q._cellToChildren,n._cellToChildrenSize=Q._cellToChildrenSize,n._cellToLatLng=Q._cellToLatLng,n._cellToLocalIj=Q._cellToLocalIj,n._cellToParent=Q._cellToParent,n._cellToVertex=Q._cellToVertex,n._cellToVertexes=Q._cellToVertexes,n._cellsToDirectedEdge=Q._cellsToDirectedEdge,n._cellsToLinkedMultiPolygon=Q._cellsToLinkedMultiPolygon,n._childPosToCell=Q._childPosToCell,n._compactCells=Q._compactCells,n._constructCell=Q._constructCell,n._destroyLinkedMultiPolygon=Q._destroyLinkedMultiPolygon,n._directedEdgeToBoundary=Q._directedEdgeToBoundary,n._directedEdgeToCells=Q._directedEdgeToCells,n._edgeLengthKm=Q._edgeLengthKm,n._edgeLengthM=Q._edgeLengthM,n._edgeLengthRads=Q._edgeLengthRads;var J=n._emscripten_replace_memory=Q._emscripten_replace_memory;n._free=Q._free,n._getBaseCellNumber=Q._getBaseCellNumber,n._getDirectedEdgeDestination=Q._getDirectedEdgeDestination,n._getDirectedEdgeOrigin=Q._getDirectedEdgeOrigin,n._getHexagonAreaAvgKm2=Q._getHexagonAreaAvgKm2,n._getHexagonAreaAvgM2=Q._getHexagonAreaAvgM2,n._getHexagonEdgeLengthAvgKm=Q._getHexagonEdgeLengthAvgKm,n._getHexagonEdgeLengthAvgM=Q._getHexagonEdgeLengthAvgM,n._getIcosahedronFaces=Q._getIcosahedronFaces,n._getIndexDigit=Q._getIndexDigit,n._getNumCells=Q._getNumCells,n._getPentagons=Q._getPentagons,n._getRes0Cells=Q._getRes0Cells,n._getResolution=Q._getResolution,n._greatCircleDistanceKm=Q._greatCircleDistanceKm,n._greatCircleDistanceM=Q._greatCircleDistanceM,n._greatCircleDistanceRads=Q._greatCircleDistanceRads,n._gridDisk=Q._gridDisk,n._gridDiskDistances=Q._gridDiskDistances,n._gridDistance=Q._gridDistance,n._gridPathCells=Q._gridPathCells,n._gridPathCellsSize=Q._gridPathCellsSize,n._gridRing=Q._gridRing,n._gridRingUnsafe=Q._gridRingUnsafe,n._i64Add=Q._i64Add,n._i64Subtract=Q._i64Subtract,n._isPentagon=Q._isPentagon,n._isResClassIII=Q._isResClassIII,n._isValidCell=Q._isValidCell,n._isValidDirectedEdge=Q._isValidDirectedEdge,n._isValidIndex=Q._isValidIndex,n._isValidVertex=Q._isValidVertex,n._latLngToCell=Q._latLngToCell,n._llvm_ctlz_i64=Q._llvm_ctlz_i64,n._llvm_maxnum_f64=Q._llvm_maxnum_f64,n._llvm_minnum_f64=Q._llvm_minnum_f64,n._llvm_round_f64=Q._llvm_round_f64,n._localIjToCell=Q._localIjToCell,n._malloc=Q._malloc,n._maxFaceCount=Q._maxFaceCount,n._maxGridDiskSize=Q._maxGridDiskSize,n._maxPolygonToCellsSize=Q._maxPolygonToCellsSize,n._maxPolygonToCellsSizeExperimental=Q._maxPolygonToCellsSizeExperimental,n._memcpy=Q._memcpy,n._memset=Q._memset,n._originToDirectedEdges=Q._originToDirectedEdges,n._pentagonCount=Q._pentagonCount,n._polygonToCells=Q._polygonToCells,n._polygonToCellsExperimental=Q._polygonToCellsExperimental,n._readInt64AsDoubleFromPointer=Q._readInt64AsDoubleFromPointer,n._res0CellCount=Q._res0CellCount,n._round=Q._round,n._sbrk=Q._sbrk,n._sizeOfCellBoundary=Q._sizeOfCellBoundary,n._sizeOfCoordIJ=Q._sizeOfCoordIJ,n._sizeOfGeoLoop=Q._sizeOfGeoLoop,n._sizeOfGeoPolygon=Q._sizeOfGeoPolygon,n._sizeOfH3Index=Q._sizeOfH3Index,n._sizeOfLatLng=Q._sizeOfLatLng,n._sizeOfLinkedGeoPolygon=Q._sizeOfLinkedGeoPolygon,n._uncompactCells=Q._uncompactCells,n._uncompactCellsSize=Q._uncompactCellsSize,n._vertexToLatLng=Q._vertexToLatLng,n.establishStackSpace=Q.establishStackSpace;var K,W,q=n.stackAlloc=Q.stackAlloc,Y=n.stackRestore=Q.stackRestore,X=n.stackSave=Q.stackSave;if(n.asm=Q,n.cwrap=function(e,t,n,i){var r=(n=n||[]).every(function(e){return"number"===e});return"string"!==t&&r&&!i?c(e):function(){return u(e,t,n,arguments)}},n.setValue=function(e,t,n,i){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":h[e|0]=t;break;case"i16":p[e>>1]=t;break;case"i32":g[e>>2]=t;break;case"i64":U=[t>>>0,(N=t,+I(N)>=1?N>0?(0|F(+R(N/4294967296),4294967295))>>>0:~~+L((N-+(~~N>>>0))/4294967296)>>>0:0)],g[e>>2]=U[0],g[e+4>>2]=U[1];break;case"float":m[e>>2]=t;break;case"double":b[e>>3]=t;break;default:ie("invalid type for setValue: "+n)}},n.getValue=function(e,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return h[e|0];case"i16":return p[e>>1];case"i32":case"i64":return g[e>>2];case"float":return m[e>>2];case"double":return b[e>>3];default:ie("invalid type for getValue: "+t)}return null},k){z(k)||(K=k,k=n.locateFile?n.locateFile(K,o):o+K),O++,n.monitorRunDependencies&&n.monitorRunDependencies(O);var Z=function(e){e.byteLength&&(e=new Uint8Array(e)),d.set(e,8),n.memoryInitializerRequest&&delete n.memoryInitializerRequest.response,function(){if(O--,n.monitorRunDependencies&&n.monitorRunDependencies(O),0==O&&D){var e=D;D=null,e()}}()},$=function(){r(k,Z,function(){throw"could not load memory initializer "+k})},ee=j(k);if(ee)Z(ee.buffer);else if(n.memoryInitializerRequest){var te=function(){var e=n.memoryInitializerRequest,t=e.response;if(200!==e.status&&0!==e.status){var i=j(n.memoryInitializerRequestURL);if(!i)return void $();t=i.buffer}Z(t)};n.memoryInitializerRequest.response?setTimeout(te,0):n.memoryInitializerRequest.addEventListener("load",te)}else $()}function ne(e){function t(){W||(W=!0,l||(w(M),w(S),n.onRuntimeInitialized&&n.onRuntimeInitialized(),function(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)P(n.postRun.shift());w(T)}()))}O>0||(!function(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)E(n.preRun.shift());w(B)}(),O>0||(n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),t()},1)):t()))}function ie(e){throw n.onAbort&&n.onAbort(e),s(e+=""),a(e),l=!0,"abort("+e+"). Build with -s ASSERTIONS=1 for more info."}if(D=function e(){W||ne(),W||(D=e)},n.run=ne,n.abort=ie,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return ne(),e}("object"==typeof lh?lh:{}),ch="number",uh={0:"Success",1:"The operation failed but a more specific error is not available",2:"Argument was outside of acceptable range",3:"Latitude or longitude arguments were outside of acceptable range",4:"Resolution argument was outside of acceptable range",5:"Cell argument was not valid",6:"Directed edge argument was not valid",7:"Undirected edge argument was not valid",8:"Vertex argument was not valid",9:"Pentagon distortion was encountered",10:"Duplicate input",11:"Cell arguments were not neighbors",12:"Cell arguments had incompatible resolutions",13:"Memory allocation failed",14:"Bounds of provided memory were insufficient",15:"Mode or flags argument was not valid",16:"Index argument was not valid",17:"Base cell number was outside of acceptable range",18:"Child indexing digits invalid",19:"Child indexing digits refer to a deleted subsequence"},fh={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function hh(e,t,n){var i=n&&"value"in n,r=new Error((e[t]||"Unknown error")+" (code: "+t+(i?", value: "+n.value:"")+")");return r.code=t,r}function dh(e,t){return hh(uh,e,2===arguments.length?{value:t}:{})}function ph(e,t){return hh(fh,e,2===arguments.length?{value:t}:{})}function gh(e){if(0!==e)throw dh(e)}var mh={};[["sizeOfH3Index",ch],["sizeOfLatLng",ch],["sizeOfCellBoundary",ch],["sizeOfGeoLoop",ch],["sizeOfGeoPolygon",ch],["sizeOfLinkedGeoPolygon",ch],["sizeOfCoordIJ",ch],["readInt64AsDoubleFromPointer",ch],["isValidCell",ch,[ch,ch]],["isValidIndex",ch,[ch,ch]],["latLngToCell",ch,[ch,ch,ch,ch]],["cellToLatLng",ch,[ch,ch,ch]],["cellToBoundary",ch,[ch,ch,ch]],["maxGridDiskSize",ch,[ch,ch]],["gridDisk",ch,[ch,ch,ch,ch]],["gridDiskDistances",ch,[ch,ch,ch,ch,ch]],["gridRing",ch,[ch,ch,ch,ch]],["gridRingUnsafe",ch,[ch,ch,ch,ch]],["maxPolygonToCellsSize",ch,[ch,ch,ch,ch]],["polygonToCells",ch,[ch,ch,ch,ch]],["maxPolygonToCellsSizeExperimental",ch,[ch,ch,ch,ch]],["polygonToCellsExperimental",ch,[ch,ch,ch,ch,ch,ch]],["cellsToLinkedMultiPolygon",ch,[ch,ch,ch]],["destroyLinkedMultiPolygon",null,[ch]],["compactCells",ch,[ch,ch,ch,ch]],["uncompactCells",ch,[ch,ch,ch,ch,ch,ch]],["uncompactCellsSize",ch,[ch,ch,ch,ch,ch]],["isPentagon",ch,[ch,ch]],["isResClassIII",ch,[ch,ch]],["getBaseCellNumber",ch,[ch,ch]],["getResolution",ch,[ch,ch]],["getIndexDigit",ch,[ch,ch,ch]],["constructCell",ch,[ch,ch,ch,ch]],["maxFaceCount",ch,[ch,ch,ch]],["getIcosahedronFaces",ch,[ch,ch,ch]],["cellToParent",ch,[ch,ch,ch,ch]],["cellToChildren",ch,[ch,ch,ch,ch]],["cellToCenterChild",ch,[ch,ch,ch,ch]],["cellToChildrenSize",ch,[ch,ch,ch,ch]],["cellToChildPos",ch,[ch,ch,ch,ch]],["childPosToCell",ch,[ch,ch,ch,ch,ch,ch]],["areNeighborCells",ch,[ch,ch,ch,ch,ch]],["cellsToDirectedEdge",ch,[ch,ch,ch,ch,ch]],["getDirectedEdgeOrigin",ch,[ch,ch,ch]],["getDirectedEdgeDestination",ch,[ch,ch,ch]],["isValidDirectedEdge",ch,[ch,ch]],["directedEdgeToCells",ch,[ch,ch,ch]],["originToDirectedEdges",ch,[ch,ch,ch]],["directedEdgeToBoundary",ch,[ch,ch,ch]],["gridDistance",ch,[ch,ch,ch,ch,ch]],["gridPathCells",ch,[ch,ch,ch,ch,ch]],["gridPathCellsSize",ch,[ch,ch,ch,ch,ch]],["cellToLocalIj",ch,[ch,ch,ch,ch,ch,ch]],["localIjToCell",ch,[ch,ch,ch,ch,ch]],["getHexagonAreaAvgM2",ch,[ch,ch]],["getHexagonAreaAvgKm2",ch,[ch,ch]],["getHexagonEdgeLengthAvgM",ch,[ch,ch]],["getHexagonEdgeLengthAvgKm",ch,[ch,ch]],["greatCircleDistanceM",ch,[ch,ch]],["greatCircleDistanceKm",ch,[ch,ch]],["greatCircleDistanceRads",ch,[ch,ch]],["cellAreaM2",ch,[ch,ch,ch]],["cellAreaKm2",ch,[ch,ch,ch]],["cellAreaRads2",ch,[ch,ch,ch]],["edgeLengthM",ch,[ch,ch,ch]],["edgeLengthKm",ch,[ch,ch,ch]],["edgeLengthRads",ch,[ch,ch,ch]],["getNumCells",ch,[ch,ch]],["getRes0Cells",ch,[ch]],["res0CellCount",ch],["getPentagons",ch,[ch,ch]],["pentagonCount",ch],["cellToVertex",ch,[ch,ch,ch,ch]],["cellToVertexes",ch,[ch,ch,ch]],["vertexToLatLng",ch,[ch,ch,ch]],["isValidVertex",ch,[ch,ch]]].forEach(function(e){mh[e[0]]=lh.cwrap.apply(lh,e)});var bh=16,yh=mh.sizeOfH3Index(),vh=mh.sizeOfLatLng(),_h=mh.sizeOfCellBoundary();mh.sizeOfGeoPolygon(),mh.sizeOfGeoLoop();var Ch=mh.sizeOfLinkedGeoPolygon();mh.sizeOfCoordIJ();var xh="m",wh="km";var Bh=/[^0-9a-fA-F]/;function Mh(e){if(Array.isArray(e)&&2===e.length&&Number.isInteger(e[0])&&Number.isInteger(e[1]))return e;if("string"!=typeof e||Bh.test(e))return[0,0];var t=parseInt(e.substring(0,e.length-8),bh);return[parseInt(e.substring(e.length-8),bh),t]}function Sh(e){if(e>=0)return e.toString(bh);var t=Th(8,(e&=2147483647).toString(bh));return t=(parseInt(t[0],bh)+8).toString(bh)+t.substring(1)}function Th(e,t){for(var n=e-t.length,i="",r=0;r<n;r++)i+="0";return i+=t}function Eh(e,t){void 0===t&&(t=0);var n=lh.getValue(e+yh*t,"i32"),i=lh.getValue(e+yh*t+4,"i32");return i?function(e,t){return Sh(t)+Th(8,Sh(e))}(n,i):null}function Ph(e,t,n){lh.HEAPU32.set(Mh(e),t/4+2*n)}function Ih(e){return 180*lh.getValue(e,"double")/Math.PI}function Lh(e){return[Ih(e+8),Ih(e)]}function Rh(e){var t=Mh(e),n=t[0],i=t[1];return Boolean(mh.isPentagon(n,i))}function Fh(e){var t=Mh(e),n=t[0],i=t[1];return mh.isValidCell(n,i)?mh.getResolution(n,i):-1}function Oh(e,t,n){var i=lh._malloc(vh);lh.HEAPF64.set([e,t].map(zh),i/8);var r=lh._malloc(yh);try{return gh(mh.latLngToCell(i,n,r)),function(e){if(!e)throw ph(1002);return e}(Eh(r))}finally{lh._free(r),lh._free(i)}}function Dh(e){var t,n=lh._malloc(vh),i=Mh(e),r=i[0],o=i[1];try{return gh(mh.cellToLatLng(r,o,n)),[Ih(t=n),Ih(t+8)]}finally{lh._free(n)}}function Nh(e,t){var n=lh._malloc(_h),i=Mh(e),r=i[0],o=i[1];try{return gh(mh.cellToBoundary(r,o,n)),function(e){for(var t=lh.getValue(e,"i32"),n=e+8,i=[],r=Lh,o=0;o<2*t;o+=2)i.push(r(n+8*o));return i.push(i[0]),i}(n)}finally{lh._free(n)}}function Uh(e,t){if(!e||!e.length)return[];var n=e.length,i=lh._calloc(n,yh);!function(e,t){for(var n=t.length,i=0;i<n;i++)Ph(t[i],e,i)}(i,e);var r=lh._calloc(Ch);try{return gh(mh.cellsToLinkedMultiPolygon(i,n,r)),function(e){for(var t,n,i,r,o=[],s=Lh;e;){for(o.push(t=[]),n=lh.getValue(e,"i8*");n;){for(t.push(i=[]),r=lh.getValue(n,"i8*");r;)i.push(s(r)),r=lh.getValue(r+16,"i8*");i.push(i[0]),n=lh.getValue(n+8,"i8*")}e=lh.getValue(e+8,"i8*")}return o}(r)}finally{mh.destroyLinkedMultiPolygon(r),lh._free(r),lh._free(i)}}function kh(e,t){var n,i=Mh(e),r=i[0],o=i[1],s=Mh(t),a=s[0],A=s[1],l=lh._malloc(8);try{return gh(mh.gridDistance(r,o,a,A,l)),n=l,mh.readInt64AsDoubleFromPointer(n)}finally{lh._free(l)}}function Gh(e,t){!function(e){if("number"!=typeof e||e<0||e>15||Math.floor(e)!==e)throw dh(4,e)}(e);var n,i,r=lh._malloc(8);try{switch(t){case xh:gh(mh.getHexagonEdgeLengthAvgM(e,r));break;case wh:gh(mh.getHexagonEdgeLengthAvgKm(e,r));break;default:throw ph(1e3,t)}return n=r,void 0===i&&(i=0),lh.getValue(n+8*i,"double")}finally{lh._free(r)}}function zh(e){return e*Math.PI/180}function Vh(e,t){t=void 0===t?e[0][0]:t;for(const n of e){const e=n[0]-t;e>180?n[0]-=360:e<-180&&(n[0]+=360)}}function Hh(e,t,n){const i=e(t,n),[r,o]=Dh(i);return[o,r]}function jh(e,t=1){const n=Nh(e);return 1!==t?function(e,t,n){const[i,r]=Dh(e),o=t.length;Vh(t,r);const s=t[0]===t[o-1]?o-1:o;for(let a=0;a<s;a++)t[a][0]=Ee(r,t[a][0],n),t[a][1]=Ee(i,t[a][1],n)}(e,n,t):Vh(n),n}function Qh(e){const t=new Float64Array(2*e.length);let n=0;for(const i of e)t[n++]=i[0],t[n++]=i[1];return t}class Jh extends Za{indexToBounds(){const{data:e,getPentagon:t}=this.props;return{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>{const i=t(e,n);return Qh(function(e,{closedRing:t=!0,segments:n="auto"}={closedRing:!0,segments:"auto"}){if(0n===e)return[];const{S:i,segment:r,origin:o,resolution:s}=rh(e);"auto"===n&&(n=Math.max(1,Math.pow(2,6-s)));const a=$u(sh({S:i,segment:r,origin:o,resolution:s}).splitEdges(n).getVertices().map(e=>oh.inverse(e,o.id)).map(e=>Zu(e)));return t&&a.push(a[0]),a.reverse(),a}("string"==typeof i?BigInt(`0x${i}`):i,{closedRing:!0,segments:"auto"}))}}}}function Kh(e){return"string"==typeof e?e.charAt(0).toLowerCase()+e.slice(1):e}function Wh(e){if(Array.isArray(e))return e.map(e=>Wh(e));if(e&&"object"==typeof e){const t={};for(const[n,i]of Object.entries(e))t[Kh(n)]=Wh(i);return t}return e}Jh.layerName="A5Layer",Jh.defaultProps={getPentagon:{type:"accessor",value:e=>e.pentagon}};const qh=":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",Yh=new RegExp("^"+("["+qh+"]["+(qh+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*")+"$");function Xh(e,t){const n=[];let i=t.exec(e);for(;i;){const r=[];r.startIndex=t.lastIndex-i[0].length;const o=i.length;for(let e=0;e<o;e++)r.push(i[e]);n.push(r),i=t.exec(e)}return n}const Zh=function(e){const t=Yh.exec(e);return!(null==t)};const $h=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],ed=["__proto__","constructor","prototype"],td={allowBooleanAttributes:!1,unpairedTags:[]};function nd(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function id(e,t){const n=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){const i=e.substr(n,t-n);if(t>5&&"xml"===i)return ud("InvalidXml","XML declaration allowed only at the start of the document.",dd(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}continue}return t}function rd(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let n=1;for(t+=8;t<e.length;t++)if("<"===e[t])n++;else if(">"===e[t]&&(n--,0===n))break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7])for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}return t}const od='"',sd="'";function ad(e,t){let n="",i="",r=!1;for(;t<e.length;t++){if(e[t]===od||e[t]===sd)""===i?i=e[t]:i!==e[t]||(i="");else if(">"===e[t]&&""===i){r=!0;break}n+=e[t]}return""===i&&{value:n,index:t,tagClosed:r}}const Ad=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function ld(e,t){const n=Xh(e,Ad),i={};for(let r=0;r<n.length;r++){if(0===n[r][1].length)return ud("InvalidAttr","Attribute '"+n[r][2]+"' has no space in starting.",pd(n[r]));if(void 0!==n[r][3]&&void 0===n[r][4])return ud("InvalidAttr","Attribute '"+n[r][2]+"' is without value.",pd(n[r]));if(void 0===n[r][3]&&!t.allowBooleanAttributes)return ud("InvalidAttr","boolean attribute '"+n[r][2]+"' is not allowed.",pd(n[r]));const e=n[r][2];if(!fd(e))return ud("InvalidAttr","Attribute '"+e+"' is an invalid name.",pd(n[r]));if(Object.prototype.hasOwnProperty.call(i,e))return ud("InvalidAttr","Attribute '"+e+"' is repeated.",pd(n[r]));i[e]=1}return!0}function cd(e,t){if(";"===e[++t])return-1;if("#"===e[t])return function(e,t){let n=/\d/;for("x"===e[t]&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(n))break}return-1}(e,++t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(";"===e[t])break;return-1}return t}function ud(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function fd(e){return Zh(e)}function hd(e){return Zh(e)}function dd(e,t){const n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function pd(e){return e.startIndex+e[1].length}const gd={cent:"¢",pound:"£",curren:"¤",yen:"¥",euro:"€",dollar:"$",euro:"€",fnof:"ƒ",inr:"₹",af:"؋",birr:"ብር",peso:"₱",rub:"₽",won:"₩",yuan:"¥",cedil:"¸"},md={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},bd={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},yd=new Set("!?\\\\/[]$%{}^&*()<>|+");function vd(e){if("#"===e[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${e}"`);for(const t of e)if(yd.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${e}"`);return e}function _d(...e){const t=/* @__PURE__ */Object.create(null);for(const n of e)if(n)for(const e of Object.keys(n)){const i=n[e];if("string"==typeof i)t[e]=i;else if(i&&"object"==typeof i&&void 0!==i.val){const n=i.val;"string"==typeof n&&(t[e]=n)}}return t}const Cd="external",xd="base",wd="all";const Bd=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Md=/* @__PURE__ */new Set([9,10,13]);class Sd{constructor(e={}){var t;this._limit=e.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof e.postCheck?e.postCheck:e=>e,this._limitTiers=(t=this._limit.applyLimitsTo??Cd)&&t!==Cd?t===wd?/* @__PURE__ */new Set([wd]):t===xd?/* @__PURE__ */new Set([xd]):Array.isArray(t)?new Set(t):/* @__PURE__ */new Set([Cd]):/* @__PURE__ */new Set([Cd]),this._numericAllowed=e.numericAllowed??!0,this._baseMap=_d(md,e.namedEntities||null),this._externalMap=/* @__PURE__ */Object.create(null),this._inputMap=/* @__PURE__ */Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(e.remove&&Array.isArray(e.remove)?e.remove:[]),this._leaveSet=new Set(e.leave&&Array.isArray(e.leave)?e.leave:[]);const n=function(e){if(!e)return{xmlVersion:1,onLevel:Bd.allow,nullLevel:Bd.remove};const t=1.1===e.xmlVersion?1.1:1,n=Bd[e.onNCR]??Bd.allow,i=Bd[e.nullNCR]??Bd.remove;return{xmlVersion:t,onLevel:n,nullLevel:Math.max(i,Bd.remove)}}(e.ncr);this._ncrXmlVersion=n.xmlVersion,this._ncrOnLevel=n.onLevel,this._ncrNullLevel=n.nullLevel}setExternalEntities(e){if(e)for(const t of Object.keys(e))vd(t);this._externalMap=_d(e)}addExternalEntity(e,t){vd(e),"string"==typeof t&&-1===t.indexOf("&")&&(this._externalMap[e]=t)}addInputEntities(e){this._totalExpansions=0,this._expandedLength=0,this._inputMap=_d(e)}reset(){return this._inputMap=/* @__PURE__ */Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(e){this._ncrXmlVersion=1.1===e?1.1:1}decode(e){if("string"!=typeof e||0===e.length)return e;const t=e,n=[],i=e.length;let r=0,o=0;const s=this._maxTotalExpansions>0,a=this._maxExpandedLength>0,A=s||a;for(;o<i;){if(38!==e.charCodeAt(o)){o++;continue}let t=o+1;for(;t<i&&59!==e.charCodeAt(t)&&t-o<=32;)t++;if(t>=i||59!==e.charCodeAt(t)){o++;continue}const l=e.slice(o+1,t);if(0===l.length){o++;continue}let c,u;if(this._removeSet.has(l))c="",void 0===u&&(u=Cd);else{if(this._leaveSet.has(l)){o++;continue}if(35===l.charCodeAt(0)){const e=this._resolveNCR(l);if(void 0===e){o++;continue}c=e,u=xd}else{const e=this._resolveName(l);c=e?.value,u=e?.tier}}if(void 0!==c){if(o>r&&n.push(e.slice(r,o)),n.push(c),r=t+1,o=r,A&&this._tierCounts(u)){if(s&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(a){const e=c.length-(l.length+2);if(e>0&&(this._expandedLength+=e,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else o++}r<i&&n.push(e.slice(r));const l=0===n.length?e:n.join("");return this._postCheck(l,t)}_tierCounts(e){return!!this._limitTiers.has(wd)||this._limitTiers.has(e)}_resolveName(e){return e in this._inputMap?{value:this._inputMap[e],tier:Cd}:e in this._externalMap?{value:this._externalMap[e],tier:Cd}:e in this._baseMap?{value:this._baseMap[e],tier:xd}:void 0}_classifyNCR(e){return 0===e?this._ncrNullLevel:e>=55296&&e<=57343||1===this._ncrXmlVersion&&e>=1&&e<=31&&!Md.has(e)?Bd.remove:-1}_applyNCRAction(e,t,n){switch(e){case Bd.allow:return String.fromCodePoint(n);case Bd.remove:return"";case Bd.leave:return;case Bd.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${t}; (U+${n.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(n)}}_resolveNCR(e){const t=e.charCodeAt(1);let n;if(n=120===t||88===t?parseInt(e.slice(2),16):parseInt(e.slice(1),10),Number.isNaN(n)||n<0||n>1114111)return;const i=this._classifyNCR(n);if(!this._numericAllowed&&i<Bd.remove)return;const r=-1===i?this._ncrOnLevel:Math.max(this._ncrOnLevel,i);return this._applyNCRAction(r,e,n)}}const Td=e=>$h.includes(e)?"__"+e:e,Ed={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(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Td};function Pd(e,t){if("string"!=typeof e)return;const n=e.toLowerCase();if($h.some(e=>n===e.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);if(ed.some(e=>n===e.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Id(e,t){return"boolean"==typeof e?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof e&&null!==e?{enabled:!1!==e.enabled,maxEntitySize:Math.max(1,e.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,e.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,e.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,e.maxExpandedLength??1e5),maxEntityCount:Math.max(1,e.maxEntityCount??1e3),allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null,appliesTo:e.appliesTo??"all"}:Id(!0)}const Ld=function(e){const t=Object.assign({},Ed,e),n=[{value:t.attributeNamePrefix,name:"attributeNamePrefix"},{value:t.attributesGroupName,name:"attributesGroupName"},{value:t.textNodeName,name:"textNodeName"},{value:t.cdataPropName,name:"cdataPropName"},{value:t.commentPropName,name:"commentPropName"}];for(const{value:i,name:r}of n)i&&Pd(i,r);return null===t.onDangerousProperty&&(t.onDangerousProperty=Td),t.processEntities=Id(t.processEntities,t.htmlEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(e=>"string"==typeof e&&e.startsWith("*.")?".."+e.substring(2):e)),t};let Rd;Rd="function"!=typeof Symbol?"@@xmlMetadata":/* @__PURE__ */Symbol("XML Node Metadata");class Fd{constructor(e){this.tagname=e,this.child=[],this[":@"]=/* @__PURE__ */Object.create(null)}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][Rd]={startIndex:t})}static getMetaDataSymbol(){return Rd}}const Od=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",Dd=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",Nd=Dd+"\\-\\.\\d·̀-ͯ҇‿-⁀",Ud=(e,t,n="")=>{const i=`[${e.replace(":","")}][${t.replace(":","")}]*`;return{name:new RegExp(`^[${e}][${t}]*$`,n),ncName:new RegExp(`^${i}$`,n),qName:new RegExp(`^${i}(?::${i})?$`,n),nmToken:new RegExp(`^[${t}]+$`,n),nmTokens:new RegExp(`^[${t}]+(?:\\s+[${t}]+)*$`,n)}},kd=Ud(Od,Od+"\\-\\.\\d·̀-ͯ‿-⁀"),Gd=Ud(Dd,Nd,"u"),zd=(e,{xmlVersion:t="1.0"}={})=>((e="1.0")=>"1.1"===e?Gd:kd)(t).qName.test(e);class Vd{constructor(e,t){this.suppressValidationErr=!e,this.options=e,this.xmlVersion=t||1}setXmlVersion(e=1){this.xmlVersion=e}readDocType(e,t){const n=/* @__PURE__ */Object.create(null);let i=0;if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let r=1,o=!1,s=!1,a="";for(;t<e.length;t++)if("<"!==e[t]||s)if(">"===e[t]){if(s?"-"===e[t-1]&&"-"===e[t-2]&&(s=!1,r--):r--,0===r)break}else"["===e[t]?o=!0:a+=e[t];else{if(o&&jd(e,"!ENTITY",t)){let r,o;if(t+=7,[r,o,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),-1===o.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);n[r]=o,i++}}else if(o&&jd(e,"!ELEMENT",t)){t+=8;const{index:n}=this.readElementExp(e,t+1);t=n}else if(o&&jd(e,"!ATTLIST",t))t+=8;else if(o&&jd(e,"!NOTATION",t)){t+=9;const{index:n}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=n}else{if(!jd(e,"!--",t))throw new Error("Invalid DOCTYPE");s=!0}r++,a=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:t}}readEntityExp(e,t){const n=t=Hd(e,t);for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)t++;let i=e.substring(n,t);if(Qd(i,{xmlVersion:this.xmlVersion}),t=Hd(e,t),!this.suppressValidationErr){if("SYSTEM"===e.substring(t,t+6).toUpperCase())throw new Error("External entities are not supported");if("%"===e[t])throw new Error("Parameter entities are not supported")}let r="";if([t,r]=this.readIdentifierVal(e,t,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[i,r,--t]}readNotationExp(e,t){const n=t=Hd(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);!this.suppressValidationErr&&Qd(i,{xmlVersion:this.xmlVersion}),t=Hd(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==r&&"PUBLIC"!==r)throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=Hd(e,t);let o=null,s=null;if("PUBLIC"===r)[t,o]=this.readIdentifierVal(e,t,"publicIdentifier"),'"'!==e[t=Hd(e,t)]&&"'"!==e[t]||([t,s]=this.readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===r&&([t,s]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!s))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:o,systemIdentifier:s,index:--t}}readIdentifierVal(e,t,n){let i="";const r=e[t];if('"'!==r&&"'"!==r)throw new Error(`Expected quoted string, found "${r}"`);const o=++t;for(;t<e.length&&e[t]!==r;)t++;if(i=e.substring(o,t),e[t]!==r)throw new Error(`Unterminated ${n} value`);return[++t,i]}readElementExp(e,t){const n=t=Hd(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);if(!this.suppressValidationErr&&!zd(i,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid element name: "${i}"`);let r="";if("E"===e[t=Hd(e,t)]&&jd(e,"MPTY",t))t+=4;else if("A"===e[t]&&jd(e,"NY",t))t+=2;else if("("===e[t]){const n=++t;for(;t<e.length&&")"!==e[t];)t++;if(r=e.substring(n,t),")"!==e[t])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:r.trim(),index:t}}readAttlistExp(e,t){let n=t=Hd(e,t);for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(n,t);for(Qd(i,{xmlVersion:this.xmlVersion}),n=t=Hd(e,t);t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(n,t);if(!Qd(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid attribute name: "${r}"`);t=Hd(e,t);let o="";if("NOTATION"===e.substring(t,t+8).toUpperCase()){if(o="NOTATION","("!==e[t=Hd(e,t+=8)])throw new Error(`Expected '(', found "${e[t]}"`);t++;let n=[];for(;t<e.length&&")"!==e[t];){const i=t;for(;t<e.length&&"|"!==e[t]&&")"!==e[t];)t++;let r=e.substring(i,t);if(r=r.trim(),!Qd(r,{xmlVersion:this.xmlVersion}))throw new Error(`Invalid notation name: "${r}"`);n.push(r),"|"===e[t]&&(t++,t=Hd(e,t))}if(")"!==e[t])throw new Error("Unterminated list of notations");t++,o+=" ("+n.join("|")+")"}else{const n=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;o+=e.substring(n,t);const i=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!i.includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}t=Hd(e,t);let s="";return"#REQUIRED"===e.substring(t,t+8).toUpperCase()?(s="#REQUIRED",t+=8):"#IMPLIED"===e.substring(t,t+7).toUpperCase()?(s="#IMPLIED",t+=7):[t,s]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:r,attributeType:o,defaultValue:s,index:t}}}const Hd=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function jd(e,t,n){for(let i=0;i<t.length;i++)if(t[i]!==e[n+i+1])return!1;return!0}function Qd(e,t){if(zd(e,{xmlVersion:t}))return e;throw new Error(`Invalid entity name ${e}`)}const Jd=/^[-+]?0x[a-fA-F0-9]+$/,Kd=/^0b[01]+$/,Wd=/^0o[0-7]+$/,qd=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Yd={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function Xd(e,t={}){if(t=Object.assign({},Yd,t),!e||"string"!=typeof e)return e;let n=e.trim();if(0===n.length)return e;if(void 0!==t.skipLike&&t.skipLike.test(n))return e;if("0"===n)return 0;if(t.hex&&Jd.test(n))return $d(n,16);if(t.binary&&Kd.test(n))return $d(n,2);if(t.octal&&Wd.test(n))return $d(n,8);if(isFinite(n)){if(n.includes("e")||n.includes("E"))return function(e,t,n){if(!n.eNotation)return e;const i=t.match(Zd);if(i){let r=i[1]||"";const o=-1===i[3].indexOf("e")?"E":"e",s=i[2],a=r?e[s.length+1]===o:e[s.length]===o;return s.length>1&&a?e:(1!==s.length||!i[3].startsWith(`.${o}`)&&i[3][0]!==o)&&s.length>0?n.leadingZeros&&!a?(t=(i[1]||"")+i[3],Number(t)):e:Number(t)}return e}(e,n,t);{const i=qd.exec(n);if(i){const r=i[1]||"",o=i[2];let s=function(e){if(e&&-1!==e.indexOf("."))return"."===(e=e.replace(/0+$/,""))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substring(0,e.length-1)),e;return e}(i[3]);const a=r?"."===e[o.length+1]:"."===e[o.length];if(!t.leadingZeros&&(o.length>1||1===o.length&&!a))return e;{const i=Number(n),a=String(i);if(0===i)return i;if(-1!==a.search(/[eE]/))return t.eNotation?i:e;if(-1!==n.indexOf("."))return"0"===a||a===s||a===`${r}${s}`?i:e;let A=o?s:n;return o?A===a||r+A===a?i:e:A===a||A===r+a?i:e}}return e}}return function(e,t,n){const i=t===1/0;switch(n.infinity.toLowerCase()){case"null":return null;case"infinity":return t;case"string":return i?"Infinity":"-Infinity";default:return e}}(e,Number(n),t)}const Zd=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function $d(e,t){const n=e.trim();if(2!==t&&8!==t||(e=n.substring(2)),parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}class ep{constructor(e,t={},n){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this.data=n,this._hasDeepWildcard=this.segments.some(e=>"deep-wildcard"===e.type),this._hasAttributeCondition=this.segments.some(e=>void 0!==e.attrName),this._hasPositionSelector=this.segments.some(e=>void 0!==e.position)}_parse(e){const t=[];let n=0,i="";for(;n<e.length;)e[n]===this.separator?n+1<e.length&&e[n+1]===this.separator?(i.trim()&&(t.push(this._parseSegment(i.trim())),i=""),t.push({type:"deep-wildcard"}),n+=2):(i.trim()&&t.push(this._parseSegment(i.trim())),i="",n++):(i+=e[n],n++);return i.trim()&&t.push(this._parseSegment(i.trim())),t}_parseSegment(e){const t={type:"tag"};let n=null,i=e;const r=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(i=r[1]+r[3],r[2])){const e=r[2].slice(1,-1);e&&(n=e)}let o,s,a=i;if(i.includes("::")){const t=i.indexOf("::");if(o=i.substring(0,t).trim(),a=i.substring(t+2).trim(),!o)throw new Error(`Invalid namespace in pattern: ${e}`)}let A=null;if(a.includes(":")){const e=a.lastIndexOf(":"),t=a.substring(0,e).trim(),n=a.substring(e+1).trim();["first","last","odd","even"].includes(n)||/^nth\(\d+\)$/.test(n)?(s=t,A=n):s=a}else s=a;if(!s)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=s,o&&(t.namespace=o),n)if(n.includes("=")){const e=n.indexOf("=");t.attrName=n.substring(0,e).trim(),t.attrValue=n.substring(e+1).trim()}else t.attrName=n.trim();if(A){const e=A.match(/^nth\((\d+)\)$/);e?(t.position="nth",t.positionValue=parseInt(e[1],10)):t.position=A}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class tp{constructor(){this._byDepthAndTag=/* @__PURE__ */new Map,this._wildcardByDepth=/* @__PURE__ */new Map,this._deepWildcards=[],this._patterns=/* @__PURE__ */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;const t=e.length,n=e.segments[e.segments.length-1],i=n?.tag;if(i&&"*"!==i){const n=`${t}:${i}`;this._byDepthAndTag.has(n)||this._byDepthAndTag.set(n,[]),this._byDepthAndTag.get(n).push(e)}else this._wildcardByDepth.has(t)||this._wildcardByDepth.set(t,[]),this._wildcardByDepth.get(t).push(e);return this}addAll(e){for(const t of e)this.add(t);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 null!==this.findMatch(e)}findMatch(e){const t=e.getDepth(),n=`${t}:${e.getCurrentTag()}`,i=this._byDepthAndTag.get(n);if(i)for(let o=0;o<i.length;o++)if(e.matches(i[o]))return i[o];const r=this._wildcardByDepth.get(t);if(r)for(let o=0;o<r.length;o++)if(e.matches(r[o]))return r[o];for(let o=0;o<this._deepWildcards.length;o++)if(e.matches(this._deepWildcards[o]))return this._deepWildcards[o];return null}}class np{constructor(e){this._matcher=e}get separator(){return this._matcher.separator}getCurrentTag(){const e=this._matcher.path;return e.length>0?e[e.length-1].tag:void 0}getCurrentNamespace(){const e=this._matcher.path;return e.length>0?e[e.length-1].namespace:void 0}getAttrValue(e){const t=this._matcher.path;if(0!==t.length)return t[t.length-1].values?.[e]}hasAttr(e){const t=this._matcher.path;if(0===t.length)return!1;const n=t[t.length-1];return void 0!==n.values&&e in n.values}getPosition(){const e=this._matcher.path;return 0===e.length?-1:e[e.length-1].position??0}getCounter(){const e=this._matcher.path;return 0===e.length?-1:e[e.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(e,t=!0){return this._matcher.toString(e,t)}toArray(){return this._matcher.path.map(e=>e.tag)}matches(e){return this._matcher.matches(e)}matchesAny(e){return e.matchesAny(this._matcher)}}class ip{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new np(this)}push(e,t=null,n=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=/* @__PURE__ */new Map);const r=this.siblingStacks[i],o=n?`${n}:${e}`:e,s=r.get(o)||0;let a=0;for(const l of r.values())a+=l;r.set(o,s+1);const A={tag:e,position:a,counter:s};null!=n&&(A.namespace=n),null!=t&&(A.values=t),this.path.push(A)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const 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){const t=this.path[this.path.length-1];null!=e&&(t.values=e)}}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){if(0!==this.path.length)return this.path[this.path.length-1].values?.[e]}hasAttr(e){if(0===this.path.length)return!1;const t=this.path[this.path.length-1];return void 0!==t.values&&e in t.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){const n=e||this.separator;if(n===this.separator&&!0===t){if(null!==this._pathStringCache)return this._pathStringCache;const e=this.path.map(e=>e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n);return this._pathStringCache=e,e}return this.path.map(e=>t&&e.namespace?`${e.namespace}:${e.tag}`:e.tag).join(n)}toArray(){return this.path.map(e=>e.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(e){const t=e.segments;return 0!==t.length&&(e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t))}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++)if(!this._matchSegment(e[t],this.path[t],t===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,n=e.length-1;for(;n>=0&&t>=0;){const i=e[n];if("deep-wildcard"===i.type){if(n--,n<0)return!0;const i=e[n];let r=!1;for(let e=t;e>=0;e--)if(this._matchSegment(i,this.path[e],e===this.path.length-1)){t=e-1,n--,r=!0;break}if(!r)return!1}else{if(!this._matchSegment(i,this.path[t],t===this.path.length-1))return!1;t--,n--}}return n<0}_matchSegment(e,t,n){if("*"!==e.tag&&e.tag!==t.tag)return!1;if(void 0!==e.namespace&&"*"!==e.namespace&&e.namespace!==t.namespace)return!1;if(void 0!==e.attrName){if(!n)return!1;if(!t.values||!(e.attrName in t.values))return!1;if(void 0!==e.attrValue&&String(t.values[e.attrName])!==String(e.attrValue))return!1}if(void 0!==e.position){if(!n)return!1;const i=t.counter??0;if("first"===e.position&&0!==i)return!1;if("odd"===e.position&&i%2!=1)return!1;if("even"===e.position&&i%2!=0)return!1;if("nth"===e.position&&i!==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.path=e.path.map(e=>({...e})),this.siblingStacks=e.siblingStacks.map(e=>new Map(e))}readOnly(){return this._view}}function rp(e,t){if(!e)return{};const n=t.attributesGroupName?e[t.attributesGroupName]:e;if(!n)return{};const i={};for(const r in n)if(r.startsWith(t.attributeNamePrefix)){i[r.substring(t.attributeNamePrefix.length)]=n[r]}else i[r]=n[r];return i}function op(e){if(!e||"string"!=typeof e)return;const t=e.indexOf(":");if(-1!==t&&t>0){const n=e.substring(0,t);if("xmlns"!==n)return n}}class sp{constructor(e,t){var n;this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=up,this.parseTextData=ap,this.resolveNameSpace=Ap,this.buildAttributesMap=cp,this.isItStopNode=pp,this.replaceEntitiesValue=hp,this.readStopNodeData=yp,this.saveTextToParentTag=dp,this.addChild=fp,this.ignoreAttributesFn="function"==typeof(n=this.options.ignoreAttributes)?n:Array.isArray(n)?e=>{for(const t of n){if("string"==typeof t&&e===t)return!0;if(t instanceof RegExp&&t.test(e))return!0}}:()=>!1,this.entityExpansionCount=0,this.currentExpandedLength=0;let i={...md};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?i=this.options.htmlEntities:!0===this.options.htmlEntities&&(i={...bd,...gd}),this.entityDecoder=new Sd({namedEntities:{...i,...t},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo}})),this.matcher=new ip,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new tp;const r=this.options.stopNodes;if(r&&r.length>0){for(let e=0;e<r.length;e++){const t=r[e];"string"==typeof t?this.stopNodeExpressionsSet.add(new ep(t)):t instanceof ep&&this.stopNodeExpressionsSet.add(t)}this.stopNodeExpressionsSet.seal()}}}function ap(e,t,n,i,r,o,s){const a=this.options;if(void 0!==e&&(a.trimValues&&!i&&(e=e.trim()),e.length>0)){s||(e=this.replaceEntitiesValue(e,t,n));const i=a.jPath?n.toString():n,A=a.tagValueProcessor(t,e,i,r,o);if(null==A)return e;if(typeof A!=typeof e||A!==e)return A;if(a.trimValues)return vp(e,a.parseTagValue,a.numberParseOptions);return e.trim()===e?vp(e,a.parseTagValue,a.numberParseOptions):e}}function Ap(e){if(this.options.removeNSPrefix){const t=e.split(":"),n="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=n+t[1])}return e}const lp=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function cp(e,t,n,i=!1){const r=this.options;if(!0===i||!0!==r.ignoreAttributes&&"string"==typeof e){const i=Xh(e,lp),o=i.length,s={},a=new Array(o);let A=!1;const l={};for(let e=0;e<o;e++){const t=this.resolveNameSpace(i[e][1]),o=i[e][4];if(t.length&&void 0!==o){let i=o;r.trimValues&&(i=i.trim()),i=this.replaceEntitiesValue(i,n,this.readonlyMatcher),a[e]=i,l[t]=i,A=!0}}A&&"object"==typeof t&&t.updateCurrent&&t.updateCurrent(l);const c=r.jPath?t.toString():this.readonlyMatcher;let u=!1;for(let e=0;e<o;e++){const t=this.resolveNameSpace(i[e][1]);if(this.ignoreAttributesFn(t,c))continue;let n=r.attributeNamePrefix+t;if(t.length)if(r.transformAttributeName&&(n=r.transformAttributeName(n)),n=Cp(n,r),void 0!==i[e][4]){const i=a[e],o=r.attributeValueProcessor(t,i,c);s[n]=null==o?i:typeof o!=typeof i||o!==i?o:vp(i,r.parseAttributeValue,r.numberParseOptions),u=!0}else r.allowBooleanAttributes&&(s[n]=!0,u=!0)}if(!u)return;if(r.attributesGroupName&&!r.preserveOrder){const e={};return e[r.attributesGroupName]=s,e}return s}}const up=function(e){e=e.replace(/\r\n?/g,"\n");const t=new Fd("!xml");let n=t,i="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const r=this.options,o=new Vd(r.processEntities),s=e.length;for(let a=0;a<s;a++){if("<"===e[a]){const A=e.charCodeAt(a+1);if(47===A){const t=gp(e,">",a,"Closing Tag is not closed.");let o=e.substring(a+2,t).trim();if(r.removeNSPrefix){const e=o.indexOf(":");-1!==e&&(o=o.substr(e+1))}o=_p(r.transformTagName,o,"",r).tagName,n&&(i=this.saveTextToParentTag(i,n,this.readonlyMatcher));const s=this.matcher.getCurrentTag();if(o&&r.unpairedTagsSet.has(o))throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);s&&r.unpairedTagsSet.has(s)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,n=this.tagsNodeStack.pop(),i="",a=t}else if(63===A){let t=bp(e,a,!1,"?>");if(!t)throw new Error("Pi Tag is not closed.");i=this.saveTextToParentTag(i,n,this.readonlyMatcher);const s=this.buildAttributesMap(t.tagExp,this.matcher,t.tagName,!0);if(s){const e=s[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(e)||1),o.setXmlVersion(Number(e)||1)}if(r.ignoreDeclaration&&"?xml"===t.tagName||r.ignorePiTags);else{const e=new Fd(t.tagName);e.add(r.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&!0!==r.ignoreAttributes&&(e[":@"]=s),this.addChild(n,e,this.readonlyMatcher,a)}a=t.closeIndex+1}else if(33===A&&45===e.charCodeAt(a+2)&&45===e.charCodeAt(a+3)){const t=gp(e,"--\x3e",a+4,"Comment is not closed.");if(r.commentPropName){const o=e.substring(a+4,t-2);i=this.saveTextToParentTag(i,n,this.readonlyMatcher),n.add(r.commentPropName,[{[r.textNodeName]:o}])}a=t}else if(33===A&&68===e.charCodeAt(a+2)){const t=o.readDocType(e,a);this.entityDecoder.addInputEntities(t.entities),a=t.i}else if(33===A&&91===e.charCodeAt(a+2)){const t=gp(e,"]]>",a,"CDATA is not closed.")-2,o=e.substring(a+9,t);i=this.saveTextToParentTag(i,n,this.readonlyMatcher);let s=this.parseTextData(o,n.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==s&&(s=""),r.cdataPropName?n.add(r.cdataPropName,[{[r.textNodeName]:o}]):n.add(r.textNodeName,s),a=t+2}else{let o=bp(e,a,r.removeNSPrefix);if(!o){const t=e.substring(Math.max(0,a-50),Math.min(s,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${t}"`)}let A=o.tagName;const l=o.rawTagName;let c=o.tagExp,u=o.attrExpPresent,f=o.closeIndex;if(({tagName:A,tagExp:c}=_p(r.transformTagName,A,c,r)),r.strictReservedNames&&(A===r.commentPropName||A===r.cdataPropName||A===r.textNodeName||A===r.attributesGroupName))throw new Error(`Invalid tag name: ${A}`);n&&i&&"!xml"!==n.tagname&&(i=this.saveTextToParentTag(i,n,this.readonlyMatcher,!1));const h=n;h&&r.unpairedTagsSet.has(h.tagname)&&(n=this.tagsNodeStack.pop(),this.matcher.pop());let d=!1;c.length>0&&c.lastIndexOf("/")===c.length-1&&(d=!0,"/"===A[A.length-1]?(A=A.substr(0,A.length-1),c=A):c=c.substr(0,c.length-1),u=A!==c);let p,g=null;p=op(l),A!==t.tagname&&this.matcher.push(A,{},p),A!==c&&u&&(g=this.buildAttributesMap(c,this.matcher,A),g&&rp(g,r)),A!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const m=a;if(this.isCurrentNodeStopNode){let t="";if(d)a=o.closeIndex;else if(r.unpairedTagsSet.has(A))a=o.closeIndex;else{const n=this.readStopNodeData(e,l,f+1);if(!n)throw new Error(`Unexpected end of ${l}`);a=n.i,t=n.tagContent}const i=new Fd(A);g&&(i[":@"]=g),i.add(r.textNodeName,t),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(n,i,this.readonlyMatcher,m)}else{if(d){({tagName:A,tagExp:c}=_p(r.transformTagName,A,c,r));const e=new Fd(A);g&&(e[":@"]=g),this.addChild(n,e,this.readonlyMatcher,m),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(r.unpairedTagsSet.has(A)){const e=new Fd(A);g&&(e[":@"]=g),this.addChild(n,e,this.readonlyMatcher,m),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=o.closeIndex;continue}{const e=new Fd(A);if(this.tagsNodeStack.length>r.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(n),g&&(e[":@"]=g),this.addChild(n,e,this.readonlyMatcher,m),n=e}}i="",a=f}}}else i+=e[a]}return t.child};function fp(e,t,n,i){this.options.captureMetaData||(i=void 0);const r=this.options.jPath?n.toString():n,o=this.options.updateTag(t.tagname,r,t[":@"]);!1===o||("string"==typeof o?(t.tagname=o,e.addChild(t,i)):e.addChild(t,i))}function hp(e,t,n){const i=this.options.processEntities;if(!i||!i.enabled)return e;if(i.allowedTags){const r=this.options.jPath?n.toString():n;if(!(Array.isArray(i.allowedTags)?i.allowedTags.includes(t):i.allowedTags(t,r)))return e}if(i.tagFilter){const r=this.options.jPath?n.toString():n;if(!i.tagFilter(t,r))return e}return this.entityDecoder.decode(e)}function dp(e,t,n,i){return e&&(void 0===i&&(i=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,n,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,i))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function pp(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function gp(e,t,n,i){const r=e.indexOf(t,n);if(-1===r)throw new Error(i);return r+t.length-1}function mp(e,t,n,i){const r=e.indexOf(t,n);if(-1===r)throw new Error(i);return r}function bp(e,t,n,i=">"){const r=function(e,t,n=">"){let i=0;const r=e.length,o=n.charCodeAt(0),s=n.length>1?n.charCodeAt(1):-1;let a="",A=t;for(let l=t;l<r;l++){const t=e.charCodeAt(l);if(i)t===i&&(i=0);else if(34===t||39===t)i=t;else if(t===o){if(-1===s)return a+=e.substring(A,l),{data:a,index:l};if(e.charCodeAt(l+1)===s)return a+=e.substring(A,l),{data:a,index:l}}else 9!==t||i||(a+=e.substring(A,l)+" ",A=l+1)}}(e,t+1,i);if(!r)return;let o=r.data;const s=r.index,a=o.search(/\s/);let A=o,l=!0;-1!==a&&(A=o.substring(0,a),o=o.substring(a+1).trimStart());const c=A;if(n){const e=A.indexOf(":");-1!==e&&(A=A.substr(e+1),l=A!==r.data.substr(e+1))}return{tagName:A,tagExp:o,closeIndex:s,attrExpPresent:l,rawTagName:c}}function yp(e,t,n){const i=n;let r=1;const o=e.length;for(;n<o;n++)if("<"===e[n]){const o=e.charCodeAt(n+1);if(47===o){const o=mp(e,">",n,`${t} is not closed`);if(e.substring(n+2,o).trim()===t&&(r--,0===r))return{tagContent:e.substring(i,n),i:o};n=o}else if(63===o){n=gp(e,"?>",n+1,"StopNode is not closed.")}else if(33===o&&45===e.charCodeAt(n+2)&&45===e.charCodeAt(n+3)){n=gp(e,"--\x3e",n+3,"StopNode is not closed.")}else if(33===o&&91===e.charCodeAt(n+2)){n=gp(e,"]]>",n,"StopNode is not closed.")-2}else{const i=bp(e,n,!1);if(i){(i&&i.tagName)===t&&"/"!==i.tagExp[i.tagExp.length-1]&&r++,n=i.closeIndex}}}}function vp(e,t,n){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&Xd(e,n)}return void 0!==e?e:""}function _p(e,t,n,i){if(e){const i=e(t);n===t&&(n=i),t=i}return{tagName:t=Cp(t,i),tagExp:n}}function Cp(e,t){if(ed.includes(e))throw new Error(`[SECURITY] Invalid name: "${e}" is a reserved JavaScript keyword that could cause prototype pollution`);return $h.includes(e)?t.onDangerousProperty(e):e}const xp=Fd.getMetaDataSymbol();function wp(e,t){if(!e||"object"!=typeof e)return{};if(!t)return e;const n={};for(const i in e)if(i.startsWith(t)){n[i.substring(t.length)]=e[i]}else n[i]=e[i];return n}function Bp(e,t,n,i){return Mp(e,t,n,i)}function Mp(e,t,n,i){let r;const o={};for(let s=0;s<e.length;s++){const a=e[s],A=Sp(a);if(void 0!==A&&A!==t.textNodeName){const e=wp(a[":@"]||{},t.attributeNamePrefix);n.push(A,e)}if(A===t.textNodeName)void 0===r?r=a[A]:r+=""+a[A];else{if(void 0===A)continue;if(a[A]){let e=Mp(a[A],t,n,i);const r=Ep(e,t);if(0===Object.keys(e).length&&t.alwaysCreateTextNode&&(e[t.textNodeName]=""),a[":@"]?Tp(e,a[":@"],i,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==a[xp]&&"object"==typeof e&&null!==e&&(e[xp]=a[xp]),void 0!==o[A]&&Object.prototype.hasOwnProperty.call(o,A))Array.isArray(o[A])||(o[A]=[o[A]]),o[A].push(e);else{const n=t.jPath?i.toString():i;t.isArray(A,n,r)?o[A]=[e]:o[A]=e}void 0!==A&&A!==t.textNodeName&&n.pop()}}}return"string"==typeof r?r.length>0&&(o[t.textNodeName]=r):void 0!==r&&(o[t.textNodeName]=r),o}function Sp(e){const t=Object.keys(e);for(let n=0;n<t.length;n++){const e=t[n];if(":@"!==e)return e}}function Tp(e,t,n,i){if(t){const r=Object.keys(t),o=r.length;for(let s=0;s<o;s++){const o=r[s],a=o.startsWith(i.attributeNamePrefix)?o.substring(i.attributeNamePrefix.length):o,A=i.jPath?n.toString()+"."+a:n;i.isArray(o,A,!0,!0)?e[o]=[t[o]]:e[o]=t[o]}}}function Ep(e,t){const{textNodeName:n}=t,i=Object.keys(e).length;return 0===i||!(1!==i||!e[n]&&"boolean"!=typeof e[n]&&0!==e[n])}class Pp{constructor(e){this.externalEntities={},this.options=Ld(e)}parse(e,t){if("string"!=typeof e&&e.toString)e=e.toString();else if("string"!=typeof e)throw new Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});const n=function(e,t){t=Object.assign({},td,t);const n=[];let i=!1,r=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let o=0;o<e.length;o++)if("<"===e[o]&&"?"===e[o+1]){if(o+=2,o=id(e,o),o.err)return o}else{if("<"!==e[o]){if(nd(e[o]))continue;return ud("InvalidChar","char '"+e[o]+"' is not expected.",dd(e,o))}{let s=o;if(o++,"!"===e[o]){o=rd(e,o);continue}{let a=!1;"/"===e[o]&&(a=!0,o++);let A="";for(;o<e.length&&">"!==e[o]&&" "!==e[o]&&"\t"!==e[o]&&"\n"!==e[o]&&"\r"!==e[o];o++)A+=e[o];if(A=A.trim(),"/"===A[A.length-1]&&(A=A.substring(0,A.length-1),o--),!hd(A)){let t;return t=0===A.trim().length?"Invalid space after '<'.":"Tag '"+A+"' is an invalid name.",ud("InvalidTag",t,dd(e,o))}const l=ad(e,o);if(!1===l)return ud("InvalidAttr","Attributes for '"+A+"' have open quote.",dd(e,o));let c=l.value;if(o=l.index,"/"===c[c.length-1]){const n=o-c.length;c=c.substring(0,c.length-1);const r=ld(c,t);if(!0!==r)return ud(r.err.code,r.err.msg,dd(e,n+r.err.line));i=!0}else if(a){if(!l.tagClosed)return ud("InvalidTag","Closing tag '"+A+"' doesn't have proper closing.",dd(e,o));if(c.trim().length>0)return ud("InvalidTag","Closing tag '"+A+"' can't have attributes or invalid starting.",dd(e,s));if(0===n.length)return ud("InvalidTag","Closing tag '"+A+"' has not been opened.",dd(e,s));{const t=n.pop();if(A!==t.tagName){let n=dd(e,t.tagStartPos);return ud("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+A+"'.",dd(e,s))}0==n.length&&(r=!0)}}else{const a=ld(c,t);if(!0!==a)return ud(a.err.code,a.err.msg,dd(e,o-c.length+a.err.line));if(!0===r)return ud("InvalidXml","Multiple possible root nodes found.",dd(e,o));-1!==t.unpairedTags.indexOf(A)||n.push({tagName:A,tagStartPos:s}),i=!0}for(o++;o<e.length;o++)if("<"===e[o]){if("!"===e[o+1]){o++,o=rd(e,o);continue}if("?"!==e[o+1])break;if(o=id(e,++o),o.err)return o}else if("&"===e[o]){const t=cd(e,o);if(-1==t)return ud("InvalidChar","char '&' is not expected.",dd(e,o));o=t}else if(!0===r&&!nd(e[o]))return ud("InvalidXml","Extra text at the end",dd(e,o));"<"===e[o]&&o--}}}return i?1==n.length?ud("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",dd(e,n[0].tagStartPos)):!(n.length>0)||ud("InvalidXml","Invalid '"+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):ud("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new sp(this.options,this.externalEntities),i=n.parseXml(e);return this.options.preserveOrder||void 0===i?i:Bp(i,this.options,n.matcher,n.readonlyMatcher)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===t)throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return Fd.getMetaDataSymbol()}}function Ip(e,t){if(t?._parser&&"fast-xml-parser"!==t._parser)throw new Error(t?._parser);const n=function(e,t){const n=new Pp({ignoreAttributes:!1,attributeNamePrefix:"",...t}),i=n.parse(e);return i}(e,{allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(e,n,i,r)=>Boolean(t?.arrayPaths?.some(e=>n===e)),...t?._fastXML});return t?.uncapitalizeKeys?Wh(n):n}const Lp={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:"4.4.2",worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:function(e){return e.startsWith("<?xml")},options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(e,t)=>Ip((new TextDecoder).decode(e),{...Lp.options.xml,...t?.xml}),parseTextSync:(e,t)=>Ip(e,{...Lp.options.xml,...t?.xml})};const Rp={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:"4.4.2",worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:function(e){return e.startsWith("<?xml")},options:{wms:{throwOnError:!1}},parse:async(e,t)=>Fp((new TextDecoder).decode(e),t),parseSync:(e,t)=>Fp((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Fp(e,t)};function Fp(e,t){const n={...Rp.options.wms,...t?.wms},i=function(e,t){const n=Lp.parseTextSync?.(e,t),i=n?.ServiceExceptionReport?.ServiceException||n?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return"string"==typeof i?i:i.value||i.code||"Unknown error"}(e,n),r=n.minimalErrors?i:`WMS Service error: ${i}`;if(n.throwOnError)throw new Error(r);return r}function Op(e){return Array.isArray(e)?e:e?[e]:[]}function Dp(e){const t=Op(e);return t.length>0&&t.every(e=>"string"==typeof e)?t:[]}function Np(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseFloat(e);default:return}}function Up(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseInt(e,10);default:return}}function kp(e){switch(e){case"true":case"1":return!0;default:return!1}}function Gp(e,t){const n=Lp.parseTextSync?.(e,t),i=n.WMT_MS_Capabilities||n.WMS_Capabilities||n,r=function(e){const t={version:String(e.version||""),name:String(e.Service?.Name||"unnamed"),title:e.Service?.Title?String(e.Service?.Title):void 0,abstract:e.Service?.Abstract?String(e.Service?.Abstract):void 0,keywords:Dp(e.Service?.KeywordList?.Keyword),fees:e.Service?.Fees?JSON.stringify(e.Service?.Fees):void 0,accessConstraints:e.Service?.AccessConstraints?JSON.stringify(e.Service?.AccessConstraints):void 0,layerLimit:Up(e.Service?.LayerLimit),maxWidth:Up(e.Service?.maxWidth),maxHeight:Up(e.Service?.maxHeight),layers:[],requests:zp(e.Capability?.Request),exceptions:Vp(e.Exception)},n=Op(e.Capability?.Layer);for(const i of n)t.layers.push(Hp(i));for(const[i,r]of Object.entries(t))void 0===r&&delete t[i];return t}(i);if(t?.inheritedLayerProps)for(const o of r.layers)jp(o,null);return t?.includeRawJSON&&(r.json=i),t?.includeXMLText&&(r.xml=e),r}function zp(e){const t={};for(const[n,i]of Object.entries(e||{})){const e=Dp(i?.Format);t[n]={mimeTypes:e}}return t}function Vp(e){if(Op(e?.Format).length>0)return{mimeTypes:Dp(e)}}function Hp(e){const t={title:String(e?.Title||""),name:e?.Name&&String(e?.Name),abstract:e?.Name&&String(e?.Abstract),keywords:Dp(e.KeywordList?.Keyword)},n=e?.CRS||e?.SRS;n&&Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(t.crs=n);let i=e?.EX_GeographicBoundingBox&&function(e){const{westBoundLongitude:t,northBoundLatitude:n,eastBoundLongitude:i,southBoundLatitude:r}=e;return[[t,r],[i,n]]}(e?.EX_GeographicBoundingBox);i&&(t.geographicBoundingBox=i),i=e?.LatLonBoundingBox&&function(e){const{minx:t,miny:n,maxx:i,maxy:r}=e;return[[t,n],[i,r]]}(e?.LatLonBoundingBox),i&&(t.geographicBoundingBox=i);const r=e?.BoundingBox&&(o=e?.BoundingBox,Op(o).map(e=>function(e){const{CRS:t,SRS:n,minx:i,miny:r,maxx:o,maxy:s,resx:a,resy:A}=e,l={crs:t||n,boundingBox:[[Np(i),Np(r)],[Np(o),Np(s)]]};return a&&(l.xResolution=a),A&&(l.yResolution=A),l}(e)));var o;r&&r.length>0&&(t.boundingBoxes=r);const s=Op(e?.Dimension).map(e=>function(e){const{name:t,units:n,value:i}=e,r={name:t,units:n,extent:i};e.unitSymbol&&(r.unitSymbol=e.unitSymbol);e.default&&(r.defaultValue=e.default);e.multipleValues&&(r.multipleValues=kp(e.multipleValues));e.nearestValue&&(r.nearestValue=kp(e.nearestValue));e.current&&(r.current=kp(e.current));return r}(e));s.length&&(t.dimensions=s),e?.opaque&&(t.opaque=kp(e?.opaque)),e?.cascaded&&(t.cascaded=kp(e?.cascaded)),e?.queryable&&(t.queryable=kp(e?.queryable));const a=Op(e?.Layer),A=[];for(const l of a)A.push(Hp(l));A.length>0&&(t.layers=A);for(const[l,c]of Object.entries(t))void 0===c&&delete t[l];return t}function jp(e,t){t?.geographicBoundingBox&&!e.geographicBoundingBox&&(e.geographicBoundingBox=[...t.geographicBoundingBox]),t?.crs&&!e.crs&&(e.crs=[...t.crs]),t?.boundingBoxes&&!e.boundingBoxes&&(e.boundingBoxes=[...t.boundingBoxes]),t?.dimensions&&!e.dimensions&&(e.dimensions=[...t.dimensions]);for(const n of e.layers||[])jp(n,e)}const Qp={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:"4.4.2",worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:function(e){return e.startsWith("<?xml")},options:{wms:{}},parse:async(e,t)=>Gp((new TextDecoder).decode(e),t?.wms),parseTextSync:(e,t)=>Gp(e,t?.wms)};function Jp(e,t){const n=Lp.parseTextSync?.(e,t),i=n.FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(i)?i:[i]).map(e=>function(e){const t=e||{};return{attributes:t,type:"",bounds:{bottom:0,top:0,left:0,right:0}}}(e))}}const Kp={...Qp,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(e,t)=>Jp((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Jp(e,t)};function Wp(e,t){const n=Lp.parseTextSync?.(e,t);return n}const qp={...Qp,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(e,t)=>Wp((new TextDecoder).decode(e),t),parseTextSync:(e,t)=>Wp(e,t)},Yp={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:e=>e.toLowerCase().includes("wms"),createDataSource:(e,t)=>new Xp(e,t)};class Xp extends _t{substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e,t){super(e,t,Yp.defaultOptions),this.substituteCRS84=t.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,...t.wmsParameters,...t.wms?.wmsParameters},this.vendorParameters=t.wms?.vendorParameters||t.vendorParameters||{}}async getMetadata(){const e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){const{boundingBox:t,bbox:n,...i}=e,r={bbox:t?[...t[0],...t[1]]:n,...i};return await this.getMap(r)}normalizeMetadata(e){return e}async getCapabilities(e,t){const n=this.getCapabilitiesURL(e,t),i=await this.fetch(n),r=await i.arrayBuffer();this._checkResponse(i,r);const o=await Qp.parse(r,this.loadOptions);return this.capabilities=o,o}async getMap(e,t){const n=this.getMapURL(e,t),i=await this.fetch(n),r=await i.arrayBuffer();this._checkResponse(i,r);try{return await He.parse(r,this.loadOptions)}catch{throw this._parseError(r)}}async getFeatureInfo(e,t){const n=this.getFeatureInfoURL(e,t),i=await this.fetch(n),r=await i.arrayBuffer();return this._checkResponse(i,r),await Kp.parse(r,this.loadOptions)}async getFeatureInfoText(e,t){const n=this.getFeatureInfoURL(e,t),i=await this.fetch(n),r=await i.arrayBuffer();return this._checkResponse(i,r),(new TextDecoder).decode(r)}async describeLayer(e,t){const n=this.describeLayerURL(e,t),i=await this.fetch(n),r=await i.arrayBuffer();return this._checkResponse(i,r),await qp.parse(r,this.loadOptions)}async getLegendGraphic(e,t){const n=this.getLegendGraphicURL(e,t),i=await this.fetch(n),r=await i.arrayBuffer();this._checkResponse(i,r);try{return await He.parse(r,this.loadOptions)}catch{throw this._parseError(r)}}getCapabilitiesURL(e,t){const n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",n,t)}getMapURL(e,t){e=this._getWMS130Parameters(e);const n={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",n,t)}getFeatureInfoURL(e,t){e=this._getWMS130Parameters(e);const{boundingBox:n,bbox:i}=e;e.bbox=n?[...n[0],...n[1]]:i;const r={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",r,t)}describeLayerURL(e,t){const n={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",n,t)}getLegendGraphicURL(e,t){const n={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",n,t)}_parseWMSUrl(e){const[t,n]=e.split("?"),i=n.split("&"),r={};for(const o of i){const[e,t]=o.split("=");r[e]=t}return{url:t,parameters:r}}_getWMSUrl(e,t,n){let i=this.url,r=!0;const o={service:"WMS",version:t.version,request:e,...t,...this.vendorParameters,...n},s=["transparent","time","elevation"];for(const[a,A]of Object.entries(o))s.includes(a)&&!A||(i+=r?"?":"&",r=!1,i+=this._getURLParameter(a,A,t));return encodeURI(i)}_getWMS130Parameters(e){const t={...e};return t.srs&&(t.crs=t.crs||t.srs,delete t.srs),t}_getURLParameter(e,t,n){switch(e){case"crs":"1.3.0"!==n.version?e="srs":this.substituteCRS84&&"EPSG:4326"===t&&(t="CRS:84");break;case"srs":"1.3.0"===n.version&&(e="crs");break;case"bbox":const i=this._flipBoundingBox(t,n);i&&(t=i);break;case"x":"1.3.0"===n.version&&(e="i");break;case"y":"1.3.0"===n.version&&(e="j")}return e=e.toUpperCase(),Array.isArray(t)?`${e}=${t.join(",")}`:`${e}=${t?String(t):""}`}_flipBoundingBox(e,t){if(!Array.isArray(e)||4!==e.length)return null;const n=e;return"1.3.0"===t.version&&this.flipCRS.includes(t.crs||"")&&!(this.substituteCRS84&&"EPSG:4326"===t.crs)?[n[1],n[0],n[3],n[2]]:n}async _fetchArrayBuffer(e){const t=await this.fetch(e),n=await t.arrayBuffer();return this._checkResponse(t,n),n}_checkResponse(e,t){const n=e.headers["content-type"];if(!e.ok||Rp.mimeTypes.includes(n)){const e=b(this.loadOptions,{wms:{throwOnError:!0}}),n=Rp.parseSync?.(t,e);throw new Error(n)}}_parseError(e){const t=Rp.parseSync?.(e,this.options.core?.loadOptions);return new Error(t)}}const Zp=6378137*Math.PI;function $p(e){const t=Ve(e);return t[0]=(t[0]/256-1)*Zp,t[1]=(t[1]/256-1)*Zp,t}const eg={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:(e,t)=>{}}};class tg extends fo{get isLoaded(){return 0===this.state?.loadCounter&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:t,oldProps:n}){const{viewport:i}=this.context;e.dataChanged||t.serviceType!==n.serviceType?(this.state.imageSource=this._createImageSource(t),this._loadMetadata(),this.debounce(()=>this.loadImage(i,"image source changed"),0)):Ie(t.layers,n.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(i,"viewport changed")):this.debounce(()=>this.loadImage(i,"layers changed"),0)}finalizeState(){}renderLayers(){const{bounds:e,image:t,lastRequestParameters:n}=this.state;return t&&new So({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:"EPSG:4326"===n.srs?je.LNGLAT:je.CARTESIAN,bounds:e,image:t})}async getFeatureInfoText(e,t){const{lastRequestParameters:n}=this.state;if(n){return await(this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:e,y:t,info_format:"application/vnd.ogc.gml"}))}return""}_createImageSource(e){if(e.data instanceof Ct)return e.data;if("string"==typeof e.data)return function(e,t,n){const i=n?.core?.type||n.type||"auto",r="auto"===i?function(e,t){for(const n of t)if(n.testURL&&n.testURL(e))return n;return null}(e,t):function(e,t){for(const n of t)if(n.type===e)return n;return null}(i,t);if(!r)throw new Error("Not a valid source type");return r.createDataSource(e,n)}(e.data,[Yp],{core:{type:e.serviceType,loadOptions:e.loadOptions}});throw new Error("invalid image source in props.data")}async _loadMetadata(){const{imageSource:e}=this.state;try{this.state.loadCounter++;const t=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(t)}catch(t){this.getCurrentLayer()?.props.onMetadataLoadError(t)}finally{this.state.loadCounter--}}async loadImage(e,t){const{layers:n,serviceType:i}=this.props;if("wms"===i&&0===n.length)return;const r=e.getBounds(),{width:o,height:s}=e,a=this.getRequestId();let{srs:A}=this.props;"auto"===A&&(A=e.resolution?"EPSG:4326":"EPSG:3857");const l={width:o,height:s,boundingBox:[[r[0],r[1]],[r[2],r[3]]],layers:n,crs:A};if("EPSG:3857"===A){const e=$p([r[0],r[1]]),t=$p([r[2],r[3]]);l.boundingBox=[e,t]}try{this.state.loadCounter++,this.props.onImageLoadStart(a);const e=await this.state.imageSource.getImage(l);this.state.lastRequestId<a&&(this.getCurrentLayer()?.props.onImageLoad(a),this.setState({image:e,bounds:r,lastRequestParameters:l,lastRequestId:a}))}catch(c){this.raiseError(c,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(a,c)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(e,t=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>e(),t)}}tg.layerName="WMSLayer",tg.defaultProps=eg;class ng extends vo{}ng.layerName="GreatCircleLayer",ng.defaultProps={getHeight:{type:"accessor",value:0},greatCircle:!0};var ig,rg,og,sg,ag={exports:{}};const Ag=/* @__PURE__ */lt((ig||(ig=1,og=ag.exports,sg=function(){function e(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var n={},i={};function r(e,t){var r,o,a;return t?(a=0<=(e>>>=0)&&e<256)&&(o=i[e])?o:(r=s(e,(0|e)<0?-1:0,!0),a&&(i[e]=r),r):(a=-128<=(e|=0)&&e<128)&&(o=n[e])?o:(r=s(e,e<0?-1:0,!1),a&&(n[e]=r),r)}function o(e,t){if(isNaN(e)||!isFinite(e))return t?p:d;if(t){if(e<0)return p;if(e>=u)return v}else{if(e<=-f)return _;if(e+1>=f)return y}return e<0?o(-e,t).neg():s(e%c|0,e/c|0,t)}function s(t,n,i){return new e(t,n,i)}e.fromInt=r,e.fromNumber=o,e.fromBits=s;var a=Math.pow;function A(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return d;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return A(e.substring(1),t,n).neg();for(var r=o(a(n,8)),s=d,l=0;l<e.length;l+=8){var c=Math.min(8,e.length-l),u=parseInt(e.substring(l,l+c),n);if(c<8){var f=o(a(n,c));s=s.mul(f).add(o(u))}else s=(s=s.mul(r)).add(o(u))}return s.unsigned=t,s}function l(t){return t instanceof e?t:"number"==typeof t?o(t):"string"==typeof t?A(t):s(t.low,t.high,t.unsigned)}e.fromString=A,e.fromValue=l;var c=4294967296,u=c*c,f=u/2,h=r(1<<24),d=r(0);e.ZERO=d;var p=r(0,!0);e.UZERO=p;var g=r(1);e.ONE=g;var m=r(1,!0);e.UONE=m;var b=r(-1);e.NEG_ONE=b;var y=s(-1,2147483647,!1);e.MAX_VALUE=y;var v=s(-1,-1,!0);e.MAX_UNSIGNED_VALUE=v;var _=s(0,-2147483648,!1);e.MIN_VALUE=_;var C=e.prototype;return C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},C.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(_)){var t=o(e),n=this.div(t),i=n.mul(t).sub(this);return n.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=o(a(e,6),this.unsigned),s=this,A="";;){var l=s.div(r),c=(s.sub(l.mul(r)).toInt()>>>0).toString(e);if((s=l).isZero())return c+A;for(;c.length<6;)c="0"+c;A=""+c+A}},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(_)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},C.isZero=function(){return 0===this.high&&0===this.low},C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return!(1&~this.low)},C.isEven=function(){return!(1&this.low)},C.equals=function(e){return t(e)||(e=l(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},C.eq=C.equals,C.notEquals=function(e){return!this.eq(e)},C.neq=C.notEquals,C.lessThan=function(e){return this.comp(e)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(e){return this.comp(e)<=0},C.lte=C.lessThanOrEqual,C.greaterThan=function(e){return this.comp(e)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(e){return this.comp(e)>=0},C.gte=C.greaterThanOrEqual,C.compare=function(e){if(t(e)||(e=l(e)),this.eq(e))return 0;var n=this.isNegative(),i=e.isNegative();return n&&!i?-1:!n&&i?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},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(_)?_:this.not().add(g)},C.neg=C.negate,C.add=function(e){t(e)||(e=l(e));var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,o=65535&this.low,a=e.high>>>16,A=65535&e.high,c=e.low>>>16,u=0,f=0,h=0,d=0;return h+=(d+=o+(65535&e.low))>>>16,f+=(h+=r+c)>>>16,u+=(f+=i+A)>>>16,u+=n+a,s((h&=65535)<<16|(d&=65535),(u&=65535)<<16|(f&=65535),this.unsigned)},C.subtract=function(e){return t(e)||(e=l(e)),this.add(e.neg())},C.sub=C.subtract,C.multiply=function(e){if(this.isZero())return d;if(t(e)||(e=l(e)),e.isZero())return d;if(this.eq(_))return e.isOdd()?_:d;if(e.eq(_))return this.isOdd()?_:d;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(h)&&e.lt(h))return o(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,a=65535&this.low,A=e.high>>>16,c=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,g=0,m=0,b=0;return m+=(b+=a*f)>>>16,g+=(m+=r*f)>>>16,m&=65535,g+=(m+=a*u)>>>16,p+=(g+=i*f)>>>16,g&=65535,p+=(g+=r*u)>>>16,g&=65535,p+=(g+=a*c)>>>16,p+=n*f+i*u+r*c+a*A,s((m&=65535)<<16|(b&=65535),(p&=65535)<<16|(g&=65535),this.unsigned)},C.mul=C.multiply,C.divide=function(e){if(t(e)||(e=l(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?p:d;var n,i,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return p;if(e.gt(this.shru(1)))return m;r=p}else{if(this.eq(_))return e.eq(g)||e.eq(b)?_:e.eq(_)?g:(n=this.shr(1).div(e).shl(1)).eq(d)?e.isNegative()?g:b:(i=this.sub(e.mul(n)),r=n.add(i.div(e)));if(e.eq(_))return this.unsigned?p:d;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();r=d}for(i=this;i.gte(e);){n=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),A=s<=48?1:a(2,s-48),c=o(n),u=c.mul(e);u.isNegative()||u.gt(i);)u=(c=o(n-=A,this.unsigned)).mul(e);c.isZero()&&(c=g),r=r.add(c),i=i.sub(u)}return r},C.div=C.divide,C.modulo=function(e){return t(e)||(e=l(e)),this.sub(this.div(e).mul(e))},C.mod=C.modulo,C.not=function(){return s(~this.low,~this.high,this.unsigned)},C.and=function(e){return t(e)||(e=l(e)),s(this.low&e.low,this.high&e.high,this.unsigned)},C.or=function(e){return t(e)||(e=l(e)),s(this.low|e.low,this.high|e.high,this.unsigned)},C.xor=function(e){return t(e)||(e=l(e)),s(this.low^e.low,this.high^e.high,this.unsigned)},C.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?s(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):s(0,this.low<<e-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?s(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):s(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;return e<32?s(this.low>>>e|n<<32-e,n>>>e,this.unsigned):s(32===e?n:n>>>e-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(e){return e?this.toBytesLE():this.toBytesBE()},C.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e},(rg=ag)&&rg.exports?rg.exports=sg():(og.dcodeIO=og.dcodeIO||{}).Long=sg()),ag.exports)),lg=180/Math.PI;function cg(e,t,n){const i=1<<t;return[(e[0]+n[0])/i,(e[1]+n[1])/i]}function ug(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function fg(e){return[ug(e[0]),ug(e[1])]}function hg(e,[t,n]){switch(e){case 0:return[1,t,n];case 1:return[-t,1,n];case 2:return[-t,-n,1];case 3:return[-1,-n,-t];case 4:return[n,-1,-t];case 5:return[n,t,-1];default:throw new Error("Invalid face")}}function dg([e,t,n]){const i=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*lg,i*lg]}function pg(e,t,n,i){if(0===i){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const i=t[0];t[0]=t[1],t[1]=i}}function gg(e){if("string"==typeof e){if(e.indexOf("/")>0)return e;e=function(e){const t=e.padEnd(16,"0");return Ag.fromString(t,16)}(e)}return function(e){let t=Ag.fromString(e,!0,10).toString(2);for(;t.length<64;)t="0"+t;const n=t.lastIndexOf("1"),i=t.substring(0,3),r=t.substring(3,n),o=r.length/2,s=Ag.fromString(i,!0,2).toString(10);let a=Ag.fromString(r,!0,2).toString(4);for(;a.length<o;)a="0"+a;return`${s}/${a}`}(e.toString())}function mg(e){return function({face:e,ij:t,level:n}){const i=[[0,0],[0,1],[1,1],[1,0],[0,0]],r=Math.max(1,Math.ceil(100*Math.pow(2,-n))),o=new Float64Array(4*r*2+2);let s=0,a=0;for(let A=0;A<4;A++){const l=i[A].slice(0),c=i[A+1],u=(c[0]-l[0])/r,f=(c[1]-l[1])/r;for(let i=0;i<r;i++){l[0]+=u,l[1]+=f;const i=dg(hg(e,fg(cg(t,n,l))));Math.abs(i[1])>89.999&&(i[0]=a);const r=i[0]-a;i[0]+=r>180?-360:r<-180?360:0,o[s++]=i[0],o[s++]=i[1],a=i[0]}}return o[s++]=o[0],o[s++]=o[1],o}(function(e){const t=e.split("/"),n=parseInt(t[0],10),i=t[1],r=i.length,o=[0,0];let s;for(let a=r-1;a>=0;a--){s=r-a;const e=i[a];let t=0,n=0;"1"===e?n=1:"2"===e?(t=1,n=1):"3"===e&&(t=1);const A=Math.pow(2,s-1);pg(A,o,t,n),o[0]+=A*t,o[1]+=A*n}if(n%2==1){const e=o[0];o[0]=o[1],o[1]=e}return{face:n,ij:o,level:s}}(gg(e)))}class bg extends Za{indexToBounds(){const{data:e,getS2Token:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>mg(t(e,n))}}}bg.layerName="S2Layer",bg.defaultProps={getS2Token:{type:"accessor",value:e=>e.token}};function yg(e,t=1){const[n,i]=function(e,t){let n=0,i=0,r=1<<e.length;const o=r/512;for(let s=0;s<e.length;s++){r>>=1;const t=parseInt(e[s]);t%2&&(n|=r),t>1&&(i|=r)}return[[n/o,512-i/o],[(n+t)/o,512-(i+t)/o]]}(e,t),[r,o]=Qe(n),[s,a]=Qe(i);return[s,o,s,a,r,a,r,o,s,o]}class vg extends Za{indexToBounds(){const{data:e,extruded:t,getQuadkey:n}=this.props,i=t?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,t)=>yg(n(e,t),i),updateTriggers:{getPolygon:i}}}}vg.layerName="QuadkeyLayer",vg.defaultProps={getQuadkey:{type:"accessor",value:e=>e.quadkey}};class _g{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,this.boundingBox="west"in e?[[e.west,e.south],[e.east,e.north]]:[[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(){const e=this.content?this.content.byteLength:0;return Number.isFinite(e),e}async _loadData({getData:e,requestScheduler:t,onLoad:n,onError:i}){const{index:r,id:o,bbox:s,userData:a,zoom:A}=this,l=this._loaderId;this._abortController=new AbortController;const{signal:c}=this._abortController,u=await t.scheduleRequest(this,e=>e.isSelected?1:-1);if(!u)return void(this._isCancelled=!0);if(this._isCancelled)return void u.done();let f,h=null;try{h=await e({index:r,id:o,bbox:s,userData:a,zoom:A,signal:c})}catch(d){f=d||!0}finally{u.done()}l===this._loaderId&&(this._loader=void 0,this.content=h,!this._isCancelled||h?(this._isLoaded=!0,this._isCancelled=!1,f?i(f,this):n(this)):this._isLoaded=!1)}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())}}const Cg=-1,xg=0,wg=1,Bg=new ye,Mg=new ye;class Sg{constructor(e=[0,0,0],t=[0,0,0],n){n=n||Bg.copy(e).add(t).scale(.5),this.center=new ye(n),this.halfDiagonal=new ye(t).subtract(this.center),this.minimum=new ye(e),this.maximum=new ye(t)}clone(){return new Sg(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){const{halfDiagonal:t}=this,n=Mg.from(e.normal),i=t.x*Math.abs(n.x)+t.y*Math.abs(n.y)+t.z*Math.abs(n.z),r=this.center.dot(n)+e.distance;return r-i>0?wg:r+i<0?Cg:xg}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=Bg.from(e).subtract(this.center),{halfDiagonal:n}=this;let i,r=0;return i=Math.abs(t.x)-n.x,i>0&&(r+=i*i),i=Math.abs(t.y)-n.y,i>0&&(r+=i*i),i=Math.abs(t.z)-n.z,i>0&&(r+=i*i),r}}const Tg=new ye,Eg=new ye;class Pg{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new ye,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=Tg.from(t),this.center=(new ye).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Pg(this.center,this.radius)}union(e){const t=this.center,n=this.radius,i=e.center,r=e.radius,o=Tg.copy(i).subtract(t),s=o.magnitude();if(n>=s+r)return this.clone();if(r>=s+n)return e.clone();const a=.5*(n+s+r);return Eg.copy(o).scale((-n+a)/s).add(t),this.center.copy(Eg),this.radius=a,this}expand(e){const t=Tg.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=Je(Tg,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=Tg.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,n=this.radius,i=e.normal.dot(t)+e.distance;return i<-n?Cg:i<n?xg:wg}}const Ig=new ye,Lg=new ye,Rg=new ye,Fg=new ye,Og=new ye,Dg=new ye,Ng=new ye,Ug=0,kg=1,Gg=2,zg=3,Vg=4,Hg=5,jg=6,Qg=7,Jg=8;class Kg{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new ye).from(e),this.halfAxes=new Dt(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new ye(e).len(),new ye(t).len(),new ye(n).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new ye(e).normalize(),r=new ye(t).normalize(),o=new ye(n).normalize();return(new $t).fromMatrix3(new Dt([...i,...r,...o]))}fromCenterHalfSizeQuaternion(e,t,n){const i=new $t(n),r=(new Dt).fromQuaternion(i);return r[0]=r[0]*t[0],r[1]=r[1]*t[0],r[2]=r[2]*t[0],r[3]=r[3]*t[1],r[4]=r[4]*t[1],r[5]=r[5]*t[1],r[6]=r[6]*t[2],r[7]=r[7]*t[2],r[8]=r[8]*t[2],this.center=(new ye).from(e),this.halfAxes=r,this}clone(){return new Kg(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Pg){const t=this.halfAxes,n=t.getColumn(0,Rg),i=t.getColumn(1,Fg),r=t.getColumn(2,Og),o=Ig.copy(n).add(i).add(r);return e.center.copy(this.center),e.radius=o.magnitude(),e}intersectPlane(e){const t=this.center,n=e.normal,i=this.halfAxes,r=n.x,o=n.y,s=n.z,a=Math.abs(r*i[Ug]+o*i[kg]+s*i[Gg])+Math.abs(r*i[zg]+o*i[Vg]+s*i[Hg])+Math.abs(r*i[jg]+o*i[Qg]+s*i[Jg]),A=n.dot(t)+e.distance;return A<=-a?Cg:A>=a?wg:xg}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=Lg.from(e).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,Rg),r=n.getColumn(1,Fg),o=n.getColumn(2,Og),s=i.magnitude(),a=r.magnitude(),A=o.magnitude();i.normalize(),r.normalize(),o.normalize();let l,c=0;return l=Math.abs(t.dot(i))-s,l>0&&(c+=l*l),l=Math.abs(t.dot(r))-a,l>0&&(c+=l*l),l=Math.abs(t.dot(o))-A,l>0&&(c+=l*l),c}computePlaneDistances(e,t,n=[-0,-0]){let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const o=this.center,s=this.halfAxes,a=s.getColumn(0,Rg),A=s.getColumn(1,Fg),l=s.getColumn(2,Og),c=Dg.copy(a).add(A).add(l).add(o),u=Ng.copy(c).subtract(e);let f=t.dot(u);return i=Math.min(f,i),r=Math.max(f,r),c.copy(o).add(a).add(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),c.copy(o).add(a).subtract(A).add(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),c.copy(o).add(a).subtract(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),o.copy(c).subtract(a).add(A).add(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),o.copy(c).subtract(a).add(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),o.copy(c).subtract(a).subtract(A).add(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),o.copy(c).subtract(a).subtract(A).subtract(l),u.copy(c).subtract(e),f=t.dot(u),i=Math.min(f,i),r=Math.max(f,r),n[0]=i,n[1]=r,n}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,Rg);t.transformAsPoint(e);const n=this.halfAxes.getColumn(1,Fg);n.transformAsPoint(e);const i=this.halfAxes.getColumn(2,Og);return i.transformAsPoint(e),this.halfAxes=new Dt([...t,...n,...i]),this}getTransform(){throw new Error("not implemented")}}const Wg=new ye,qg=new ye;class Yg{constructor(e=[0,0,1],t=0){this.normal=new ye,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return Ke(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Wg.from(e),this.normal.from(t).normalize();const n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,t,n,i){return this.normal.set(e,t,n),Ke(We(this.normal.len(),1)),this.distance=i,this}clone(){return new Yg(this.normal,this.distance)}equals(e){return We(this.distance,e.distance)&&We(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=qg.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,t)}projectPointOntoPlane(e,t=[0,0,0]){const n=Wg.from(e),i=this.getPointDistance(n),r=qg.copy(this.normal).scale(i);return n.subtract(r).to(t)}}const Xg=[new ye([1,0,0]),new ye([0,1,0]),new ye([0,0,1])],Zg=new ye,$g=new ye;class em{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*Xg.length;const t=e.center,n=e.radius;let i=0;for(const r of Xg){let e=this.planes[i],o=this.planes[i+1];e||(e=this.planes[i]=new Yg),o||(o=this.planes[i+1]=new Yg);const s=Zg.copy(r).scale(-n).add(t);e.fromPointNormal(s,r);const a=Zg.copy(r).scale(n).add(t),A=$g.copy(r).negate();o.fromPointNormal(a,A),i+=2}return this}computeVisibility(e){let t=wg;for(const n of this.planes){switch(e.intersectPlane(n)){case Cg:return Cg;case xg:t=xg}}return t}computeVisibilityWithPlaneMask(e,t){if(Ke(Number.isFinite(t),"parentPlaneMask is required."),t===em.MASK_OUTSIDE||t===em.MASK_INSIDE)return t;let n=em.MASK_INSIDE;const i=this.planes;for(let r=0;r<this.planes.length;++r){const o=r<31?1<<r:0;if(r<31&&0===(t&o))continue;const s=i[r],a=e.intersectPlane(s);if(a===Cg)return em.MASK_OUTSIDE;a===xg&&(n|=o)}return n}}em.MASK_OUTSIDE=4294967295,em.MASK_INSIDE=0,em.MASK_INDETERMINATE=2147483647,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye;const tm=new Dt,nm=new Dt,im=new Dt,rm=new Dt,om=new Dt;function sm(e,t={}){let n=0,i=0;const r=nm,o=im;r.identity(),o.copy(e);const s=1e-20*function(e){let t=0;for(let n=0;n<9;++n){const i=e[n];t+=i*i}return Math.sqrt(t)}(o);for(;i<10&&lm(o)>s;)cm(o,rm),om.copy(rm).transpose(),o.multiplyRight(rm),o.multiplyLeft(om),r.multiplyRight(rm),++n>2&&(++i,n=0);return t.unitary=r.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const am=[1,0,0],Am=[2,2,1];function lm(e){let t=0;for(let n=0;n<3;++n){const i=e[tm.getElementIndex(Am[n],am[n])];t+=2*i*i}return Math.sqrt(t)}function cm(e,t){let n=0,i=1;for(let A=0;A<3;++A){const t=Math.abs(e[tm.getElementIndex(Am[A],am[A])]);t>n&&(i=A,n=t)}const r=am[i],o=Am[i];let s=1,a=0;if(Math.abs(e[tm.getElementIndex(o,r)])>1e-15){const t=(e[tm.getElementIndex(o,o)]-e[tm.getElementIndex(r,r)])/2/e[tm.getElementIndex(o,r)];let n;n=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),s=1/Math.sqrt(1+n*n),a=n*s}return Dt.IDENTITY.to(t),t[tm.getElementIndex(r,r)]=t[tm.getElementIndex(o,o)]=s,t[tm.getElementIndex(o,r)]=a,t[tm.getElementIndex(r,o)]=-a,t}const um=new ye,fm=new ye,hm=new ye,dm=new ye,pm=new ye,gm=new Dt,mm={diagonal:new Dt,unitary:new Dt};function bm(e,t=new Kg){if(!e||0===e.length)return t.halfAxes=new Dt([0,0,0,0,0,0,0,0,0]),t.center=new ye,t;const n=e.length,i=new ye(0,0,0);for(const B of e)i.add(B);const r=1/n;i.multiplyByScalar(r);let o=0,s=0,a=0,A=0,l=0,c=0;for(const B of e){const e=um.copy(B).subtract(i);o+=e.x*e.x,s+=e.x*e.y,a+=e.x*e.z,A+=e.y*e.y,l+=e.y*e.z,c+=e.z*e.z}o*=r,s*=r,a*=r,A*=r,l*=r,c*=r;const u=gm;u[0]=o,u[1]=s,u[2]=a,u[3]=s,u[4]=A,u[5]=l,u[6]=a,u[7]=l,u[8]=c;const{unitary:f}=sm(u,mm),h=t.halfAxes.copy(f);let d=h.getColumn(0,hm),p=h.getColumn(1,dm),g=h.getColumn(2,pm),m=-Number.MAX_VALUE,b=-Number.MAX_VALUE,y=-Number.MAX_VALUE,v=Number.MAX_VALUE,_=Number.MAX_VALUE,C=Number.MAX_VALUE;for(const B of e)um.copy(B),m=Math.max(um.dot(d),m),b=Math.max(um.dot(p),b),y=Math.max(um.dot(g),y),v=Math.min(um.dot(d),v),_=Math.min(um.dot(p),_),C=Math.min(um.dot(g),C);d=d.multiplyByScalar(.5*(v+m)),p=p.multiplyByScalar(.5*(_+b)),g=g.multiplyByScalar(.5*(C+y)),t.center.copy(d).add(p).add(g);const x=fm.set(m-v,b-_,y-C).multiplyByScalar(.5),w=new Dt([x[0],0,0,0,x[1],0,0,0,x[2]]);return t.halfAxes.multiplyRight(w),t}const ym=512,vm=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],_m=vm.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),Cm=_m.concat([[.25,.5],[.75,.5]]);class xm{constructor(e,t,n){this.x=e,this.y=t,this.z=n}get children(){if(!this._children){const e=2*this.x,t=2*this.y,n=this.z+1;this._children=[new xm(e,t,n),new xm(e,t+1,n),new xm(e+1,t,n),new xm(e+1,t+1,n)]}return this._children}update(e){const{viewport:t,cullingVolume:n,elevationBounds:i,minZ:r,maxZ:o,bounds:s,offset:a,project:A}=e,l=this.getBoundingVolume(i,a,A);if(s&&!this.insideBounds(s))return!1;if(n.computeVisibility(l)<0)return!1;if(!this.childVisible){let{z:e}=this;if(e<o&&e>=r){const n=l.distanceTo(t.cameraPosition)*t.scale/t.height;e+=Math.floor(Math.log2(n))}if(e>=o)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(const c of this.children)c.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(const t of this._children)t.getSelected(e);return e}insideBounds([e,t,n,i]){const r=Math.pow(2,this.z),o=ym/r;return this.x*o<n&&this.y*o<i&&(this.x+1)*o>e&&(this.y+1)*o>t}getBoundingVolume(e,t,n){if(n){const t=this.z<1?Cm:this.z<2?_m:vm,i=[];for(const r of t){const t=Lm(this.x+r[0],this.y+r[1],this.z);t[2]=e[0],i.push(n(t)),e[0]!==e[1]&&(t[2]=e[1],i.push(n(t)))}return bm(i)}const i=Math.pow(2,this.z),r=ym/i,o=this.x*r+t*ym,s=ym-(this.y+1)*r;return new Sg([o,s,e[0]],[o+r,s+r,e[1]])}}const wm=512,Bm=[-1/0,-1/0,1/0,1/0],Mm={type:"object",value:null,validate:(e,t)=>t.optional&&null===e||"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e),equal:(e,t)=>{if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}};function Sm(e,t){const n=[t.transformAsPoint([e[0],e[1]]),t.transformAsPoint([e[2],e[1]]),t.transformAsPoint([e[0],e[3]]),t.transformAsPoint([e[2],e[3]])];return[Math.min(...n.map(e=>e[0])),Math.min(...n.map(e=>e[1])),Math.max(...n.map(e=>e[0])),Math.max(...n.map(e=>e[1]))]}function Tm(e,t){if(!e||!e.length)return null;const{index:n,id:i}=t;if(Array.isArray(e)){e=e[r=i,Math.abs(r.split("").reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0))%e.length]}var r;let o=e;for(const s of Object.keys(n)){const e=new RegExp(`{${s}}`,"g");o=o.replace(e,String(n[s]))}return Number.isInteger(n.y)&&Number.isInteger(n.z)&&(o=o.replace(/\{-y\}/g,String(Math.pow(2,n.z)-n.y-1))),o}function Em({viewport:e,z:t,cullRect:n}){return(e.subViewports||[e]).map(e=>Pm(e,t||0,n))}function Pm(e,t,n){if(!Array.isArray(t)){const i=n.x-e.x,r=n.y-e.y,{width:o,height:s}=n,a={targetZ:t},A=e.unproject([i,r],a),l=e.unproject([i+o,r],a),c=e.unproject([i,r+s],a),u=e.unproject([i+o,r+s],a);return[Math.min(A[0],l[0],c[0],u[0]),Math.min(A[1],l[1],c[1],u[1]),Math.max(A[0],l[0],c[0],u[0]),Math.max(A[1],l[1],c[1],u[1])]}const i=Pm(e,t[0],n),r=Pm(e,t[1],n);return[Math.min(i[0],r[0]),Math.min(i[1],r[1]),Math.max(i[2],r[2]),Math.max(i[3],r[3])]}function Im(e,t){return Math.pow(2,e)*wm/t}function Lm(e,t,n){const i=Im(n,wm),r=e/i*360-180,o=Math.PI-2*Math.PI*t/i;return[r,180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)))]}function Rm(e,t,n,i){const r=Im(n,i);return[e/r*wm,t/r*wm]}function Fm(e,t,n,i,r=wm){if(e.isGeospatial){const[e,r]=Lm(t,n,i),[o,s]=Lm(t+1,n+1,i);return{west:e,north:r,east:o,south:s}}const[o,s]=Rm(t,n,i,r),[a,A]=Rm(t+1,n+1,i,r);return{left:o,top:s,right:a,bottom:A}}function Om(e,t,n,i,r){const o=function(e,t,n){let i;return i=e.getBounds(),e.isGeospatial?[Math.max(i[0],n[0]),Math.max(i[1],n[1]),Math.min(i[2],n[2]),Math.min(i[3],n[3])]:[Math.max(Math.min(i[0],n[2]),n[0]),Math.max(Math.min(i[1],n[3]),n[1]),Math.min(Math.max(i[2],n[0]),n[2]),Math.min(Math.max(i[3],n[1]),n[3])]}(e,0,i),s=Im(t,n),[a,A,l,c]=function(e,t,n){if(n)return Sm(e,n).map(e=>e*t/wm);return e.map(e=>e*t/wm)}(o,s,r),u=[];for(let f=Math.floor(a);f<l;f++)for(let e=Math.floor(A);e<c;e++)u.push({x:f,y:e,z:t});return u}function Dm({viewport:e,maxZoom:t,minZoom:n,zRange:i,extent:r,tileSize:o=wm,modelMatrix:s,modelMatrixInverse:a,zoomOffset:A=0,visibleMinZoom:l,visibleMaxZoom:c}){let u=e.isGeospatial?Math.round(e.zoom+Math.log2(wm/o)+A):Math.ceil(e.zoom+A);if("number"==typeof n&&Number.isFinite(n)&&u<n){if(!r)return[];u=n}if("number"==typeof t&&Number.isFinite(t)&&u>t&&(u=t),null!=l&&e.zoom<l)return[];if(null!=c&&e.zoom>c)return[];let f=r;return s&&a&&r&&!e.isGeospatial&&(f=Sm(r,s)),e.isGeospatial?function(e,t,n,i){const r=e instanceof qe&&e.resolution?e.projectPosition:null,o=Object.values(e.getFrustumPlanes()).map(({normal:e,distance:t})=>new Yg(e.clone().negate(),t)),s=new em(o),a=e.distanceScales.unitsPerMeter[2],A=n&&n[0]*a||0,l=n&&n[1]*a||0,c=e instanceof ce&&e.pitch<=60?t:0;if(i){const[e,t,n,r]=i,o=Ve([e,r]),s=Ve([n,t]);i=[o[0],ym-o[1],s[0],ym-s[1]]}const u=new xm(0,0,0),f={viewport:e,project:r,cullingVolume:s,elevationBounds:[A,l],minZ:c,maxZ:t,bounds:i,offset:0};if(u.update(f),e instanceof ce&&e.subViewports&&e.subViewports.length>1){for(f.offset=-1;u.update(f)&&!(--f.offset<-3););for(f.offset=1;u.update(f)&&!(++f.offset>3););}return u.getSelected()}(e,u,i,r):Om(e,u,o,f||Bm,a)}function Nm(e,t){if(e===t)return!0;if(Array.isArray(e)){const n=e.length;if(!t||t.length!==n)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}return!1}const Um="never",km="no-overlap",Gm="best-available",zm={[Gm]:function(e){for(const t of e)t.state=0;for(const t of e)t.isSelected&&!jm(t)&&Qm(t);for(const t of e)t.isVisible=Boolean(2&t.state)},[km]:function(e){for(const n of e)n.state=0;for(const n of e)n.isSelected&&jm(n);const t=Array.from(e).sort((e,t)=>e.zoom-t.zoom);for(const n of t)if(n.isVisible=Boolean(2&n.state),n.children&&(n.isVisible||1&n.state))for(const e of n.children)e.state=1;else n.isSelected&&Qm(n)},[Um]:()=>{}},Vm={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:()=>{}};class Hm{constructor(e){this._getCullBounds=function(e){let t,n={};return i=>{for(const r in i)if(!Nm(i[r],n[r])){t=e(i),n=i;break}return t}}(Em),this.opts={...Vm,...e},this.setOptions(this.opts),this.onTileLoad=e=>{this.opts.onTileLoad?.(e),null!==this.opts.maxCacheByteSize&&(this._cacheByteSize+=e.byteLength,this._resizeCache())},this._requestScheduler=new vt({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=/* @__PURE__ */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 ee,this._modelMatrixInverse=new ee}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return null!==this._selectedTiles&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return null!==this._selectedTiles&&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(const e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(const e of this._cache.keys()){const t=this._cache.get(e);this._selectedTiles&&this._selectedTiles.includes(t)?t.setNeedsReload():this._cache.delete(e)}}update(e,{zRange:t,modelMatrix:n}={zRange:null,modelMatrix:null}){const i=n?new ee(n):new ee,r=!i.equals(this._modelMatrix);if(this._viewport&&e.equals(this._viewport)&&We(this._zRange,t)&&!r)this.needsReload&&(this._selectedTiles=this._selectedTiles.map(e=>this._getTile(e.index,!0)));else{r&&(this._modelMatrixInverse=i.clone().invert(),this._modelMatrix=i),this._viewport=e,this._zRange=t;const n=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:t,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=n.map(e=>this._getTile(e,!0)),this._dirty&&this._rebuildTree()}const o=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),o&&this._frameNumber++,this._frameNumber}isTileVisible(e,t,n){if(!e.isVisible)return!1;if(t&&this._viewport){const i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:t});let{bbox:r}=e;for(const[e,t,o,s]of i){let i;if("west"in r)i=r.west<o&&r.east>e&&r.south<s&&r.north>t;else{if(n&&!ee.IDENTITY.equals(n)){const[e,t,i,o]=Sm([r.left,r.top,r.right,r.bottom],n);r={left:e,top:t,right:i,bottom:o}}const a=Math.min(r.top,r.bottom),A=Math.max(r.top,r.bottom);i=r.left<o&&r.right>e&&a<s&&A>t}if(i)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:t,minZoom:n,zRange:i,modelMatrix:r,modelMatrixInverse:o}){const{tileSize:s,extent:a,zoomOffset:A,visibleMinZoom:l,visibleMaxZoom:c}=this.opts;return Dm({viewport:e,maxZoom:t,minZoom:n,zRange:i,tileSize:s,extent:a,modelMatrix:r,modelMatrixInverse:o,zoomOffset:A,visibleMinZoom:l,visibleMaxZoom:c})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){const{tileSize:t}=this.opts;return{bbox:Fm(this._viewport,e.x,e.y,e.z,t)}}getParentIndex(e){return{x:Math.floor(e.x/2),y:Math.floor(e.y/2),z:e.z-1}}updateTileStates(){const e=this.opts.refinementStrategy||Gm,t=new Array(this._cache.size);let n=0;for(const i of this._cache.values())t[n++]=i.isVisible,i.isSelected=!1,i.isVisible=!1;for(const i of this._selectedTiles)i.isSelected=!0,i.isVisible=!0;("function"==typeof e?e:zm[e])(Array.from(this._cache.values())),n=0;for(const i of this._cache.values())if(t[n++]!==i.isVisible)return!0;return!1}_pruneRequests(){const{maxRequests:e=0}=this.opts,t=[];let n=0;for(const i of this._cache.values())i.isLoading&&(n++,i.isSelected||i.isVisible||t.push(i));for(;e>0&&n>e&&t.length>0;){t.shift().abort(),n--}}_rebuildTree(){const{_cache:e}=this;for(const t of e.values())t.parent=null,t.children&&(t.children.length=0);for(const t of e.values()){const e=this._getNearestAncestor(t);t.parent=e,e?.children&&e.children.push(t)}}_resizeCache(){const{_cache:e,opts:t}=this,n=t.maxCacheSize??(null!==t.maxCacheByteSize?1/0:5*this.selectedTiles.length),i=t.maxCacheByteSize??1/0;if(e.size>n||this._cacheByteSize>i){for(const[r,o]of e)if(o.isVisible||o.isSelected||(this._cacheByteSize-=null!==t.maxCacheByteSize?o.byteLength:0,e.delete(r),this.opts.onTileUnload?.(o)),e.size<=n&&this._cacheByteSize<=i)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((e,t)=>e.zoom-t.zoom),this._dirty=!1)}_getTile(e,t){const n=this.getTileId(e);let i=this._cache.get(n),r=!1;return!i&&t?(i=new _g(e),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:n,zoom:this.getTileZoom(i.index)}),r=!0,this._cache.set(n,i),this._dirty=!0):i&&i.needsReload&&(r=!0),i&&r&&i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),i}_getNearestAncestor(e){const{_minZoom:t=0}=this;let n=e.index;for(;this.getTileZoom(n)>t;){n=this.getParentIndex(n);const e=this._getTile(n);if(e)return e}return null}}function jm(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=2,!0;t=t.parent}return!1}function Qm(e){for(const t of e.children)t.isLoaded||t.content?t.state|=2:Qm(t)}const Jm={TilesetClass:Hm,data:{type:"data",value:[]},dataComparator:Mm.equal,renderSubLayers:{type:"function",value:e=>new Ya(e)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:e=>{}},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:Gm,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,visibleMinZoom:null,visibleMaxZoom:null};class Km extends fo{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(e=>e.isLoaded))))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:t}=this.state;const n=e.propsOrDataChanged||e.updateTriggersChanged,i=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);t?n&&(t.setOptions(this._getTilesetOptions()),i?t.reloadAll():t.tiles.forEach(e=>{e.layers=null})):(t=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:t})),this._updateTileset()}_getTilesetOptions(){const{tileSize:e,maxCacheSize:t,maxCacheByteSize:n,refinementStrategy:i,extent:r,maxZoom:o,minZoom:s,maxRequests:a,debounceTime:A,zoomOffset:l,visibleMinZoom:c,visibleMaxZoom:u}=this.props;return{maxCacheSize:t,maxCacheByteSize:n,maxZoom:o,minZoom:s,tileSize:e,refinementStrategy:i,extent:r,maxRequests:a,debounceTime:A,zoomOffset:l,visibleMinZoom:c,visibleMaxZoom:u,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){const e=this.state.tileset,{zRange:t,modelMatrix:n}=this.props,i=e.update(this.context.viewport,{zRange:t,modelMatrix:n}),{isLoaded:r}=e,o=this.state.isLoaded!==r,s=this.state.frameNumber!==i;r&&(o||s)&&this._onViewportLoad(),s&&this.setState({frameNumber:i}),this.state.isLoaded=r}_onViewportLoad(){const{tileset:e}=this.state,{onViewportLoad:t}=this.props;t&&t(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,t){this.props.onTileError(e),t.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){const{data:t,getTileData:n,fetch:i}=this.props,{signal:r}=e;return e.url="string"==typeof t||Array.isArray(t)?Tm(t,e):null,n?n(e):i&&e.url?i(e.url,{propName:"data",layer:this,signal:r}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){const t=e.sourceLayer,n=t.props.tile,i=e.info;return i.picked&&(i.tile=n),i.sourceTile=n,i.sourceTileSubLayer=t,i}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){const{visibleMinZoom:e,visibleMaxZoom:t,minZoom:n,extent:i}=this.props,r=this.context.viewport.zoom;if(null!=e&&r<e||null!=t&&r>t||null!=n&&!i&&r<n){for(const e of this.state.tileset.tiles)e.layers=null;return[]}return this.state.tileset.tiles.map(e=>{const t=this.getSubLayerPropsByTile(e);if(e.isLoaded||e.content)if(e.layers)t&&e.layers[0]&&Object.keys(t).some(n=>e.layers[0].props[n]!==t[n])&&(e.layers=e.layers.map(e=>e.clone(t)));else{const n=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=Ge(n,Boolean).map(n=>n.clone({tile:e,...t}))}else;return e.layers})}filterSubLayer({layer:e,cullRect:t}){const{tile:n}=e.props,{modelMatrix:i}=this.props;return this.state.tileset.isTileVisible(n,t,i?new ee(i):null)}}Km.defaultProps=Jm,Km.layerName="TileLayer";const Wm="layout(std140) uniform tripsUniforms {\n bool fadeTrail;\n float trailLength;\n float currentTime;\n} trips;\n",qm={name:"trips",vs:Wm,fs:Wm,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};class Ym extends Rs{getShaders(){const e=super.getShaders();return e.inject={"vs:#decl":"in float instanceTimestamps;\nin float instanceNextTimestamps;\nout float vTime;\n","vs:#main-end":"vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;\n","fs:#decl":"in float vTime;\n","fs:#main-start":"if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {\n discard;\n}\n","fs:DECKGL_FILTER_COLOR":"if(trips.fadeTrail) {\n color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;\n}\n"},e.modules=[...e.modules,qm],e}initializeState(){super.initializeState();this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){const{fadeTrail:t,trailLength:n,currentTime:i}=this.props,r={fadeTrail:t,trailLength:n,currentTime:i};this.state.model.shaderInputs.setProps({trips:r}),super.draw(e)}}Ym.layerName="TripsLayer",Ym.defaultProps={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}};const Xm={...aa.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0};class Zm extends fo{initializeState(){Zm._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:t}){if(!0!==e.highPrecision&&(t.dataChanged||t.updateTriggersChanged&&t.updateTriggersChanged.getHexagon)){const e=this._calculateH3DataProps();this.setState(e)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,t=!1,n=!1;const{iterable:i,objectInfo:r}=ir(this.props.data);for(const o of i){r.index++;const i=this.props.getHexagon(o,r),s=Fh(i);if(e<0){if(e=s,!this.props.highPrecision)break}else if(e!==s){n=!0;break}if(Rh(i)){t=!0;break}}return{resolution:e,edgeLengthKM:e>=0?Gh(e,"km"):0,hasMultipleRes:n,hasPentagon:t}}_shouldUseHighPrecision(){if("auto"===this.props.highPrecision){const{resolution:e,hasPentagon:t,hasMultipleRes:n}=this.state,{viewport:i}=this.context;return Boolean(i?.resolution)||n||t||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;const{resolution:t,edgeLengthKM:n,centerHex:i}=this.state;if(t<0)return;const r=this.props.centerHexagon||Oh(e.latitude,e.longitude,t);if(i===r)return;if(i)try{if(kh(i,r)*n<10)return}catch{}const{unitsPerMeter:o}=e.distanceScales;let s=jh(r);const[a,A]=Dh(r),[l,c]=e.projectFlat([A,a]);s=s.map(t=>{const n=e.projectFlat(t);return[(n[0]-l)/o[0],(n[1]-c)/o[1]]}),this.setState({centerHex:r,vertices:s})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){const{elevationScale:e,material:t,coverage:n,extruded:i,wireframe:r,stroked:o,filled:s,lineWidthUnits:a,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,getFillColor:u,getElevation:f,getLineColor:h,getLineWidth:d,transitions:p,updateTriggers:g}=this.props;return{elevationScale:e,extruded:i,coverage:n,wireframe:r,stroked:o,filled:s,lineWidthUnits:a,lineWidthScale:A,lineWidthMinPixels:l,lineWidthMaxPixels:c,material:t,getElevation:f,getFillColor:u,getLineColor:h,getLineWidth:d,transitions:p,updateTriggers:{getFillColor:g.getFillColor,getElevation:g.getElevation,getLineColor:g.getLineColor,getLineWidth:g.getLineWidth}}}_renderPolygonLayer(){const{data:e,getHexagon:t,updateTriggers:n,coverage:i}=this.props,r=this.getSubLayerClass("hexagon-cell-hifi",aa),o=this._getForwardProps();return o.updateTriggers.getPolygon=function(e,t){let n;return n=null==e?t:"object"==typeof e?{...e,coverage:t}:{getHexagon:e,coverage:t},n}(n.getHexagon,i),new r(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(e,n)=>Qh(jh(t(e,n),i))})}_renderColumnLayer(){const{data:e,getHexagon:t,updateTriggers:n}=this.props,i=this.getSubLayerClass("hexagon-cell",ws),r=this._getForwardProps();return r.updateTriggers.getPosition=n.getHexagon,new i(r,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:r.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:Hh.bind(null,t)})}}Zm.defaultProps=Xm,Zm.layerName="H3HexagonLayer",Zm._checkH3Lib=()=>{};class $m extends Za{initializeState(){Zm._checkH3Lib()}updateState({props:e,changeFlags:t}){if(t.dataChanged||t.updateTriggersChanged&&t.updateTriggersChanged.getHexagons){const{data:t,getHexagons:n}=e,i=[],{iterable:r,objectInfo:o}=ir(t);for(const e of r){o.index++;const t=Uh(n(e,o));for(const n of t){for(const e of n)Vh(e);i.push(this.getSubLayerRow({polygon:n},e,o.index))}}this.setState({polygons:i})}}indexToBounds(){const{getElevation:e,getFillColor:t,getLineColor:n,getLineWidth:i}=this.props;return{data:this.state.polygons,getPolygon:e=>e.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(t),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(i)}}}$m.layerName="H3ClusterLayer",$m.defaultProps={getHexagons:{type:"accessor",value:e=>e.hexagons}};const eb=Math.PI/180,tb=new Float32Array(16),nb=new Float32Array(12);function ib(e,t,n){const i=t[0]*eb,r=t[1]*eb,o=t[2]*eb,s=Math.sin(o),a=Math.sin(i),A=Math.sin(r),l=Math.cos(o),c=Math.cos(i),u=Math.cos(r),f=n[0],h=n[1],d=n[2];e[0]=f*u*c,e[1]=f*A*c,e[2]=f*-a,e[3]=h*(-A*l+u*a*s),e[4]=h*(u*l+A*a*s),e[5]=h*c*s,e[6]=d*(A*s+u*a*l),e[7]=d*(-u*s+A*a*l),e[8]=d*c*l}function rb(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}const ob={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(e,{startRow:t,endRow:n}){const{data:i,getOrientation:r,getScale:o,getTranslation:s,getTransformMatrix:a}=this.props,A=Array.isArray(a),l=A&&16===a.length,c=Array.isArray(o),u=Array.isArray(r),f=Array.isArray(s),h=l||!A&&Boolean(a(i[0]));e.constant=h?l:u&&c&&f;const d=e.value;if(e.constant){let t;if(h)tb.set(a),t=rb(tb);else{t=nb;ib(t,r,o),t.set(s,9)}e.value=new Float32Array(t)}else{let A=t*e.size;const{iterable:p,objectInfo:g}=ir(i,t,n);for(const e of p){let t;if(g.index++,h)tb.set(l?a:a(e,g)),t=rb(tb);else{t=nb;ib(t,u?r:r(e,g),c?o:o(e,g)),t.set(f?s:s(e,g),9)}d[A++]=t[0],d[A++]=t[1],d[A++]=t[2],d[A++]=t[3],d[A++]=t[4],d[A++]=t[5],d[A++]=t[6],d[A++]=t[7],d[A++]=t[8],d[A++]=t[9],d[A++]=t[10],d[A++]=t[11]}}}};function sb(e,t){return"cartesian"===t||"meter-offsets"===t||"default"===t&&!e.isGeospatial}const ab="layout(std140) uniform simpleMeshUniforms {\n float sizeScale;\n bool composeModelMatrix;\n bool hasTexture;\n bool flatShading;\n} simpleMesh;\n",Ab={name:"simpleMesh",vs:ab,fs:ab,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};function lb(e){const t=e.positions||e.POSITION;Ce.assert(t,'no "postions" or "POSITION" attribute in mesh');const n=t.value.length/t.size;let i=e.COLOR_0||e.colors;i||(i={size:3,value:new Float32Array(3*n).fill(1)});let r=e.NORMAL||e.normals;r||(r={size:3,value:new Float32Array(3*n).fill(0)});let o=e.TEXCOORD_0||e.texCoords;return o||(o={size:2,value:new Float32Array(2*n).fill(0)}),{positions:t,colors:i,normals:r,texCoords:o}}function cb(e){return e instanceof Qi?(e.attributes=lb(e.attributes),e):e.attributes?new Qi({...e,topology:"triangle-list",attributes:lb(e.attributes)}):new Qi({topology:"triangle-list",attributes:lb(e)})}const ub={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:e=>e.position},getColor:{type:"accessor",value:[0,0,0,255]},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}};class fb extends co{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = texCoords;\ngeometry.pickingColor = instancePickingColors;\nvTexCoord = texCoords;\ncameraPosition = project.cameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation;\nif (simpleMesh.composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);\ngeometry.position = position_commonspace;\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\n}\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform sampler2D sampler;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (simpleMesh.flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;\nDECKGL_FILTER_COLOR(color, geometry);\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * layer.opacity);\n}\n",modules:[Jn,Vn,Kn,Ab]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;const{mesh:t}=this.props;if(!t)return null;if(e=t.header?.boundingBox,!e){const{attributes:n}=cb(t);n.POSITION=n.POSITION||n.positions,e=function(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],A=a&&a.length;for(let l=0;l<A;l+=3){const e=a[l],A=a[l+1],c=a[l+2];t=e<t?e:t,n=A<n?A:n,i=c<i?c:i,r=e>r?e:r,o=A>o?A:o,s=c>s?c:s}return[[t,n,i],[r,o,s]]}(n)}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:ob}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:n,changeFlags:i}=e;if(t.mesh!==n.mesh||i.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),t.mesh){this.state.model=this.getModel(t.mesh);const e=t.mesh.attributes||t.mesh;this.setState({hasNormals:Boolean(e.NORMAL||e.normals)})}this.getAttributeManager().invalidateAll()}t.texture!==n.texture&&t.texture instanceof pe&&this.setTexture(t.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}){const{model:t}=this.state;if(!t)return;const{viewport:n,renderPass:i}=this.context,{sizeScale:r,coordinateSystem:o,_instanced:s}=this.props,a={sizeScale:r,composeModelMatrix:!s||sb(n,o),flatShading:!this.state.hasNormals};t.shaderInputs.setProps({simpleMesh:a}),t.draw(i)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){const t=new ki(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:cb(e),isInstanced:!0}),{texture:n}=this.props,{emptyTexture:i}=this.state,r={sampler:n||i,hasTexture:Boolean(n)};return t.shaderInputs.setProps({simpleMesh:r}),t}setTexture(e){const{emptyTexture:t,model:n}=this.state;if(n){const i={sampler:e||t,hasTexture:Boolean(e)};n.shaderInputs.setProps({simpleMesh:i})}}}fb.defaultProps=ub,fb.layerName="SimpleMeshLayer";const hb="basis_transcoder.js",db="basis_transcoder.wasm",pb="basis_encoder.js",gb="basis_encoder.wasm";let mb,bb;async function yb(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const n=function(e){const t=globalThis.loaders?.modules?.[e];return t||null}("basis");return n||(mb||=async function(e){let t=null,n=null;return[t,n]=await Promise.all([await dt(hb,"textures",e),await dt(db,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e(n).then(e=>{const{BasisFile:n,initializeBasis:i}=e;i(),t({BasisFile:n})})})}(t,n)}(e),await mb)}async function vb(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(bb=bb||async function(e){let t=null,n=null;return[t,n]=await Promise.all([await dt(pb,"textures",e),await dt(gb,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e(n).then(e=>{const{BasisFile:n,KTX2File:i,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:n,KTX2File:i,BasisEncoder:o})})})}(t,n)}(e),await bb)}const _b=["","WEBKIT_","MOZ_"],Cb={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"]};let xb=null;function wb(e){if(!xb){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,xb=/* @__PURE__ */new Set;for(const t of _b)for(const n in Cb)if(e&&e.getExtension(`${t}${n}`))for(const e of Cb[n])xb.add(e)}return xb}const Bb=[171,75,84,88,32,50,48,187,13,10,26,10];let Mb=Promise.resolve();const Sb={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"}};function Tb(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");const e=i.getNumImages(),t=[];for(let r=0;r<e;r++){const e=i.getNumLevels(r),o=[];for(let t=0;t<e;t++)o.push(Eb(i,r,t,n));t.push(o)}return t}finally{i.close(),i.delete()}}function Eb(e,t,n,i){const r=e.getImageWidth(t,n),o=e.getImageHeight(t,n),s=e.getHasAlpha(),{compressed:a,format:A,basisFormat:l,textureFormat:c}=Lb(i,s),u=e.getImageTranscodedSizeInBytes(t,n,l),f=new Uint8Array(u);if(!e.transcodeImage(f,t,n,l,0,0))throw new Error("failed to start Basis transcoding");return{shape:"texture-level",width:r,height:o,data:f,compressed:a,...void 0!==A?{format:A}:{},...void 0!==c?{textureFormat:c}:{},hasAlpha:s}}function Pb(e,t,n){const i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=i.getLevels(),t=[];for(let r=0;r<e;r++)t.push(Ib(i,r,n));return[t]}finally{i.close(),i.delete()}}function Ib(e,t,n){const{alphaFlag:i,height:r,width:o}=e.getImageLevelInfo(t,0,0),{compressed:s,format:a,basisFormat:A,textureFormat:l}=Lb(n,i),c=e.getImageTranscodedSizeInBytes(t,0,0,A),u=new Uint8Array(c);if(!e.transcodeImage(u,t,0,0,A,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{shape:"texture-level",width:o,height:r,data:u,compressed:s,...void 0!==a?{format:a}:{},...void 0!==l?{textureFormat:l}:{},levelSize:c,hasAlpha:i}}function Lb(e,t){let n=e.basis?.format||"auto";"auto"===n&&(n=e.basis?.supportedTextureFormats?Rb(e.basis.supportedTextureFormats):Rb()),"object"==typeof n&&(n=t?n.alpha:n.noAlpha);const i=n.toLowerCase(),r=Sb[i];if(!r)throw new Error(`Unknown Basis format ${n}`);return r}function Rb(e=wb()){const t=new Set(e);return Fb(t,["astc-4x4-unorm","astc-4x4-unorm-srgb"])?"astc-4x4":Fb(t,["bc7-rgba-unorm","bc7-rgba-unorm-srgb"])?{alpha:"bc7-m5",noAlpha:"bc7-m6-opaque-only"}:Fb(t,["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"}:Fb(t,["pvrtc-rgb4unorm-webgl","pvrtc-rgba4unorm-webgl","pvrtc-rgb2unorm-webgl","pvrtc-rgba2unorm-webgl"])?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:Fb(t,["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"])?"etc2":t.has("etc1-rgb-unorm-webgl")?"etc1":Fb(t,["atc-rgb-unorm-webgl","atc-rgba-unorm-webgl","atc-rgbai-unorm-webgl"])?{alpha:"atc-rgba-interpolated-alpha",noAlpha:"atc-rgb"}:"rgb565"}function Fb(e,t){return t.some(t=>e.has(t))}Object.freeze(Object.keys(Sb));const Ob={...{dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:"4.4.2",worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",containerFormat:"auto",module:"transcoder"}}},parse:async function(e,t={}){const n=ht(t);return await async function(e){const t=Mb;let n;Mb=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}(async()=>{if(!t.basis?.containerFormat||"auto"===t.basis.containerFormat){if(function(e){const t=new Uint8Array(e);return!(t.byteLength<Bb.length||t[0]!==Bb[0]||t[1]!==Bb[1]||t[2]!==Bb[2]||t[3]!==Bb[3]||t[4]!==Bb[4]||t[5]!==Bb[5]||t[6]!==Bb[6]||t[7]!==Bb[7]||t[8]!==Bb[8]||t[9]!==Bb[9]||t[10]!==Bb[10]||t[11]!==Bb[11])}(e)){return Pb((await vb(n)).KTX2File,e,t)}const{BasisFile:i}=await yb(n);return Tb(i,e,t)}if("encoder"===t.basis.module){const i=await vb(n);return"ktx2"===t.basis.containerFormat?Pb(i.KTX2File,e,t):Tb(i.BasisFile,e,t)}{const{BasisFile:i}=await yb(n);return Tb(i,e,t)}})}};var Db,Nb;function Ub(e){return{addressModeU:kb(e.wrapS),addressModeV:kb(e.wrapT),magFilter:Gb(e.magFilter),...zb(e.minFilter)}}function kb(e){switch(e){case Db.CLAMP_TO_EDGE:return"clamp-to-edge";case Db.REPEAT:return"repeat";case Db.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function Gb(e){switch(e){case Db.NEAREST:return"nearest";case Db.LINEAR:return"linear";default:return}}function zb(e){switch(e){case Db.NEAREST:return{minFilter:"nearest"};case Db.LINEAR:return{minFilter:"linear"};case Db.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case Db.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case Db.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case Db.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}(Nb=Db||(Db={}))[Nb.POINTS=0]="POINTS",Nb[Nb.LINES=1]="LINES",Nb[Nb.LINE_LOOP=2]="LINE_LOOP",Nb[Nb.LINE_STRIP=3]="LINE_STRIP",Nb[Nb.TRIANGLES=4]="TRIANGLES",Nb[Nb.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",Nb[Nb.TRIANGLE_FAN=6]="TRIANGLE_FAN",Nb[Nb.ONE=1]="ONE",Nb[Nb.SRC_ALPHA=770]="SRC_ALPHA",Nb[Nb.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",Nb[Nb.FUNC_ADD=32774]="FUNC_ADD",Nb[Nb.LINEAR=9729]="LINEAR",Nb[Nb.NEAREST=9728]="NEAREST",Nb[Nb.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",Nb[Nb.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",Nb[Nb.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",Nb[Nb.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",Nb[Nb.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",Nb[Nb.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",Nb[Nb.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",Nb[Nb.REPEAT=10497]="REPEAT",Nb[Nb.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",Nb[Nb.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",Nb[Nb.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL";const Vb=[jb("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),jb("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),jb("normal","pbr_normalSampler","normalTexture",["normalTexture"]),jb("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),jb("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),jb("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),jb("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),jb("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),jb("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),jb("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),jb("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),jb("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),jb("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),jb("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),jb("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),jb("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),jb("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],Hb=new Map(Vb.map(e=>[e.slot,e]));function jb(e,t,n,i){return{slot:e,binding:t,displayName:n,pathSegments:i,uvSetUniform:`${e}UVSet`,uvTransformUniform:`${e}UVTransform`}}function Qb(e){const t=Hb.get(e);if(!t)throw new Error(`Unknown PBR texture transform slot ${e}`);return t}function Jb(e){const t=e?.extensions?.KHR_texture_transform;return{offset:t?.offset?[t.offset[0],t.offset[1]]:[0,0],rotation:t?.rotation??0,scale:t?.scale?[t.scale[0],t.scale[1]]:[1,1]}}function Kb(e){const t=e?.extensions?.KHR_texture_transform;return t?.texCoord??e?.texCoord??0}function Wb(e){const t=(new Dt).set(1,0,0,0,1,0,e.offset[0],e.offset[1],1),n=(new Dt).set(Math.cos(e.rotation),Math.sin(e.rotation),0,-Math.sin(e.rotation),Math.cos(e.rotation),0,0,0,1),i=(new Dt).set(e.scale[0],0,0,0,e.scale[1],0,0,0,1);return Array.from(t.multiplyRight(n).multiplyRight(i))}function qb(e,t){const n=new Dt(Wb(e)),i=new Dt(Wb(t)),r=new Dt(n).invert();return Array.from(i.multiplyRight(r))}function Yb(e,t,n,i){const r={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};r.defines.USE_TEX_LOD=!0;const{imageBasedLightingEnvironment:o}=i;return o&&(r.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,r.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,r.bindings.pbr_brdfLUT=o.brdfLutTexture.texture,r.uniforms.IBLenabled=!0,r.uniforms.scaleIBLAmbient=[1,1]),i?.pbrDebug&&(r.defines.PBR_DEBUG=!0,r.uniforms.scaleDiffBaseMR=[0,0,0,0],r.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(r.defines.HAS_NORMALS=!0),n.TANGENT&&i?.useTangents&&(r.defines.HAS_TANGENTS=!0),n.TEXCOORD_0&&(r.defines.HAS_UV=!0),n.TEXCOORD_1&&(r.defines.HAS_UV_1=!0),n.JOINTS_0&&n.WEIGHTS_0&&(r.defines.HAS_SKIN=!0),n.COLOR_0&&(r.defines.HAS_COLORS=!0),i?.imageBasedLightingEnvironment&&(r.defines.USE_IBL=!0),i?.lights&&(r.defines.USE_LIGHTS=!0),t&&(!1!==i.validateAttributes&&function(e,t){const n=Xb(e,0);n.length>0&&!t.TEXCOORD_0&&ie.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();const i=Xb(e,1);i.length>0&&!t.TEXCOORD_1&&ie.warn(`glTF material uses ${i.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)();const r=Boolean(e.unlit||e.extensions?.KHR_materials_unlit);if(r||t.NORMAL)return;const o=e.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";ie.warn(`glTF primitive is missing NORMAL while using ${o}; shading will fall back to geometric normals`)()}(t,n),function(e,t,n,i,r){n.uniforms.unlit=Boolean(t.unlit||t.extensions?.KHR_materials_unlit),t.pbrMetallicRoughness&&function(e,t,n,i,r){t.baseColorTexture&&$b(e,t.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"baseColor"});n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&$b(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"metallicRoughness"});const{metallicFactor:o=1,roughnessFactor:s=1}=t;n.uniforms.metallicRoughnessValues=[o,s]}(e,t.pbrMetallicRoughness,n,i,r);if(t.normalTexture){$b(e,t.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"normal"});const{scale:o=1}=t.normalTexture;n.uniforms.normalScale=o}if(t.occlusionTexture){$b(e,t.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"occlusion"});const{strength:o=1}=t.occlusionTexture;n.uniforms.occlusionStrength=o}n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0],t.emissiveTexture&&$b(e,t.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:r,attributes:i,textureTransformSlot:"emissive"});switch(function(e,t,n,i,r={}){if(!t)return;(function(e){return Boolean(e.KHR_materials_specular||e.KHR_materials_ior||e.KHR_materials_transmission||e.KHR_materials_volume||e.KHR_materials_clearcoat||e.KHR_materials_sheen||e.KHR_materials_iridescence||e.KHR_materials_anisotropy)})(t)&&(n.defines.USE_MATERIAL_EXTENSIONS=!0);(function(e,t,n,i,r={}){if(!t)return;t.specularColorFactor&&(n.uniforms.specularColorFactor=t.specularColorFactor);void 0!==t.specularFactor&&(n.uniforms.specularIntensityFactor=t.specularFactor);t.specularColorTexture&&$b(e,t.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"specularColor"});t.specularTexture&&$b(e,t.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"specularIntensity"})})(e,t.KHR_materials_specular,n,i,r),function(e,t){void 0!==e?.ior&&(t.uniforms.ior=e.ior)}(t.KHR_materials_ior,n),function(e,t,n,i,r={}){if(!t)return;void 0!==t.transmissionFactor&&(n.uniforms.transmissionFactor=t.transmissionFactor);t.transmissionTexture&&$b(e,t.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"transmission"});((t.transmissionFactor??0)>0||t.transmissionTexture)&&(ie.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),function(e){e.parameters.blend=!0,e.parameters.depthWriteEnabled=!1,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="one",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.depthMask=!1,e.glParameters.blendEquation=Db.FUNC_ADD,e.glParameters.blendFunc=[Db.ONE,Db.ONE_MINUS_SRC_ALPHA,Db.ONE,Db.ONE_MINUS_SRC_ALPHA]}(n))}(e,t.KHR_materials_transmission,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.thicknessFactor&&(n.uniforms.thicknessFactor=t.thicknessFactor);t.thicknessTexture&&$b(e,t.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:i,attributes:r,textureTransformSlot:"thickness"});void 0!==t.attenuationDistance&&(n.uniforms.attenuationDistance=t.attenuationDistance);t.attenuationColor&&(n.uniforms.attenuationColor=t.attenuationColor)}(e,t.KHR_materials_volume,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.clearcoatFactor&&(n.uniforms.clearcoatFactor=t.clearcoatFactor);void 0!==t.clearcoatRoughnessFactor&&(n.uniforms.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor);t.clearcoatTexture&&$b(e,t.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"clearcoat"});t.clearcoatRoughnessTexture&&$b(e,t.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"clearcoatRoughness"});t.clearcoatNormalTexture&&$b(e,t.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:i,attributes:r,textureTransformSlot:"clearcoatNormal"})}(e,t.KHR_materials_clearcoat,n,i,r),function(e,t,n,i,r={}){if(!t)return;t.sheenColorFactor&&(n.uniforms.sheenColorFactor=t.sheenColorFactor);void 0!==t.sheenRoughnessFactor&&(n.uniforms.sheenRoughnessFactor=t.sheenRoughnessFactor);t.sheenColorTexture&&$b(e,t.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"sheenColor"});t.sheenRoughnessTexture&&$b(e,t.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"sheenRoughness"})}(e,t.KHR_materials_sheen,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.iridescenceFactor&&(n.uniforms.iridescenceFactor=t.iridescenceFactor);void 0!==t.iridescenceIor&&(n.uniforms.iridescenceIor=t.iridescenceIor);void 0===t.iridescenceThicknessMinimum&&void 0===t.iridescenceThicknessMaximum||(n.uniforms.iridescenceThicknessRange=[t.iridescenceThicknessMinimum??100,t.iridescenceThicknessMaximum??400]);t.iridescenceTexture&&$b(e,t.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"iridescence"});t.iridescenceThicknessTexture&&$b(e,t.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:i,attributes:r,textureTransformSlot:"iridescenceThickness"})}(e,t.KHR_materials_iridescence,n,i,r),function(e,t,n,i,r={}){if(!t)return;void 0!==t.anisotropyStrength&&(n.uniforms.anisotropyStrength=t.anisotropyStrength);void 0!==t.anisotropyRotation&&(n.uniforms.anisotropyRotation=t.anisotropyRotation);t.anisotropyTexture&&$b(e,t.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:i,attributes:r,textureTransformSlot:"anisotropy"})}(e,t.KHR_materials_anisotropy,n,i,r),function(e,t){void 0!==e?.emissiveStrength&&(t.uniforms.emissiveStrength=e.emissiveStrength)}(t.KHR_materials_emissive_strength,n)}(e,t.extensions,n,r,i),t.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{const{alphaCutoff:e=.5}=t;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoffEnabled=!0,n.uniforms.alphaCutoff=e;break}case"BLEND":ie.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),function(e){e.parameters.blend=!0,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="src-alpha",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.blendEquation=Db.FUNC_ADD,e.glParameters.blendFunc=[Db.SRC_ALPHA,Db.ONE_MINUS_SRC_ALPHA,Db.ONE,Db.ONE_MINUS_SRC_ALPHA]}(n)}}(e,t,r,n,i.gltf)),r}function Xb(e,t){const n=[];for(const i of Vb){const r=Zb(e,i.pathSegments);r&&(Kb(r)===t&&n.push(i.displayName))}return n}function Zb(e,t){let n=e;for(const i of t)if(n=n?.[i],!n)return null;return n}function $b(e,t,n,i,r={}){const{featureOptions:o={},gltf:s,attributes:a={},textureTransformSlot:A}=r,{define:l,enabledUniformName:c}=o,u=Kb(t);if(u>1)return void ie.warn(`Skipping ${String(n)} because ${u} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();if(1===u&&!a.TEXCOORD_1)return void ie.warn(`Skipping ${String(n)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();const f=function(e,t){if(e.texture||void 0===e.index||!t?.textures)return e;const n=t.textures[e.index];if(!n)return e;if("texture"in n&&n.texture)return{...n,...e,texture:n.texture};if(!("source"in n))return e;return{...e,texture:n}}(t,s),h=f.texture?.source?.image;if(!h)return void ie.warn(`Skipping unresolved glTF texture for ${String(n)}`)();const d={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...f?.texture?.sampler},p={id:f.uniformName||f.id,sampler:Ub(d)};let g;if(h.compressed)g=function(e,t,n){let i;i=Array.isArray(t.data)&&t.data[0]?.data?t.data:"mipmaps"in t&&Array.isArray(t.mipmaps)?t.mipmaps:[];if(0===i.length||!i[0]?.data)return ie.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),ey(e,n);const r=i[0],o=r.width??t.width??0,s=r.height??t.height??0;if(o<=0||s<=0)return ie.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),ey(e,n);const a=ty(r);if(!a)return ie.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),ey(e,n);const A=function(e,t,n){const{blockWidth:i=1,blockHeight:r=1}=Ye.getInfo(n);let o=1;for(let s=1;;s++){const n=Math.max(1,e>>s),a=Math.max(1,t>>s);if(n<i||a<r)break;o++}return o}(o,s,a),l=Math.min(i.length,A);let c=1;for(let f=1;f<l;f++){const e=i[f];if(!e.data||e.width<=0||e.height<=0){ie.warn(`createCompressedTexture: mip level ${f} has invalid data/dimensions, truncating`)();break}const t=ty(e);if(t&&t!==a){ie.warn(`createCompressedTexture: mip level ${f} format '${t}' differs from base '${a}', truncating`)();break}const n=Math.max(1,o>>f),r=Math.max(1,s>>f);if(e.width!==n||e.height!==r){ie.warn(`createCompressedTexture: mip level ${f} dimensions ${e.width}x${e.height} don't match expected ${n}x${r}, truncating`)();break}c++}const u=e.createTexture({...n,format:a,usage:pe.TEXTURE|pe.COPY_DST,width:o,height:s,mipLevels:c,data:r.data});for(let f=1;f<c;f++)u.writeData(i[f].data,{width:i[f].width,height:i[f].height,mipLevel:f});return u}(e,h,p);else{const{width:t,height:n}=e.getExternalImageSize(h);g=e.createTexture({...p,width:t,height:n,data:h})}if(i.bindings[n]=g,l&&(i.defines[l]=!0),c&&(i.uniforms[c]=!0),A){const e=Qb(A);i.uniforms[e.uvSetUniform]=u,i.uniforms[e.uvTransformUniform]=Wb(Jb(t))}i.generatedTextures.push(g)}function ey(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function ty(e){return e.textureFormat}function ny(e,t={}){const n=e.lights||e.extensions?.KHR_lights_punctual?.lights;if(!n||!Array.isArray(n)||0===n.length)return[];const i=[],r=function(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of n.children||[])t.set(e.id,n);return t}(e.nodes||[]),o=/* @__PURE__ */new Map;for(const s of e.nodes||[]){const e=s.light??s.extensions?.KHR_lights_punctual?.light;if("number"!=typeof e)continue;const a=n[e];if(!a)continue;const A=iy(a.color||[1,1,1],t.useByteColors??!0),l=a.intensity??1,c=a.range,u=ay(s,r,o);switch(a.type){case"directional":i.push(oy(u,A,l));break;case"point":i.push(ry(u,A,l,c));break;case"spot":i.push(sy(u,A,l,c,a.spot))}}return i}function iy(e,t){return t?e.map(e=>255*e):nn(e,!1)}function ry(e,t,n,i){let r=[1,0,0];return void 0!==i&&i>0&&(r=[1,0,1/(i*i)]),{type:"point",position:Ay(e),color:t,intensity:n,attenuation:r}}function oy(e,t,n){return{type:"directional",direction:ly(e),color:t,intensity:n}}function sy(e,t,n,i,r={}){let o=[1,0,0];return void 0!==i&&i>0&&(o=[1,0,1/(i*i)]),{type:"spot",position:Ay(e),direction:ly(e),color:t,intensity:n,attenuation:o,innerConeAngle:r.innerConeAngle??0,outerConeAngle:r.outerConeAngle??Math.PI/4}}function ay(e,t,n){const i=n.get(e.id);if(i)return i;const r=function(e){if(e.matrix)return new ee(e.matrix);const t=new ee;e.translation&&t.translate(e.translation);e.rotation&&t.multiplyRight((new ee).fromQuaternion(e.rotation));e.scale&&t.scale(e.scale);return t}(e),o=t.get(e.id),s=o?new ee(ay(o,t,n)).multiplyRight(r):r;return n.set(e.id,s),s}function Ay(e){return e.transformAsPoint([0,0,0])}function ly(e){return e.transformDirection([0,0,-1])}function cy(e,t){const n=t.materialFactory||new zi(e,{modules:[jn]}),i={...t.parsedPPBRMaterial.uniforms};delete i.camera;const r=Object.fromEntries(Object.entries({...i,...t.parsedPPBRMaterial.bindings}).filter(([e,t])=>n.ownsBinding(e)&&function(e){return e instanceof re||e instanceof Ri||e instanceof ge||e instanceof pe||e instanceof a}(t))),o=n.createMaterial({id:t.id,bindings:r});return o.setProps({pbrMaterial:i}),o}function uy(e,t){const{id:n,geometry:i,parsedPPBRMaterial:r,vertexCount:o,modelOptions:s={}}=t;ie.info(4,"createGLTFModel defines: ",r.defines)();const a={id:n,source:"\nstruct VertexInputs {\n @location(0) positions: vec3f,\n#ifdef HAS_NORMALS\n @location(1) normals: vec3f,\n#endif\n#ifdef HAS_TANGENTS\n @location(2) TANGENT: vec4f,\n#endif\n#ifdef HAS_UV\n @location(3) texCoords: vec2f,\n#endif\n#ifdef HAS_UV_1\n @location(4) texCoords1: vec2f,\n#endif\n#ifdef HAS_SKIN\n @location(5) JOINTS_0: vec4u,\n @location(6) WEIGHTS_0: vec4f,\n#endif\n};\n\nstruct FragmentInputs {\n @builtin(position) position: vec4f,\n @location(0) pbrPosition: vec3f,\n @location(1) pbrUV0: vec2f,\n @location(2) pbrUV1: vec2f,\n @location(3) pbrNormal: vec3f,\n#ifdef HAS_TANGENTS\n @location(4) pbrTangent: vec4f,\n#endif\n};\n\n@vertex\nfn vertexMain(inputs: VertexInputs) -> FragmentInputs {\n var outputs: FragmentInputs;\n var position = vec4f(inputs.positions, 1.0);\n var normal = vec3f(0.0, 0.0, 1.0);\n var tangent = vec4f(1.0, 0.0, 0.0, 1.0);\n var uv0 = vec2f(0.0, 0.0);\n var uv1 = vec2f(0.0, 0.0);\n\n#ifdef HAS_NORMALS\n normal = inputs.normals;\n#endif\n#ifdef HAS_UV\n uv0 = inputs.texCoords;\n#endif\n#ifdef HAS_UV_1\n uv1 = inputs.texCoords1;\n#endif\n#ifdef HAS_TANGENTS\n tangent = inputs.TANGENT;\n#endif\n#ifdef HAS_SKIN\n let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);\n position = skinMatrix * position;\n normal = normalize((skinMatrix * vec4f(normal, 0.0)).xyz);\n#ifdef HAS_TANGENTS\n tangent = vec4f(normalize((skinMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w);\n#endif\n#endif\n\n let worldPosition = pbrProjection.modelMatrix * position;\n\n#ifdef HAS_NORMALS\n normal = normalize((pbrProjection.normalMatrix * vec4f(normal, 0.0)).xyz);\n#endif\n#ifdef HAS_TANGENTS\n let worldTangent = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);\n outputs.pbrTangent = vec4f(worldTangent, tangent.w);\n#endif\n\n outputs.position = pbrProjection.modelViewProjectionMatrix * position;\n outputs.pbrPosition = worldPosition.xyz / worldPosition.w;\n outputs.pbrUV0 = uv0;\n outputs.pbrUV1 = uv1;\n outputs.pbrNormal = normal;\n return outputs;\n}\n\n@fragment\nfn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {\n fragmentInputs.pbr_vPosition = inputs.pbrPosition;\n fragmentInputs.pbr_vUV0 = inputs.pbrUV0;\n fragmentInputs.pbr_vUV1 = inputs.pbrUV1;\n fragmentInputs.pbr_vNormal = inputs.pbrNormal;\n#ifdef HAS_TANGENTS\n let tangent = normalize(inputs.pbrTangent.xyz);\n let bitangent = normalize(cross(inputs.pbrNormal, tangent)) * inputs.pbrTangent.w;\n fragmentInputs.pbr_vTBN = mat3x3f(tangent, bitangent, inputs.pbrNormal);\n#endif\n return pbr_filterColor(vec4f(1.0));\n}\n",vs:"#version 300 es\n\n // in vec4 POSITION;\n in vec4 positions;\n\n #ifdef HAS_NORMALS\n // in vec4 NORMAL;\n in vec4 normals;\n #endif\n\n #ifdef HAS_TANGENTS\n in vec4 TANGENT;\n #endif\n\n #ifdef HAS_UV\n // in vec2 TEXCOORD_0;\n in vec2 texCoords;\n #endif\n\n #ifdef HAS_UV_1\n in vec2 texCoords1;\n #endif\n\n #ifdef HAS_SKIN\n in uvec4 JOINTS_0;\n in vec4 WEIGHTS_0;\n #endif\n\n void main(void) {\n vec4 _NORMAL = vec4(0.);\n vec4 _TANGENT = vec4(0.);\n vec2 _TEXCOORD_0 = vec2(0.);\n vec2 _TEXCOORD_1 = vec2(0.);\n\n #ifdef HAS_NORMALS\n _NORMAL = normals;\n #endif\n\n #ifdef HAS_TANGENTS\n _TANGENT = TANGENT;\n #endif\n\n #ifdef HAS_UV\n _TEXCOORD_0 = texCoords;\n #endif\n\n #ifdef HAS_UV_1\n _TEXCOORD_1 = texCoords1;\n #endif\n\n vec4 pos = positions;\n\n #ifdef HAS_SKIN\n mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0);\n pos = skinMat * pos;\n _NORMAL = skinMat * _NORMAL;\n _TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w);\n #endif\n\n pbr_setPositionNormalTangentUV(pos, _NORMAL, _TANGENT, _TEXCOORD_0, _TEXCOORD_1);\n gl_Position = pbrProjection.modelViewProjectionMatrix * pos;\n }\n",fs:"#version 300 es\n out vec4 fragmentColor;\n\n void main(void) {\n vec3 pos = pbr_vPosition;\n fragmentColor = pbr_filterColor(vec4(1.0));\n }\n",geometry:i,topology:i.topology,vertexCount:o,modules:[jn,ln],...s,defines:{...r.defines,...s.defines},parameters:{depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back",...r.parameters,...s.parameters}},A=t.material||cy(e,{id:n?`${n}-material`:void 0,parsedPPBRMaterial:r});a.material=A;const l=new ki(e,a),c={...r.uniforms,...s.uniforms,...r.bindings,...s.bindings},u=function(e,t,n){const i=/* @__PURE__ */new Map;for(const o of e){for(const e of Object.keys(o.uniformTypes||{}))i.set(e,o.name);for(const e of o.bindingLayout||[])i.set(e.name,o.name)}const r={};for(const[o,s]of Object.entries(n)){if(void 0===s)continue;const e=i.get(o);e&&!t.ownsModule(e)&&(r[e]||={},r[e][o]=s)}return r}(l.shaderInputs.getModules(),A,c);return l.shaderInputs.setProps(u),new qi({managedResources:[],model:l})}const fy={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1,useByteColors:!0};function hy(e,t,n={}){const i={...fy,...n},r=new zi(e,{modules:[jn]}),o=(t.materials||[]).map((n,o)=>cy(e,{id:dy(n,o),parsedPPBRMaterial:Yb(e,n,{},{...i,gltf:t,validateAttributes:!1}),materialFactory:r})),s=/* @__PURE__ */new Map;(t.materials||[]).forEach((e,t)=>{s.set(e.id,o[t])});const a=/* @__PURE__ */new Map;t.meshes.forEach((n,r)=>{const o=function(e,t,n,i,r){const o=t.primitives||[],s=o.map((o,s)=>function({device:e,gltfPrimitive:t,primitiveIndex:n,gltfMesh:i,gltf:r,gltfMaterialIdToMaterialMap:o,options:s}){const a=t.name||`${i.name||i.id}-primitive-${n}`,A=function(e){switch(e){case Db.POINTS:return"point-list";case Db.LINES:return"line-list";case Db.LINE_STRIP:return"line-strip";case Db.TRIANGLES:return"triangle-list";case Db.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(e))}}(t.mode??4),l=t.indices?t.indices.count:function(e){let t=1/0;for(const n of Object.values(e))if(n){const{value:e,size:i,components:r}=n,o=i??r;void 0!==e?.length&&o>=1&&(t=Math.min(t,e.length/o))}if(!Number.isFinite(t))throw new Error("Could not determine vertex count from attributes");return t}(t.attributes),c=function(e,t,n){const i={};for(const[r,o]of Object.entries(t.attributes)){const{components:e,size:t,value:n,normalized:s}=o;i[r]={size:t??e,value:n,normalized:s}}return new Qi({id:e,topology:n,indices:t.indices?.value,attributes:i})}(a,t,A),u=Yb(e,t.material,c.attributes,{...s,gltf:r}),f=uy(e,{id:a,geometry:c,material:t.material&&o.get(t.material.id)||null,parsedPPBRMaterial:u,modelOptions:s.modelOptions,vertexCount:l});return f.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],f}({device:e,gltfPrimitive:o,primitiveIndex:s,gltfMesh:t,gltf:n,gltfMaterialIdToMaterialMap:i,options:r})),a=new Wi({id:t.name||t.id,children:s});return a}(e,n,t,s,i);a.set(n.id,o)});const A=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;t.nodes.forEach((e,t)=>{const n=function(e,t){return new Wi({id:t.name||t.id,children:[],matrix:t.matrix,position:t.translation,rotation:t.rotation,scale:t.scale})}(0,e);A.set(t,n),l.set(e.id,n)}),t.nodes.forEach((e,t)=>{if(A.get(t).add((e.children??[]).map(({id:e})=>{const n=l.get(e);if(!n)throw new Error(`Cannot find child ${e} of node ${t}`);return n})),e.mesh){const n=a.get(e.mesh.id);if(!n)throw new Error(`Cannot find mesh child ${e.mesh.id} of node ${t}`);A.get(t).add(n)}});return{scenes:t.scenes.map(e=>{const t=(e.nodes||[]).map(({id:t})=>{const n=l.get(t);if(!n)throw new Error(`Cannot find child ${t} of scene ${e.name||e.id}`);return n});return new Wi({id:e.name||e.id,children:t})}),materials:o,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:l,gltfNodeIndexToNodeMap:A}}function dy(e,t){return e.name||e.id||`material-${t}`}function py(e,{input:t,interpolation:n,output:i},r,o){const s=gy(e,{input:t,interpolation:n,output:i},o);s&&function(e,t,n){switch(t){case"translation":return e.setPosition(n).updateMatrix();case"rotation":return e.setRotation(n).updateMatrix();case"scale":return e.setScale(n).updateMatrix();default:ie.warn(`Bad animation path ${t}`)()}}(r,o,s)}function gy(e,{input:t,interpolation:n,output:i},r){const o=t[t.length-1];if(!Number.isFinite(o)||o<=0)return i[0]||null;const s=e%o,a=t.findIndex(e=>e>=s);if(a<0)return i[i.length-1]||null;const A=Math.max(0,a-1),l=t[A],c=t[a];switch(n){case"STEP":return i[A];case"LINEAR":if(c>l){const e=(s-l)/(c-l);return function(e,t,n,i){if("rotation"===e)return(new $t).slerp({start:t,target:n,ratio:i});const r=[];for(let o=0;o<t.length;o++)r[o]=i*n[o]+(1-i)*t[o];return r}(r,i[A],i[a],e)}return i[A]||null;case"CUBICSPLINE":if(c>l){const e=(s-l)/(c-l),t=c-l;return function({p0:e,outTangent0:t,inTangent1:n,p1:i,tDiff:r,ratio:o}){const s=[];for(let a=0;a<e.length;a++){const A=t[a]*r,l=n[a]*r;s[a]=(2*Math.pow(o,3)-3*Math.pow(o,2)+1)*e[a]+(Math.pow(o,3)-2*Math.pow(o,2)+o)*A+(-2*Math.pow(o,3)+3*Math.pow(o,2))*i[a]+(Math.pow(o,3)-Math.pow(o,2))*l}return s}({p0:i[3*A+1],outTangent0:i[3*A+2],inTangent1:i[3*a+0],p1:i[3*a+1],tDiff:t,ratio:e})}return i[3*A+1]||null;default:return ie.warn(`Interpolation ${n} not supported`)(),null}}class my{animation;gltfNodeIdToNodeMap;materials;startTime=0;playing=!0;speed=1;materialTextureTransformState=/* @__PURE__ */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(e=>"node"!==e.type)&&!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;const t=(e/1e3-this.startTime)*this.speed;this.animation.channels.forEach(e=>{if("node"===e.type){const{sampler:n,targetNodeId:i,path:r}=e,o=this.gltfNodeIdToNodeMap.get(i);if(!o)throw new Error(`Cannot find animation target node ${i}`);return void py(t,n,o,r)}const n=this.materials[e.targetMaterialIndex];if(!n)throw new Error(`Cannot find animation target material ${e.targetMaterialIndex} for ${e.pointer}`);const i=gy(t,e.sampler);i&&("material"===e.type?function(e,t,n){const i=void 0!==t.component?{[t.property]:vy(yy(e,t.property),t.component,n[0])}:{[t.property]:1===n.length?n[0]:n};e.setProps({pbrMaterial:i})}(n,e,i):function(e,t,n,i){const r=Qb(t.textureSlot),o=function(e,t,n){const i=e.get(t)||{};let r=i[n.textureSlot];r||(r={offset:[...n.baseTransform.offset],rotation:n.baseTransform.rotation,scale:[...n.baseTransform.scale]},i[n.textureSlot]=r,e.set(t,i));return r}(i,e,t);switch(t.path){case"offset":void 0!==t.component?o.offset[t.component]=n[0]:o.offset=[n[0],n[1]];break;case"rotation":o.rotation=n[0];break;case"scale":void 0!==t.component?o.scale[t.component]=n[0]:o.scale=[n[0],n[1]]}e.setProps({pbrMaterial:{[r.uvTransformUniform]:qb(t.baseTransform,o)}})}(n,e,i,this.materialTextureTransformState))})}}class by{animations;constructor(e){this.animations=e.animations.map((t,n)=>{const i=t.name||`Animation-${n}`;return new my({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,materials:e.materials,animation:{name:i,channels:t.channels}})})}animate(e){ie.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(e)}setTime(e){this.animations.forEach(t=>t.setTime(e))}getAnimations(){return this.animations}}function yy(e,t){const n=e.shaderInputs.getUniformValues(),i=n.pbrMaterial?.[t];return Array.isArray(i)?[...i]:[]}function vy(e,t,n){const i=[...e];return i[t]=n,i}const _y={supportLevel:"none",comment:"Not currently listed in the luma.gl glTF extension support registry."},Cy={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 xy(e){const t=Array.from(function(e){const t=e,n=/* @__PURE__ */new Set;By(n,e.extensionsUsed),By(n,e.extensionsRequired),By(n,t.extensionsRemoved),By(n,Object.keys(e.extensions||{})),(t.lights?.length||(e.nodes||[]).some(e=>"light"in e))&&n.add("KHR_lights_punctual");(e.materials||[]).some(e=>{const t=e;return t.unlit||t.extensions?.KHR_materials_unlit})&&n.add("KHR_materials_unlit");return n}(e)).sort(),n=t.map(e=>{const t=Cy[e]||_y;return[e,{extensionName:e,supported:"built-in"===t.supportLevel||"parsed-and-wired"===t.supportLevel,supportLevel:t.supportLevel,comment:t.comment}]});return new Map(n)}function wy(e){return Cy[e]||null}function By(e,t=[]){for(const n of t)e.add(n)}const My={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Sy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Ty(e){const t=Sy[e.componentType],n=My[e.type],i=n*e.count,{buffer:r,byteOffset:o=0}=e.bufferView?.data??{};return{typedArray:new t(r,o+(e.byteOffset||0),i),components:n}}function Ey(e){const t=e.animations||[],n=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;return t.flatMap((t,r)=>{const o=t.name||`Animation-${r}`,s=/* @__PURE__ */new Map,a=t.channels.flatMap(({sampler:r,target:o})=>{let a=s.get(r);if(!a){const o=t.samplers[r];if(!o)throw new Error(`Cannot find animation sampler ${r}`);const{input:A,interpolation:l="LINEAR",output:c}=o;a={input:Oy(e.accessors[A],n),interpolation:l,output:Dy(e.accessors[c],i)},s.set(r,a)}const A=function(e,t,n){if("pointer"===t.path)return function(e,t,n){const i=t.extensions?.KHR_animation_pointer?.pointer;if("string"!=typeof i||!i.startsWith("/"))return ie.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;const r=function(e){return e.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}(i);switch(r[0]){case"nodes":return function(e,t,n,i){if(3!==t.length)return Fy(i,"node pointers must use /nodes/{index}/{translation|rotation|scale|weights}"),null;const r=Number(t[1]),o=e.nodes[r];if(!Number.isInteger(r)||!o)return ie.warn(`KHR_animation_pointer target ${i} references a missing node and will be skipped`)(),null;const s=Py(t[2]);if(!s)return Fy(i,`node property "${t[2]}" has no runtime animation mapping`),null;if("weights"===s)return ie.warn(`KHR_animation_pointer target ${i} will be skipped because morph weights are not implemented in GLTFAnimator`)(),null;return{type:"node",sampler:n,targetNodeId:o.id,path:s}}(e,r,n,i);case"materials":return function(e,t,n,i){if(t.length<3)return Fy(i,"material pointers must include a material index and target property path"),null;const r=Number(t[1]),o=e.materials[r];if(!Number.isInteger(r)||!o)return ie.warn(`KHR_animation_pointer target ${i} references a missing material and will be skipped`)(),null;const s=function(e,t){const n=function(e,t){const n=t.lastIndexOf("extensions");if(n<0||"KHR_texture_transform"!==t[n+1]||n<1)return{reason:"not-a-texture-transform-target"};const i=function(e){return Vb.find(t=>t.pathSegments.length===e.length&&t.pathSegments.every((t,n)=>e[n]===t))||null}(t.slice(0,n));if(!i)return{reason:Ly(t.slice(0,n))};const r=function(e,t){let n=e;for(const i of t)if(n=n?.[i],!n)return null;return n}(e,i.pathSegments);if(!r)return{reason:`texture-transform target "${t.slice(0,n).join("/")}" does not exist on the referenced material`};const o=t[n+2];if("texCoord"===o)return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if("offset"!==o&&"rotation"!==o&&"scale"!==o)return{reason:`KHR_texture_transform property "${o}" is not animatable; supported properties are offset, rotation, and scale`};const s=t[n+3];if(t.length>n+4)return{reason:`KHR_texture_transform.${o} does not support nested property paths`};let a;if(void 0!==s){if(a=Number(s),"rotation"===o)return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(a)||a<0||a>1)return{reason:`KHR_texture_transform.${o} component index "${s}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:i.slot,path:o,component:a,baseTransform:Jb(r)}}(e,t);if(!("reason"in n))return n;if("not-a-texture-transform-target"!==n.reason)return n;switch(t.join("/")){case"pbrMetallicRoughness/baseColorFactor":return e.pbrMetallicRoughness?{type:"material",property:"baseColorFactor"}:{reason:Iy(t)};case"pbrMetallicRoughness/metallicFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:Iy(t)};case"pbrMetallicRoughness/roughnessFactor":return e.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:Iy(t)};case"normalTexture/scale":return e.normalTexture?{type:"material",property:"normalScale"}:{reason:Iy(t)};case"occlusionTexture/strength":return e.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:Iy(t)};case"emissiveFactor":return{type:"material",property:"emissiveFactor"};case"alphaCutoff":return{type:"material",property:"alphaCutoff"};case"extensions/KHR_materials_specular/specularFactor":return e.extensions?.KHR_materials_specular?{type:"material",property:"specularIntensityFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_specular/specularColorFactor":return e.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_ior/ior":return e.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:Iy(t)};case"extensions/KHR_materials_transmission/transmissionFactor":return e.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_volume/thicknessFactor":return e.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_volume/attenuationDistance":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:Iy(t)};case"extensions/KHR_materials_volume/attenuationColor":return e.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:Iy(t)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return e.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_sheen/sheenColorFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return e.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:Iy(t)};case"extensions/KHR_materials_iridescence/iridescenceIor":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:Iy(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:Iy(t)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return e.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:Iy(t)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:Iy(t)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return e.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:Iy(t)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return e.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:Iy(t)};default:return{reason:Iy(t)}}}(o,t.slice(2));if("reason"in s)return Fy(i,s.reason),null;return{sampler:n,pointer:i,targetMaterialIndex:r,...s}}(e,r,n,i);default:return Fy(i,`top-level target "${r[0]}" has no runtime animation mapping`),null}}(e,t,n);const i=Py(t.path);if(!i)return null;const r=e.nodes[t.node??0];if(!r)throw new Error(`Cannot find animation target ${t.node}`);return{type:"node",sampler:n,targetNodeId:r.id,path:i}}(e,o,a);return A?[A]:[]});return a.length?[{name:o,channels:a}]:[]})}function Py(e){switch(e){case"translation":case"rotation":case"scale":case"weights":return e;default:return null}}function Iy(e){const t=Ry(e);if(t){const e=wy(t);if("none"===e?.supportLevel)return`${t} is referenced by this pointer, but ${e.comment.charAt(0).toLowerCase()}${e.comment.slice(1)}`}return`no runtime target exists for material property "${e.join("/")}"`}function Ly(e){const t=Ry(e);if(t){const e=wy(t);if("none"===e?.supportLevel)return`${t} is referenced by this pointer, but ${e.comment.charAt(0).toLowerCase()}${e.comment.slice(1)}`}return`texture-transform target "${e.join("/")}" has no runtime texture-slot mapping`}function Ry(e){const t=e.indexOf("extensions"),n=e[t+1];return t>=0&&n?n:null}function Fy(e,t){ie.warn(`KHR_animation_pointer target ${e} will be skipped because ${t}`)()}function Oy(e,t){if(t.has(e))return t.get(e);const{typedArray:n,components:i}=Ty(e);Ny(1===i,"accessorToJsArray1D must have exactly 1 component");const r=Array.from(n);return t.set(e,r),r}function Dy(e,t){if(t.has(e))return t.get(e);const{typedArray:n,components:i}=Ty(e);Ny(i>=1,"accessorToJsArray2D must have at least 1 component");const r=[];for(let o=0;o<n.length;o+=i)r.push(Array.from(n.slice(o,o+i)));return t.set(e,r),r}function Ny(e,t){if(!e)throw new Error(t)}function Uy(e,t,n){const{scenes:i,materials:r,gltfMeshIdToNodeMap:o,gltfNodeIdToNodeMap:s,gltfNodeIndexToNodeMap:a}=hy(e,t,n),A=Ey(t),l=new by({animations:A,gltfNodeIdToNodeMap:s,materials:r}),c=ny(t,{useByteColors:n?.useByteColors??!0}),u=xy(t),f=i.map(e=>ky(e.getBounds())),h=function(e){let t=null;for(const n of e)if(n.bounds)if(t)for(let e=0;e<3;e++)t[0][e]=Math.min(t[0][e],n.bounds[0][e]),t[1][e]=Math.max(t[1][e],n.bounds[1][e]);else t=[[...n.bounds[0]],[...n.bounds[1]]];return ky(t)}(f);return{scenes:i,materials:r,animator:l,lights:c,extensionSupport:u,sceneBounds:f,modelBounds:h,gltfMeshIdToNodeMap:o,gltfNodeIdToNodeMap:s,gltfNodeIndexToNodeMap:a,gltf:t}}function ky(e){if(!e)return{bounds:null,center:[0,0,0],size:[0,0,0],radius:.5,recommendedOrbitDistance:1};const t=[[e[0][0],e[0][1],e[0][2]],[e[1][0],e[1][1],e[1][2]]],n=[t[1][0]-t[0][0],t[1][1]-t[0][1],t[1][2]-t[0][2]],i=[t[0][0]+.5*n[0],t[0][1]+.5*n[1],t[0][2]+.5*n[2]],r=.5*Math.max(n[0],n[1],n[2]),o=Math.max(.5*Math.hypot(n[0],n[1],n[2]),.001);return{bounds:t,center:i,size:n,radius:o,recommendedOrbitDistance:Math.max(Math.max(r,.001)/Math.tan(Math.PI/6)*1.15,1.1*o)}}function Gy(e,t){if(!e)throw new Error(t||"assert failed: gltf")}const zy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vy={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Hy=["SCALAR","VEC2","VEC3","VEC4"],jy=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Qy=new Map(jy),Jy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ky={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Wy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function qy(e){return Hy[e-1]||Hy[0]}function Yy(e){const t=Qy.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Xy(e,t){const n=Wy[e.componentType],i=Jy[e.type],r=Ky[e.componentType],o=e.count*i,s=e.count*i*r;Gy(s>=0&&s<=t.byteLength);return{ArrayType:n,length:o,byteLength:s,componentByteSize:Vy[e.componentType],numberOfComponentsInElement:zy[e.type]}}function Zy(e){let{images:t,bufferViews:n}=e;t=t||[],n=n||[];const i=t.map(e=>e.bufferView);n=n.filter(e=>!i.includes(e));const r=n.reduce((e,t)=>e+t.byteLength,0),o=t.reduce((e,t)=>{const{width:n,height:i}=t.image;return e+n*i},0);return r+Math.ceil(4*o*1.33)}class $y{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},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){const t=this.getUsedExtensions().find(t=>t===e),n=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof n}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),n=this.json.extensions||{};return t?n[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}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,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];if(!n)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return n}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,n=this.gltf.buffers[t];Gy(n);const i=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,n){const i="number"==typeof n?e.accessors?.[n]:n;if(!i)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);const r=e.bufferViews?.[i.bufferView||0];if(!r)throw new Error(`No gltf buffer view for accessor ${r}`);const{arrayBuffer:o,byteOffset:s}=t[r.buffer],a=(s||0)+(i.byteOffset||0)+(r.byteOffset||0),{ArrayType:A,length:l,componentByteSize:c,numberOfComponentsInElement:u}=Xy(i,r),f=c*u,h=r.byteStride||f;if(void 0===r.byteStride||r.byteStride===f)return new A(o,a,l);const d=new A(l);for(let p=0;p<i.count;p++){const e=new A(o,a+p*h,u);d.set(e,p*u)}return d}(this.gltf.json,this.gltf.buffers,t)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,i=t.byteOffset||0;return new Uint8Array(n,i,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,n){return e.extensions=e.extensions||{},e.extensions[t]=n,this.registerUsedExtension(t),this}setObjectExtension(e,t,n){(e.extensions||{})[t]=n}removeObjectExtension(e,t){const n=e?.extensions||{};if(n[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const e=this.json.extensionsRemoved;e.includes(t)||e.push(t)}delete n[t]}addExtension(e,t={}){return Gy(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return Gy(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.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){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:n}=e;this.json.nodes=this.json.nodes||[];const i={mesh:t};return n&&(i.matrix=n),this.json.nodes.push(i),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:i,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(n){const e=this._addIndices(n);o.primitives[0].indices=e}return Number.isFinite(i)&&(o.primitives[0].material=i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const n=Xe(e),i=t||n?.mimeType,r={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e,t=0,n=this.byteLength){const i=e.byteLength;Gy(Number.isFinite(i)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:t,byteOffset:n,byteLength:i};return this.byteLength+=mt(i,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:qy(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const n=this.addBufferView(e);let i={min:t.min,max:t.max};i.min&&i.max||(i=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:Yy(e),count:Math.round(e.length/t.size),min:i.min,max:i.max};return this.addAccessor(n,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,n={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(n),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(){const e=this.byteLength,t=new ArrayBuffer(e),n=new Uint8Array(t);let i=0;for(const r of this.sourceBuffers||[])i=bt(r,n,i);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t],this.gltf.buffers=[{arrayBuffer:t,byteOffset:0,byteLength:t.byteLength}]}_removeStringFromArray(e,t){let n=!0;for(;n;){const i=e.indexOf(t);i>-1?e.splice(i,1):n=!1}}_addAttributes(e={}){const t={};for(const n in e){const i=e[n],r=this._getGltfAttributeName(n),o=this.addBinaryBuffer(i.value,i);t[r]=o}return t}_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,t){const n={min:null,max:null};if(e.length<t)return n;n.min=[],n.max=[];const i=e.subarray(0,t);for(const r of i)n.min.push(r),n.max.push(r);for(let r=t;r<e.length;r+=t)for(let i=0;i<t;i++)n.min[0+i]=Math.min(n.min[0+i],e[r+i]),n.max[0+i]=Math.max(n.max[0+i],e[r+i]);return n}}function ev(e){return(e%1+1)%1}const tv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},nv={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},iv={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function rv(e,t){return iv[t]*tv[e]}function ov(e,t,n,i){if("UINT8"!==n&&"UINT16"!==n&&"UINT32"!==n&&"UINT64"!==n)return null;const r=sv(e.getTypedArrayForBufferView(t),"SCALAR",n,i+1);return r instanceof BigInt64Array||r instanceof BigUint64Array?null:r}function sv(e,t,n,i=1){const r=nv[n],o=iv[n],s=i*tv[t],a=s*o;let A=e.buffer,l=e.byteOffset;if(l%o!==0){A=new Uint8Array(A).slice(l,l+a).buffer,l=0}return new r($e(A),l,s)}function av(e,t,n){const i=`TEXCOORD_${t.texCoord||0}`,r=n.attributes[i],o=e.getTypedArrayForAccessor(r),s=e.gltf.json,a=t.index,A=s.textures?.[a]?.source;if(void 0!==A){const n=s.images?.[A]?.mimeType,i=e.gltf.images?.[A];if(i&&void 0!==i.width){const e=[];for(let r=0;r<o.length;r+=2){const s=lv(i,n,o,r,t.channels);e.push(s)}return e}}return[]}function Av(e,t,n,i,r){if(!n?.length)return;const o=[];for(const c of n){let e=i.findIndex(e=>e===c);-1===e&&(e=i.push(c)-1),o.push(e)}const s=new Uint32Array(o),a=e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,A=e.addBufferView(s,a,0),l=e.addAccessor(A,{size:1,componentType:Yy(s),count:s.length});r.attributes[t]=l}function lv(e,t,n,i,r=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=n[i],a=n[i+1];let A=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(A=4);const l=function(e,t,n,i=1){const r=n.width,o=ev(e)*(r-1),s=Math.round(o),a=n.height,A=ev(t)*(a-1),l=Math.round(A),c=n.components?n.components:i,u=(l*r+s)*c;return u}(s,a,e,A);let c=0;for(const u of r){const t="number"==typeof u?Object.values(o)[u]:o[u],n=l+t.offset,i=Ze(e);if(i.data.length<=n)throw new Error(`${i.data.length} <= ${n}`);c|=i.data[n]<<t.shift}return c}function cv(e,t,n,i,r){const o=[];for(let s=0;s<t;s++){const t=n[s],a=n[s+1]-n[s];if(a+t>i)break;const A=t/r,l=a/r;o.push(e.slice(A,A+l))}return o}function uv(e,t,n){const i=[];for(let r=0;r<t;r++){const t=r*n;i.push(e.slice(t,t+n))}return i}function fv(e,t,n,i){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(i){const n=[],r=new TextDecoder("utf8");let o=0;for(let s=0;s<e;s++){const e=i[s+1]-i[s];if(e+o<=t.length){const i=t.subarray(o,e+o),s=r.decode(i);n.push(s),o+=e}}return n}return[]}const hv="EXT_mesh_features",dv=hv;function pv(e,t,n){if(!n?.gltf?.loadBuffers)return;const i=t.extensions?.[hv],r=i?.featureIds;if(r)for(const o of r){let i;if(void 0!==o.attribute){const n=`_FEATURE_ID_${o.attribute}`,r=t.attributes[n];i=e.getTypedArrayForAccessor(r)}else i=void 0!==o.texture&&n?.gltf?.loadImages?av(e,o.texture,t):[];o.data=i}}function gv(e,t){const n=t.extensions?.[hv];if(!n)return;const i=n.featureIds;i.forEach((n,r)=>{if(n.data){const{accessorKey:o,index:s}=function(e){const t="_FEATURE_ID_",n=Object.keys(e).filter(e=>0===e.indexOf(t));let i=-1;for(const o of n){const e=Number(o.substring(t.length));e>i&&(i=e)}i++;const r=`${t}${i}`;return{accessorKey:r,index:i}}(t.attributes),a=new Uint32Array(n.data);i[r]={featureCount:a.length,propertyTable:n.propertyTable,attribute:s},e.gltf.buffers.push({arrayBuffer:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength});const A=e.addBufferView(a),l=e.addAccessor(A,{size:1,componentType:Yy(a),count:a.length});t.attributes[o]=l}})}const mv=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,createExtMeshFeatures:function(e,t,n,i){t.extensions||(t.extensions={});let r=t.extensions[hv];r||(r={featureIds:[]},t.extensions[hv]=r);const{featureIds:o}=r,s={featureCount:n.length,propertyTable:i,data:n};o.push(s),e.addObjectExtension(t,hv,r)},decode:async function(e,t){!function(e,t){const n=e.gltf.json;if(!n.meshes)return;for(const i of n.meshes)for(const n of i.primitives)pv(e,n,t)}(new $y(e),t)},encode:function(e,t){const n=new $y(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const n of t)for(const t of n.primitives)gv(e,t)}(n),n.createBinaryChunk(),n.gltf},name:dv},Symbol.toStringTag,{value:"Module"})),bv="EXT_structural_metadata",yv=bv;function vv(e,t){for(const n of e)if(n.class===t)return n;return null}function _v(e,t,n,i){if(!t)return;const r=n.extensions?.[bv],o=r?.propertyTextures;if(o)for(const s of o){Cv(e,t[s],n,i)}}function Cv(e,t,n,i){if(!t.properties)return;i.dataAttributeNames||(i.dataAttributeNames=[]);const r=t.class;for(const o in t.properties){const s=`${r}_${o}`,a=t.properties?.[o];if(!a)continue;a.data||(a.data=[]);const A=a.data,l=av(e,a,n);null!==l&&(Av(e,s,l,A,n),a.data=A,i.dataAttributeNames.push(s))}}function xv(e,t,n){const i=t.classes?.[n.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const o in i.properties){const s=i.properties[o],a=n.properties?.[o];if(a){const n=wv(e,t,s,r,a);a.data=n}}}function wv(e,t,n,i,r){let o=[];const s=r.values,a=e.getTypedArrayForBufferView(s),A=function(e,t,n,i){if(t.array&&void 0===t.count&&void 0!==n.arrayOffsets)return ov(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",i);return null}(e,n,r,i),l=function(e,t,n){if(void 0!==t.stringOffsets)return ov(e,t.stringOffsets,t.stringOffsetType||"UINT32",n);return null}(e,r,i);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":o=function(e,t,n,i){const r=e.array,o=e.count,s=rv(e.type,e.componentType),a=n.byteLength/s;let A;A=e.componentType?sv(n,e.type,e.componentType,a):n;if(r)return i?cv(A,t,i,n.length,s):o?uv(A,t,o):[];return A}(n,i,a,A);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":o=fv(i,a,A,l);break;case"ENUM":o=function(e,t,n,i,r){const o=t.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const s=e.enums?.[o];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);const a=s.valueType||"UINT16",A=rv(t.type,a),l=i.byteLength/A;let c=sv(i,t.type,a,l);c||(c=i);if(t.array){if(r)return function(e){const{valuesData:t,numberOfElements:n,arrayOffsets:i,valuesDataBytesLength:r,elementSize:o,enumEntry:s}=e,a=[];for(let A=0;A<n;A++){const e=i[A],n=i[A+1]-i[A];if(n+e>r)break;const l=Bv(t,e/o,n/o,s);a.push(l)}return a}({valuesData:c,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:i.length,elementSize:A,enumEntry:s});const e=t.count;return e?function(e,t,n,i){const r=[];for(let o=0;o<t;o++){const t=Bv(e,n*o,n,i);r.push(t)}return r}(c,n,e,s):[]}return Bv(c,0,n,s)}(t,n,i,a,A);break;default:throw new Error(`Unknown classProperty type ${n.type}`)}return o}function Bv(e,t,n,i){const r=[];for(let o=0;o<n;o++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)r.push("");else{const n=Mv(i,e[t+o]);n?r.push(n.name):r.push("")}return r}function Mv(e,t){for(const n of e.values)if(n.value===t)return n;return null}function Sv(e,t,n){for(const i in e.properties){const r=e.properties[i].data;if(r){const o=t.properties[i];if(o){const t=Tv(r,o,n);e.properties[i]=t}}}}function Tv(e,t,n){const i={values:0};if("STRING"===t.type){const{stringData:t,stringOffsets:r}=function(e){const t=new TextEncoder,n=[];let i=0;for(const A of e){const e=t.encode(A);i+=e.length,n.push(e)}const r=new Uint8Array(i),o=[];let s=0;for(const A of n)r.set(A,s),o.push(s),s+=A.length;o.push(s);const a=new Uint32Array(o);return{stringData:r,stringOffsets:a}}(e);i.stringOffsets=Pv(r,n),i.values=Pv(t,n)}else if("SCALAR"===t.type&&t.componentType){const r=function(e,t){const n=[];for(const r of e)n.push(Number(r));const i=Ev[t];if(!i)throw new Error("Illegal component type");return new i(n)}(e,t.componentType);i.values=Pv(r,n)}return i}const Ev={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function Pv(e,t){return t.gltf.buffers.push({arrayBuffer:$e(e.buffer),byteOffset:e.byteOffset,byteLength:e.byteLength}),t.addBufferView(e)}const Iv=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,createExtStructuralMetadata:function(e,t,n="schemaClassId"){let i=e.getExtension(bv);i||(i=e.addExtension(bv)),i.schema=function(e,t,n){const i=n??{id:"schema_id"},r={properties:{}};for(const o of e){const e={type:o.elementType,componentType:o.componentType};r.properties[o.name]=e}return i.classes={},i.classes[t]=r,i}(t,n,i.schema);const r=function(e,t,n){const i={class:t,count:0};let r=0;const o=n.classes?.[t];for(const s of e){if(0===r&&(r=s.values.length),r!==s.values.length&&s.values.length)throw new Error("Illegal values in attributes");const e=o?.properties[s.name];e&&(i.properties||(i.properties={}),i.properties[s.name]={values:0,data:s.values})}return i.count=r,i}(t,n,i.schema);return i.propertyTables||(i.propertyTables=[]),i.propertyTables.push(r)-1},decode:async function(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(bv);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.propertyTextures,i=e.gltf.json;if(n&&i.meshes)for(const r of i.meshes)for(const i of r.primitives)_v(e,n,i,t)}(e,n);!function(e,t){const n=t.schema;if(!n)return;const i=n.classes,r=t.propertyTables;if(i&&r)for(const o in i){const t=vv(r,o);t&&xv(e,n,t)}}(e,n)}(new $y(e),t)},encode:function(e,t){const n=new $y(e);return function(e){const t=e.getExtension(bv);if(!t)return;if(t.propertyTables)for(const n of t.propertyTables){const i=n.class,r=t.schema?.classes?.[i];n.properties&&r&&Sv(n,r,e)}}(n),n.createBinaryChunk(),n.gltf},name:yv},Symbol.toStringTag,{value:"Module"})),Lv="EXT_feature_metadata",Rv=Lv;function Fv(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}function Ov(e,t){for(const n in e){const i=e[n];if(i.class===t)return i}return null}function Dv(e,t,n){if(!n.class)return;const i=t.classes?.[n.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const o in i.properties){const s=i.properties[o],a=n.properties?.[o];if(a){const n=Uv(e,t,s,r,a);a.data=n}}}function Nv(e,t,n){const i=t.class;for(const r in n.properties){const n=t?.properties?.[r];if(n){const t=kv(e,n,i);n.data=t}}}function Uv(e,t,n,i,r){let o=[];const s=r.bufferView,a=e.getTypedArrayForBufferView(s),A=function(e,t,n,i){if("ARRAY"===t.type&&void 0===t.componentCount&&void 0!==n.arrayOffsetBufferView)return ov(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",i);return null}(e,n,r,i),l=function(e,t,n,i){if(void 0!==n.stringOffsetBufferView)return ov(e,n.stringOffsetBufferView,n.offsetType||"UINT32",i);return null}(e,0,r,i);return"STRING"===n.type||"STRING"===n.componentType?o=fv(i,a,A,l):function(e){const t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||void 0!==e.componentType&&t.includes(e.componentType)}(n)&&(o=function(e,t,n,i){const r="ARRAY"===e.type,o=e.componentCount,s="SCALAR",a=e.componentType||e.type,A=rv(s,a),l=n.byteLength/A,c=sv(n,s,a,l);if(r)return i?cv(c,t,i,n.length,A):o?uv(c,t,o):[];return c}(n,i,a,A)),o}function kv(e,t,n){const i=e.gltf.json;if(!i.meshes)return[];const r=[];for(const o of i.meshes)for(const i of o.primitives)Gv(e,n,t,r,i);return r}function Gv(e,t,n,i,r){const o=av(e,{channels:n.channels,...n.texture},r);o&&Av(e,t,o,i,r)}const zv=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e,t){!function(e,t){if(!t.gltf?.loadBuffers)return;const n=e.getExtension(Lv);if(!n)return;t.gltf?.loadImages&&function(e,t){const n=t.schema;if(!n)return;const i=n.classes,{featureTextures:r}=t;if(i&&r)for(const o in i){const t=i[o],n=Ov(r,o);n&&Nv(e,n,t)}}(e,n);!function(e,t){const n=t.schema;if(!n)return;const i=n.classes,r=t.featureTables;if(i&&r)for(const o in i){const t=Fv(r,o);t&&Dv(e,n,t)}}(e,n)}(new $y(e),t)},name:Rv},Symbol.toStringTag,{value:"Module"})),Vv=!0,Hv=1735152710,jv=1313821514,Qv=5130562;function Jv(e,t,n=0,i={}){const r=new DataView(t),o=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(r,n+0),s=r.getUint32(n+4,Vv),a=r.getUint32(n+8,Vv);switch(Object.assign(e,{header:{byteOffset:n,byteLength:a,hasBinChunk:!1},type:o,version:s,json:{},binChunks:[]}),n+=12,e.version){case 1:return function(e,t,n){g(e.header.byteLength>20);const i=t.getUint32(n+0,Vv),r=t.getUint32(n+4,Vv);return n+=8,g(0===r),Kv(e,t,n,i),n+=i,n+=Wv(e,t,n,e.header.byteLength),n}(e,r,n);case 2:return function(e,t,n,i){return g(e.header.byteLength>20),function(e,t,n,i){for(;n+8<=e.header.byteLength;){const r=t.getUint32(n+0,Vv),o=t.getUint32(n+4,Vv);switch(n+=8,o){case jv:Kv(e,t,n,r);break;case Qv:Wv(e,t,n,r);break;case 0:i.strict||Kv(e,t,n,r);break;case 1:i.strict||Wv(e,t,n,r)}n+=mt(r,4)}}(e,t,n,i),n+e.header.byteLength}(e,r,n,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function Kv(e,t,n,i){const r=new Uint8Array(t.buffer,n,i),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),mt(i,4)}function Wv(e,t,n,i){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:i,arrayBuffer:t.buffer}),mt(i,4)}function qv(e,t,n){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=n?.baseUrl||function(e){if(!e)return;if(e.endsWith("/"))return e;const t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):""}(t?.core?.baseUrl);if(!i)throw new Error(`'baseUrl' must be provided to resolve relative url ${e}`);return i.endsWith("/")?`${i}${e}`:`${i}/${e}`}const Yv="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",Xv="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",Zv=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]),$v=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]),e_={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},t_={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function n_(e,t,n,i,r,o="NONE"){const s=await async function(){i_||(i_=async function(){let e=Yv;WebAssembly.validate(Zv)&&(e=Xv);const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;++i){const n=e.charCodeAt(i);t[i]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let n=0;for(let i=0;i<e.length;++i)t[n++]=t[i]<60?$v[t[i]]:64*(t[i]-60)+t[++i];return t.buffer.slice(0,n)}(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}());return i_}();!function(e,t,n,i,r,o,s){const a=e.exports.sbrk,A=i+3&-4,l=a(A*r),c=a(o.length),u=new Uint8Array(e.exports.memory.buffer);u.set(o,c);const f=t(l,i,r,c,o.length);0===f&&s&&s(l,A,r);if(n.set(u.subarray(l,l+i*r)),a(l-a(0)),0!==f)throw new Error(`Malformed buffer data: ${f}`)}(s,s.exports[t_[r]],e,t,n,i,s.exports[e_[o||"NONE"]])}let i_;const r_="EXT_meshopt_compression",o_=r_;async function s_(e,t){const n=e.getObjectExtension(t,r_);if(n){const{byteOffset:i=0,byteLength:r=0,byteStride:o,count:s,mode:a,filter:A="NONE",buffer:l}=n,c=e.gltf.buffers[l],u=new Uint8Array(c.arrayBuffer,c.byteOffset+i,r),f=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);await n_(f,s,o,u,a,A),e.removeObjectExtension(t,r_)}}const a_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e,t){const n=new $y(e);if(!t?.gltf?.decompressMeshes||!t.gltf?.loadBuffers)return;const i=[];for(const r of e.json.bufferViews||[])i.push(s_(n,r));await Promise.all(i),n.removeExtension(r_)},name:o_},Symbol.toStringTag,{value:"Module"})),A_="EXT_texture_webp",l_=A_;const c_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,name:l_,preprocess:function(e,t){const n=new $y(e);if(!Mt("image/webp")){if(n.getRequiredExtensions().includes(A_))throw new Error(`gltf: Required extension ${A_} not supported by browser`);return}const{json:i}=n;for(const r of i.textures||[]){const e=n.getObjectExtension(r,A_);e&&(r.source=e.source),n.removeObjectExtension(r,A_)}n.removeExtension(A_)}},Symbol.toStringTag,{value:"Module"})),u_="KHR_texture_basisu",f_=u_;const h_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,name:f_,preprocess:function(e,t){const n=new $y(e),{json:i}=n;for(const r of i.textures||[]){const e=n.getObjectExtension(r,u_);e&&(r.source=e.source,n.removeObjectExtension(r,u_))}n.removeExtension(u_)}},Symbol.toStringTag,{value:"Module"})),d_="https://www.gstatic.com/draco/versioned/decoders/1.5.6",p_="draco_wasm_wrapper.js",g_="draco_decoder.wasm",m_="draco_decoder.js",b_="draco_encoder.js",y_={[p_]:`${d_}/${p_}`,[g_]:`${d_}/${g_}`,[m_]:`${d_}/${m_}`,[b_]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${b_}`};let v_;async function __(e={},t){const n=e.modules||{};return n.draco3d?v_||=n.draco3d.createDecoderModule({}).then(e=>({draco:e})):v_||=async function(e,t){let n,i;if("js"===t)n=await dt(y_[m_],"draco",e,m_);else try{[n,i]=await Promise.all([await dt(y_[p_],"draco",e,p_),await dt(y_[g_],"draco",e,g_)])}catch{n=null,i=null}n=C_(n,"DracoDecoderModule"),n=n||globalThis.DracoDecoderModule,n||f||([n,i]=await Promise.all([await dt(y_[p_],"draco",{...e,useLocalLibraries:!0},p_),await dt(y_[g_],"draco",{...e,useLocalLibraries:!0},g_)]),n=C_(n,"DracoDecoderModule"),n=n||globalThis.DracoDecoderModule);return await function(e,t){if("function"!=typeof e)throw new Error("DracoDecoderModule could not be loaded");const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e({...n,onModuleLoaded:e=>t({draco:e})})})}(n,i)}(e,t),await v_}function C_(e,t){if(e&&"object"==typeof e){if(e.default)return e.default;if(e[t])return e[t]}return e}function x_(e,t,n){return wt(e,t,n?w_(n.metadata):void 0)}function w_(e){Object.entries(e);const t={};for(const n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}const B_={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},M_={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class S_{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,t={}){const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const i=this.decoder.GetEncodedGeometryType(n),r=i===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(i){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const o=this._getDracoLoaderData(r,i,t),s=this._getMeshData(r,o,t),a=function(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],A=a&&a.length;for(let l=0;l<A;l+=3){const e=a[l],A=a[l+1],c=a[l+2];t=e<t?e:t,n=A<n?A:n,i=c<i?c:i,r=e>r?e:r,o=A>o?A:o,s=c>s?c:s}return[[t,n,i],[r,o,s]]}(s.attributes),A=function(e,t,n){const i=w_(t.metadata),r=[],o=function(e){const t={};for(const n in e){const i=e[n];t[i.name||"undefined"]=i}return t}(t.attributes);for(const s in e){const t=x_(s,e[s],o[s]);r.push(t)}if(n){const e=x_("indices",n);r.push(e)}return{fields:r,metadata:i}}(s.attributes,o,s.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...s,schema:A}}finally{this.draco.destroy(n),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,n){const i=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,n);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:i,attributes:r}}_getDracoAttributes(e,t){const n={};for(let i=0;i<e.num_attributes();i++){const r=this.decoder.GetAttribute(e,i),o=this._getAttributeMetadata(e,i);n[r.unique_id()]={unique_id:r.unique_id(),attribute_type:r.attribute_type(),data_type:r.data_type(),num_components:r.num_components(),byte_offset:r.byte_offset(),byte_stride:r.byte_stride(),normalized:r.normalized(),attribute_index:i,metadata:o};const s=this._getQuantizationTransform(r,t);s&&(n[r.unique_id()].quantization_transform=s);const a=this._getOctahedronTransform(r,t);a&&(n[r.unique_id()].octahedron_transform=a)}return n}_getMeshData(e,t,n){const i=this._getMeshAttributes(t,e,n);if(!i.POSITION)throw new Error("DRACO: No position attribute found.");return e instanceof this.draco.Mesh?"triangle-strip"===n.topology?{topology:"triangle-strip",mode:4,attributes:i,indices:{value:this._getTriangleStripIndices(e),size:1}}:{topology:"triangle-list",mode:5,attributes:i,indices:{value:this._getTriangleListIndices(e),size:1}}:{topology:"point-list",mode:0,attributes:i}}_getMeshAttributes(e,t,n){const i={};for(const r of Object.values(e.attributes)){const e=this._deduceAttributeName(r,n);r.name=e;const o=this._getAttributeValues(t,r);if(o){const{value:t,size:n}=o;i[e]={value:t,size:n,byteOffset:r.byte_offset,byteStride:r.byte_stride,normalized:r.normalized}}}return i}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,i=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,i),new Uint32Array(this.draco.HEAPF32.buffer,i,t).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=M_[t.data_type];if(!n)return null;const i=t.num_components,r=e.num_points()*i,o=r*n.BYTES_PER_ELEMENT,s=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,n);let a;const A=this.draco._malloc(o);try{const i=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,i,s,o,A),a=new n(this.draco.HEAPF32.buffer,A,r).slice()}finally{this.draco._free(A)}return{value:a,size:i}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[o,s]of Object.entries(t.extraAttributes||{}))if(s===n)return o;const i=e.attribute_type;for(const o in B_){if(this.draco[o]===i)return B_[o]}const r=t.attributeNameEntry||"name";return e.metadata[r]?e.metadata[r].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const n=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},n=this.metadataQuerier.NumEntries(e);for(let i=0;i<n;i++){const n=this.metadataQuerier.GetEntryName(e,i);t[n]=this._getDracoMetadataField(e,n)}return t}_getDracoMetadataField(e,t){const n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,n);const i=function(e){const t=e.size(),n=new Int32Array(t);for(let i=0;i<t;i++)n[i]=e.GetValue(i);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:i}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,i=[...t,...n];for(const r of i)this.decoder.SkipAttributeTransform(this.draco[r])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,i=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:n=[]}=t,i=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(i)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const T_={...{dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:"4.4.2",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",extraAttributes:{},attributeNameEntry:void 0}}},parse:async function(e,t){const{draco:n}=await __(ht(t),t?.draco?.decoderType||"wasm"),i=new S_(n);try{return i.parseSync(e,t?.draco)}finally{i.destroy()}}};function E_(e){const{buffer:t,size:n,count:i}=function(e){let t=e,n=1,i=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,n=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(n&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),i=t.length/n);return{buffer:t,size:n,count:i}}(e);return{value:t,size:n,byteOffset:0,count:i,type:qy(n),componentType:Yy(t)}}const P_="KHR_draco_mesh_compression",I_=P_;async function L_(e,t,n,i){const r=e.getObjectExtension(t,P_);if(!r)return;const o=e.getTypedArrayForBufferView(r.bufferView),s=et(o.buffer,o.byteOffset),a={...n};delete a["3d-tiles"];const A=await ct(s,T_,a,i),l=function(e){const t={};for(const n in e){const i=e[n];if("indices"!==n){const e=E_(i);t[n]=e}}return t}(A.attributes);for(const[c,u]of Object.entries(l))if(c in t.attributes){const n=t.attributes[c],i=e.getAccessor(n);i?.min&&i?.max&&(u.min=i.min,u.max=i.max)}t.attributes=l,A.indices&&(t.indices=E_(A.indices)),e.removeObjectExtension(t,P_),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function R_(e,t,n=4,i,r){if(!i.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=i.DracoWriter.encodeSync({attributes:e}),s=r?.parseSync?.({attributes:e}),a=i._addFauxAttributes(s.attributes),A=i.addBufferView(o);return{primitives:[{attributes:a,mode:n,extensions:{[P_]:{bufferView:A,attributes:a}}}]}}function*F_(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}const O_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e,t,n){if(!t?.gltf?.decompressMeshes)return;const i=new $y(e),r=[];for(const o of F_(i))i.getObjectExtension(o,P_)&&r.push(L_(i,o,t,n));await Promise.all(r),i.removeExtension(P_)},encode:function(e,t={}){const n=new $y(e);for(const i of n.json.meshes||[])R_(i),n.addRequiredExtension(P_)},name:I_,preprocess:function(e,t,n){const i=new $y(e);for(const r of F_(i))i.getObjectExtension(r,P_)}},Symbol.toStringTag,{value:"Module"})),D_="KHR_texture_transform",N_=D_,U_=new ye,k_=new Dt,G_=new Dt;function z_(e,t){const n=t.json.materials?.[e],i=[n?.pbrMetallicRoughness?.baseColorTexture,n?.emissiveTexture,n?.normalTexture,n?.occlusionTexture,n?.pbrMetallicRoughness?.metallicRoughnessTexture],r=[];for(const o of i)o&&o?.extensions?.[D_]&&V_(t,e,o,r)}function V_(e,t,n,i){const r=function(e,t){const n=e.extensions?.[D_],{texCoord:i=0}=e,{texCoord:r=i}=n,o=-1!==t.findIndex(([e,t])=>e===i&&t===r);if(!o){const o=function(e){const{offset:t=[0,0],rotation:n=0,scale:i=[1,1]}=e,r=(new Dt).set(1,0,0,0,1,0,t[0],t[1],1),o=k_.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),s=G_.set(i[0],0,0,0,i[1],0,0,0,1);return r.multiplyRight(o).multiplyRight(s)}(n);return i!==r&&(e.texCoord=r),t.push([i,r]),{originalTexCoord:i,texCoord:r,matrix:o}}return null}(n,i);if(!r)return;const o=e.json.meshes||[];for(const s of o)for(const n of s.primitives){const i=n.material;Number.isFinite(i)&&t===i&&H_(e,n,r)}}function H_(e,t,n){const{originalTexCoord:i,texCoord:r,matrix:o}=n,s=t.attributes[`TEXCOORD_${i}`];if(Number.isFinite(s)){const n=e.json.accessors?.[s];if(n&&void 0!==n.bufferView){const s=e.json.bufferViews?.[n.bufferView];if(s){const{arrayBuffer:a,byteOffset:A}=e.buffers[s.buffer],l=(A||0)+(n.byteOffset||0)+(s.byteOffset||0),{ArrayType:c,length:u}=Xy(n,s),f=Vy[n.componentType],h=zy[n.type],d=s.byteStride||f*h,p=new Float32Array(u);for(let e=0;e<n.count;e++){const t=new c(a,l+e*d,2);U_.set(t[0],t[1],1),U_.transformByMatrix3(o),p.set([U_[0],U_[1]],e*h)}i===r?function(e,t,n,i){e.componentType=5126,e.byteOffset=0;const r=t.json.accessors||[],o=r.reduce((e,t)=>t.bufferView===i?e+1:e,0)>1;t.buffers.push({arrayBuffer:$e(n.buffer),byteOffset:0,byteLength:n.buffer.byteLength});const s=t.buffers.length-1;if(t.json.bufferViews=t.json.bufferViews||[],o)return t.json.bufferViews.push({buffer:s,byteLength:n.buffer.byteLength,byteOffset:0}),void(e.bufferView=t.json.bufferViews.length-1);const a=t.json.bufferViews[i];if(!a)return;a.buffer=s,a.byteOffset=0,a.byteLength=n.buffer.byteLength,void 0!==a.byteStride&&delete a.byteStride}(n,e,p,n.bufferView):function(e,t,n,i,r){i.buffers.push({arrayBuffer:$e(r.buffer),byteOffset:0,byteLength:r.buffer.byteLength}),i.json.bufferViews=i.json.bufferViews||[];const o=i.json.bufferViews;o.push({buffer:i.buffers.length-1,byteLength:r.buffer.byteLength,byteOffset:0});const s=i.json.accessors;if(!s)return;s.push({bufferView:o?.length-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),n.attributes[`TEXCOORD_${e}`]=s.length-1}(r,n,t,e,p)}}}}const j_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e,t){if(!new $y(e).hasExtension(D_)||!t.gltf?.loadBuffers)return;const n=e.json.materials||[];for(let i=0;i<n.length;i++)z_(i,e)},name:N_},Symbol.toStringTag,{value:"Module"})),Q_="KHR_lights_punctual",J_=Q_;const K_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e){const t=new $y(e),{json:n}=t,i=t.getExtension(Q_);i&&(t.json.lights=i.lights,t.removeExtension(Q_));for(const r of n.nodes||[]){const e=t.getObjectExtension(r,Q_);e&&(r.light=e.light),t.removeObjectExtension(r,Q_)}},encode:async function(e){const t=new $y(e),{json:n}=t;if(n.lights){const e=t.addExtension(Q_);Gy(!e.lights),e.lights=n.lights,delete n.lights}if(t.json.lights){for(const e of t.json.lights){const n=e.node;t.addObjectExtension(n,Q_,e)}delete t.json.lights}},name:J_},Symbol.toStringTag,{value:"Module"})),W_="KHR_materials_unlit",q_=W_;const Y_=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e){const t=new $y(e),{json:n}=t;for(const i of n.materials||[]){i.extensions&&i.extensions.KHR_materials_unlit&&(i.unlit=!0),t.removeObjectExtension(i,W_)}t.removeExtension(W_)},encode:function(e){const t=new $y(e),{json:n}=t;if(t.materials)for(const i of n.materials||[])i.unlit&&(delete i.unlit,t.addObjectExtension(i,W_,{}),t.addExtension(W_))},name:q_},Symbol.toStringTag,{value:"Module"})),X_="KHR_techniques_webgl",Z_=X_;function $_(e,t){const n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in n)&&(n[t]=e.uniforms[t].value)}),Object.keys(n).forEach(e=>{"object"==typeof n[e]&&void 0!==n[e].index&&(n[e].texture=t.getTexture(n[e].index))}),n}const eC=[Iv,mv,a_,c_,h_,O_,K_,Y_,/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,decode:async function(e){const t=new $y(e),{json:n}=t,i=t.getExtension(X_);if(i){const e=function(e,t){const{programs:n=[],shaders:i=[],techniques:r=[]}=e,o=new TextDecoder;return i.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))}),n.forEach(e=>{e.fragmentShader=i[e.fragmentShader],e.vertexShader=i[e.vertexShader]}),r.forEach(e=>{e.program=n[e.program]}),r}(i,t);for(const i of n.materials||[]){const n=t.getObjectExtension(i,X_);n&&(i.technique=Object.assign({},n,e[n.technique]),i.technique.values=$_(i.technique,t)),t.removeObjectExtension(i,X_)}t.removeExtension(X_)}},encode:async function(e,t){},name:Z_},Symbol.toStringTag,{value:"Module"})),j_,zv];function tC(e,t){const n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}const nC="KHR_binary_glTF";const iC={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},rC={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class oC{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return}if(!t.normalize)throw new Error("glTF v1 is not supported.");this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new $y(e),{json:n}=t;for(const i of n.images||[]){const e=t.getObjectExtension(i,nC);e&&Object.assign(i,e),t.removeObjectExtension(i,nC)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(nC)}(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_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(const t in iC)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const i in n){const r=n[i];r.id=r.id||i;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][i]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in iC)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:n,material:i}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),i&&(t.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e],i=this._convertIdToIndex(t,e);n[e]=i}}_convertIdToIndex(e,t){const n=rC[t];if(n in this.idToIndexMap){const i=this.idToIndexMap[n][e];if(!Number.isFinite(i))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return i}return e}_updateObjects(e){for(const t of this.json.buffers)delete t.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const n=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,i=e.textures.findIndex(e=>e.id===n);-1!==i&&(t.pbrMetallicRoughness.baseColorTexture={index:i})}}}async function sC(e,t,n=0,i,r){return function(e,t,n,i){i.core?.baseUrl&&(e.baseUri=i.core?.baseUrl);if(t instanceof ArrayBuffer&&!function(e,t=0,n={}){const i=new DataView(e),{magic:r=Hv}=n,o=i.getUint32(t,!1);return o===r||o===Hv}(t,n,i.glb)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=gt(t);else if(t instanceof ArrayBuffer){const r={};n=Jv(r,t,n,i.glb),Gy("glTF"===r.type,`Invalid GLB magic string ${r.type}`),e._glb=r,e.json=r.json}else Gy(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,n,i),function(e,t={}){(new oC).normalize(e,t)}(e,{normalize:i?.gltf?.normalize}),function(e,t={},n){const i=eC.filter(e=>tC(e.name,t));for(const r of i)r.preprocess?.(e,t,n)}(e,i,r),i?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,n){const i=e.json.buffers||[];for(let r=0;r<i.length;++r){const o=i[r];if(o.uri){const{fetch:i}=n;Gy(i);const s=qv(o.uri,t,n),a=await(n?.fetch?.(s)),A=await(a?.arrayBuffer?.());e.buffers[r]={arrayBuffer:A,byteOffset:0,byteLength:A.byteLength},delete o.uri}else null===e.buffers[r]&&(e.buffers[r]={arrayBuffer:new ArrayBuffer(o.byteLength),byteOffset:0,byteLength:o.byteLength})}}(e,i,r),i?.gltf?.loadImages&&await async function(e,t,n){const i=function(e){const t=/* @__PURE__ */new Set,n=e.json.textures||[];for(const i of n)void 0!==i.source&&t.add(i.source);return Array.from(t).sort()}(e),r=e.json.images||[],o=[];for(const s of i)o.push(aC(e,r[s],s,t,n));return await Promise.all(o)}(e,i,r),await async function(e,t={},n){const i=eC.filter(e=>tC(e.name,t));for(const r of i)await(r.decode?.(e,t,n))}(e,i,r),e}async function aC(e,t,n,i,r){let o;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=qv(t.uri,i,r),{fetch:n}=r,s=await n(e);o=await s.arrayBuffer(),t.bufferView={data:o}}if(Number.isFinite(t.bufferView)){const n=function(e,t,n){const i=e.bufferViews[n];Gy(i);const r=t[i.buffer];Gy(r);const o=(i.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,i.byteLength)}(e.json,e.buffers,t.bufferView);o=et(n.buffer,n.byteOffset,n.byteLength)}Gy(o,"glTF image has no data");const s=i,a={...s,core:{...s?.core,mimeType:t.mimeType}};let A=await ct(o,[He,Ob],a,r);A&&A[0]&&(A={compressed:!0,mipmaps:!1,width:A[0].width,height:A[0].height,data:A[0]}),e.images=e.images||[],e.images[n]=A}const AC={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.4.2",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},n){const i={...AC.options,...t};i.gltf={...AC.options.gltf,...i.gltf};const r=t?.glb?.byteOffset||0;return await sC({},e,r,i,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0}}};const lC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},cC={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},uC=10240,fC=10241,hC=10242,dC=10243,pC=10497,gC=9729,mC=9986,bC={magFilter:uC,minFilter:fC,wrapS:hC,wrapT:dC},yC={[uC]:gC,[fC]:mC,[hC]:pC,[dC]:pC};class vC{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:n,buffers:i=[],images:r=[]}=e,{baseUri:o=""}=e;return Gy(n),this.baseUri=o,this.buffers=i,this.images=r,this.jsonUnprocessed=n,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const n={...e};return this.json=n,e.bufferViews&&(n.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(n.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(n.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(n.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(n.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(n.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(n.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(n.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),n.nodes=n.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(n.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(n.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}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,t){if("object"==typeof t)return t;const n=e&&e[t];return n}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const n={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(n.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(n.camera=this.getCamera(e.camera)),void 0!==e.skin&&(n.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(n.mesh=e.meshes.reduce((e,t)=>{const n=this.getMesh(t);return e.id=n.id,e.primitives=e.primitives.concat(n.primitives),e},{primitives:[]})),n}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const n="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:n}}_resolveMesh(e,t){const n={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(n.primitives=e.primitives.map(e=>{const t={...e,attributes:{},indices:void 0,material:void 0},n=e.attributes;for(const i in n)t.attributes[i]=this.getAccessor(n[i]);return void 0!==e.indices&&(t.indices=this.getAccessor(e.indices)),void 0!==e.material&&(t.material=this.getMaterial(e.material)),t})),n}_resolveMaterial(e,t){const n={...e,id:e.id||`material-${t}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};const e=n.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return n}_resolveAccessor(e,t){const n=(i=e.componentType,cC[i]);var i;const r=(o=e.type,lC[o]);var o;const s=n*r,a={...e,id:e.id||`accessor-${t}`,bytesPerComponent:n,components:r,bytesPerElement:s,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(a.bufferView=this.getBufferView(e.bufferView)),a.bufferView){const e=a.bufferView.buffer,{ArrayType:t,byteLength:n}=Xy(a,a.bufferView),i=(a.bufferView.byteOffset||0)+(a.byteOffset||0)+e.byteOffset;let r=tt(e.arrayBuffer,i,n);a.bufferView.byteStride&&(r=this._getValueFromInterleavedBuffer(e,i,a.bufferView.byteStride,a.bytesPerElement,a.count)),a.value=new t(r)}return a}_getValueFromInterleavedBuffer(e,t,n,i,r){const o=new Uint8Array(r*i);for(let s=0;s<r;s++){const r=t+s*n;o.set(new Uint8Array(e.arrayBuffer.slice(r,r+i)),s*i)}return o.buffer}_resolveTexture(e,t){return{...e,id:e.id||`texture-${t}`,sampler:"number"==typeof e.sampler?this.getSampler(e.sampler):{id:"default-sampler",parameters:yC},source:"number"==typeof e.source?this.getImage(e.source):void 0}}_resolveSampler(e,t){const n={id:e.id||`sampler-${t}`,...e,parameters:{}};for(const i in n){const e=this._enumSamplerParameter(i);void 0!==e&&(n.parameters[e]=n[i])}return n}_enumSamplerParameter(e){return bC[e]}_resolveImage(e,t){const n={...e,id:e.id||`image-${t}`,image:null,bufferView:void 0!==e.bufferView?this.getBufferView(e.bufferView):void 0},i=this.images[t];return i&&(n.image=i),n}_resolveBufferView(e,t){const n=e.buffer,i=this.buffers[n].arrayBuffer;let r=this.buffers[n].byteOffset||0;e.byteOffset&&(r+=e.byteOffset);return{id:`bufferView-${t}`,...e,buffer:this.buffers[n],data:new Uint8Array(i,r,e.byteLength)}}_resolveCamera(e,t){const n={...e,id:e.id||`camera-${t}`};return n.perspective,n.orthographic,n}}function _C(e,t){return(new vC).postProcess(e,t)}async function CC(e){const t=[];return e.scenes.forEach(e=>{e.traverse(e=>{})}),await async function(e){for(;e();)await new Promise(e=>requestAnimationFrame(e))}(()=>t.some(e=>!e.loaded))}const xC="layout(std140) uniform scenegraphUniforms {\n float sizeScale;\n float sizeMinPixels;\n float sizeMaxPixels;\n mat4 sceneModelMatrix;\n bool composeModelMatrix;\n} scenegraph;\n",wC={name:"scenegraph",vs:xC,fs:xC,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}},BC=[255,255,255,255],MC={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?"object"==typeof e.scene?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.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:e=>e.position},getColor:{type:"accessor",value:BC},_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:[AC]};class SC extends co{getShaders(){const e={};let t;"pbr"===this.props._lighting?(t=jn,e.LIGHTING_PBR=1):t={name:"pbrMaterial"};const n=[Jn,Kn,wC,t];return super.getShaders({defines:e,vs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-vertex-shader\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nin vec3 positions;\n#ifdef HAS_UV\nin vec2 texCoords;\n#endif\n#ifdef LIGHTING_PBR\n#ifdef HAS_NORMALS\nin vec3 normals;\n#endif\n#endif\nout vec4 vColor;\n#ifndef LIGHTING_PBR\n#ifdef HAS_UV\nout vec2 vTEXCOORD_0;\n#endif\n#endif\nvoid main(void) {\n#if defined(HAS_UV) && !defined(LIGHTING_PBR)\nvTEXCOORD_0 = texCoords;\ngeometry.uv = texCoords;\n#endif\ngeometry.worldPosition = instancePositions;\ngeometry.pickingColor = instancePickingColors;\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 normal = vec3(0.0, 0.0, 1.0);\n#ifdef LIGHTING_PBR\n#ifdef HAS_NORMALS\nnormal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(normals, 0.0)).xyz;\n#endif\n#endif\nfloat originalSize = project_size_to_pixel(scenegraph.sizeScale);\nfloat clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels);\nvec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * (clampedSize / originalSize) + instanceTranslation;\nif(scenegraph.composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\ngeometry.normal = project_normal(normal);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);\ngeometry.normal = project_normal(normal);\n}\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef LIGHTING_PBR\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV0 = texCoords;\n#else\npbr_vUV0 = vec2(0., 0.);\n#endif\npbr_vUV1 = vec2(0., 0.);\ngeometry.uv = pbr_vUV0;\n#endif\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-fragment-shader\nin vec4 vColor;\nout vec4 fragColor;\n#ifndef LIGHTING_PBR\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nin vec2 vTEXCOORD_0;\nuniform sampler2D pbr_baseColorSampler;\n#endif\n#endif\nvoid main(void) {\n#ifdef LIGHTING_PBR\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV0;\n#else\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nfragColor = vColor * texture(pbr_baseColorSampler, vTEXCOORD_0);\ngeometry.uv = vTEXCOORD_0;\n#else\nfragColor = vColor;\n#endif\n#endif\nfragColor.a *= layer.opacity;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:n})}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:BC,transition:!0},instanceModelMatrix:ob})}updateState(e){super.updateState(e);const{props:t,oldProps:n}=e;t.scenegraph!==n.scenegraph?this._updateScenegraph():t._animations!==n._animations&&this._applyAnimationsProp(this.state.animator,t._animations)}finalizeState(e){super.finalizeState(e),this._destroyScenegraphAssets()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){const e=this.props,{device:t}=this.context;let n=null;if(e.scenegraph instanceof Ki)n={scenes:[e.scenegraph]};else if(e.scenegraph&&"object"==typeof e.scenegraph){const i=e.scenegraph,r=Uy(t,i.json?_C(i):i,this._getModelOptions());n=r,CC(r).then(()=>this.setNeedsRedraw()).catch(e=>{this.raiseError(e,"loading glTF")})}const i={layer:this,device:this.context.device},r=e.getScene(n,i),o=e.getAnimator(n,i);if(r instanceof Wi){this._destroyScenegraphAssets(),this._applyAnimationsProp(o,e._animations);const t=[];r.traverse(e=>{e instanceof qi&&t.push(e.model)}),this.setState({scenegraph:r,animator:o,materials:n?.materials||null,models:t,firstDrawSignaled:!1}),this.getAttributeManager().invalidateAll()}else null!==r&&Ce.warn("invalid scenegraph:",r)()}_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,t){if(!e||!t)return;const n=e.getAnimations();Object.keys(t).sort().forEach(e=>{const i=t[e];if("*"===e)n.forEach(e=>{Object.assign(e,i)});else if(Number.isFinite(Number(e))){const t=Number(e);t>=0&&t<n.length?Object.assign(n[t],i):Ce.warn(`animation ${e} not found`)()}else{const t=n.find(({animation:t})=>t.name===e);t?Object.assign(t,i):Ce.warn(`animation ${e} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t;return e&&(t="function"==typeof e?e({gl:this.context.gl,layer:this}):e),{imageBasedLightingEnvironment:t,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());const{viewport:t,renderPass:n}=this.context,{sizeScale:i,sizeMinPixels:r,sizeMaxPixels:o,coordinateSystem:s}=this.props,a={camera:t.cameraPosition},A=this.getNumInstances();this.state.scenegraph.traverse((e,{worldMatrix:l})=>{if(e instanceof qi){const{model:c}=e;c.setInstanceCount(A);const u={sizeScale:i,sizeMinPixels:r,sizeMaxPixels:o,composeModelMatrix:sb(t,s),sceneModelMatrix:l};c.shaderInputs.setProps({pbrProjection:a,scenegraph:u}),c.draw(n)}}),this.state.firstDrawSignaled||(this.state.firstDrawSignaled=!0,this.props.onFirstDraw?.())}}SC.defaultProps=MC,SC.layerName="ScenegraphLayer";const TC="layout(std140) uniform meshUniforms {\n bool pickFeatureIds;\n} mesh;\n",EC={name:"mesh",vs:TC,fs:TC,uniformTypes:{pickFeatureIds:"f32"}};class PC extends fb{getShaders(){const e=super.getShaders();return e.modules.push(jn,EC),{...e,vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec4 uvRegions;\nin vec3 featureIdsPickingColors;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvec2 applyUVRegion(vec2 uv) {\n#ifdef HAS_UV_REGIONS\nreturn fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n#else\nreturn uv;\n#endif\n}\nvoid main(void) {\nvec2 uv = applyUVRegion(texCoords);\ngeometry.uv = uv;\nif (mesh.pickFeatureIds) {\ngeometry.pickingColor = featureIdsPickingColors;\n} else {\ngeometry.pickingColor = instancePickingColors;\n}\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvTexCoord = uv;\ncameraPosition = project.cameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nvec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale;\nvec3 projectedPosition = project_position(positions);\nposition_commonspace = vec4(projectedPosition, 1.0);\ngl_Position = project_common_position_to_clipspace(position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef MODULE_PBRMATERIAL\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV0 = uv;\n#else\npbr_vUV0 = vec2(0., 0.);\n#endif\npbr_vUV1 = vec2(0., 0.);\ngeometry.uv = pbr_vUV0;\n#endif\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform sampler2D sampler;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\n#ifdef MODULE_PBRMATERIAL\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV0;\nfragColor.a *= layer.opacity;\n#else\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (simpleMesh.flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * layer.opacity);\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);const{props:t,oldProps:n}=e;t.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(t.pbrMaterial)}draw(e){const{featureIds:t}=this.props,{model:n}=this.state;if(!n)return;const i={pickFeatureIds:Boolean(t)},r={camera:this.context.viewport.cameraPosition};n.shaderInputs.setProps({pbrProjection:r,mesh:i}),super.draw(e)}getModel(e){const{id:t}=this.props,n=this.parseMaterial(this.props.pbrMaterial,e);this.setState({parsedPBRMaterial:n});const i=this.getShaders();!function(e){const t=e.positions||e.POSITION,n=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(4*n).fill(255),normalized:!0})}(e.attributes);return new ki(this.context.device,{...this.getShaders(),id:t,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...i.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:n}=this.props,i=this.parseMaterial(e,n);this.setState({parsedPBRMaterial:i});const{pbr_baseColorSampler:r}=i.bindings,{emptyTexture:o}=this.state,s={sampler:r||o,hasTexture:Boolean(r)},{camera:a,...A}={...i.bindings,...i.uniforms};t.shaderInputs.setProps({simpleMesh:s,pbrMaterial:A})}}parseMaterial(e,t){const n=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return Yb(this.context.device,{unlit:n,...e},{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){const t=this.props.featureIds,n=new Uint8ClampedArray(t.length*e.size),i=[];for(let r=0;r<t.length;r++)this.encodePickingColor(t[r],i),n[3*r]=i[0],n[3*r+1]=i[1],n[3*r+2]=i[2];e.value=n}finalizeState(e){super.finalizeState(e),this.state.parsedPBRMaterial?.generatedTextures.forEach(e=>e.destroy()),this.setState({parsedPBRMaterial:null})}}PC.layerName="MeshLayer",PC.defaultProps={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};function IC(e){return e}function LC(e,t=[]){return function(e,t=[],n=IC){return"longitude"in e?(t[0]=n(e.longitude),t[1]=n(e.latitude),t[2]=e.height):"x"in e?(t[0]=n(e.x),t[1]=n(e.y),t[2]=e.z):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}(e,t,x._cartographicRadians?IC:it)}function RC(e,t){return function(e,t,n=IC){return"longitude"in t?(t.longitude=n(e[0]),t.latitude=n(e[1]),t.height=e[2]):"x"in t?(t.x=n(e[0]),t.y=n(e[1]),t.z=e[2]):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}(e,t,x._cartographicRadians?IC:nt)}new ye;const FC=new ye,OC={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"}},DC={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},NC={east:new ye,north:new ye,up:new ye,west:new ye,south:new ye,down:new ye},UC=new ye,kC=new ye,GC=new ye;function zC(e,t,n,i,r,o){const s=OC[t]&&OC[t][n];let a,A,l;Ke(s&&(!i||i===s));const c=FC.copy(r);if(We(c.x,0,1e-14)&&We(c.y,0,1e-14)){const e=Math.sign(c.z);a=UC.fromArray(DC[t]),"east"!==t&&"west"!==t&&a.scale(e),A=kC.fromArray(DC[n]),"east"!==n&&"west"!==n&&A.scale(e),l=GC.fromArray(DC[i]),"east"!==i&&"west"!==i&&l.scale(e)}else{const{up:r,east:o,north:s}=NC;o.set(-c.y,c.x,0).normalize(),e.geodeticSurfaceNormal(c,r),s.copy(r).cross(o);const{down:u,west:f,south:h}=NC;u.copy(r).scale(-1),f.copy(o).scale(-1),h.copy(s).scale(-1),a=NC[t],A=NC[n],l=NC[i]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=A.x,o[5]=A.y,o[6]=A.z,o[7]=0,o[8]=l.x,o[9]=l.y,o[10]=l.z,o[11]=0,o[12]=c.x,o[13]=c.y,o[14]=c.z,o[15]=1,o}const VC=new ye,HC=new ye,jC=new ye;const QC=new ye,JC=new ye,KC=new ye,WC=new ye,qC=new ye,YC=new ye;class XC{constructor(e=0,t=0,n=0){this.centerToleranceSquared=.1,Ke(e>=0),Ke(t>=0),Ke(n>=0),this.radii=new ye(e,t,n),this.radiiSquared=new ye(e*e,t*t,n*n),this.radiiToTheFourth=new ye(e*e*e*e,t*t*t*t,n*n*n*n),this.oneOverRadii=new ye(0===e?0:1/e,0===t?0:1/t,0===n?0:1/n),this.oneOverRadiiSquared=new ye(0===e?0:1/(e*e),0===t?0:1/(t*t),0===n?0:1/(n*n)),this.minimumRadius=Math.min(e,t,n),this.maximumRadius=Math.max(e,t,n),0!==this.radiiSquared.z&&(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,t=[0,0,0]){const n=JC,i=KC,[,,r]=e;this.geodeticSurfaceNormalCartographic(e,n),i.copy(this.radiiSquared).scale(n);const o=Math.sqrt(n.dot(i));return i.scale(1/o),n.scale(r),i.add(n),i.to(t)}cartesianToCartographic(e,t=[0,0,0]){YC.from(e);const n=this.scaleToGeodeticSurface(YC,WC);if(!n)return;const i=this.geodeticSurfaceNormal(n,JC),r=qC;r.copy(YC).subtract(n);return RC([Math.atan2(i.y,i.x),Math.asin(i.z),Math.sign(H(r,YC))*rt(r)],t)}eastNorthUpToFixedFrame(e,t=new ee){return zC(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,n,i,r=new ee){return zC(this,e,t,n,i,r)}geocentricSurfaceNormal(e,t=[0,0,0]){return QC.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const n=LC(e),i=n[0],r=n[1],o=Math.cos(r);return QC.set(o*Math.cos(i),o*Math.sin(i),Math.sin(r)).normalize(),QC.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return QC.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,n=[]){const{oneOverRadii:i,oneOverRadiiSquared:r,centerToleranceSquared:o}=t;VC.from(e);const s=VC.x,a=VC.y,A=VC.z,l=i.x,c=i.y,u=i.z,f=s*s*l*l,h=a*a*c*c,d=A*A*u*u,p=f+h+d,g=Math.sqrt(1/p);if(!Number.isFinite(g))return;const m=HC;if(m.copy(e).scale(g),p<o)return m.to(n);const b=r.x,y=r.y,v=r.z,_=jC;_.set(m.x*b*2,m.y*y*2,m.z*v*2);let C,x,w,B,M=(1-g)*VC.len()/(.5*_.len()),S=0;do{M-=S,C=1/(1+M*b),x=1/(1+M*y),w=1/(1+M*v);const e=C*C,t=x*x,n=w*w;B=f*e+h*t+d*n-1,S=B/(-2*(f*(e*C)*b+h*(t*x)*y+d*(n*w)*v))}while(Math.abs(B)>1e-12);return VC.scale([C,x,w]).to(n)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){WC.from(e);const n=WC.x,i=WC.y,r=WC.z,o=this.oneOverRadiiSquared,s=1/Math.sqrt(n*n*o.x+i*i*o.y+r*r*o.z);return WC.multiplyScalar(s).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return WC.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return WC.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,n=[0,0,0]){Ke(We(this.radii.x,this.radii.y,1e-15)),Ke(this.radii.z>0),WC.from(e);const i=WC.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-t))return WC.set(0,0,i).to(n)}}XC.WGS84=new XC(6378137,6378137,6356752.314245179);class ZC{item;previous;next;constructor(e,t,n){this.item=e,this.previous=t,this.next=n}}class $C{head=null;tail=null;_length=0;get length(){return this._length}add(e){const t=new ZC(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}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,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const n=e.next;e.next=t,this.tail===e?this.tail=t:n.previous=t,t.next=n,t.previous=e,++this._length}}class ex{_list;_sentinel;_trimTiles;constructor(){this._list=new $C,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;t&&this._list.splice(this._sentinel,t)}add(e,t,n){t._cacheNode||(t._cacheNode=this._list.add(t),n&&n(e,t))}unloadTile(e,t,n){const i=t._cacheNode;i&&(this._list.remove(i),t._cacheNode=null,n&&n(e,t))}unloadTiles(e,t){const n=this._trimTiles;this._trimTiles=!1;const i=this._list,r=1024*e.maximumMemoryUsage*1024,o=this._sentinel;let s=i.head;for(;s!==o&&(e.gpuMemoryUsageInBytes>r||n);){const n=s.item;s=s.next,this.unloadTile(e,n,t)}}trim(){this._trimTiles=!0}}function tx(e,t){g(e),g(t);const{rtcCenter:n,gltfUpAxis:i}=t,{computedTransform:r,boundingVolume:{center:o}}=e;let s=new ee(r);switch(n&&s.translate(n),i){case"Z":break;case"Y":const e=(new ee).rotateX(Math.PI/2);s=s.multiplyRight(e);break;case"X":const t=(new ee).rotateY(-Math.PI/2);s=s.multiplyRight(t)}t.isQuantized&&s.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const a=new ye(o);t.cartesianModelMatrix=s,t.cartesianOrigin=a;const A=XC.WGS84.cartesianToCartographic(a,new ye),l=XC.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=l.multiplyRight(s),t.cartographicOrigin=A;const c=function(e){const t=e.gltf;if(!t)return null;const n="number"==typeof t.scene?t.scene:0,i=t.scenes?.[n],r=i?.nodes?.[0];if(!r?.matrix)return null;const o=r.matrix;return o[12]*o[12]+o[13]*o[13]+o[14]*o[14]<=nx?null:r}(t);c&&(t.cartesianModelMatrix=new ee(s).multiplyRight(c.matrix),t.cartographicModelMatrix.multiplyRight(c.matrix),c.matrix=ee.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}const nx=1e6**2;const ix=new ye,rx=new ye,ox=new em([new Yg,new Yg,new Yg,new Yg,new Yg,new Yg]);function sx(e,t){const{cameraDirection:n,cameraUp:i,height:r}=e,{metersPerUnit:o}=e.distanceScales,s=Ax(e,e.center),a=XC.WGS84.eastNorthUpToFixedFrame(s),A=e.unprojectPosition(e.cameraPosition),l=XC.WGS84.cartographicToCartesian(A,new ye),c=new ye(a.transformAsVector(new ye(n).scale(o))).normalize(),u=new ye(a.transformAsVector(new ye(i).scale(o))).normalize();!function(e){const t=e.getFrustumPlanes(),n=ax(t.near,e.cameraPosition),i=Ax(e,n),r=Ax(e,e.cameraPosition,rx);let o=0;ox.planes[o++].fromPointNormal(i,ix.copy(i).subtract(r));for(const s in t){if("near"===s)continue;const r=Ax(e,ax(t[s],n,rx),rx);ox.planes[o++].fromPointNormal(r,ix.copy(i).subtract(r))}}(e);const f=e.constructor,{longitude:h,latitude:d,width:p,bearing:g,zoom:m}=e;return{camera:{position:l,direction:c,up:u},viewport:e,topDownViewport:new f({longitude:h,latitude:d,height:r,width:p,bearing:g,zoom:m,pitch:0}),height:r,cullingVolume:ox,frameNumber:t,sseDenominator:1.15}}function ax(e,t,n=new ye){const i=e.normal.dot(t);return n.copy(e.normal).scale(e.distance-i).add(t),n}function Ax(e,t,n=new ye){const i=e.unprojectPosition(t);return XC.WGS84.cartographicToCartesian(i,n)}const lx=6356752.314245179,cx=new ye;function ux(e,t){if(e instanceof Kg){const{halfAxes:n}=e,i=function(e){e.getColumn(0,cx);const t=e.getColumn(1),n=e.getColumn(2),i=cx.add(t).add(n);return i.len()}(n);return Math.log2(lx/(i+t[2]))}if(e instanceof Pg){const{radius:n}=e;return Math.log2(lx/(n+t[2]))}if(e.width&&e.height){const{width:t,height:n}=e;return(Math.log2(6378137/t)+Math.log2(6378137/n))/2}return 1}function fx(e,t,n){XC.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],cx);const i=Math.sqrt(Math.pow(cx[0]-n[0],2)+Math.pow(cx[1]-n[1],2)+Math.pow(cx[2]-n[2],2));return Math.log2(lx/(i+t[2]))}const hx=0,dx=1,px=3,gx=4,mx=5;var bx,yx,vx,_x,Cx,xx,wx,Bx;(yx=bx||(bx={}))[yx.ADD=1]="ADD",yx[yx.REPLACE=2]="REPLACE",(_x=vx||(vx={})).EMPTY="empty",_x.SCENEGRAPH="scenegraph",_x.POINTCLOUD="pointcloud",_x.MESH="mesh",(xx=Cx||(Cx={})).I3S="I3S",xx.TILES3D="TILES3D",(Bx=wx||(wx={})).GEOMETRIC_ERROR="geometricError",Bx.MAX_SCREEN_THRESHOLD="maxScreenThreshold";const Mx=1;function Sx(e){return null!=e}const Tx=new ye,Ex=new ye,Px=new ye,Ix=new ye,Lx=new ye,Rx=new ye,Fx=new ye,Ox=new ye;function Dx(e,t,n){if(g(e,"3D Tile: boundingVolume must be defined"),e.box)return Ux(e.box,t,n);if(e.region)return function(e){const[t,n,i,r,o,s]=e,a=XC.WGS84.cartographicToCartesian([ot(t),ot(r),o],Px),A=XC.WGS84.cartographicToCartesian([ot(i),ot(n),s],Ix),l=(new ye).addVectors(a,A).multiplyByScalar(.5);return XC.WGS84.cartesianToCartographic(l,Lx),XC.WGS84.cartographicToCartesian([ot(i),Lx[1],Lx[2]],Rx),XC.WGS84.cartographicToCartesian([Lx[0],ot(r),Lx[2]],Fx),XC.WGS84.cartographicToCartesian([Lx[0],Lx[1],s],Ox),Ux([...l,...Rx.subtract(l),...Fx.subtract(l),...Ox.subtract(l)],new ee)}(e.region);if(e.sphere)return function(e,t,n){const i=new ye(e[0],e[1],e[2]);t.transform(i,i);const r=t.getScale(Ex),o=Math.max(Math.max(r[0],r[1]),r[2]),s=e[3]*o;if(Sx(n))return n.center=i,n.radius=s,n;return new Pg(i,s)}(e.sphere,t,n);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Nx(e,t){if(e.box)return function(e){const t=kx(),{halfAxes:n}=e,i=new ye(n.getColumn(0)),r=new ye(n.getColumn(1)),o=new ye(n.getColumn(2));for(let s=0;s<2;s++){for(let n=0;n<2;n++){for(let n=0;n<2;n++)Tx.copy(e.center),Tx.add(i),Tx.add(r),Tx.add(o),Gx(t,Tx),o.negate();r.negate()}i.negate()}return t}(t);if(e.region){const[t,n,i,r,o,s]=e.region;return[[ot(t),ot(n),o],[ot(i),ot(r),s]]}if(e.sphere)return function(e){const t=kx(),{center:n,radius:i}=e,r=XC.WGS84.scaleToGeodeticSurface(n,Tx);let o;o=r?XC.WGS84.geodeticSurfaceNormal(r):new ye(0,0,1);let s=new ye(o[2],-o[1],0);s.len()>0?s.normalize():s=new ye(0,1,0);const a=s.clone().cross(o);for(const A of[s,a,o]){Ex.copy(A).scale(i);for(let e=0;e<2;e++)Tx.copy(n),Tx.add(Ex),Gx(t,Tx),Ex.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function Ux(e,t,n){const i=new ye(e[0],e[1],e[2]);t.transform(i,i);let r=[];if(10===e.length){const t=e.slice(3,6),n=new $t;n.fromArray(e,6);const i=new ye([1,0,0]),o=new ye([0,1,0]),s=new ye([0,0,1]);i.transformByQuaternion(n),i.scale(t[0]),o.transformByQuaternion(n),o.scale(t[1]),s.transformByQuaternion(n),s.scale(t[2]),r=[...i.toArray(),...o.toArray(),...s.toArray()]}else r=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const o=t.transformAsVector(r.slice(0,3)),s=t.transformAsVector(r.slice(3,6)),a=t.transformAsVector(r.slice(6,9)),A=new Dt([o[0],o[1],o[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return Sx(n)?(n.center=i,n.halfAxes=A,n):new Kg(i,A)}function kx(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Gx(e,t){XC.WGS84.cartesianToCartographic(t,Tx),e[0][0]=Math.min(e[0][0],Tx[0]),e[0][1]=Math.min(e[0][1],Tx[1]),e[0][2]=Math.min(e[0][2],Tx[2]),e[1][0]=Math.max(e[1][0],Tx[0]),e[1][1]=Math.max(e[1][1],Tx[1]),e[1][2]=Math.max(e[1][2],Tx[2])}function zx(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const n=e.dynamicScreenSpaceErrorComputedDensity,i=e.dynamicScreenSpaceErrorFactor,r=function(e,t){const n=e*t;return 1-Math.exp(-n*n)}(t,n)*i;return r}return 0}new ye,new ye,new ee,new ye,new ye,new ye;const Vx=new ye,Hx=new ye,jx=new ye,Qx=new ye,Jx=new ye,Kx=new ee,Wx=new ee;function qx(e,t){const{topDownViewport:n}=t,i=e.header.mbs[1],r=e.header.mbs[0],o=e.header.mbs[2],s=e.header.mbs[3],a=[...e.boundingVolume.center],A=n.unprojectPosition(n.cameraPosition);XC.WGS84.cartographicToCartesian(A,Vx),Hx.copy(Vx).subtract(a).normalize(),XC.WGS84.eastNorthUpToFixedFrame(a,Kx),Wx.copy(Kx).invert(),jx.copy(Vx).transform(Wx);const l=Math.sqrt(jx[0]*jx[0]+jx[1]*jx[1]),c=l*l/jx[2];Qx.copy([jx[0],jx[1],c]);const u=Qx.transform(Kx).subtract(a).normalize(),f=Hx.cross(u).normalize().scale(s).add(a),h=XC.WGS84.cartesianToCartographic(f),d=n.project([r,i,o]),p=n.project(h);return Jx.copy(d).subtract(p).magnitude()}class Yx{_map=/* @__PURE__ */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 g(e<this._array.length),this._array[e]}set(e,t){g(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){g(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){g(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=/* @__PURE__ */new Map,this._length=0}find(e){return this._map.has(e)}}const Xx={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class Zx{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=/* @__PURE__ */(new Date).getTime();updateDebounceTime=1e3;_traversalStack=new Yx;_emptyTraversalStack=new Yx;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...Xx,...e}}traverse(e,t,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){const e=n.pop();let i=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),i=this.updateAndPushChildren(e,t,n,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const r=e.parent,o=Boolean(!r||r._shouldRefine),s=!i;e.hasRenderContent?e.refine===bx.ADD?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===bx.REPLACE&&(this.loadTile(e,t),s&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),s&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=i&&o}const i=/* @__PURE__ */(new Date).getTime();(this.traversalFinished(t)||i-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=i,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const n=e.children;for(const i of n)this.updateTile(i,t)}updateAndPushChildren(e,t,n,i){const{loadSiblings:r,skipLevelOfDetail:o}=this.options,s=e.children;s.sort(this.compareDistanceToCamera.bind(this));const a=e.refine===bx.REPLACE&&e.hasRenderContent&&!o;let A=!1,l=!0;for(const c of s)if(c._selectionDepth=i,c.isVisibleAndInRequestVolume?(n.find(c)&&n.delete(c),n.push(c),A=!0):(a||r)&&(this.loadTile(c,t),this.touchTile(c,t)),a){let e;if(e=!!c._inRequestVolume&&(c.hasRenderContent?c.contentAvailable:this.executeEmptyTraversal(c,t)),l=l&&e,!l)return!1}return A||(l=!1),l}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,t))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,n=!1){let i=e._screenSpaceError;return n&&(i=e.getScreenSpaceError(t,!0)),i>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,t){const n=[];if(this.options.viewportTraversersMap)for(const i in this.options.viewportTraversersMap){this.options.viewportTraversersMap[i]===t.viewport.id&&n.push(i)}else n.push(t.viewport.id);e.updateVisibility(t,n)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let n=!1;for(const i of e.children)i.updateVisibility(t),n=n||i.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,t){let n=!0;const i=this._emptyTraversalStack;for(i.push(e);i.length>0;){const e=i.pop(),r=!e.hasRenderContent&&this.canTraverse(e,t),o=!e.hasRenderContent&&0===e.children.length;if(r||e.contentAvailable||o||(n=!1),this.updateTile(e,t),e.isVisibleAndInRequestVolume||(this.loadTile(e,t),this.touchTile(e,t)),r){const t=e.children;for(const e of t)i.push(e)}}return e.hasEmptyContent||n}}const $x=new ye;class ew{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=hx;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new ee;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Zx({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new ee;_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,t,n,i=""){this.header=t,this.tileset=e,this.id=i||t.id,this.url=t.url,this.parent=n,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}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===px||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===hx}get contentExpired(){return this.contentState===gx}get contentFailed(){return this.contentState===mx}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Nx(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case Cx.I3S:return qx(this,e);case Cx.TILES3D:return function(e,t,n){const i=e.tileset,r=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=n?r:e.lodMetricValue;if(0===o)return 0;const s=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:A}=t,{viewDistanceScale:l}=i.options;let c=o*a*(l||1)/(s*A);return c-=zx(i,s),c}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,n=this.refine===bx.ADD||t;if(n&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===hx)return-1;const i=this.parent,r=i&&(!n||0===this._screenSpaceError||i.hasTilesetContent)?i._screenSpaceError:this._screenSpaceError,o=e.root?e.root._screenSpaceError:0;return Math.max(o-r,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=dx;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=hx,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,n=this.tileset.loadOptions[t.id]||{},i={...this.tileset.loadOptions,[t.id]:{...n,isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await ke(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=px,this._onContentLoaded(),!0}catch(t){throw this.contentState=mx,t}finally{e.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=hx,this.tileDrawn=!0,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const n=this.parent,i=n?n._visibilityPlaneMask:em.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,i),this._visible=this._visibilityPlaneMask!==em.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:n}=e,{boundingVolume:i}=this;return n.computeVisibilityWithPlaneMask(i,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return $x.subVectors(t.center,e.position),e.direction.dot($x)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=gx,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){this.lodMetricType="lodMetricType"in e?e.lodMetricType:this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,this.lodMetricValue="lodMetricValue"in e?e.lodMetricValue:this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue}_initializeTransforms(e){this.transform=e.transform?new ee(e.transform):new ee;const t=this.parent,n=this.tileset,i=t&&t.computedTransform?t.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new ee(i).multiplyRight(this.transform);const r=t&&t._initialTransform?t._initialTransform.clone():new ee;this._initialTransform=new ee(r).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=hx,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=em.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||bx.REPLACE}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=Dx(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=Dx(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=Dx(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new ee){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){return"i3s"===e?{...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}:{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"};var t}}class tw extends Zx{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const n=e.children.length>0;if(e.hasTilesetContent&&n){const n=e.children[0];return this.updateTileVisibility(n,t),void(e._visible=n._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const i=e.refine===bx.REPLACE,r=e._optimChildrenWithinParent===Mx;i&&r&&n&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:n}=e;return!(!n||n.hasTilesetContent||n.refine!==bx.ADD)&&!this.shouldRefine(e,t,!0)}}class nw{frameNumberMap=/* @__PURE__ */new Map;register(e,t){const n=this.frameNumberMap.get(e)||/* @__PURE__ */new Map,i=n.get(t)||0;n.set(t,i+1),this.frameNumberMap.set(e,n)}deregister(e,t){const n=this.frameNumberMap.get(e);if(!n)return;const i=n.get(t)||1;n.set(t,i-1)}isZero(e,t){return 0===(this.frameNumberMap.get(e)?.get(t)||0)}}const iw="REQUESTED",rw="COMPLETED",ow="ERROR";class sw{_statusMap;pendingTilesRegister=new nw;constructor(){this._statusMap={}}add(e,t,n,i){if(!this._statusMap[t]){const{frameNumber:r,viewport:{id:o}}=i;this._statusMap[t]={request:e,callback:n,key:t,frameState:i,status:iw},this.pendingTilesRegister.register(o,r),e().then(e=>{this._statusMap[t].status=rw;const{frameNumber:n,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,n),this._statusMap[t].callback(e,i)}).catch(e=>{this._statusMap[t].status=ow;const{frameNumber:i,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,i),n(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:n,viewport:{id:i}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(i,n);const{frameNumber:r,viewport:{id:o}}=t;this.pendingTilesRegister.register(o,r),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class aw extends Zx{_tileManager;constructor(e){super(e),this._tileManager=new sw}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const n=2*qx(e,t);return n<2?"OUT":!e.header.children||n<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const n=e.header.children||[],i=e.children,r=e.tileset;for(const o of n){const n=`${o.id}-${t.viewport.id}`,s=i&&i.find(e=>e.id===n);if(s)s&&this.updateTile(s,t);else{let i=()=>this._loadTile(o.id,r);this._tileManager.find(n)?this._tileManager.update(n,t):(r.tileset.nodePages&&(i=()=>r.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(i,n,t=>this._onTileLoad(t,e,n),t))}}return!1}async _loadTile(e,t){const{loader:n}=t,i=t.getTileUrl(`${t.url}/nodes/${e}`),r={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await ke(i,n,r)}_onTileLoad(e,t,n){const i=new ew(t.tileset,e,t,n);t.children.push(i);const r=this._tileManager.find(i.id).frameState;this.updateTile(i,r),this._frameNumber===r.frameNumber&&(this.traversalFinished(r)||/* @__PURE__ */(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,r)}}const Aw={description:"",ellipsoid:XC.WGS84,modelMatrix:new ee,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},lw="Tiles In Tileset(s)",cw="Tiles In Memory",uw="Tiles In View",fw="Tiles To Render",hw="Tiles Loaded",dw="Tiles Loading",pw="Tiles Unloaded",gw="Failed Tile Loads",mw="Points/Vertices",bw="Tile Memory Use",yw="Maximum Screen Space Error";class vw{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 ex;_requestScheduler;_heldTiles=/* @__PURE__ */new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,t){this.options={...Aw,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||st(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 vt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=1024*this.options.maximumMemoryUsage*1024,this._cacheOverflowBytes=1024*this.options.memoryCacheOverflow*1024,this.stats=new m({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}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 t=e;return this.queryParams.length&&(t=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),t}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(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(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)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const n=[];for(const i of t){const e=i.id;this._needTraverse(e)?n.push(e):this.traverseCounter--}for(const i of t){const e=i.id;if(this.roots[e]||(this.roots[e]=this._initializeTileHeaders(this.tileset,null)),!n.includes(e))continue;const t=sx(i,this._frameNumber);this._traverser.traverse(this.roots[e],t,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const n=this.frameStateData[t],i=Object.values(this._traverser.selectedTiles),[r,o]=function(e,t,n){if(0===n||e.length<=n)return[e,[]];const i=[],{longitude:r,latitude:o}=t.viewport;for(const[l,c]of e.entries()){const[e,t]=c.header.mbs,n=Math.abs(r-e),s=Math.abs(o-t),a=Math.sqrt(s*s+n*n);i.push([l,a])}const s=i.sort((e,t)=>e[1]-t[1]),a=[];for(let l=0;l<n;l++)a.push(e[s[l][0]]);const A=[];for(let l=n;l<s.length;l++)A.push(e[s[l][0]]);return[a,A]}(i,e,this.options.maximumTilesSelected);n.selectedTiles=r;for(const s of o)s.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,this.traverseCounter>0||this._updateTiles()}_updateTiles(){const e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const i in this.frameStateData){const e=this.frameStateData[i];this.selectedTiles=this.selectedTiles.concat(e.selectedTiles),this._requestedTiles=this._requestedTiles.concat(e._requestedTiles),this._emptyTiles=this._emptyTiles.concat(e._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);const t=new Set(this.selectedTiles.map(e=>e.id));let n=0;if(this.selectedTiles.some(e=>!e.tileDrawn)){for(const e of t)this._heldTiles.add(e);for(const e of this._heldTiles){if(t.has(e))continue;const i=this._tiles[e];i&&i.contentAvailable?(i._selectedFrame=this._frameNumber,this.selectedTiles.push(i),n++):this._heldTiles.delete(e)}}else this._heldTiles=t;n>0&&setTimeout(()=>{this.selectTiles()},0);for(const 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,t){if(e.length!==t.length)return!0;const n=new Set(e.map(e=>e.id)),i=new Set(t.map(e=>e.id));let r=e.filter(e=>!i.has(e.id)).length>0;return r=r||t.filter(e=>!n.has(e.id)).length>0,r}_loadTiles(){this._requestedTiles.sort((e,t)=>e._priority-t._priority);for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const n of this.selectedTiles)n.contentAvailable&&n.content&&(e++,n.content.pointCount?t+=n.content.pointCount:t+=n.content.vertexCount);this.stats.get(uw).count=this.selectedTiles.length,this.stats.get(fw).count=e,this.stats.get(mw).count=t,this.stats.get(yw).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===Cx.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===Cx.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===Cx.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:n,ymin:i,ymax:r,zmin:o,zmax:s}=e;return this.cartographicCenter=new ye(t+(n-t)/2,i+(r-i)/2,o+(s-o)/2),this.cartesianCenter=new ye,XC.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=fx(e,this.cartographicCenter,this.cartesianCenter))}const t=this.tileset.store?.extent;if(t){const[e,n,i,r]=t;return this.cartographicCenter=new ye(e+(i-e)/2,n+(r-n)/2,0),this.cartesianCenter=new ye,XC.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=function(e,t,n){const[i,r,o,s]=e;return fx({xmax:o,ymax:s,zmax:0},t,n)}(t,this.cartographicCenter,this.cartesianCenter))}this.cartographicCenter=new ye,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return this.cartographicCenter=new ye,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?(this.cartographicCenter=new ye,XC.WGS84.cartesianToCartographic(t,this.cartographicCenter)):this.cartographicCenter=new ye(0,0,-XC.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=ux(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(lw),this.stats.get(dw),this.stats.get(cw),this.stats.get(uw),this.stats.get(fw),this.stats.get(hw),this.stats.get(pw),this.stats.get(gw),this.stats.get(mw),this.stats.get(bw,"memory"),this.stats.get(yw)}_initializeTileHeaders(e,t){const n=new ew(this,e.root,t);if(t&&(t.children.push(n),n.depth=t.depth+1),this.type===Cx.TILES3D){const e=[];for(e.push(n);e.length>0;){const t=e.pop();this.stats.get(lw).incrementCount();const n=t.header.children||[];for(const i of n){const n=new ew(this,i,t);if(n.contentUrl?.includes("?session=")){const e=new URL(n.contentUrl).searchParams.get("session");e&&(this._queryParams.session=e)}t.children.push(n),n.depth=t.depth+1,e.push(n)}}}return n}_initializeTraverser(){let e;switch(this.type){case Cx.TILES3D:e=tw;break;case Cx.I3S:e=aw;break;default:e=Zx}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(n){this._onTileLoadError(e,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get(gw).incrementCount();const n=t.message||t.toString(),i=e.url;this.options.onTileError(e,n,i)}_onTileLoad(e,t){if(t){if(this.type===Cx.I3S){const e=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(lw).reset(),this.stats.get(lw).addCount(e)}e&&e.content&&tx(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===Cx.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}else if(this.type===Cx.TILES3D){const{extensionsRemoved:t=[]}=e.content?.gltf||{};t.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),t.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),t.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(dw).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(dw).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(hw).incrementCount(),this.stats.get(cw).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(bw).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(cw).decrementCount(),this.stats.get(pw).incrementCount(),this.stats.get(bw).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const n of t.children)e.push(n);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,n=[];for(n.push(t);n.length>0;){e=n.pop();for(const t of e.children)n.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){const t=new URLSearchParams(e.queryString),n=Object.fromEntries(t.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version&&"1.1"!==this.asset.version)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(){const e=this.loadOptions.i3s;e&&"object"==typeof e&&"token"in e&&(this._queryParams.token=e.token)}}const _w="4.4.2",Cw="cmpt",xw="pnts",ww="b3dm",Bw="i3dm",Mw="glTF";function Sw(e,t,n){g(e instanceof ArrayBuffer);const i=new TextDecoder("utf8"),r=new Uint8Array(e,t,n);return i.decode(r)}const Tw={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Ew={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Tw},Pw={[Tw.DOUBLE]:Float64Array,[Tw.FLOAT]:Float32Array,[Tw.UNSIGNED_SHORT]:Uint16Array,[Tw.UNSIGNED_INT]:Uint32Array,[Tw.UNSIGNED_BYTE]:Uint8Array,[Tw.BYTE]:Int8Array,[Tw.SHORT]:Int16Array,[Tw.INT]:Int32Array},Iw={DOUBLE:Tw.DOUBLE,FLOAT:Tw.FLOAT,UNSIGNED_SHORT:Tw.UNSIGNED_SHORT,UNSIGNED_INT:Tw.UNSIGNED_INT,UNSIGNED_BYTE:Tw.UNSIGNED_BYTE,BYTE:Tw.BYTE,SHORT:Tw.SHORT,INT:Tw.INT},Lw="Failed to convert GL type";class Rw{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Pw){if(Pw[t]===e)return t}throw new Error(Lw)}static fromName(e){const t=Iw[e];if(!t)throw new Error(Lw);return t}static getArrayType(e){switch(e){case Tw.UNSIGNED_SHORT_5_6_5:case Tw.UNSIGNED_SHORT_4_4_4_4:case Tw.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Pw[e];if(!t)throw new Error(Lw);return t}}static getByteSize(e){return Rw.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(Rw.getArrayType(e))}static createTypedArray(e,t,n=0,i){void 0===i&&(i=(t.byteLength-n)/Rw.getByteSize(e));const r=ArrayBuffer.isView(t)?t.buffer:t;return new(Rw.getArrayType(e))(r,n,i)}}function Fw(e,t=[0,0,0]){const n=e>>11&31,i=e>>5&63,r=31&e;return t[0]=n<<3,t[1]=i<<2,t[2]=r<<3,t}function Ow(e,t=255){return at(e,0,t)/t*2-1}function Dw(e){return e<0?-1:1}function Nw(e,t,n,i){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(i),e<0||e>n||t<0||t>n)throw new Error(`x and y must be unsigned normalized integers between 0 and ${n}`);if(i.x=Ow(e,n),i.y=Ow(t,n),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){const e=i.x;i.x=(1-Math.abs(i.y))*Dw(e),i.y=(1-Math.abs(e))*Dw(i.y)}return i.normalize()}function Uw(e,t,n){return Nw(e,t,255,n)}new Tt,new ye,new Tt,new Tt;class kw{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,t){this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=Ew.UNSIGNED_INT,n=1){const i=this.json[e];return i&&Number.isFinite(i.byteOffset)?this._getTypedArrayFromBinary(e,t,n,1,i.byteOffset):i}getPropertyArray(e,t,n){const i=this.json[e];return i&&Number.isFinite(i.byteOffset)?("componentType"in i&&(t=Rw.fromName(i.componentType)),this._getTypedArrayFromBinary(e,t,n,this.featuresLength,i.byteOffset)):this._getTypedArrayFromArray(e,t,i)}getProperty(e,t,n,i,r){const o=this.json[e];if(!o)return o;const s=this.getPropertyArray(e,t,n);if(1===n)return s[i];for(let a=0;a<n;++a)r[a]=s[n*i+a];return r}_getTypedArrayFromBinary(e,t,n,i,r){const o=this._cachedTypedArrays;let s=o[e];return s||(s=Rw.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+r,i*n),o[e]=s),s}_getTypedArrayFromArray(e,t,n){const i=this._cachedTypedArrays;let r=i[e];if(!r){if(ArrayBuffer.isView(n)){const e=n.byteOffset,i=n.byteLength/Rw.getByteSize(t);r=Rw.createTypedArray(t,n.buffer,e,i)}else if(n instanceof ArrayBuffer)r=Rw.createTypedArray(t,n);else{r=new(Rw.getArrayType(t))(n)}i[e]=r}return r}}const Gw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zw={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},Vw={SCALAR:(e,t,n)=>{t[n]=e},VEC2:(e,t,n)=>{t[2*n+0]=e[0],t[2*n+1]=e[1]},VEC3:(e,t,n)=>{t[3*n+0]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2]},VEC4:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT2:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT3:(e,t,n)=>{t[9*n+0]=e[0],t[9*n+1]=e[1],t[9*n+2]=e[2],t[9*n+3]=e[3],t[9*n+4]=e[4],t[9*n+5]=e[5],t[9*n+6]=e[6],t[9*n+7]=e[7],t[9*n+8]=e[8],t[9*n+9]=e[9]},MAT4:(e,t,n)=>{t[16*n+0]=e[0],t[16*n+1]=e[1],t[16*n+2]=e[2],t[16*n+3]=e[3],t[16*n+4]=e[4],t[16*n+5]=e[5],t[16*n+6]=e[6],t[16*n+7]=e[7],t[16*n+8]=e[8],t[16*n+9]=e[9],t[16*n+10]=e[10],t[16*n+11]=e[11],t[16*n+12]=e[12],t[16*n+13]=e[13],t[16*n+14]=e[14],t[16*n+15]=e[15]}};const Hw=e=>void 0!==e;function jw(e,t,n){if(!t)return null;let i=e.getExtension("3DTILES_batch_table_hierarchy");const r=t.HIERARCHY;return r&&(t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=r,i=r),i?function(e,t){let n,i,r;const o=e.instancesLength,s=e.classes;let a,A=e.classIds,l=e.parentCounts,c=e.parentIds,u=o;Hw(A.byteOffset)&&(A.componentType=defaultValue(A.componentType,GL.UNSIGNED_SHORT),A.type=AttributeType.SCALAR,r=getBinaryAccessor(A),A=r.createArrayBufferView(t.buffer,t.byteOffset+A.byteOffset,o));if(Hw(l))for(Hw(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,r=getBinaryAccessor(l),l=r.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,o)),a=new Uint16Array(o),u=0,n=0;n<o;++n)a[n]=u,u+=l[n];Hw(c)&&Hw(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,r=getBinaryAccessor(c),c=r.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,u));const f=s.length;for(n=0;n<f;++n){const e=s[n].length,i=s[n].instances,r=getBinaryProperties(e,i,t);s[n].instances=combine(r,i)}const h=new Array(f).fill(0),d=new Uint16Array(o);for(n=0;n<o;++n)i=A[n],d[n]=h[i],++h[i];const p={classes:s,classIds:A,classIndexes:d,parentCounts:l,parentIndexes:a,parentIds:c};return function(e){const t=e.classIds,n=t.length;for(let i=0;i<n;++i)Jw(e,i,stack)}(p),p}(i,n):null}function Qw(e,t,n){if(!e)return;const i=e.parentCounts;return e.parentIds?n(e,t):i>0?function(e,t,n){const i=e.classIds,r=e.parentCounts,o=e.parentIds,s=e.parentIndexes,a=i.length,A=scratchVisited;A.length=Math.max(A.length,a);const l=++marker,c=scratchStack;c.length=0,c.push(t);for(;c.length>0;){if(A[t=c.pop()]===l)continue;A[t]=l;const i=n(e,t);if(Hw(i))return i;const a=r[t],u=s[t];for(let e=0;e<a;++e){const n=o[u+e];n!==t&&c.push(n)}}return null}(e,t,n):function(e,t,n){let i=!0;for(;i;){const r=n(e,t);if(Hw(r))return r;const o=e.parentIds[t];i=o!==t,t=o}throw new Error("traverseHierarchySingleParent")}(e,t,n)}function Jw(e,t,n){const i=e.parentCounts,r=e.parentIds,o=e.parentIndexes,s=e.classIds.length;if(!Hw(r))return;assert(t<s,`Parent index ${t} exceeds the total number of instances: ${s}`),assert(-1===n.indexOf(t),"Circular dependency detected in the batch table hierarchy."),n.push(t);const a=Hw(i)?i[t]:1,A=Hw(i)?o[t]:t;for(let l=0;l<a;++l){const i=r[A+l];i!==t&&Jw(e,i,n)}n.pop(t)}function Kw(e){return null!=e}const Ww=(e,t)=>e,qw={HIERARCHY:!0,extensions:!0,extras:!0};class Yw{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,n,i={}){g(n>=0),this.json=e||{},this.binary=t,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(const r in this.json)qw[r]||(this._properties[r]=this.json[r]);this._binaryProperties=this._initializeBinaryProperties(),i["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=jw(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),g("string"==typeof t,t),this._hierarchy){return Kw(Qw(this._hierarchy,e,(e,n)=>{const i=e.classIds[n];return e.classes[i].name===t}))}return!1}isExactClass(e,t){return g("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),g("string"==typeof t,t),Kw(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Kw(t)?t:[]).length=0;const n=Object.keys(this._properties);return t.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),g("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(Kw(n))return this._getBinaryProperty(n,e)}const n=this._properties[t];if(Kw(n))return Ww(n[e]);if(this._hierarchy){const n=this._getHierarchyProperty(e,t);if(Kw(n))return n}}setProperty(e,t,n){const i=this.featureCount;if(this._checkBatchId(e),g("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(i)return void this._setBinaryProperty(i,e,n)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,n))return;let r=this._properties[t];Kw(r)||(this._properties[t]=new Array(i),r=this._properties[t]),r[e]=Ww(n)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,n){e.pack(n,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const n=this._properties[t],i=this._initializeBinaryProperty(t,n);i&&(e=e||{},e[t]=i)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const n=t;g(this.binary,`Property ${e} requires a batch table binary.`),g(n.type,`Property ${e} requires a type.`);const i=function(e,t,n,i){const{componentType:r}=e;g(e.componentType);const o="string"==typeof r?Rw.fromName(r):r,s=Gw[e.type],a=zw[e.type],A=Vw[e.type];return n+=e.byteOffset,{values:Rw.createTypedArray(o,t,n,s*i),type:o,size:s,unpacker:a,packer:A}}(n,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:i.values,componentCount:i.size,unpack:i.unpacker,pack:i.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const n=Qw(this._hierarchy,e,(e,n)=>{const i=e.classIds[n];return Kw(e.classes[i].instances[t])});return Kw(n)}_getPropertyNamesInHierarchy(e,t){Qw(this._hierarchy,e,(e,n)=>{const i=e.classIds[n],r=e.classes[i].instances;for(const o in r)r.hasOwnProperty(o)&&-1===t.indexOf(o)&&t.push(o)})}_getHierarchyProperty(e,t){return Qw(this._hierarchy,e,(e,n)=>{const i=e.classIds[n],r=e.classes[i],o=e.classIndexes[n],s=r.instances[t];return Kw(s)?Kw(s.typedArray)?this._getBinaryProperty(s,o):Ww(s[o]):null})}_setHierarchyProperty(e,t,n,i){const r=Qw(this._hierarchy,t,(e,r)=>{const o=e.classIds[r],s=e.classes[o],a=e.classIndexes[r],A=s.instances[n];return!!Kw(A)&&(g(r===t,`Inherited property "${n}" is read-only.`),Kw(A.typedArray)?this._setBinaryProperty(A,a,i):A[a]=Ww(i),!0)});return Kw(r)}}function Xw(e,t,n=0){const i=new DataView(t);if(e.magic=i.getUint32(n,!0),n+=4,e.version=i.getUint32(n,!0),n+=4,e.byteLength=i.getUint32(n,!0),n+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return n}function Zw(e,t,n){const i=new DataView(t);let r;e.header=e.header||{};let o=i.getUint32(n,!0);n+=4;let s=i.getUint32(n,!0);n+=4;let a=i.getUint32(n,!0);n+=4;let A=i.getUint32(n,!0);return n+=4,a>=570425344?(n-=8,r=o,a=s,A=0,o=0,s=0):A>=570425344&&(n-=4,r=a,a=o,A=s,o=0,s=0),e.header.featureTableJsonByteLength=o,e.header.featureTableBinaryByteLength=s,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=A,e.header.batchLength=r,n}function $w(e,t,n,i){return n=function(e,t,n){const{featureTableJsonByteLength:i,featureTableBinaryByteLength:r,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},i&&i>0){const r=Sw(t,n,i);e.featureTableJson=JSON.parse(r)}return n+=i||0,e.featureTableBinary=new Uint8Array(t,n,r),n+=r||0,n}(e,t,n),n=function(e,t,n){const{batchTableJsonByteLength:i,batchTableBinaryByteLength:r}=e.header||{};if(i&&i>0){const o=Sw(t,n,i);e.batchTableJson=JSON.parse(o),n+=i,r&&r>0&&(e.batchTableBinary=new Uint8Array(t,n,r),e.batchTableBinary=new Uint8Array(e.batchTableBinary),n+=r)}return n}(e,t,n),n}function eB(e,t,n){if(!(t||e&&e.batchIds&&n))return null;const{batchIds:i,isRGB565:r,pointCount:o=0}=e;if(i&&n){const e=new Uint8ClampedArray(3*o);for(let t=0;t<o;t++){const r=i[t],o=n.getProperty(r,"dimensions").map(e=>255*e);e[3*t]=o[0],e[3*t+1]=o[1],e[3*t+2]=o[2]}return{type:Ew.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&r){const e=new Uint8ClampedArray(3*o);for(let n=0;n<o;n++){const i=Fw(t[n]);e[3*n]=i[0],e[3*n+1]=i[1],e[3*n+2]=i[2]}return{type:Ew.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*o?{type:Ew.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Ew.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}const tB=new ye;function nB(e,t,n){return e.isQuantized?n["3d-tiles"]&&n["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const n=new ye,i=new Float32Array(3*e.pointCount);for(let r=0;r<e.pointCount;r++)n.set(t[3*r],t[3*r+1],t[3*r+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(i,3*r);return i}(e,t)):{type:Ew.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function iB(e,t,n,i,r){n=$w(e,t,n=Zw(e,t,n=Xw(e,t,n))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:o,batchTable:s}=function(e){const t=new kw(e.featureTableJson,e.featureTableBinary),n=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=n,e.featuresLength=n,e.pointsLength=n,e.pointCount=n,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",Ew.FLOAT,3);const i=function(e,t){let n=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Ew.UNSIGNED_SHORT,1),e.batchIds)){const i=t.getGlobalProperty("BATCH_LENGTH");if(!i)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:r,batchTableBinary:o}=e;n=new Yw(r,o,i)}return n}(e,t);return{featureTable:t,batchTable:i}}(e);return await async function(e,t,n,i,r){let o,s,a;const A=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];A&&(a=A.properties);const l=t.getExtension("3DTILES_draco_point_compression");if(l){s=l.properties;const t=l.byteOffset,n=l.byteLength;if(!s||!Number.isFinite(t)||!n)throw new Error("Draco properties, byteOffset, and byteLength must be defined");o=(e.featureTableBinary||[]).slice(t,t+n),e.hasPositions=Number.isFinite(s.POSITION),e.hasColors=Number.isFinite(s.RGB)||Number.isFinite(s.RGBA),e.hasNormals=Number.isFinite(s.NORMAL),e.hasBatchIds=Number.isFinite(s.BATCH_ID),e.isTranslucent=Number.isFinite(s.RGBA)}if(!o)return!0;const c={buffer:o,properties:{...s,...a},batchTableProperties:a};return await async function(e,t,n,i){if(!i)return;const r={...n,draco:{...n?.draco,extraAttributes:t.batchTableProperties||{}}};delete r["3d-tiles"];const o=await ct(t.buffer,T_,r,i),s=o.attributes.POSITION&&o.attributes.POSITION.value,a=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,A=o.attributes.NORMAL&&o.attributes.NORMAL.value,l=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,c=s&&o.attributes.POSITION.value.quantization,u=A&&o.attributes.NORMAL.value.quantization;if(c){const t=o.POSITION.data.quantization,n=t.range;e.quantizedVolumeScale=new ye(n,n,n),e.quantizedVolumeOffset=new ye(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}u&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const f={};if(t.batchTableProperties)for(const h of Object.keys(t.batchTableProperties))o.attributes[h]&&o.attributes[h].value&&(f[h.toLowerCase()]=o.attributes[h].value);e.attributes={positions:s,colors:eB(e,a,void 0),normals:A,batchIds:l,...f}}(e,c,i,r)}(e,o,0,i,r),function(e,t,n){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",Ew.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const i=t.getPropertyArray("POSITION_QUANTIZED",Ew.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ew.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ew.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=nB(e,i,n)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,o,i),function(e,t,n){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let i=null;t.hasProperty("RGBA")?(i=t.getPropertyArray("RGBA",Ew.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?i=t.getPropertyArray("RGB",Ew.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(i=t.getPropertyArray("RGB565",Ew.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=eB(e,i,n)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Ew.UNSIGNED_BYTE,4))}(e,o,s),function(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let n=null;t.hasProperty("NORMAL")?n=t.getPropertyArray("NORMAL",Ew.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(n=t.getPropertyArray("NORMAL_OCT16P",Ew.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const n=new Float32Array(3*(e.pointsLength||0));for(let i=0;i<(e.pointsLength||0);i++)Uw(t[2*i],t[2*i+1],tB),tB.toArray(n,3*i);return{type:Ew.FLOAT,size:2,value:n}}return{type:Ew.FLOAT,size:2,value:t}}(e,n)}}(e,o),n}const rB=0,oB=1;function sB(e,t,n,i){e.rotateYtoZ=!0;const r=(e.byteOffset||0)+(e.byteLength||0)-n;if(0===r)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=i?.["3d-tiles"]&&i["3d-tiles"].assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=et(t,n,r),e.gltfByteOffset=0,e.gltfByteLength=r,(e.byteOffset||0)+(e.byteLength||0)}async function aB(e,t,n,i){const r=n?.["3d-tiles"]||{};if(function(e,t){switch(t){case rB:if(e.gltfArrayBuffer){const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),n=(new TextDecoder).decode(t);e.gltfUrl=n.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case oB:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),r.loadGLTF){if(!i)return;if(e.gltfUrl){const{fetch:t}=i,r=await t(e.gltfUrl,n?.core);e.gltfArrayBuffer=await r.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){const t=await ct(e.gltfArrayBuffer,AC,n,i);e.gltf=_C(t),e.gpuMemoryUsageInBytes=Zy(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}async function AB(e,t,n,i,r){n=function(e,t,n,i){n=Xw(e,t,n),n=Zw(e,t,n),n=$w(e,t,n),n=sB(e,t,n,i);const r=new kw(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=r.getGlobalProperty("RTC_CENTER",Ew.FLOAT,3),n}(e,t,n,i),await aB(e,oB,i,r);const o=e?.gltf?.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),n}async function lB(e,t,n,i,r){return n=function(e,t,n,i){if(n=Xw(e,t,n),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);n=Zw(e,t,n);const r=new DataView(t);if(e.gltfFormat=r.getUint32(n,!0),n+=4,n=$w(e,t,n),n=sB(e,t,n,i),!e?.header?.featureTableJsonByteLength||0===e.header.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new kw(e.featureTableJson,e.featureTableBinary),s=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=s,!Number.isFinite(s))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",Ew.FLOAT,3);new Yw(e.batchTableJson,e.batchTableBinary,s);return function(e,t,n,i){const r=new Array(i),o=new ye;new ye,new ye,new ye;const s=new Dt,a=new $t,A=new ye,l={},c=new ee,u=[],f=[],h=[],d=[];for(let p=0;p<i;p++){let n;if(t.hasProperty("POSITION"))n=t.getProperty("POSITION",Ew.FLOAT,3,p,o);else if(t.hasProperty("POSITION_QUANTIZED")){n=t.getProperty("POSITION_QUANTIZED",Ew.UNSIGNED_SHORT,3,p,o);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ew.FLOAT,3);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const i=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ew.FLOAT,3);if(!i)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const r=65535;for(let t=0;t<3;t++)n[t]=n[t]/r*i[t]+e[t]}if(!n)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(o.copy(n),l.translation=o,e.normalUp=t.getProperty("NORMAL_UP",Ew.FLOAT,3,p,u),e.normalRight=t.getProperty("NORMAL_RIGHT",Ew.FLOAT,3,p,f),e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",Ew.UNSIGNED_SHORT,2,p,u),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Ew.UNSIGNED_SHORT,2,p,f),e.octNormalUp){if(!e.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}e.eastNorthUp?(XC.WGS84.eastNorthUpToFixedFrame(o,c),c.getRotationMatrix3(s)):s.identity()}a.fromMatrix3(s),l.rotation=a,A.set(1,1,1);const i=t.getProperty("SCALE",Ew.FLOAT,1,p,h);Number.isFinite(i)&&A.multiplyByScalar(i);const g=t.getProperty("SCALE_NON_UNIFORM",Ew.FLOAT,3,p,u);g&&A.scale(g),l.scale=A;let m=t.getProperty("BATCH_ID",Ew.UNSIGNED_SHORT,1,p,d);void 0===m&&(m=p);const b=(new ee).fromQuaternion(l.rotation);c.identity(),c.translate(l.translation),c.multiplyRight(b),c.scale(l.scale);const y=c.clone();r[p]={modelMatrix:y,batchId:m}}e.instances=r}(e,o,0,s),n}(e,t,n,i),await aB(e,e.gltfFormat||0,i,r),n}async function cB(e,t=0,n,i,r={shape:"tile3d"}){switch(r.byteOffset=t,r.type=function(e,t=0){const n=new DataView(e);return`${String.fromCharCode(n.getUint8(t+0))}${String.fromCharCode(n.getUint8(t+1))}${String.fromCharCode(n.getUint8(t+2))}${String.fromCharCode(n.getUint8(t+3))}`}(e,t),r.type){case Cw:return await async function(e,t,n,i,r,o){n=Xw(e,t,n);const s=new DataView(t);for(e.tilesLength=s.getUint32(n,!0),n+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-n>12;){const s={shape:"tile3d"};e.tiles.push(s),n=await o(t,n,i,r,s)}return n}(r,e,t,n,i,cB);case ww:return await AB(r,e,t,n,i);case Mw:return await async function(e,t,n,i){if(e.rotateYtoZ=!0,e.gltfUpAxis=n?.["3d-tiles"]?.assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",n?.["3d-tiles"]?.loadGLTF){if(!i)return t.byteLength;const r=await ct(t,AC,n,i);e.gltf=_C(r),e.gpuMemoryUsageInBytes=Zy(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(r,e,n,i);case Bw:return await lB(r,e,t,n,i);case xw:return await iB(r,e,t,n,i);default:throw new Error(`3DTileLoader: unknown type ${r.type}`)}}async function uB(e,t,n,i){const r=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof r)return;const o=e.bufferViews[r],s=e.buffers[o.buffer];if(!i?.baseUrl)throw new Error("Url is not provided");if(!i.fetch)throw new Error("fetch is not provided");if(s.uri){const e=`${i?.baseUrl||""}/${s.uri}`,n=await i.fetch(e),r=await n.arrayBuffer();return void(t.explicitBitstream=new Uint8Array(r,o.byteOffset,o.byteLength))}const a=e.buffers.slice(0,o.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(n.slice(a,a+s.byteLength),o.byteOffset,o.byteLength)}function fB(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const hB={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:_w,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,n){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const i=fB(e.slice(8,16)),r=new Uint8Array(e,24,i),o=new TextDecoder("utf8").decode(r),s=JSON.parse(o),a=fB(e.slice(16,24));let A=new ArrayBuffer(0);if(a&&(A=e.slice(24+i)),await uB(s,s.tileAvailability,A,n),Array.isArray(s.contentAvailability))for(const l of s.contentAvailability)await uB(s,l,A,n);else await uB(s,s.contentAvailability,A,n);return await uB(s,s.childSubtreeAvailability,A,n),s},options:{}};var dB=null;try{dB=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 pB(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function gB(e){return!0===(e&&e.__isLong__)}function mB(e){var t=Math.clz32(e&-e);return e?31-t:t}pB.prototype.__isLong__,Object.defineProperty(pB.prototype,"__isLong__",{value:!0}),pB.isLong=gB;var bB={},yB={};function vB(e,t){var n,i,r;return t?(r=0<=(e>>>=0)&&e<256)&&(i=yB[e])?i:(n=CB(e,0,!0),r&&(yB[e]=n),n):(r=-128<=(e|=0)&&e<128)&&(i=bB[e])?i:(n=CB(e,e<0?-1:0,!1),r&&(bB[e]=n),n)}function _B(e,t){if(isNaN(e))return t?IB:PB;if(t){if(e<0)return IB;if(e>=SB)return DB}else{if(e<=-TB)return NB;if(e+1>=TB)return OB}return e<0?_B(-e,t).neg():CB(e%MB|0,e/MB|0,t)}function CB(e,t,n){return new pB(e,t,n)}pB.fromInt=vB,pB.fromNumber=_B,pB.fromBits=CB;var xB=Math.pow;function wB(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?IB:PB;if((n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return wB(e.substring(1),t,n).neg();for(var r=_B(xB(n,8)),o=PB,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),A=parseInt(e.substring(s,s+a),n);if(a<8){var l=_B(xB(n,a));o=o.mul(l).add(_B(A))}else o=(o=o.mul(r)).add(_B(A))}return o.unsigned=t,o}function BB(e,t){return"number"==typeof e?_B(e,t):"string"==typeof e?wB(e,t):CB(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}pB.fromString=wB,pB.fromValue=BB;var MB=4294967296,SB=MB*MB,TB=SB/2,EB=vB(1<<24),PB=vB(0);pB.ZERO=PB;var IB=vB(0,!0);pB.UZERO=IB;var LB=vB(1);pB.ONE=LB;var RB=vB(1,!0);pB.UONE=RB;var FB=vB(-1);pB.NEG_ONE=FB;var OB=CB(-1,2147483647,!1);pB.MAX_VALUE=OB;var DB=CB(-1,-1,!0);pB.MAX_UNSIGNED_VALUE=DB;var NB=CB(0,-2147483648,!1);pB.MIN_VALUE=NB;var UB=pB.prototype;UB.toInt=function(){return this.unsigned?this.low>>>0:this.low},UB.toNumber=function(){return this.unsigned?(this.high>>>0)*MB+(this.low>>>0):this.high*MB+(this.low>>>0)},UB.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(NB)){var t=_B(e),n=this.div(t),i=n.mul(t).sub(this);return n.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=_B(xB(e,6),this.unsigned),o=this,s="";;){var a=o.div(r),A=(o.sub(a.mul(r)).toInt()>>>0).toString(e);if((o=a).isZero())return A+s;for(;A.length<6;)A="0"+A;s=""+A+s}},UB.getHighBits=function(){return this.high},UB.getHighBitsUnsigned=function(){return this.high>>>0},UB.getLowBits=function(){return this.low},UB.getLowBitsUnsigned=function(){return this.low>>>0},UB.getNumBitsAbs=function(){if(this.isNegative())return this.eq(NB)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},UB.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},UB.isZero=function(){return 0===this.high&&0===this.low},UB.eqz=UB.isZero,UB.isNegative=function(){return!this.unsigned&&this.high<0},UB.isPositive=function(){return this.unsigned||this.high>=0},UB.isOdd=function(){return!(1&~this.low)},UB.isEven=function(){return!(1&this.low)},UB.equals=function(e){return gB(e)||(e=BB(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},UB.eq=UB.equals,UB.notEquals=function(e){return!this.eq(e)},UB.neq=UB.notEquals,UB.ne=UB.notEquals,UB.lessThan=function(e){return this.comp(e)<0},UB.lt=UB.lessThan,UB.lessThanOrEqual=function(e){return this.comp(e)<=0},UB.lte=UB.lessThanOrEqual,UB.le=UB.lessThanOrEqual,UB.greaterThan=function(e){return this.comp(e)>0},UB.gt=UB.greaterThan,UB.greaterThanOrEqual=function(e){return this.comp(e)>=0},UB.gte=UB.greaterThanOrEqual,UB.ge=UB.greaterThanOrEqual,UB.compare=function(e){if(gB(e)||(e=BB(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?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},UB.comp=UB.compare,UB.negate=function(){return!this.unsigned&&this.eq(NB)?NB:this.not().add(LB)},UB.neg=UB.negate,UB.add=function(e){gB(e)||(e=BB(e));var t=this.high>>>16,n=65535&this.high,i=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,A=0,l=0,c=0,u=0;return c+=(u+=r+(65535&e.low))>>>16,l+=(c+=i+a)>>>16,A+=(l+=n+s)>>>16,A+=t+o,CB((c&=65535)<<16|(u&=65535),(A&=65535)<<16|(l&=65535),this.unsigned)},UB.subtract=function(e){return gB(e)||(e=BB(e)),this.add(e.neg())},UB.sub=UB.subtract,UB.multiply=function(e){if(this.isZero())return this;if(gB(e)||(e=BB(e)),dB)return CB(dB.mul(this.low,this.high,e.low,e.high),dB.get_high(),this.unsigned);if(e.isZero())return this.unsigned?IB:PB;if(this.eq(NB))return e.isOdd()?NB:PB;if(e.eq(NB))return this.isOdd()?NB:PB;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(EB)&&e.lt(EB))return _B(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,i=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,A=65535&e.low,l=0,c=0,u=0,f=0;return u+=(f+=r*A)>>>16,c+=(u+=i*A)>>>16,u&=65535,c+=(u+=r*a)>>>16,l+=(c+=n*A)>>>16,c&=65535,l+=(c+=i*a)>>>16,c&=65535,l+=(c+=r*s)>>>16,l+=t*A+n*a+i*s+r*o,CB((u&=65535)<<16|(f&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},UB.mul=UB.multiply,UB.divide=function(e){if(gB(e)||(e=BB(e)),e.isZero())throw Error("division by zero");var t,n,i;if(dB)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?CB((this.unsigned?dB.div_u:dB.div_s)(this.low,this.high,e.low,e.high),dB.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?IB:PB;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return IB;if(e.gt(this.shru(1)))return RB;i=IB}else{if(this.eq(NB))return e.eq(LB)||e.eq(FB)?NB:e.eq(NB)?LB:(t=this.shr(1).div(e).shl(1)).eq(PB)?e.isNegative()?LB:FB:(n=this.sub(e.mul(t)),i=t.add(n.div(e)));if(e.eq(NB))return this.unsigned?IB:PB;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=PB}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),o=r<=48?1:xB(2,r-48),s=_B(t),a=s.mul(e);a.isNegative()||a.gt(n);)a=(s=_B(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=LB),i=i.add(s),n=n.sub(a)}return i},UB.div=UB.divide,UB.modulo=function(e){return gB(e)||(e=BB(e)),dB?CB((this.unsigned?dB.rem_u:dB.rem_s)(this.low,this.high,e.low,e.high),dB.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},UB.mod=UB.modulo,UB.rem=UB.modulo,UB.not=function(){return CB(~this.low,~this.high,this.unsigned)},UB.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},UB.clz=UB.countLeadingZeros,UB.countTrailingZeros=function(){return this.low?mB(this.low):mB(this.high)+32},UB.ctz=UB.countTrailingZeros,UB.and=function(e){return gB(e)||(e=BB(e)),CB(this.low&e.low,this.high&e.high,this.unsigned)},UB.or=function(e){return gB(e)||(e=BB(e)),CB(this.low|e.low,this.high|e.high,this.unsigned)},UB.xor=function(e){return gB(e)||(e=BB(e)),CB(this.low^e.low,this.high^e.high,this.unsigned)},UB.shiftLeft=function(e){return gB(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?CB(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):CB(0,this.low<<e-32,this.unsigned)},UB.shl=UB.shiftLeft,UB.shiftRight=function(e){return gB(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?CB(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):CB(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},UB.shr=UB.shiftRight,UB.shiftRightUnsigned=function(e){return gB(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?CB(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):CB(32===e?this.high:this.high>>>e-32,0,this.unsigned)},UB.shru=UB.shiftRightUnsigned,UB.shr_u=UB.shiftRightUnsigned,UB.rotateLeft=function(e){var t;return gB(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?CB(this.high,this.low,this.unsigned):e<32?(t=32-e,CB(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),CB(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},UB.rotl=UB.rotateLeft,UB.rotateRight=function(e){var t;return gB(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?CB(this.high,this.low,this.unsigned):e<32?(t=32-e,CB(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),CB(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},UB.rotr=UB.rotateRight,UB.toSigned=function(){return this.unsigned?CB(this.low,this.high,!1):this},UB.toUnsigned=function(){return this.unsigned?this:CB(this.low,this.high,!0)},UB.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},UB.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},UB.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},pB.fromBytes=function(e,t,n){return n?pB.fromBytesLE(e,t):pB.fromBytesBE(e,t)},pB.fromBytesLE=function(e,t){return new pB(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},pB.fromBytesBE=function(e,t){return new pB(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(pB.fromBigInt=function(e,t){return CB(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},pB.fromValue=function(e,t){return"bigint"==typeof e?pB.fromBigInt(e,t):BB(e,t)},UB.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});function kB(e){"X"===e&&(e="");const t=e.padEnd(16,"0");return pB.fromString(t,!0,16)}const GB=180/Math.PI;function zB(e,t,n){const i=1<<t;return[(e[0]+n[0])/i,(e[1]+n[1])/i]}function VB(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function HB(e){return[VB(e[0]),VB(e[1])]}function jB(e,[t,n]){switch(e){case 0:return[1,t,n];case 1:return[-t,1,n];case 2:return[-t,-n,1];case 3:return[-1,-n,-t];case 4:return[n,-1,-t];case 5:return[n,t,-1];default:throw new Error("Invalid face")}}function QB([e,t,n]){const i=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*GB,i*GB]}function JB(e,t,n,i){if(0===i){1===n&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const i=t[0];t[0]=t[1],t[1]=i}}function KB(e){const{face:t,ij:n,level:i}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-i))),s=new Float64Array(4*o*2+2);let a=0,A=0;for(let l=0;l<4;l++){const e=r[l].slice(0),c=r[l+1],u=(c[0]-e[0])/o,f=(c[1]-e[1])/o;for(let r=0;r<o;r++){e[0]+=u,e[1]+=f;const r=QB(jB(t,HB(zB(n,i,e))));Math.abs(r[1])>89.999&&(r[0]=A);const o=r[0]-A;r[0]+=o>180?-360:o<-180?360:0,s[a++]=r[0],s[a++]=r[1],A=r[0]}}return s[a++]=s[0],s[a++]=s[1],s}function WB(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=kB(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const n=t.lastIndexOf("1"),i=t.substring(0,3),r=t.substring(3,n),o=r.length/2,s=pB.fromString(i,!0,2).toString(10);let a="";if(0!==o)for(a=pB.fromString(r,!0,2).toString(4);a.length<o;)a="0"+a;return`${s}/${a}`}(t)}(e);return function(e){if(0===e.length)throw new Error(`Invalid Hilbert quad key ${e}`);const t=e.split("/"),n=parseInt(t[0],10),i=t[1],r=i.length;let o=0;const s=[0,0];for(let a=r-1;a>=0;a--){o=r-a;const e=i[a];let t=0,n=0;"1"===e?n=1:"2"===e?(t=1,n=1):"3"===e&&(t=1);const A=Math.pow(2,o-1);JB(A,s,t,n),s[0]+=A*t,s[1]+=A*n}if(n%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:n,ij:s,level:o}}(t)}function qB(e){return function(e){const t=HB(zB(e.ij,e.level,[.5,.5]));return QB(jB(e.face,t))}(WB(e))}function YB(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],n=[];for(let i=0;i<e.length;i+=2)t.push(e[i]),n.push(e[i+1]);return t.sort((e,t)=>e-t),n.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:n[n.length-1],south:n[0]}}function XB(e,t){const n=t?.minimumHeight||0,i=t?.maximumHeight||0,r=function(e){let t;if(2===e.face||5===e.face){let n=null,i=0;for(let t=0;t<4;t++){const r=KB(WB(`${e.face}/${t}`));null==n&&(n=new Float64Array(4*r.length)),n.set(r,i),i+=r.length}t=YB(n)}else t=YB(KB(e));return t}(WB(e)),o=r.west,s=r.south,a=r.east,A=r.north,l=[];return l.push(new ye(o,A,n)),l.push(new ye(a,A,n)),l.push(new ye(a,s,n)),l.push(new ye(o,s,n)),l.push(new ye(o,A,i)),l.push(new ye(a,A,i)),l.push(new ye(a,s,i)),l.push(new ye(o,s,i)),l}function ZB(e){const t=e.token,n={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},i=XB(t,n),r=qB(t),o=r[0],s=r[1],a=XC.WGS84.cartographicToCartesian([o,s,n.maximumHeight]),A=new ye(a[0],a[1],a[2]);i.push(A);const l=bm(i);return[...l.center,...l.halfAxes]}const $B={QUADTREE:4,OCTREE:8};function eM(e,t,n){if(e?.box){const i=function(e,t){const n=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(pB.fromNumber(2*t+1-4).multiply(n))}(kB(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const n=t;t*=4;const i=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-i.length).join("0")+i}(i),o={...e.s2VolumeInfo};if(o.token=r,"OCTREE"===n){const t=e.s2VolumeInfo,n=t.maximumHeight-t.minimumHeight,i=n/2,r=t.minimumHeight+n/2;t.minimumHeight=r-i,t.maximumHeight=r+i}return{box:ZB(o),s2VolumeInfo:o}}}async function tM(e){const{subtree:t,subtreeData:n={level:0,x:0,y:0,z:0},parentData:i={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:r=0,implicitOptions:o,loaderOptions:s,s2VolumeBox:a}=e,{subdivisionScheme:A,subtreeLevels:l,maximumLevel:c,contentUrlTemplate:u,subtreesUriTemplate:f,basePath:h}=o,d={children:[],lodMetricValue:0,contentUrl:""};if(!c)return ut.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${u} won't be loaded...`),d;const p=i.localLevel+1,g=n.level+p;if(g>c)return d;const m=$B[A],b=Math.log2(m),y=1&r,v=r>>1&1,_=r>>2&1,C=iM(i.localX,y,1),x=iM(i.localY,v,1),w=iM(i.localZ,_,1),B=iM(n.x,C,p),M=iM(n.y,x,p),S=iM(n.z,w,p),T=iM(i.mortonIndex,r,b);let E,P,I,L;if(p===l&&nM(t.childSubtreeAvailability,T)){const e=rM(`${h}/${f}`,g,B,M,S);E=await ke(e,hB,s),L=0,P={level:g,x:B,y:M,z:S},I={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else{E=t;L=(m**p-1)/(m-1)+T,P=n,I={mortonIndex:T,localLevel:p,localX:C,localY:x,localZ:w}}if(!nM(E.tileAvailability,L))return d;nM(E.contentAvailability,L)&&(d.contentUrl=rM(u,g,B,M,S));for(let R=0;R<m;R++){const e=eM(a,R,A),t=await tM({subtree:E,subtreeData:P,parentData:I,childIndex:R,implicitOptions:o,loaderOptions:s,s2VolumeBox:e});(t.contentUrl||t.children.length)&&d.children.push(t)}if(d.contentUrl||d.children.length){const e=function(e,t,n,i){const{basePath:r,refine:o,getRefine:s,lodMetricType:a,getTileType:A,rootLodMetricValue:l,rootBoundingVolume:c}=n,u=e.contentUrl&&e.contentUrl.replace(`${r}/`,""),f=l/2**t.level,h=i?.box?{box:i.box}:c,d=function(e,t,n){if(e.region){const{level:i,x:r,y:o,z:s}=t,[a,A,l,c,u,f]=e.region,h=2**i,d=(l-a)/h,[p,g]=[a+d*r,a+d*(r+1)],m=(c-A)/h,[b,y]=[A+m*o,A+m*(o+1)];let v,_;if("OCTREE"===n){const e=(f-u)/h;[v,_]=[u+e*s,u+e*(s+1)]}else[v,_]=[u,f];return{region:[p,b,g,y,v,_]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}(h,t,n.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:u},id:e.contentUrl,refine:s(o),type:A(e),lodMetricType:a,lodMetricValue:f,geometricError:f,transform:e.transform,boundingVolume:d}}(d,{level:g,x:B,y:M,z:S},o,a);return e}return d}function nM(e,t){let n;return Array.isArray(e)?(n=e[0],e.length>1&&ut.once('Not supported extension "3DTILES_multiple_contents" has been detected')):n=e,"constant"in n?Boolean(n.constant):!!n.explicitBitstream&&function(e,t){const n=Math.floor(e/8),i=e%8;return 1==(t[n]>>i&1)}(t,n.explicitBitstream)}function iM(e,t,n){return(e<<n)+t}function rM(e,t,n,i,r){const o=function(e){const t={};for(const n in e)t[`{${n}}`]=e[n];return t}({level:t,x:n,y:i,z:r});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>o[e])}function oM(e,t=""){if(!t)return vx.EMPTY;const n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return vx.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return vx.SCENEGRAPH;default:return n||vx.EMPTY}}function sM(e){switch(e){case"REPLACE":case"replace":return bx.REPLACE;case"ADD":case"add":return bx.ADD;default:return e}}function aM(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const n=new URL(e,`${t}/`);return decodeURI(n.toString())}return e.startsWith("/")?e:At(t,e)}function AM(e,t){if(!e)return null;let n;if(e.content){const i=e.content.uri||e.content?.url;void 0!==i&&(n=aM(i,t))}return{...e,id:n,contentUrl:n,lodMetricType:wx.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:oM(0,n),refine:sM(e.refine)}}async function lM(e,t,n,i,r){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:A,subtrees:{uri:l}}=i,c=aM(rM(l,0,0,0,0),n),u=await ke(c,hB,r),f=e.content?.uri,h=f?aM(f,n):"",d=t?.root?.refine,p=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:ZB(g),s2VolumeInfo:g};e.boundingVolume=t}const m=e.boundingVolume,b={contentUrlTemplate:h,subtreesUriTemplate:l,subdivisionScheme:o,subtreeLevels:A,maximumLevel:Number.isFinite(a)?a-1:s,refine:d,basePath:n,lodMetricType:wx.GEOMETRIC_ERROR,rootLodMetricValue:p,rootBoundingVolume:m,getTileType:oM,getRefine:sM};return await async function(e,t,n,i,r){if(!e)return null;const{children:o,contentUrl:s}=await tM({subtree:n,implicitOptions:i,loaderOptions:r});let a,A=null;s&&(a=s,A={uri:s.replace(`${t}/`,"")});const l={...e,id:a,contentUrl:a,lodMetricType:wx.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:oM(0,a),refine:sM(e.refine),content:A||e.content,children:o};return l}(e,n,u,b,r)}function cM(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const uM={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:_w,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},n){const i=t["3d-tiles"]||{};let r;r="auto"===i.isTileset?n?.url&&-1!==n.url.indexOf(".json"):i.isTileset;return r?async function(e,t,n){const i=JSON.parse((new TextDecoder).decode(e)),r=n?.url||"",o=function(e){return st(e)}(r),s=await async function(e,t,n){let i=null;const r=cM(e.root);i=r&&e.root?await lM(e.root,e,t,r,n):AM(e.root,t);const o=[];for(o.push(i);o.length>0;){const i=o.pop()||{},r=i.children||[],s=[];for(const a of r){const i=cM(a);let r;r=i?await lM(a,e,t,i,n):AM(a,t),r&&(s.push(r),o.push(r))}i.children=s}return i}(i,o,t||{}),a={...i,shape:"tileset3d",loader:uM,url:r,queryString:n?.queryString||"",basePath:o,root:s||i.root,type:Cx.TILES3D,lodMetricType:wx.GEOMETRIC_ERROR,lodMetricValue:i.root?.geometricError||0};return a}(e,t,n):async function(e,t,n){const i={content:{shape:"tile3d",featureIds:null}},r=0;return await cB(e,r,t,n,i.content),i.content}(e,t,n)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const fM=[0],hM={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:uM,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,n)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};class dM extends fo{initializeState(){"onTileLoadFail"in this.props&&Ce.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:t,changeFlags:n}){if(e.data&&e.data!==t.data&&this._loadTileset(e.data),n.viewportChanged){const{activeViewports:e}=this.state;Object.keys(e).length&&(this._updateTileset(e),this.state.lastUpdatedViewports=e,this.state.activeViewports={})}if(n.propsChanged){const{layerMap:e}=this.state;for(const t in e)e[t].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){const{activeViewports:t,lastUpdatedViewports:n}=this.state;this.internalState.viewport=e,t[e.id]=e;const i=n?.[e.id];i&&e.equals(i)||(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:t}){const n=t&&t.props.tile;return e.picked&&(e.object=n),e.sourceTile=n,e}filterSubLayer({layer:e,viewport:t,cullRect:n,isPicking:i}){const{tile:r}=e.props,{id:o}=t;if(!r.selected||!r.viewportIds.includes(o))return!1;if(i&&n&&r.content?.cartographicOrigin){const[e,i]=t.project(r.content.cartographicOrigin),o=n.x+n.width/2,s=n.y+n.height/2,a=Math.max(t.width,t.height)/4,A=e-o,l=i-s;if(A*A+l*l>a*a)return!1}return!0}_updateAutoHighlight(e){const t=e.sourceTile,n=this.state.layerMap[t?.id];n&&n.layer&&n.layer.updateAutoHighlight(e)}async _loadTileset(e){const t=this.props.loadOptions||{},n=this.props.loaders?.length?this.props.loaders:this.props.loader,i=Array.isArray(n)?n[0]:n,{tileset:r,...o}=t,s={loadOptions:{...o},...r};let a=e;if("preload"in i&&"function"==typeof i.preload){const n=await i.preload(e,t);n.url&&(a=n.url),n.headers&&(s.loadOptions.core={...s.loadOptions.core,fetch:{...s.loadOptions.core?.fetch,headers:n.headers}}),Object.assign(s,n)}const A=await ke(a,i,s.loadOptions),l=new vw(A,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,onUpdate:()=>this.setNeedsUpdate(),...s});this.setState({tileset3d:l,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(l)}_onTileLoad(e){const{lastUpdatedViewports:t}=this.state;e.tileDrawn=!1,this.props.onTileLoad(e),this._updateTileset(t),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;const{tileset3d:t}=this.state,{timeline:n}=this.context,i=Object.keys(e).length;n&&i&&t&&t.selectTiles(Object.values(e)).then(e=>{this.state.frameNumber!==e&&this.setState({frameNumber:e})})}_getSubLayer(e,t){if(!e.content)return null;switch(e.type){case vx.POINTCLOUD:return this._makePointCloudLayer(e,t);case vx.SCENEGRAPH:return this._make3DModelLayer(e);case vx.MESH:return this._makeSimpleMeshLayer(e,t);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,t){const{attributes:n,pointCount:i,constantRGBA:r,cartographicOrigin:o,modelMatrix:s}=e.content,{positions:a,normals:A,colors:l}=n;if(!a)return null;const c=t&&t.props.data||{header:{vertexCount:i},attributes:{POSITION:a,NORMAL:A,COLOR_0:l}},{pointSize:u,getPointColor:f}=this.props;return new(this.getSubLayerClass("pointcloud",Ko))({pointSize:u},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:c,coordinateSystem:je.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getColor:r||f,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:n,cartographicOrigin:i,modelMatrix:r}=e.content;return new(this.getSubLayerClass("scenegraph",SC))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:n||fM,scenegraph:t,coordinateSystem:je.METER_OFFSETS,coordinateOrigin:i,modelMatrix:r,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0,onFirstDraw:()=>{e.tileDrawn=!0}})}_makeSimpleMeshLayer(e,t){const n=e.content,{attributes:i,indices:r,modelMatrix:o,cartographicOrigin:s,coordinateSystem:a=je.METER_OFFSETS,material:A,featureIds:l}=n,{_getMeshColor:c}=this.props,u=t&&t.props.mesh||new Qi({topology:"triangle-list",attributes:pM(i),indices:r});return new(this.getSubLayerClass("mesh",PC))(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:u,data:fM,getColor:c(e),pbrMaterial:A,modelMatrix:o,coordinateOrigin:s,coordinateSystem:a,featureIds:l,_offset:0})}renderLayers(){const{tileset3d:e,layerMap:t}=this.state;return e?e.tiles.map(e=>{const n=t[e.id]=t[e.id]||{tile:e};let{layer:i}=n;return e.selected&&(i?n.needsUpdate&&(i=this._getSubLayer(e,i),n.needsUpdate=!1):i=this._getSubLayer(e)),n.layer=i,i}).filter(Boolean):null}}function pM(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}dM.defaultProps=hM,dM.layerName="Tile3DLayer";const gM={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:"4.4.2",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}}},mM=[1],bM={...Km.defaultProps,elevationData:Mm,texture:{...Mm,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:[gM]};function yM(e){return Array.isArray(e)?e.join(";"):e||""}class vM extends fo{updateState({props:e,oldProps:t}){const n=e.elevationData!==t.elevationData;if(n){const{elevationData:t}=e,n=t&&(Array.isArray(t)||_M(t));this.setState({isTiled:n})}const i=n||e.meshMaxError!==t.meshMaxError||e.elevationDecoder!==t.elevationDecoder||e.bounds!==t.bounds;if(!this.state.isTiled&&i){const t=this.loadTerrain(e);this.setState({terrain:t})}e.workerUrl&&Ce.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:t,elevationDecoder:n,meshMaxError:i,signal:r}){if(!e)return null;let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?2*i:0,...o?.terrain,bounds:t,meshMaxError:i,elevationDecoder:n}};const{fetch:s}=this.props;return s(e,{propName:"elevationData",layer:this,loadOptions:o,signal:r})}getTiledTerrainData(e){const{elevationData:t,fetch:n,texture:i,elevationDecoder:r,meshMaxError:o}=this.props,{viewport:s}=this.context,a=Tm(t,e),A=i&&Tm(i,e),{signal:l}=e;let c=[0,0],u=[0,0];if(s.isGeospatial){const t=e.bbox;c=s.projectFlat([t.west,t.south]),u=s.projectFlat([t.east,t.north])}else{const t=e.bbox;c=[t.left,t.bottom],u=[t.right,t.top]}const f=[c[0],c[1],u[0],u[1]],h=this.loadTerrain({elevationData:a,bounds:f,elevationDecoder:r,meshMaxError:o,signal:l}),d=A?n(A,{propName:"texture",layer:this,loaders:[],signal:l}).catch(e=>null):Promise.resolve(null);return Promise.all([h,d])}renderSubLayers(e){const t=this.getSubLayerClass("mesh",fb),{color:n,wireframe:i,material:r}=this.props,{data:o}=e;if(!o)return null;const[s,a]=o;return new t(e,{data:mM,mesh:s,texture:a,_instanced:!1,coordinateSystem:je.CARTESIAN,getPosition:e=>[0,0,0],getColor:n,wireframe:i,material:r})}onViewportLoad(e){if(!e)return;const{zRange:t}=this.state,n=e.map(e=>e.content).filter(Boolean).map(e=>e[0].header.boundingBox.map(e=>e[2]));if(0===n.length)return;const i=Math.min(...n.map(e=>e[0])),r=Math.max(...n.map(e=>e[1]));(!t||i<t[0]||r>t[1])&&this.setState({zRange:[i,r]})}renderLayers(){const{color:e,material:t,elevationData:n,texture:i,wireframe:r,meshMaxError:o,elevationDecoder:s,tileSize:a,maxZoom:A,minZoom:l,extent:c,maxRequests:u,onTileLoad:f,onTileUnload:h,onTileError:d,maxCacheSize:p,maxCacheByteSize:g,refinementStrategy:m}=this.props;if(this.state.isTiled)return new Km(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:yM(n),texture:yM(i),meshMaxError:o,elevationDecoder:s}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:a,maxZoom:A,minZoom:l,extent:c,maxRequests:u,onTileLoad:f,onTileUnload:h,onTileError:d,maxCacheSize:p,maxCacheByteSize:g,refinementStrategy:m});if(!n)return null;return new(this.getSubLayerClass("mesh",fb))(this.getSubLayerProps({id:"mesh"}),{data:mM,mesh:this.state.terrain,texture:i,_instanced:!1,getPosition:e=>[0,0,0],getColor:e,material:t,wireframe:r})}}vM.defaultProps=bM,vM.layerName="TerrainLayer";const _M=e=>e.includes("{x}")&&(e.includes("{y}")||e.includes("{-y}")),CM="\nlayout(std140) uniform clipUniforms {\n vec4 bounds;\n} clip;\n\nbool clip_isInBounds(vec2 position) {\n return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];\n}\n",xM={name:"clip",vs:CM,uniformTypes:{bounds:"vec4<f32>"}},wM={"vs:#decl":"\nout float clip_isVisible;\n","vs:DECKGL_FILTER_GL_POSITION":"\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n","fs:#decl":"\nin float clip_isVisible;\n","fs:DECKGL_FILTER_COLOR":"\n if (clip_isVisible < 0.5) discard;\n"},BM={name:"clip",fs:CM,uniformTypes:{bounds:"vec4<f32>"}},MM={"vs:#decl":"\nout vec2 clip_commonPosition;\n","vs:DECKGL_FILTER_GL_POSITION":"\n clip_commonPosition = geometry.position.xy;\n","fs:#decl":"\nin vec2 clip_commonPosition;\n","fs:DECKGL_FILTER_COLOR":"\n if (!clip_isInBounds(clip_commonPosition)) discard;\n"};class SM extends ho{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return void 0!==this.props.clipByInstance&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,e?{modules:[xM],inject:wM}:{modules:[BM],inject:MM}}draw(){const{clipBounds:e}=this.props,t={};if(this.state.clipByInstance)t.bounds=e;else{const n=this.projectPosition([e[0],e[1],0]),i=this.projectPosition([e[2],e[3],0]);t.bounds=[Math.min(n[0],i[0]),Math.min(n[1],i[1]),Math.max(n[0],i[0]),Math.max(n[1],i[1])]}this.setShaderModuleProps({clip:t})}}function TM(e,t,n){switch(e.type){case"Point":return function(e,t,n){const{positions:i}=e,r=PM(i,t,n);if(r.length>1)return{type:"MultiPoint",coordinates:r};return{type:"Point",coordinates:r[0]}}(e,t,n);case"LineString":return function(e,t=-1/0,n=1/0){const{positions:i}=e,r=e.pathIndices.value.filter(e=>e>=t&&e<=n);if(!(r.length>2)){return{type:"LineString",coordinates:PM(i,r[0],r[1])}}const o=[];for(let s=0;s<r.length-1;s++){const e=PM(i,r[s],r[s+1]);o.push(e)}return{type:"MultiLineString",coordinates:o}}(e,t,n);case"Polygon":return EM(e,t,n);default:const i=e;throw new Error(`Unsupported geometry type: ${i?.type}`)}}function EM(e,t=-1/0,n=1/0){const{positions:i}=e,r=e.polygonIndices.value.filter(e=>e>=t&&e<=n),o=e.primitivePolygonIndices.value.filter(e=>e>=t&&e<=n);if(!(r.length>2)){const e=[];for(let t=0;t<o.length-1;t++){const n=PM(i,o[t],o[t+1]);e.push(n)}return{type:"Polygon",coordinates:e}}const s=[];for(let a=0;a<r.length-1;a++){const t=EM(e,r[a],r[a+1]).coordinates;s.push(t)}return{type:"MultiPolygon",coordinates:s}}function PM(e,t,n){t=t||0,n=n||e.value.length/e.size;const i=[];for(let r=t;r<n;r++){const t=Array();for(let n=r*e.size;n<(r+1)*e.size;n++)t.push(Number(e.value[n]));i.push(t)}return i}function IM(e,t){const n=t?.globalFeatureId;return void 0!==n?function(e,t){const n=LM(e);for(const i of n){let e=0,n=i.featureIds.value[0];for(let r=0;r<i.featureIds.value.length;r++){const o=i.featureIds.value[r];if(o!==n){if(t===i.globalFeatureIds.value[e])return RM(i,e,r);e=r,n=o}}if(t===i.globalFeatureIds.value[e])return RM(i,e,i.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}(e,n):function(e){const t=LM(e);return function(e){const t=[];for(const n of e){if(0===n.featureIds.value.length)continue;let e=0,i=n.featureIds.value[0];for(let r=0;r<n.featureIds.value.length;r++){const o=n.featureIds.value[r];o!==i&&(t.push(RM(n,e,r)),e=r,i=o)}t.push(RM(n,e,n.featureIds.value.length))}return t}(t)}(e)}function LM(e,t){const n=[];return e.points&&(e.points.type="Point",n.push(e.points)),e.lines&&(e.lines.type="LineString",n.push(e.lines)),e.polygons&&(e.polygons.type="Polygon",n.push(e.polygons)),n}function RM(e,t,n){const i=TM(e,t,n),r=function(e,t=0){const n=Object.assign({},e.properties[e.featureIds.value[t]]);for(const i in e.numericProps)n[i]=e.numericProps[i].value[t];return n}(e,t),o=function(e,t=0){return e.fields&&e.fields[e.featureIds.value[t]]}(e,t);return{type:"Feature",geometry:i,properties:r,...o}}SM.defaultProps={clipBounds:[0,0,1,1],clipByInstance:void 0},SM.extensionName="ClipExtension";const FM={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry",dataType:null,batchType:null,version:"4.4.2",worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},OM={Point:DM,MultiPoint:function(e,t,n){return NM(e,t,n)},LineString:UM,MultiLineString:function(e,t,n){return e.map(e=>UM(e,t,n))},Polygon:kM,MultiPolygon:function(e,t,n){return e.map(e=>kM(e,t,n))}};function DM([e,t],[n,i],r){const o=Ee(n[0],i[0],e),s=Ee(n[1],i[1],t);return r.unprojectFlat([o,s])}function NM(e,t,n){return e.map(e=>DM(e,t,n))}function UM(e,t,n){return NM(e,t,n)}function kM(e,t,n){return e.map(e=>NM(e,t,n))}const GM=["points","lines","polygons"];function zM(e,t,n,i){const r=e.featureIds.value;if(!r.length)return-1;let o=0,s=r[r.length-1]+1;if(i){const t=function(e,t){if(!e.__layers){const t={},{properties:n}=e;for(let e=0;e<n.length;e++){const{layerName:i}=n[e];i&&(t[i]?t[i][1]=e:t[i]=[e,e])}e.__layers=t}return e.__layers[t]}(e,i);if(!t)return-1;o=t[0],s=t[1]+1}let a=-1;if(t in e.numericProps){const i=e.numericProps[t].value.findIndex((e,t)=>e===n&&r[t]>=o&&r[t]<s);return i>=0?e.globalFeatureIds.value[i]:-1}return t?a=VM(e.properties,e=>e[t]===n,o,s):e.fields&&(a=VM(e.fields,e=>e.id===n,o,s)),a>=0?function(e,t){if(!e.__ids){const t=[],n=e.featureIds.value,i=e.globalFeatureIds.value;for(let e=0;e<n.length;e++)t[n[e]]=i[e];e.__ids=t}return e.__ids[t]}(e,a):-1}function VM(e,t,n,i){for(let r=n;r<i;r++)if(t(e[r],r))return r;return-1}const HM={...Ya.defaultProps,data:Mm,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[FM],binary:!0};class jM extends Km{initializeState(){super.initializeState();const e=void 0===this.context.viewport.resolution&&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:t,context:n,changeFlags:i}){i.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:e,oldProps:t,context:n,changeFlags:i}),this._setWGS84PropertyForTiles());const{highlightColor:r}=e;r!==t.highlightColor&&Array.isArray(r)&&this.setState({highlightColor:r})}async _updateTileData(){let e=this.props.data,t=null;if("string"!=typeof e||/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(e))e&&"object"==typeof e&&"tilejson"in e&&(t=e);else{const{onDataLoad:i,fetch:r}=this.props;this.setState({data:null,tileJSON:null});try{t=await r(e,{propName:"data",layer:this,loaders:[]})}catch(n){this.raiseError(n,"loading TileJSON"),e=null}i&&i(t,{propName:"data",layer:this})}t&&(e=t.tiles),this.setState({data:e,tileJSON:t})}_getTilesetOptions(){const e=super._getTilesetOptions(),t=this.state.tileJSON,{minZoom:n,maxZoom:i}=this.props;return t&&(Number.isFinite(t.minzoom)&&t.minzoom>n&&(e.minZoom=t.minzoom),Number.isFinite(t.maxzoom)&&(!Number.isFinite(i)||t.maxzoom<i)&&(e.maxZoom=t.maxzoom)),e}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(e){const{data:t,binary:n}=this.state,{index:i,signal:r}=e,o=Tm(t,e);if(!o)return Promise.reject("Invalid URL");let s=this.getLoadOptions();const{fetch:a}=this.props;return s={...s,core:{...s?.core,mimeType:"application/x-protobuf"},mvt:{...s?.mvt,shape:n?"binary":"geojson",coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:i}},a(o,{propName:"data",layer:this,loadOptions:s,signal:r})}renderSubLayers(e){const{x:t,y:n,z:i}=e.tile.index,r=Math.pow(2,i),o=512/r,s=-o,a=512*t/r,A=512*(1-n/r),l=(new ee).scale([o,s,1]);e.autoHighlight=!1,this.context.viewport.resolution||(e.modelMatrix=l,e.coordinateOrigin=[a,A,0],e.coordinateSystem=je.CARTESIAN,e.extensions=[...e.extensions||[],new SM]);const c=super.renderSubLayers(e);return!this.state.binary||c instanceof Ya||Ce.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),c}_updateAutoHighlight(e){const{uniqueIdProperty:t}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:i}=this.state,r=e.object;let o=null,s=null;r&&(o=QM(r,t),s=JM(r));let{highlightColor:a}=this.props;"function"==typeof a&&(a=a(e)),n===o&&i===s||this.setState({highlightColor:a,hoveredFeatureId:o,hoveredFeatureLayerName:s})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(e){const t=super.getPickingInfo(e);if(this.state.binary&&-1!==t.index){const{data:n}=e.sourceLayer.props;t.object=IM(n,{globalFeatureId:t.index})}return t.object&&!this._isWGS84()&&(t.object=WM(t.object,t.tile.bbox,this.context.viewport)),t}getSubLayerPropsByTile(e){return{highlightedObjectIndex:this.getHighlightedObjectIndex(e),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(e){const{hoveredFeatureId:t,hoveredFeatureLayerName:n,binary:i}=this.state,{uniqueIdProperty:r,highlightedFeatureId:o}=this.props,s=e.content,a=KM(o);if(!(KM(t)||a))return-1;const A=a?o:t;return Array.isArray(s)?s.findIndex(e=>{const t=QM(e,r)===A,i=a||JM(e)===n;return t&&i}):s&&i?function(e,t,n,i){for(const r of GM){const o=e[r]&&zM(e[r],t,n,i);if(o>=0)return o}return-1}(s,r,A,a?"":n):-1}_pickObjects(e){const{deck:t,viewport:n}=this.context,i=n.width,r=n.height,o=n.x,s=n.y,a=[this.id];return t.pickObjects({x:o,y:s,width:i,height:r,layerIds:a,maxObjects:e})}getRenderedFeatures(e=null){const t=this._pickObjects(e),n=/* @__PURE__ */new Set,i=[];for(const r of t){const e=QM(r.object,this.props.uniqueIdProperty);void 0===e?i.push(r.object):n.has(e)||(n.add(e),i.push(r.object))}return i}_setWGS84PropertyForTiles(){const e="dataInWGS84";this.state.tileset.selectedTiles.forEach(t=>{t.hasOwnProperty(e)||Object.defineProperty(t,e,{get:()=>{if(!t.content)return null;if(this.state.binary&&Array.isArray(t.content)&&!t.content.length)return[];const{bbox:e}=t;if(void 0===t._contentWGS84&&(n=e,Number.isFinite(n.west)&&Number.isFinite(n.north)&&Number.isFinite(n.east)&&Number.isFinite(n.south))){const n=this.state.binary?IM(t.content):t.content;t._contentWGS84=n.map(t=>WM(t,e,this.context.viewport))}var n;return t._contentWGS84}})})}}function QM(e,t){return e.properties&&t?e.properties[t]:"id"in e?e.id:void 0}function JM(e){return e.properties?.layerName||null}function KM(e){return null!=e&&""!==e}function WM(e,t,n){const i={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(i.geometry,"coordinates",{get:()=>{const i=function(e,t,n){const i=[n.projectFlat([t.west,t.north]),n.projectFlat([t.east,t.south])];return{...e,coordinates:OM[e.type](e.coordinates,i,n)}}(e.geometry,t,n);return i.coordinates}}),i}jM.layerName="MVTLayer",jM.defaultProps=HM;const qM="0123456789bcdefghjkmnpqrstuvwxyz",YM={};for(let $M=0;$M<32;$M++)YM[qM.charAt($M)]=$M;function XM(e){const[t,n,i,r]=function(e){let t,n=!0,i=90,r=-90,o=180,s=-180,a=0;for(let A=0,l=e.length;A<l;A++){const l=e[A].toLowerCase();a=YM[l];for(let e=4;e>=0;e--){const A=a>>e&1;n?(t=(o+s)/2,1===A?s=t:o=t):(t=(i+r)/2,1===A?r=t:i=t),n=!n}}return[r,s,i,o]}(e);return[r,i,r,t,n,t,n,i,r,i]}class ZM extends Za{indexToBounds(){const{data:e,getGeohash:t}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(e,n)=>XM(t(e,n))}}}ZM.layerName="GeohashLayer",ZM.defaultProps={getGeohash:{type:"accessor",value:e=>e.geohash}};export{Jh as A5Layer,ZM as GeohashLayer,ng as GreatCircleLayer,$m as H3ClusterLayer,Zm as H3HexagonLayer,jM as MVTLayer,vg as QuadkeyLayer,bg as S2Layer,vM as TerrainLayer,dM as Tile3DLayer,Km as TileLayer,Ym as TripsLayer,Za as _GeoCellLayer,_g as _Tile2DHeader,Hm as _Tileset2D,tg as _WMSLayer,Tm as _getURLFromTemplate};